Make WordPress Core

Changeset 20063


Ignore:
Timestamp:
03/01/2012 09:35:15 PM (14 years ago)
Author:
nacin
Message:

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.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-app.php

    r20062 r20063  
    2727$_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] );
    2828
     29// Allow for a plugin to insert a different class to handle requests.
     30$wp_atom_server_class = apply_filters('wp_atom_server_class', 'wp_atom_server');
     31$wp_atom_server = new $wp_atom_server_class;
     32
     33// Handle the request
     34$wp_atom_server->handle_request();
     35
     36exit;
     37
    2938/**
    3039 * Writes logging info to a file.
     
    4352            error_log( $label . ' - ' . $message );
    4453}
    45 
    46 // Allow for a plugin to insert a different class to handle requests.
    47 $wp_atom_server_class = apply_filters('wp_atom_server_class', 'wp_atom_server');
    48 $wp_atom_server = new $wp_atom_server_class;
    49 
    50 // Handle the request
    51 $wp_atom_server->handle_request();
  • trunk/wp-includes/class-wp-atom-server.php

    r20062 r20063  
    176176                        'DELETE' => 'delete_attachment'),
    177177        );
    178 
    179         add_filter( 'wp_die_handler', array( $this, 'return_atom_die_handler' ) );
    180     }
    181 
    182     /**
    183      * Override die handler
    184      * @return callback
    185      */
    186     public function return_atom_die_handler() {
    187         return array( $this, 'atom_die_handler' );
    188     }
    189 
    190     /**
    191      * Die with a message.  Only accept strings, no WP_Error objects yet
    192      * @param string $message
    193      * @return void
    194      */
    195     public function atom_die_handler( $message ) {
    196         if ( is_scalar( $message ) )
    197             die( (string) $message );
    198         die();
    199178    }
    200179
  • trunk/wp-includes/functions.php

    r20000 r20063  
    19771977    elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST )
    19781978        $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
     1979    elseif ( defined( 'APP_REQUEST' ) && APP_REQUEST )
     1980        $function = apply_filters( 'wp_die_app_bandler', '_scalar_wp_die_handler' );
    19791981    else
    19801982        $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' );
     
    21802182        die( (string) $message );
    21812183    die( '0' );
     2184}
     2185
     2186/**
     2187 * Kill WordPress execution.
     2188 *
     2189 * This is the handler for wp_die when processing APP requests.
     2190 *
     2191 * @since 3.4.0
     2192 * @access private
     2193 *
     2194 * @param string $message Optional. Response to print.
     2195 */
     2196function _scalar_wp_die_handler( $message = '' ) {
     2197    if ( is_scalar( $message ) )
     2198        die( (string) $message );
     2199    die();
    21822200}
    21832201
Note: See TracChangeset for help on using the changeset viewer.