diff --git a/src/wp-includes/class-wp-shutdown-handler.php b/src/wp-includes/class-wp-shutdown-handler.php index c55901dd4a..18eee6a2a4 100644 --- a/src/wp-includes/class-wp-shutdown-handler.php +++ b/src/wp-includes/class-wp-shutdown-handler.php @@ -136,7 +136,7 @@ class WP_Shutdown_Handler { $php_error_pluggable = WP_CONTENT_DIR . '/php-error.php'; if ( is_readable( $php_error_pluggable ) ) { require_once $php_error_pluggable; - die(); + return; } } @@ -166,7 +166,10 @@ class WP_Shutdown_Handler { $message = __( 'The site is experiencing technical difficulties.' ); - $args = array( 'response' => 500 ); + $args = array( + 'response' => 500, + 'exit' => false, + ); if ( function_exists( 'admin_url' ) ) { $args['link_url'] = admin_url(); $args['link_text'] = __( 'Log into the admin backend to fix this.' ); diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 00ebbe9c62..400161d8e7 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -2957,6 +2957,7 @@ function wp_nonce_ays( $action ) { * Default is the value of is_rtl(). * @type string $code Error code to use. Default is 'wp_die', or the main error code if $message * is a WP_Error. + * @type bool $exit Whether to exit the process after completion. Default true. * } */ function wp_die( $message = '', $title = '', $args = array() ) { @@ -3201,7 +3202,9 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) { output( $error->getXml() ); } - die(); + if ( $r['exit'] ) { + die(); + } } /** @@ -3291,9 +3298,16 @@ function _ajax_wp_die_handler( $message, $title = '', $args = array() ) { } if ( is_scalar( $message ) ) { - die( (string) $message ); + $message = (string) $message; + } else { + $message = '0'; } - die( '0' ); + + if ( $r['exit'] ) { + die( $message ); + } + + echo $message; } /** @@ -3302,15 +3316,26 @@ function _ajax_wp_die_handler( $message, $title = '', $args = array() ) { * This is the handler for wp_die when processing APP requests. * * @since 3.4.0 + * @since 5.1.0 Added the $title and $args parameters. * @access private * - * @param string $message Optional. Response to print. Default empty. + * @param string $message Optional. Response to print. Default empty. + * @param string $title Optional. Error title (unused). Default empty. + * @param string|array $args Optional. Arguments to control behavior. Default empty array. */ -function _scalar_wp_die_handler( $message = '' ) { - if ( is_scalar( $message ) ) { - die( (string) $message ); +function _scalar_wp_die_handler( $message = '', $title = '', $args = array() ) { + list( $message, $title, $r ) = _wp_die_process_input( $message, $title, $args ); + + if ( $r['exit'] ) { + if ( is_scalar( $message ) ) { + die( (string) $message ); + } + die(); + } + + if ( is_scalar( $message ) ) { + echo (string) $message; } - die(); } /** @@ -3328,6 +3353,7 @@ function _wp_die_process_input( $message, $title = '', $args = array() ) { $defaults = array( 'response' => 0, 'code' => '', + 'exit' => true, 'back_link' => false, 'link_url' => '', 'link_text' => '',