From e5b9ba2a926da2dd2441a11d05a66f6c50a354f1 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Thu, 21 Jan 2010 22:13:20 +0000 Subject: [PATCH] Allow for an alternative handler for wp_die to be used if required. See #11892. git-svn-id: https://develop.svn.wordpress.org/trunk@12790 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 296842be22..0203ff22f7 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -2470,10 +2470,11 @@ function wp_nonce_ays( $action ) { wp_die( $html, $title, array('response' => 403) ); } + /** * Kill WordPress execution and display HTML message with error message. * - * Call this function complements the die() PHP function. The difference is that + * This function complements the die() PHP function. The difference is that * HTML will be displayed to the user. It is recommended to use this function * only, when the execution should not continue any further. It is not * recommended to call this function very often and try to handle as many errors @@ -2486,6 +2487,29 @@ function wp_nonce_ays( $action ) { * @param string|array $args Optional arguements to control behaviour. */ function wp_die( $message, $title = '', $args = array() ) { + if ( function_exists( 'apply_filters' ) ) { + $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler'); + }else { + $function = '_default_wp_die_handler'; + } + + call_user_func( $function, $message, $title, $args ); +} + +/** + * Kill WordPress execution and display HTML message with error message. + * + * This is the default handler for wp_die if you want a custom one for your + * site then you can overload using the wp_die_handler filter in wp_die + * + * @since 3.0.0 + * @private + * + * @param string $message Error message. + * @param string $title Error title. + * @param string|array $args Optional arguements to control behaviour. + */ +function _default_wp_die_handler( $message, $title = '', $args = array() ) { global $wp_locale; $defaults = array( 'response' => 500 );