A WordPress-centric search engine for devs and theme authors



_ajax_wp_die_handler ›

Since3.4.0
Deprecatedn/a
_ajax_wp_die_handler ( $message, $title = '', $args = array() )
Access:
  • private
Parameters: (3)
  • (string) $message Error message.
    Required: Yes
  • (string) $title Optional. Error title (unused). Default empty.
    Required: No
    Default: (empty)
  • (string|array) $args Optional. Arguments to control behavior. Default empty array.
    Required: No
    Default: array()
Defined at:
Codex:

Kill WordPress ajax execution.

This is the handler for wp_die when processing Ajax requests.



Source

function _ajax_wp_die_handler( $message, $title = '', $args = array() ) {
	$defaults = array(
		'response' => 200,
	);
	$r        = wp_parse_args( $args, $defaults );

	if ( ! headers_sent() && null !== $r['response'] ) {
		status_header( $r['response'] );
	}

	if ( is_scalar( $message ) ) {
		die( (string) $message );
	}
	die( '0' );
}