execute(); } catch ( \Throwable $e ) { atkp_cron_error_page( get_class( $e ) . ': ' . $e->getMessage(), null, $e ); } function atkp_cron_error_page( string $title, ?string $detail = null, ?\Throwable $exception = null ) { // This URL is publicly reachable: file paths, messages and stack traces are only shown on the // command line or with WP_DEBUG enabled. They always go to the PHP error log. $show_details = php_sapi_name() == 'cli' || ( defined( 'WP_DEBUG' ) && WP_DEBUG ); if ( $exception ) { error_log( 'affiliate-toolkit cron: ' . $title . ' in ' . $exception->getFile() . ':' . $exception->getLine() . "\n" . $exception->getTraceAsString() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log } else { error_log( 'affiliate-toolkit cron: ' . $title . ( $detail ? ' - ' . $detail : '' ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log } if ( ! $show_details ) { if ( $exception ) { $title = 'An error occurred while running the cron job'; } $detail = 'The details have been written to the PHP error log. Enable WP_DEBUG to show them on this page.'; $exception = null; } if ( ! headers_sent() ) { header( 'Content-Type: text/html; charset=UTF-8', true, 500 ); } ?>