diff --git a/src/wp-includes/class-wp.php b/src/wp-includes/class-wp.php index 238e2e6660..74ea29fe6f 100644 --- a/src/wp-includes/class-wp.php +++ b/src/wp-includes/class-wp.php @@ -629,6 +629,21 @@ class WP { public function handle_404() { global $wp_query; + /** + * Filter whether to short-circuit default header status handling. + * + * Returning a non-false value from the filter will short-circuit the handling + * and return early. + * + * @since 4.5.0 + * + * @param bool $preempt Whether to short-circuit default header status handling. Default false. + * @param WP_Query $wp_query WordPress Query object. + */ + if ( false !== apply_filters( 'pre_handle_404', false, $wp_query ) ) { + return; + } + // If we've already issued a 404, bail. if ( is_404() ) return;