Changeset 56042
- Timestamp:
- 06/26/2023 07:55:28 PM (16 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.env
r55920 r56042 60 60 LOCAL_SCRIPT_DEBUG=true 61 61 LOCAL_WP_ENVIRONMENT_TYPE=local 62 LOCAL_WP_DEVELOPMENT_MODE=core 62 63 63 64 # The URL to use when running e2e tests. -
trunk/src/wp-includes/default-constants.php
r56032 r56042 78 78 } 79 79 80 /* 81 * Add define( 'WP_DEVELOPMENT_MODE', 'core' ) or define( 'WP_DEVELOPMENT_MODE', 'plugin' ) or 82 * define( 'WP_DEVELOPMENT_MODE', 'theme' ) to wp-config.php to signify development mode for WordPress core, a 83 * plugin, or a theme respectively. 84 */ 85 if ( ! defined( 'WP_DEVELOPMENT_MODE' ) ) { 86 define( 'WP_DEVELOPMENT_MODE', '' ); 87 } 88 80 89 // Add define( 'WP_DEBUG', true ); to wp-config.php to enable display of notices during development. 81 90 if ( ! defined( 'WP_DEBUG' ) ) { 82 if ( 'development' === wp_get_environment_type() ) {91 if ( wp_get_development_mode() || 'development' === wp_get_environment_type() ) { 83 92 define( 'WP_DEBUG', true ); 84 93 } else { -
trunk/src/wp-includes/global-styles-and-settings.php
r56038 r56042 67 67 68 68 /* 69 * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme69 * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme 70 70 * developer's workflow. 71 * 72 * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core. 73 */ 74 $can_use_cached = ! WP_DEBUG; 71 */ 72 $can_use_cached = wp_get_development_mode() !== 'theme'; 75 73 76 74 $settings = false; … … 152 150 function wp_get_global_stylesheet( $types = array() ) { 153 151 /* 154 * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme152 * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme 155 153 * developer's workflow. 156 * 157 * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core. 158 */ 159 $can_use_cached = empty( $types ) && ! WP_DEBUG; 154 */ 155 $can_use_cached = empty( $types ) && wp_get_development_mode() !== 'theme'; 160 156 161 157 /* … … 253 249 } 254 250 /* 255 * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme251 * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme 256 252 * developer's workflow. 257 * 258 * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core. 259 */ 260 $can_use_cached = ! WP_DEBUG; 253 */ 254 $can_use_cached = wp_get_development_mode() !== 'theme'; 261 255 262 256 /* … … 304 298 function wp_get_global_styles_svg_filters() { 305 299 /* 306 * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme300 * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme 307 301 * developer's workflow. 308 * 309 * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core. 310 */ 311 $can_use_cached = ! WP_DEBUG; 302 */ 303 $can_use_cached = wp_get_development_mode() !== 'theme'; 312 304 $cache_group = 'theme_json'; 313 305 $cache_key = 'wp_get_global_styles_svg_filters'; … … 403 395 null !== $theme_has_support && 404 396 /* 405 * Ignore static cache when `WP_DEBUG` is enabled. Why? To avoid interfering with397 * Ignore static cache when the development mode is set to 'theme', to avoid interfering with 406 398 * the theme developer's workflow. 407 *408 * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.409 399 */ 410 ! WP_DEBUG&&400 wp_get_development_mode() !== 'theme' && 411 401 /* 412 402 * Ignore cache when automated test suites are running. Why? To ensure -
trunk/src/wp-includes/load.php
r56032 r56042 260 260 261 261 return $current_env; 262 } 263 264 /** 265 * Retrieves the current development mode. 266 * 267 * The development mode affects how certain parts of the WordPress application behave, which is relevant when 268 * developing for WordPress. 269 * 270 * Valid developer modes are 'core', 'plugin', 'theme', or an empty string to disable developer mode. 271 * 272 * Developer mode is considered separately from `WP_DEBUG` and {@see wp_get_environment_type()}. It does not affect 273 * debugging output, but rather functional nuances in WordPress. 274 * 275 * @since 6.3.0 276 * 277 * @return string The current development mode. 278 */ 279 function wp_get_development_mode() { 280 static $current_mode = null; 281 282 if ( ! defined( 'WP_RUN_CORE_TESTS' ) && null !== $current_mode ) { 283 return $current_mode; 284 } 285 286 $development_mode = WP_DEVELOPMENT_MODE; 287 288 // Exclusively for core tests, rely on a global `$_wp_tests_development_mode`. 289 if ( defined( 'WP_RUN_CORE_TESTS' ) && isset( $GLOBALS['_wp_tests_development_mode'] ) ) { 290 $development_mode = $GLOBALS['_wp_tests_development_mode']; 291 } 292 293 $valid_modes = array( 294 'core', 295 'plugin', 296 'theme', 297 '', 298 ); 299 if ( ! in_array( $development_mode, $valid_modes, true ) ) { 300 $development_mode = ''; 301 } 302 303 $current_mode = $development_mode; 304 305 return $current_mode; 262 306 } 263 307 -
trunk/tests/phpunit/tests/theme/wpGetGlobalStylesSvgFilters.php
r55185 r56042 35 35 $this->assertNotSame( $svg_for_default_theme, $svg_for_block_theme, 'Cache value should have changed' ); 36 36 } 37 38 /** 39 * Tests that the function relies on the development mode for whether to use caching. 40 * 41 * @ticket 57487 42 * 43 * @covers ::wp_get_global_styles_svg_filters 44 */ 45 public function test_caching_is_used_when_developing_theme() { 46 global $_wp_tests_development_mode; 47 48 switch_theme( 'block-theme' ); 49 50 // Store SVG in cache. 51 $svg = '<svg></svg>'; 52 wp_cache_set( 'wp_get_global_styles_svg_filters', $svg, 'theme_json' ); 53 54 // By default, caching should be used, so the above value will be returned. 55 $_wp_tests_development_mode = ''; 56 $this->assertSame( $svg, wp_get_global_styles_svg_filters(), 'Caching was not used despite development mode disabled' ); 57 58 // When the development mode is set to 'theme', caching should not be used. 59 $_wp_tests_development_mode = 'theme'; 60 $this->assertNotSame( $svg, wp_get_global_styles_svg_filters(), 'Caching was used despite theme development mode' ); 61 } 37 62 } -
trunk/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php
r55572 r56042 222 222 223 223 /** 224 * Tests that the function relies on the development mode for whether to use caching. 225 * 226 * @ticket 57487 227 */ 228 public function test_caching_is_used_when_developing_theme() { 229 global $_wp_tests_development_mode; 230 231 $this->maybe_switch_theme( 'block-theme' ); 232 233 // Store CSS in cache. 234 $css = '.my-class { display: block; }'; 235 wp_cache_set( 'wp_get_global_stylesheet', $css, 'theme_json' ); 236 237 // By default, caching should be used, so the above value will be returned. 238 $_wp_tests_development_mode = ''; 239 $this->assertSame( $css, wp_get_global_stylesheet(), 'Caching was not used despite development mode disabled' ); 240 241 // When the development mode is set to 'theme', caching should not be used. 242 $_wp_tests_development_mode = 'theme'; 243 $this->assertNotSame( $css, wp_get_global_stylesheet(), 'Caching was used despite theme development mode' ); 244 } 245 246 /** 224 247 * Adds the 'editor-font-sizes' theme support with custom font sizes. 225 248 * -
trunk/tools/local-env/scripts/install.js
r54096 r56042 17 17 wp_cli( `config set SCRIPT_DEBUG ${process.env.LOCAL_SCRIPT_DEBUG} --raw --type=constant` ); 18 18 wp_cli( `config set WP_ENVIRONMENT_TYPE ${process.env.LOCAL_WP_ENVIRONMENT_TYPE} --type=constant` ); 19 wp_cli( `config set WP_DEVELOPMENT_MODE ${process.env.LOCAL_WP_DEVELOPMENT_MODE} --type=constant` ); 19 20 20 21 // Move wp-config.php to the base directory, so it doesn't get mixed up in the src or build directories.
Note: See TracChangeset
for help on using the changeset viewer.