diff --git a/wp-includes/blocks/index.php b/wp-includes/blocks/index.php index 23cbc78d26..8b0ab4652b 100644 --- a/wp-includes/blocks/index.php +++ b/wp-includes/blocks/index.php @@ -44,7 +44,7 @@ function register_core_block_style_handles() { * Ignore transient cache when the development mode is set to 'core'. Why? To avoid interfering with * the core developer's workflow. */ - if ( 'core' !== wp_get_development_mode() ) { + if ( ! wp_in_development_mode( 'core' ) ) { $transient_name = 'wp_core_block_css_files'; $files = get_transient( $transient_name ); if ( ! $files ) { diff --git a/wp-includes/default-constants.php b/wp-includes/default-constants.php index 294cdc40e5..d28b9fd10b 100644 --- a/wp-includes/default-constants.php +++ b/wp-includes/default-constants.php @@ -79,8 +79,8 @@ function wp_initial_constants() { /* * Add define( 'WP_DEVELOPMENT_MODE', 'core' ) or define( 'WP_DEVELOPMENT_MODE', 'plugin' ) or - * define( 'WP_DEVELOPMENT_MODE', 'theme' ) to wp-config.php to signify development mode for WordPress core, a - * plugin, or a theme respectively. + * define( 'WP_DEVELOPMENT_MODE', 'theme' ) or define( 'WP_DEVELOPMENT_MODE', 'all' ) to wp-config.php + * to signify development mode for WordPress core, a plugin, a theme, or all three types respectively. */ if ( ! defined( 'WP_DEVELOPMENT_MODE' ) ) { define( 'WP_DEVELOPMENT_MODE', '' ); diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index 74fdfb7887..812bf54f23 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -5233,7 +5233,7 @@ function wp_get_global_styles_svg_filters() { * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme * developer's workflow. */ - $can_use_cached = wp_get_development_mode() !== 'theme'; + $can_use_cached = ! wp_in_development_mode( 'theme' ); $cache_group = 'theme_json'; $cache_key = 'wp_get_global_styles_svg_filters'; if ( $can_use_cached ) { diff --git a/wp-includes/global-styles-and-settings.php b/wp-includes/global-styles-and-settings.php index d674434313..4b21ce6cf0 100644 --- a/wp-includes/global-styles-and-settings.php +++ b/wp-includes/global-styles-and-settings.php @@ -69,7 +69,7 @@ function wp_get_global_settings( $path = array(), $context = array() ) { * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme * developer's workflow. */ - $can_use_cached = wp_get_development_mode() !== 'theme'; + $can_use_cached = ! wp_in_development_mode( 'theme' ); $settings = false; if ( $can_use_cached ) { @@ -152,7 +152,7 @@ function wp_get_global_stylesheet( $types = array() ) { * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme * developer's workflow. */ - $can_use_cached = empty( $types ) && wp_get_development_mode() !== 'theme'; + $can_use_cached = empty( $types ) && ! wp_in_development_mode( 'theme' ); /* * By using the 'theme_json' group, this data is marked to be non-persistent across requests. @@ -251,7 +251,7 @@ function wp_get_global_styles_custom_css() { * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme * developer's workflow. */ - $can_use_cached = wp_get_development_mode() !== 'theme'; + $can_use_cached = ! wp_in_development_mode( 'theme' ); /* * By using the 'theme_json' group, this data is marked to be non-persistent across requests. @@ -360,7 +360,7 @@ function wp_theme_has_theme_json() { * Ignore static cache when the development mode is set to 'theme', to avoid interfering with * the theme developer's workflow. */ - wp_get_development_mode() !== 'theme' + ! wp_in_development_mode( 'theme' ) ) { return $theme_has_support[ $stylesheet ]; } diff --git a/wp-includes/load.php b/wp-includes/load.php index ab2a91cd78..36e8a5aa6f 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -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. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 2a5e048679..322b49a97c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-beta4-56222'; +$wp_version = '6.3-beta4-56223'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.