From db15a20fb13793b559010fdbeaf5a680f66cbd7a Mon Sep 17 00:00:00 2001 From: nacin Date: Thu, 1 Mar 2012 21:35:15 +0000 Subject: [PATCH] New wp_die_app_handler context in wp_die() for APP requests. Introduces _scalar_wp_die_handler() as a generic handler that wraps die(), for use by plugins. Move deprecated function to the end of the wp-app.php file (same as xmlrpc.php). see #20042. git-svn-id: http://svn.automattic.com/wordpress/trunk@20063 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-app.php | 16 +++++++++------- wp-includes/class-wp-atom-server.php | 21 --------------------- wp-includes/functions.php | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/wp-app.php b/wp-app.php index 1d109a0227..b41399aea8 100644 --- a/wp-app.php +++ b/wp-app.php @@ -26,6 +26,15 @@ require_once(ABSPATH . '/wp-admin/includes/image.php'); $_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] ); +// Allow for a plugin to insert a different class to handle requests. +$wp_atom_server_class = apply_filters('wp_atom_server_class', 'wp_atom_server'); +$wp_atom_server = new $wp_atom_server_class; + +// Handle the request +$wp_atom_server->handle_request(); + +exit; + /** * Writes logging info to a file. * @@ -42,10 +51,3 @@ function log_app( $label, $msg ) { if ( ! empty( $GLOBALS['app_logging'] ) ) error_log( $label . ' - ' . $message ); } - -// Allow for a plugin to insert a different class to handle requests. -$wp_atom_server_class = apply_filters('wp_atom_server_class', 'wp_atom_server'); -$wp_atom_server = new $wp_atom_server_class; - -// Handle the request -$wp_atom_server->handle_request(); diff --git a/wp-includes/class-wp-atom-server.php b/wp-includes/class-wp-atom-server.php index 23de9ed8be..1d31c506b9 100644 --- a/wp-includes/class-wp-atom-server.php +++ b/wp-includes/class-wp-atom-server.php @@ -175,27 +175,6 @@ class wp_atom_server { 'PUT' => 'put_attachment', 'DELETE' => 'delete_attachment'), ); - - add_filter( 'wp_die_handler', array( $this, 'return_atom_die_handler' ) ); - } - - /** - * Override die handler - * @return callback - */ - public function return_atom_die_handler() { - return array( $this, 'atom_die_handler' ); - } - - /** - * Die with a message. Only accept strings, no WP_Error objects yet - * @param string $message - * @return void - */ - public function atom_die_handler( $message ) { - if ( is_scalar( $message ) ) - die( (string) $message ); - die(); } /** diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 5541e80515..817dc8a0fa 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1976,6 +1976,8 @@ function wp_die( $message = '', $title = '', $args = array() ) { $function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); + elseif ( defined( 'APP_REQUEST' ) && APP_REQUEST ) + $function = apply_filters( 'wp_die_app_bandler', '_scalar_wp_die_handler' ); else $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' ); @@ -2181,6 +2183,22 @@ function _ajax_wp_die_handler( $message = '' ) { die( '0' ); } +/** + * Kill WordPress execution. + * + * This is the handler for wp_die when processing APP requests. + * + * @since 3.4.0 + * @access private + * + * @param string $message Optional. Response to print. + */ +function _scalar_wp_die_handler( $message = '' ) { + if ( is_scalar( $message ) ) + die( (string) $message ); + die(); +} + /** * Retrieve the WordPress home page URL. *