Making WordPress.org


Ignore:
Timestamp:
04/03/2016 12:09:54 PM (8 years ago)
Author:
ocean90
Message:

Translate: Short circuit WordPress' status handler to prevent unnecessary headers which prevent caching.

Doesn't affect non-logged in users because WP::send_headers() (which runs before WP::handle_404()) includes the nocache headers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/wporg-gp-customizations.php

    r2733 r2884  
    1717        add_action( 'gp_project_created', array( $this, 'update_projects_last_updated' ) );
    1818        add_action( 'gp_project_saved', array( $this, 'update_projects_last_updated' ) );
     19        add_filter( 'pre_handle_404', array( $this, 'short_circuit_handle_404' ) );
     20    }
     21
     22    /**
     23     * Short circuits WordPress' status handler to prevent unnecessary headers
     24     * which prevent caching.
     25     *
     26     * @return bool True if a request for GlotPress, false if not.
     27     */
     28    public function short_circuit_handle_404() {
     29        if ( is_glotpress() ) {
     30            return true;
     31        }
     32
     33        return false;
    1934    }
    2035
Note: See TracChangeset for help on using the changeset viewer.