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
This commit is contained in:
parent
3dd02adc17
commit
db15a20fb1
16
wp-app.php
16
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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue