| | 2774 | * Kill WordPress execution and send AJAX response with error message. |
| | 2775 | * |
| | 2776 | * This is AJAX-version of the default handler for wp_die |
| | 2777 | * |
| | 2778 | * @since 3.0.0 |
| | 2779 | * @access private |
| | 2780 | * |
| | 2781 | * @param string $message Error message. |
| | 2782 | * @param string $title Error title. |
| | 2783 | * @param string|array $args Optional arguements to control behaviour. |
| | 2784 | */ |
| | 2785 | function _ajax_wp_die_handler( $message, $title = '', $args = array() ) { |
| | 2786 | $defaults = array( 'response' => 500 ); |
| | 2787 | $r = wp_parse_args($args, $defaults); |
| | 2788 | $have_gettext = function_exists('__'); |
| | 2789 | if ( !function_exists( 'did_action' ) || !did_action( 'admin_head' ) ) : |
| | 2790 | if ( !headers_sent() ) { |
| | 2791 | status_header( $r['response'] ); |
| | 2792 | nocache_headers(); |
| | 2793 | header( 'Content-Type: text/html; charset=utf-8' ); |
| | 2794 | } |
| | 2795 | $resp = new WP_Ajax_Response( array( |
| | 2796 | 'what' => 'autosave', |
| | 2797 | 'id' => $message, |
| | 2798 | 'data' => $message |
| | 2799 | ) ); |
| | 2800 | $resp->send(); |
| | 2801 | die(); |
| | 2802 | } |
| | 2803 | |
| | 2804 | /** |