Changeset 56223
- Timestamp:
- 07/13/2023 12:27:06 AM (17 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/index.php
r56136 r56223 45 45 * the core developer's workflow. 46 46 */ 47 if ( 'core' !== wp_get_development_mode() ) {47 if ( ! wp_in_development_mode( 'core' ) ) { 48 48 $transient_name = 'wp_core_block_css_files'; 49 49 $files = get_transient( $transient_name ); -
trunk/src/wp-includes/default-constants.php
r56180 r56223 80 80 /* 81 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, a83 * plugin, or a themerespectively.82 * define( 'WP_DEVELOPMENT_MODE', 'theme' ) or define( 'WP_DEVELOPMENT_MODE', 'all' ) to wp-config.php 83 * to signify development mode for WordPress core, a plugin, a theme, or all three types respectively. 84 84 */ 85 85 if ( ! defined( 'WP_DEVELOPMENT_MODE' ) ) { -
trunk/src/wp-includes/deprecated.php
r56126 r56223 5234 5234 * developer's workflow. 5235 5235 */ 5236 $can_use_cached = wp_get_development_mode() !== 'theme';5236 $can_use_cached = ! wp_in_development_mode( 'theme' ); 5237 5237 $cache_group = 'theme_json'; 5238 5238 $cache_key = 'wp_get_global_styles_svg_filters'; -
trunk/src/wp-includes/global-styles-and-settings.php
r56185 r56223 70 70 * developer's workflow. 71 71 */ 72 $can_use_cached = wp_get_development_mode() !== 'theme';72 $can_use_cached = ! wp_in_development_mode( 'theme' ); 73 73 74 74 $settings = false; … … 153 153 * developer's workflow. 154 154 */ 155 $can_use_cached = empty( $types ) && wp_get_development_mode() !== 'theme';155 $can_use_cached = empty( $types ) && ! wp_in_development_mode( 'theme' ); 156 156 157 157 /* … … 252 252 * developer's workflow. 253 253 */ 254 $can_use_cached = wp_get_development_mode() !== 'theme';254 $can_use_cached = ! wp_in_development_mode( 'theme' ); 255 255 256 256 /* … … 361 361 * the theme developer's workflow. 362 362 */ 363 wp_get_development_mode() !== 'theme'363 ! wp_in_development_mode( 'theme' ) 364 364 ) { 365 365 return $theme_has_support[ $stylesheet ]; -
trunk/src/wp-includes/load.php
r56153 r56223 272 272 * developing for WordPress. 273 273 * 274 * Valid developer modes are 'core', 'plugin', 'theme', or an empty string to disable developer mode. 274 * Valid development modes are 'core', 'plugin', 'theme', 'all', or an empty string to disable development mode. 275 * 'all' is a special value to signify that all three development modes 'core', 'plugin', and 'theme' are enabled. 275 276 * 276 277 * Developer mode is considered separately from `WP_DEBUG` and {@see wp_get_environment_type()}. It does not affect 277 278 * debugging output, but rather functional nuances in WordPress. 279 * 280 * This function controls the currently set development mode value. To check for whether a specific development mode is 281 * enabled, use wp_in_development_mode(). 278 282 * 279 283 * @since 6.3.0 … … 299 303 'plugin', 300 304 'theme', 305 'all', 301 306 '', 302 307 ); … … 308 313 309 314 return $current_mode; 315 } 316 317 /** 318 * Checks whether the site is in the given development mode. 319 * 320 * @since 6.3.0 321 * 322 * @param string $mode Development mode to check for. Either 'core', 'plugin', 'theme', or 'all'. 323 * @return bool True if the given mode is covered by the current development mode, false otherwise. 324 */ 325 function wp_in_development_mode( $mode ) { 326 $current_mode = wp_get_development_mode(); 327 if ( empty( $current_mode ) ) { 328 return false; 329 } 330 331 // Return true if the current mode encompasses all modes. 332 if ( 'all' === $current_mode ) { 333 return true; 334 } 335 336 // Return true if the current mode is the given mode. 337 return $mode === $current_mode; 310 338 } 311 339 -
trunk/tests/phpunit/tests/load/wpGetDevelopmentMode.php
r56042 r56223 9 9 * @group load.php 10 10 * @covers ::wp_get_development_mode 11 * @covers ::wp_in_development_mode 11 12 */ 12 13 class Test_WP_Get_Development_Mode extends WP_UnitTestCase { … … 44 45 $this->assertSame( '', wp_get_development_mode() ); 45 46 } 47 48 /** 49 * Tests that `wp_in_development_mode()` returns expected results. 50 * 51 * @ticket 57487 52 * @dataProvider data_wp_in_development_mode 53 */ 54 public function test_wp_in_development_mode( $current, $given, $expected ) { 55 global $_wp_tests_development_mode; 56 57 $_wp_tests_development_mode = $current; 58 59 if ( $expected ) { 60 $this->assertTrue( wp_in_development_mode( $given ), "{$given} is expected to pass in {$current} mode" ); 61 } else { 62 $this->assertFalse( wp_in_development_mode( $given ), "{$given} is expected to fail in {$current} mode" ); 63 } 64 } 65 66 /** 67 * Data provider that returns test scenarios for the `test_wp_in_development_mode()` method. 68 * 69 * @return array[] 70 */ 71 public function data_wp_in_development_mode() { 72 return array( 73 'core mode, testing for core' => array( 74 'core', 75 'core', 76 true, 77 ), 78 'plugin mode, testing for plugin' => array( 79 'plugin', 80 'plugin', 81 true, 82 ), 83 'theme mode, testing for theme' => array( 84 'theme', 85 'theme', 86 true, 87 ), 88 'core mode, testing for plugin' => array( 89 'core', 90 'plugin', 91 false, 92 ), 93 'core mode, testing for theme' => array( 94 'core', 95 'theme', 96 false, 97 ), 98 'plugin mode, testing for core' => array( 99 'plugin', 100 'core', 101 false, 102 ), 103 'plugin mode, testing for theme' => array( 104 'plugin', 105 'theme', 106 false, 107 ), 108 'theme mode, testing for core' => array( 109 'theme', 110 'core', 111 false, 112 ), 113 'theme mode, testing for plugin' => array( 114 'theme', 115 'plugin', 116 false, 117 ), 118 'all mode, testing for core' => array( 119 'all', 120 'core', 121 true, 122 ), 123 'all mode, testing for plugin' => array( 124 'all', 125 'plugin', 126 true, 127 ), 128 'all mode, testing for theme' => array( 129 'all', 130 'theme', 131 true, 132 ), 133 'all mode, testing for all' => array( 134 'all', 135 'all', 136 true, 137 ), 138 'all mode, testing for non-standard value' => array( 139 'all', 140 'random', 141 true, 142 ), 143 'invalid mode, testing for core' => array( 144 'invalid', 145 'core', 146 false, 147 ), 148 'invalid mode, testing for plugin' => array( 149 'invalid', 150 'plugin', 151 false, 152 ), 153 'invalid mode, testing for theme' => array( 154 'invalid', 155 'theme', 156 false, 157 ), 158 ); 159 } 46 160 }
Note: See TracChangeset
for help on using the changeset viewer.