In WP::handle_404() introduce a filter pre_handle_404 to short-circuit default header status handling.

This comes handy if you use WordPress without posts, means `$wp_query` contains no results.

Props prettyboymp, hakre, prettyboymp, Denis-de-Bernardy, ethitter, ocean90.
Fixes #10722.

git-svn-id: https://develop.svn.wordpress.org/trunk@36629 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2016-02-23 16:07:39 +00:00
parent 2dc9766688
commit 4315a8867d

View File

@ -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;