Make WordPress Core


Ignore:
Timestamp:
01/31/2012 10:12:58 PM (14 years ago)
Author:
nacin
Message:

Re-purpose wp_die() for ajax responses.

  • Allows unit testing of core ajax actions.
  • wp_die() now has separate filters to choose a handler depending on the context (ajax, XML-RPC, else).
  • wp_die) in ajax context does not need to be called with a string. Conversion takes place before die().

props kurtpayne, see #15327.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/pluggable.php

    r19771 r19801  
    830830    $result = wp_verify_nonce( $nonce, $action );
    831831
    832     if ( $die && false == $result )
    833         die('-1');
     832    if ( $die && false == $result ) {
     833        if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
     834            wp_die( -1 );
     835        else
     836            die( '-1' );
     837    }
    834838
    835839    do_action('check_ajax_referer', $action, $result);
Note: See TracChangeset for help on using the changeset viewer.