{"id":5620,"date":"2026-02-12T20:44:56","date_gmt":"2026-02-13T01:44:56","guid":{"rendered":"https:\/\/chubes.net\/?documentation=error-hooks"},"modified":"2026-03-13T03:28:23","modified_gmt":"2026-03-13T07:28:23","slug":"error-hooks","status":"publish","type":"documentation","link":"https:\/\/chubes.net\/docs\/wordpress-core\/errors\/error-hooks\/","title":{"rendered":"Error Hooks"},"content":{"rendered":"<p>Actions and filters for WordPress error handling.<\/p><hr class=\"wp-block-separator\"\/><h2 class=\"wp-block-heading\">Actions<\/h2><h3 class=\"wp-block-heading\">wp_error_added<\/h3><p>Fires when an error is added to a WP_Error object.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">do_action( &#039;wp_error_added&#039;, string|int $code, string $message, mixed $data, WP_Error $wp_error )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.6.0<br \/>\n<strong>Source:<\/strong> <code>WP_Error::add()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$code<\/code><\/td><td>string|int<\/td><td>Error code<\/td><\/tr><tr><td><code>$message<\/code><\/td><td>string<\/td><td>Error message<\/td><\/tr><tr><td><code>$data<\/code><\/td><td>mixed<\/td><td>Error data (might be empty)<\/td><\/tr><tr><td><code>$wp_error<\/code><\/td><td>WP_Error<\/td><td>The WP_Error object<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Example:<\/strong><\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">add_action( &#039;wp_error_added&#039;, function( $code, $message, $data, $wp_error ) {\n    \/\/ Log all errors\n    error_log( sprintf( &#039;WP_Error: [%s] %s&#039;, $code, $message ) );\n    \n    \/\/ Track specific error codes\n    if ( $code === &#039;rest_forbidden&#039; ) {\n        do_action( &#039;my_access_denied_tracking&#039;, $message, $data );\n    }\n}, 10, 4 );<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">is_wp_error_instance<\/h3><p>Fires when <code>is_wp_error()<\/code> detects a WP_Error instance.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">do_action( &#039;is_wp_error_instance&#039;, WP_Error $thing )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.6.0<br \/>\n<strong>Source:<\/strong> <code>is_wp_error()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$thing<\/code><\/td><td>WP_Error<\/td><td>The WP_Error object<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Example:<\/strong><\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">add_action( &#039;is_wp_error_instance&#039;, function( $error ) {\n    \/\/ Debug logging for development\n    if ( WP_DEBUG ) {\n        error_log( &#039;WP_Error encountered: &#039; . $error-&gt;get_error_message() );\n    }\n} );<\/code><\/pre><\/div><p><strong>Note:<\/strong> This fires every time <code>is_wp_error()<\/code> returns true, which can be frequent. Use sparingly.<\/p><hr class=\"wp-block-separator\"\/><h2 class=\"wp-block-heading\">Filters<\/h2><h3 class=\"wp-block-heading\">wp_die_handler<\/h3><p>Filters the callback for killing WordPress execution (default\/HTML requests).<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_die_handler&#039;, callable $callback )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 3.0.0<br \/>\n<strong>Source:<\/strong> <code>wp_die()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Default<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$callback<\/code><\/td><td>callable<\/td><td><code>'_default_wp_die_handler'<\/code><\/td><td>Handler function<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Example:<\/strong><\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">add_filter( &#039;wp_die_handler&#039;, function( $handler ) {\n    return function( $message, $title, $args ) use ( $handler ) {\n        \/\/ Custom logging\n        error_log( &quot;wp_die: $message&quot; );\n        \n        \/\/ Custom template for frontend\n        if ( ! is_admin() ) {\n            include get_template_directory() . &#039;\/error.php&#039;;\n            exit;\n        }\n        \n        \/\/ Default for admin\n        call_user_func( $handler, $message, $title, $args );\n    };\n} );<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">wp_die_ajax_handler<\/h3><p>Filters the callback for killing WordPress execution for Ajax requests.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_die_ajax_handler&#039;, callable $callback )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 3.4.0<br \/>\n<strong>Source:<\/strong> <code>wp_die()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Default<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$callback<\/code><\/td><td>callable<\/td><td><code>'_ajax_wp_die_handler'<\/code><\/td><td>Handler function<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">wp_die_json_handler<\/h3><p>Filters the callback for killing WordPress execution for JSON requests.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_die_json_handler&#039;, callable $callback )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.1.0<br \/>\n<strong>Source:<\/strong> <code>wp_die()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Default<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$callback<\/code><\/td><td>callable<\/td><td><code>'_json_wp_die_handler'<\/code><\/td><td>Handler function<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">wp_die_jsonp_handler<\/h3><p>Filters the callback for killing WordPress execution for JSONP REST requests.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_die_jsonp_handler&#039;, callable $callback )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.2.0<br \/>\n<strong>Source:<\/strong> <code>wp_die()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Default<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$callback<\/code><\/td><td>callable<\/td><td><code>'_jsonp_wp_die_handler'<\/code><\/td><td>Handler function<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">wp_die_xmlrpc_handler<\/h3><p>Filters the callback for killing WordPress execution for XML-RPC requests.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_die_xmlrpc_handler&#039;, callable $callback )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 3.4.0<br \/>\n<strong>Source:<\/strong> <code>wp_die()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Default<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$callback<\/code><\/td><td>callable<\/td><td><code>'_xmlrpc_wp_die_handler'<\/code><\/td><td>Handler function<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">wp_die_xml_handler<\/h3><p>Filters the callback for killing WordPress execution for XML requests.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_die_xml_handler&#039;, callable $callback )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.2.0<br \/>\n<strong>Source:<\/strong> <code>wp_die()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Default<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$callback<\/code><\/td><td>callable<\/td><td><code>'_xml_wp_die_handler'<\/code><\/td><td>Handler function<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">wp_should_handle_php_error<\/h3><p>Filters whether a PHP error should be handled by the fatal error handler.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_should_handle_php_error&#039;, bool $should_handle, array $error )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.2.0<br \/>\n<strong>Source:<\/strong> <code>WP_Fatal_Error_Handler::should_handle_error()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Default<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$should_handle<\/code><\/td><td>bool<\/td><td><code>false<\/code><\/td><td>Whether to handle the error<\/td><\/tr><tr><td><code>$error<\/code><\/td><td>array<\/td><td>\u2014<\/td><td>Error from <code>error_get_last()<\/code><\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Note:<\/strong> This filter only fires for errors NOT already handled by default (E_ERROR, E_PARSE, etc.). It allows adding more error types.<\/p><p><strong>Example:<\/strong><\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">add_filter( &#039;wp_should_handle_php_error&#039;, function( $should_handle, $error ) {\n    \/\/ Also handle E_WARNING in production\n    if ( $error[&#039;type&#039;] === E_WARNING &amp;&amp; ! WP_DEBUG ) {\n        return true;\n    }\n    return $should_handle;\n}, 10, 2 );<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">wp_fatal_error_handler_enabled<\/h3><p>Filters whether the fatal error handler is enabled.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_fatal_error_handler_enabled&#039;, bool $enabled )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.2.0<br \/>\n<strong>Source:<\/strong> <code>wp_is_fatal_error_handler_enabled()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Default<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$enabled<\/code><\/td><td>bool<\/td><td><code>true<\/code><\/td><td>Whether handler is enabled<\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Important:<\/strong> This filter runs before plugins load. Must be defined in <code>wp-config.php<\/code>:<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">$GLOBALS[&#039;wp_filter&#039;] = array(\n    &#039;wp_fatal_error_handler_enabled&#039; =&gt; array(\n        10 =&gt; array(\n            array(\n                &#039;accepted_args&#039; =&gt; 0,\n                &#039;function&#039;      =&gt; function() {\n                    return false; \/\/ Disable handler\n                },\n            ),\n        ),\n    ),\n);<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">wp_php_error_message<\/h3><p>Filters the message displayed by the default PHP error template.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_php_error_message&#039;, string $message, array $error )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.2.0<br \/>\n<strong>Source:<\/strong> <code>WP_Fatal_Error_Handler::display_default_error_template()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$message<\/code><\/td><td>string<\/td><td>HTML error message<\/td><\/tr><tr><td><code>$error<\/code><\/td><td>array<\/td><td>Error from <code>error_get_last()<\/code><\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Example:<\/strong><\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">add_filter( &#039;wp_php_error_message&#039;, function( $message, $error ) {\n    \/\/ Add contact info\n    $message .= &#039;&lt;p&gt;Contact support: support@example.com&lt;\/p&gt;&#039;;\n    \n    \/\/ Add error details in debug mode\n    if ( WP_DEBUG_DISPLAY ) {\n        $message .= sprintf(\n            &#039;&lt;pre&gt;%s in %s on line %d&lt;\/pre&gt;&#039;,\n            esc_html( $error[&#039;message&#039;] ),\n            esc_html( $error[&#039;file&#039;] ),\n            $error[&#039;line&#039;]\n        );\n    }\n    \n    return $message;\n}, 10, 2 );<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h3 class=\"wp-block-heading\">wp_php_error_args<\/h3><p>Filters the arguments passed to <code>wp_die()<\/code> for the default PHP error template.<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">apply_filters( &#039;wp_php_error_args&#039;, array $args, array $error )<\/code><\/pre><\/div><p><strong>Since:<\/strong> 5.2.0<br \/>\n<strong>Source:<\/strong> <code>WP_Fatal_Error_Handler::display_default_error_template()<\/code><\/p><figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>$args<\/code><\/td><td>array<\/td><td>Arguments for <code>wp_die()<\/code><\/td><\/tr><tr><td><code>$error<\/code><\/td><td>array<\/td><td>Error from <code>error_get_last()<\/code><\/td><\/tr><\/tbody><\/table><\/figure><p><strong>Default args:<\/strong><\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">array(\n    &#039;response&#039; =&gt; 500,\n    &#039;exit&#039;     =&gt; false,\n)<\/code><\/pre><\/div><p><strong>Example:<\/strong><\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">add_filter( &#039;wp_php_error_args&#039;, function( $args, $error ) {\n    \/\/ Add a link to status page\n    $args[&#039;link_url&#039;]  = &#039;https:\/\/status.example.com&#039;;\n    $args[&#039;link_text&#039;] = &#039;Check system status&#039;;\n    \n    return $args;\n}, 10, 2 );<\/code><\/pre><\/div><hr class=\"wp-block-separator\"\/><h2 class=\"wp-block-heading\">Hook Reference Table<\/h2><figure class=\"wp-block-table\"><table><thead><tr><th>Hook<\/th><th>Type<\/th><th>Since<\/th><th>Context<\/th><\/tr><\/thead><tbody><tr><td><code>wp_error_added<\/code><\/td><td>Action<\/td><td>5.6.0<\/td><td>WP_Error::add()<\/td><\/tr><tr><td><code>is_wp_error_instance<\/code><\/td><td>Action<\/td><td>5.6.0<\/td><td>is_wp_error()<\/td><\/tr><tr><td><code>wp_die_handler<\/code><\/td><td>Filter<\/td><td>3.0.0<\/td><td>HTML requests<\/td><\/tr><tr><td><code>wp_die_ajax_handler<\/code><\/td><td>Filter<\/td><td>3.4.0<\/td><td>Ajax requests<\/td><\/tr><tr><td><code>wp_die_json_handler<\/code><\/td><td>Filter<\/td><td>5.1.0<\/td><td>JSON requests<\/td><\/tr><tr><td><code>wp_die_jsonp_handler<\/code><\/td><td>Filter<\/td><td>5.2.0<\/td><td>JSONP requests<\/td><\/tr><tr><td><code>wp_die_xmlrpc_handler<\/code><\/td><td>Filter<\/td><td>3.4.0<\/td><td>XML-RPC requests<\/td><\/tr><tr><td><code>wp_die_xml_handler<\/code><\/td><td>Filter<\/td><td>5.2.0<\/td><td>XML\/feed requests<\/td><\/tr><tr><td><code>wp_should_handle_php_error<\/code><\/td><td>Filter<\/td><td>5.2.0<\/td><td>Fatal error detection<\/td><\/tr><tr><td><code>wp_fatal_error_handler_enabled<\/code><\/td><td>Filter<\/td><td>5.2.0<\/td><td>Handler registration<\/td><\/tr><tr><td><code>wp_php_error_message<\/code><\/td><td>Filter<\/td><td>5.2.0<\/td><td>Error display<\/td><\/tr><tr><td><code>wp_php_error_args<\/code><\/td><td>Filter<\/td><td>5.2.0<\/td><td>Error display<\/td><\/tr><\/tbody><\/table><\/figure><hr class=\"wp-block-separator\"\/><h2 class=\"wp-block-heading\">Testing Hooks<\/h2><p>For unit tests, use filters to capture <code>wp_die()<\/code> calls:<\/p><div class=\"code-block-wrapper\"><div class=\"code-block-header\"><span class=\"code-block-language\">php<\/span><button class=\"code-copy-btn\" aria-label=\"Copy code\"><svg><use href=\"https:\/\/chubes.net\/wp-content\/themes\/chubes\/assets\/icons\/chubes.svg#icon-copy\"><\/use><\/svg><\/button><\/div><pre data-chubes-enhanced class=\"wp-block-code language-php\"><code class=\"language-php\">\/\/ In test setup\nadd_filter( &#039;wp_die_handler&#039;, function() {\n    return function( $message, $title, $args ) {\n        throw new WPDieException( $message );\n    };\n} );\n\n\/\/ In test\n$this-&gt;expectException( WPDieException::class );\nwp_die( &#039;Test error&#039; );<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Actions and filters for WordPress error handling. Actions wp_error_added Fires when an error is added to a WP_Error object. do_action( &#8216;wp_error_added&#8217;, string|int $code, string $message, mixed $data, WP_Error $wp_error )&#8230;<\/p>\n","protected":false},"featured_media":0,"template":"","meta":{"footnotes":""},"tags":[],"project":[621],"project_type":[749],"class_list":["post-5620","documentation","type-documentation","status-publish","hentry","project-errors","project_type-wordpress-reference"],"project_info":{"id":589,"name":"WordPress Core","slug":"wordpress-core"},"project_type_info":{"id":749,"name":"WordPress Reference","slug":"wordpress-reference"},"_links":{"self":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/5620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation"}],"about":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/types\/documentation"}],"version-history":[{"count":17,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/5620\/revisions"}],"predecessor-version":[{"id":10898,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/documentation\/5620\/revisions\/10898"}],"wp:attachment":[{"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/media?parent=5620"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/tags?post=5620"},{"taxonomy":"project","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/project?post=5620"},{"taxonomy":"project_type","embeddable":true,"href":"https:\/\/chubes.net\/wp-json\/wp\/v2\/project_type?post=5620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}