_ajax_wp_die_handler

Kill WordPress ajax execution.

Description

_ajax_wp_die_handler( (string) $message, (string) $title = '', (array) $args = array() ); 

This is the handler for wp_die when processing Ajax requests.

Parameters (3)

0. $message (string)
Error message.
1. $title — Optional. (string) => ''
Error title (unused). Default empty.
2. $args — Optional. (array) => array()
Arguments to control behavior. Default empty array.

Usage

  1. if ( !function_exists( '_ajax_wp_die_handler' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Error message. 
  5. $message = ''; 
  6.  
  7. // Optional. Error title (unused). Default empty. 
  8. $title = ''; 
  9.  
  10. // Optional. Arguments to control behavior. Default empty array. 
  11. $args = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = _ajax_wp_die_handler($message, $title, $args); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function _ajax_wp_die_handler( $message, $title = '', $args = array() ) { 
  2. $defaults = array( 
  3. 'response' => 200,  
  4. ); 
  5. $r = wp_parse_args( $args, $defaults ); 
  6.  
  7. if ( ! headers_sent() && null !== $r['response'] ) { 
  8. status_header( $r['response'] ); 
  9.  
  10. if ( is_scalar( $message ) ) 
  11. die( (string) $message ); 
  12. die( '0' );