Make WordPress Core


Ignore:
Timestamp:
02/23/2016 04:07:39 PM (10 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp.php

    r36525 r36629  
    630630                global $wp_query;
    631631
     632                /**
     633                 * Filter whether to short-circuit default header status handling.
     634                 *
     635                 * Returning a non-false value from the filter will short-circuit the handling
     636                 * and return early.
     637                 *
     638                 * @since 4.5.0
     639                 *
     640                 * @param bool     $preempt  Whether to short-circuit default header status handling. Default false.
     641                 * @param WP_Query $wp_query WordPress Query object.
     642                 */
     643                if ( false !== apply_filters( 'pre_handle_404', false, $wp_query ) ) {
     644                        return;
     645                }
     646
    632647                // If we've already issued a 404, bail.
    633648                if ( is_404() )
Note: See TracChangeset for help on using the changeset viewer.