WordPress.org

Make WordPress Core

Ticket #27671: admin-post.diff

File admin-post.diff, 964 bytes (added by gorantq, 4 years ago)
  • wp-admin/admin-post.php

     
    6969                do_action( "admin_post_{$action}" );
    7070        }
    7171}
     72
     73/**
     74 * Kill WordPress ajax execution.
     75 *
     76 * This is the handler for wp_die when processing Ajax requests.
     77 *
     78 * @access private
     79 *
     80 * @param string       $message Error message.
     81 * @param string       $title   Optional. Error title (unused). Default empty.
     82 * @param string|array $args    Optional. Arguments to control behavior. Default empty array.
     83 */
     84function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
     85        $defaults = array(
     86                'response' => 200,
     87        );
     88        $r = wp_parse_args( $args, $defaults );
     89
     90        if ( ! headers_sent() && null !== $r['response'] ) {
     91                status_header( $r['response'] );
     92        }
     93
     94        if ( is_scalar( $message ) )
     95                die( (string) $message );
     96        die( '0' );
     97}
     98