wp-includes/functions.php:3761Kills WordPress execution and displays HTML page with an error message.
$messagestring|WP_Erroroptional''$titlestring|intoptional''$argsstring|array|intoptionalarray()$responseintdefault: 200 for Ajax requests, 500 otherwise
$link_urlstringdefault: empty string
$link_textstringdefault: empty string
$back_linkbooldefault: false
$text_directionstringdefault: is the value of is_rtl()
$charsetstringdefault: 'utf-8'
$codestringdefault: is 'wp_die', or the main error code if $message is a WP_Error
$exitbooldefault: true
6 hooks fire while wp_die() runs, in this order:
Filters the callback for killing WordPress execution for Ajax requests.
Filters the callback for killing WordPress execution for JSON requests.
Filters the callback for killing WordPress execution for JSONP REST requests.
Filters the callback for killing WordPress execution for XML-RPC requests.
Filters the callback for killing WordPress execution for XML requests.
Filters the callback for killing WordPress execution for all non-Ajax, non-JSON, non-XML requests.
function wp_die( $message = '', $title = '', $args = array() ) { global $wp_query; if ( is_int( $args ) ) { $args = array( 'response' => $args ); } elseif ( is_int( $title ) ) { $args = array( 'response' => $title ); $title = ''; } if ( wp_doing_ajax() ) { /** * Filters the callback for killing WordPress execution for Ajax requests. * * @since 3.4.0 * * @param callable $callback Callback function name. */ $callback = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); } elseif ( wp_is_json_request() ) { /** * Filters the callback for killing WordPress execution for JSON requests. * * @since 5.1.0 * * @param callable $callback Callback function name. */ $callback = apply_filters( 'wp_die_json_handler', '_json_wp_die_handler' ); } elseif ( wp_is_serving_rest_request() && wp_is_jsonp_request() ) { /** * Filters the callback for killing WordPress execution for JSONP REST requests. * * @since 5.2.0 * * @param callable $callback Callback function name. */ $callback = apply_filters( 'wp_die_jsonp_handler', '_jsonp_wp_die_handler' ); } elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { /** * Filters the callback for killing WordPress execution for XML-RPC requests. * * @since 3.4.0 * * @param callable $callback Callback function name. */ $callback = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); } elseif ( wp_is_xml_request() || isset( $wp_query ) && ( function_exists( 'is_feed' ) && is_feed() || function_exists( 'is_comment_feed' ) && is_comment_feed() || function_exists( 'is_trackback' ) && is_trackback() ) ) { /** * Filters the callback for killing WordPress execution for XML requests. * * @since 5.2.0 * * @param callable $callback Callback function name. */ $callback = apply_filters( 'wp_die_xml_handler', '_xml_wp_die_handler' ); } else { /** * Filters the callback for killing WordPress execution for all non-Ajax, non-JSON, non-XML requests. * * @since 3.0.0 * * @param callable $callback Callback function name. */ $callback = apply_filters( 'wp_die_handler', '_default_wp_die_handler' ); } call_user_func( $callback, $message, $title, $args );}Introduced in 2.0.4. 3 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$message retyped from string|WP_Error to string|WP_Error|int.verified against sourcenever|void to void.verified against sourcenone to never|void.verified against sourcesrc/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.