mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
General: Introduce all development mode.
Introduce the development mode `all` as a a cover-all mode for the existing `theme`, `plugin` and `core` development modes. Developers can use the `all` mode if they are developing both themes and plugins, for example. Introduce the utility function `wp_in_development_mode()` allowing developers to detect the mode via a parameter. If the development mode is set to `all` this function will always return `true`. If the development mode is specific then only the chosen mode will return `true`. Follow up to [56079,56042]. Props flixos90. Fixes #57487. git-svn-id: https://develop.svn.wordpress.org/trunk@56223 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -271,11 +271,15 @@ function wp_get_environment_type() {
|
||||
* The development mode affects how certain parts of the WordPress application behave, which is relevant when
|
||||
* developing for WordPress.
|
||||
*
|
||||
* Valid developer modes are 'core', 'plugin', 'theme', or an empty string to disable developer mode.
|
||||
* Valid development modes are 'core', 'plugin', 'theme', 'all', or an empty string to disable development mode.
|
||||
* 'all' is a special value to signify that all three development modes 'core', 'plugin', and 'theme' are enabled.
|
||||
*
|
||||
* Developer mode is considered separately from `WP_DEBUG` and {@see wp_get_environment_type()}. It does not affect
|
||||
* debugging output, but rather functional nuances in WordPress.
|
||||
*
|
||||
* This function controls the currently set development mode value. To check for whether a specific development mode is
|
||||
* enabled, use wp_in_development_mode().
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @return string The current development mode.
|
||||
@@ -298,6 +302,7 @@ function wp_get_development_mode() {
|
||||
'core',
|
||||
'plugin',
|
||||
'theme',
|
||||
'all',
|
||||
'',
|
||||
);
|
||||
if ( ! in_array( $development_mode, $valid_modes, true ) ) {
|
||||
@@ -309,6 +314,29 @@ function wp_get_development_mode() {
|
||||
return $current_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the site is in the given development mode.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @param string $mode Development mode to check for. Either 'core', 'plugin', 'theme', or 'all'.
|
||||
* @return bool True if the given mode is covered by the current development mode, false otherwise.
|
||||
*/
|
||||
function wp_in_development_mode( $mode ) {
|
||||
$current_mode = wp_get_development_mode();
|
||||
if ( empty( $current_mode ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return true if the current mode encompasses all modes.
|
||||
if ( 'all' === $current_mode ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Return true if the current mode is the given mode.
|
||||
return $mode === $current_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures all of WordPress is not loaded when handling a favicon.ico request.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user