Make WordPress Core


Ignore:
Timestamp:
06/02/2016 06:46:51 PM (8 years ago)
Author:
jorbin
Message:

Introduce filters for skipping parts of the bootstrap process

Non web interfaces with WordPress (such as wp-cli) need to be able to bypass certain checks in the bootstrap process. This introduces three new filters to allow for those checks to be skipped.

  1. Provides a way of forcefully bypassing wp_maintenance().
  2. Provides a way of forcefully bypassing wp_debug_mode(). See https://github.com/wp-cli/wp-cli/issues/177
  3. Provide a way of forcefully skipping loading wp-content/advance-cache.php. See https://github.com/wp-cli/wp-cli/pull/164

These filters should not be used by plugins (in fact, they run before plugins are loaded, so they can't be used by plugins). In general, they should only be used in non-web interactions with WordPress.

See #34936.
Props jorbin, DrewAPicture.

File:
1 edited

Legend:

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

    r37613 r37626  
    184184    if ( ( time() - $upgrading ) >= 600 )
    185185        return;
     186   
     187    /**
     188     * Bypass the maintenance mode check
     189     *
     190     * This filter should *NOT* be used by plugins. It is designed for non-web
     191     * runtimes. If this filter returns true, maintenance mode will not be 
     192     * active which can cause problems during updates for web site views.
     193     *
     194     * @since 4.6.0
     195     *
     196     * @param bool True to bypass maintenance
     197     */
     198    if ( apply_filters( 'bypass_maintenance_mode', false ) ){
     199        return;
     200    }
    186201
    187202    if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
     
    286301 */
    287302function wp_debug_mode() {
     303    /**
     304     * Bypass the debug mode check
     305     *
     306     * This filter should *NOT* be used by plugins. It is designed for non-web
     307     * runtimes. Returning true causes the WP_DEBUG and related constants to
     308     * not be checked and the default php values for errors will be used unless
     309     * you take care to update them yourself.
     310     *
     311     * @since 4.6.0
     312     *
     313     * @param bool True to bypass debug mode
     314     */
     315    if ( apply_filters( 'bypass_debug_mode', false ) ){
     316        return;
     317    }
     318
    288319    if ( WP_DEBUG ) {
    289320        error_reporting( E_ALL );
Note: See TracChangeset for help on using the changeset viewer.