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. git-svn-id: https://develop.svn.wordpress.org/trunk@37626 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1f5147bf83
commit
f1fdf6a1e8
|
@ -184,6 +184,21 @@ function wp_maintenance() {
|
||||||
if ( ( time() - $upgrading ) >= 600 )
|
if ( ( time() - $upgrading ) >= 600 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bypass the maintenance mode check
|
||||||
|
*
|
||||||
|
* This filter should *NOT* be used by plugins. It is designed for non-web
|
||||||
|
* runtimes. If this filter returns true, maintenance mode will not be
|
||||||
|
* active which can cause problems during updates for web site views.
|
||||||
|
*
|
||||||
|
* @since 4.6.0
|
||||||
|
*
|
||||||
|
* @param bool True to bypass maintenance
|
||||||
|
*/
|
||||||
|
if ( apply_filters( 'bypass_maintenance_mode', false ) ){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
|
if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
|
||||||
require_once( WP_CONTENT_DIR . '/maintenance.php' );
|
require_once( WP_CONTENT_DIR . '/maintenance.php' );
|
||||||
die();
|
die();
|
||||||
|
@ -285,6 +300,22 @@ function timer_stop( $display = 0, $precision = 3 ) {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function wp_debug_mode() {
|
function wp_debug_mode() {
|
||||||
|
/**
|
||||||
|
* Bypass the debug mode check
|
||||||
|
*
|
||||||
|
* This filter should *NOT* be used by plugins. It is designed for non-web
|
||||||
|
* runtimes. Returning true causes the WP_DEBUG and related constants to
|
||||||
|
* not be checked and the default php values for errors will be used unless
|
||||||
|
* you take care to update them yourself.
|
||||||
|
*
|
||||||
|
* @since 4.6.0
|
||||||
|
*
|
||||||
|
* @param bool True to bypass debug mode
|
||||||
|
*/
|
||||||
|
if ( apply_filters( 'bypass_debug_mode', false ) ){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( WP_DEBUG ) {
|
if ( WP_DEBUG ) {
|
||||||
error_reporting( E_ALL );
|
error_reporting( E_ALL );
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,18 @@ timer_start();
|
||||||
// Check if we're in WP_DEBUG mode.
|
// Check if we're in WP_DEBUG mode.
|
||||||
wp_debug_mode();
|
wp_debug_mode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bypass the loading of advanced-cache.php
|
||||||
|
*
|
||||||
|
* This filter should *NOT* be used by plugins. It is designed for non-web
|
||||||
|
* runtimes. If true is returned, advance-cache.php will never be loaded.
|
||||||
|
*
|
||||||
|
* @since 4.6.0
|
||||||
|
*
|
||||||
|
* @param bool True to bypass advanced-cache.php
|
||||||
|
*/
|
||||||
|
if ( WP_CACHE && ! apply_filters( 'bypass_advanced_cache', false ) ) {
|
||||||
// For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
|
// For an advanced caching plugin to use. Uses a static drop-in because you would only want one.
|
||||||
if ( WP_CACHE ) {
|
|
||||||
_backup_plugin_globals();
|
_backup_plugin_globals();
|
||||||
WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' );
|
WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' );
|
||||||
_restore_plugin_globals();
|
_restore_plugin_globals();
|
||||||
|
|
Loading…
Reference in New Issue