Skip to content

Commit

Permalink
General: Rename wp_in_development_mode() to `wp_is_development_mode…
Browse files Browse the repository at this point in the history
…()`.

This changes the function name for the helper function to check whether the current environment is running with the `WP_DEVELOPMENT_MODE` constant set to be more consistent with similar functions in core, like `wp_is_maintenance_mode()` and `wp_is_recover_mode()`.

Props flixos90, swissspidy, costdev, peterwilson, robinwpdeveloper, SergeyBiryukov, joemcgill.
See 57487.


git-svn-id: https://develop.svn.wordpress.org/trunk@56249 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
joemcgill committed Jul 17, 2023
1 parent 7df1b83 commit be1cb45
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/wp-includes/blocks/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ( ! wp_in_development_mode( 'core' ) ) {
if ( ! wp_is_development_mode( 'core' ) ) {
$transient_name = 'wp_core_block_css_files';
$files = get_transient( $transient_name );
if ( ! $files ) {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -5234,7 +5234,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_in_development_mode( 'theme' );
$can_use_cached = ! wp_is_development_mode( 'theme' );
$cache_group = 'theme_json';
$cache_key = 'wp_get_global_styles_svg_filters';
if ( $can_use_cached ) {
Expand Down
8 changes: 4 additions & 4 deletions src/wp-includes/global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_in_development_mode( 'theme' );
$can_use_cached = ! wp_is_development_mode( 'theme' );

$settings = false;
if ( $can_use_cached ) {
Expand Down Expand Up @@ -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_in_development_mode( 'theme' );
$can_use_cached = empty( $types ) && ! wp_is_development_mode( 'theme' );

/*
* By using the 'theme_json' group, this data is marked to be non-persistent across requests.
Expand Down Expand Up @@ -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_in_development_mode( 'theme' );
$can_use_cached = ! wp_is_development_mode( 'theme' );

/*
* By using the 'theme_json' group, this data is marked to be non-persistent across requests.
Expand Down Expand Up @@ -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_in_development_mode( 'theme' )
! wp_is_development_mode( 'theme' )
) {
return $theme_has_support[ $stylesheet ];
}
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function wp_get_environment_type() {
* It does not affect debugging output, but rather functional nuances in WordPress.
*
* This function retrieves the currently set development mode value. To check whether
* a specific development mode is enabled, use wp_in_development_mode().
* a specific development mode is enabled, use wp_is_development_mode().
*
* @since 6.3.0
*
Expand Down Expand Up @@ -325,7 +325,7 @@ function wp_get_development_mode() {
* @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 ) {
function wp_is_development_mode( $mode ) {
$current_mode = wp_get_development_mode();
if ( empty( $current_mode ) ) {
return false;
Expand Down
16 changes: 8 additions & 8 deletions tests/phpunit/tests/load/wpGetDevelopmentMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* @group load.php
* @covers ::wp_get_development_mode
* @covers ::wp_in_development_mode
* @covers ::wp_is_development_mode
*/
class Test_WP_Get_Development_Mode extends WP_UnitTestCase {

Expand Down Expand Up @@ -46,29 +46,29 @@ public function test_wp_get_development_mode_filter_invalid_value() {
}

/**
* Tests that `wp_in_development_mode()` returns expected results.
* Tests that `wp_is_development_mode()` returns expected results.
*
* @ticket 57487
* @dataProvider data_wp_in_development_mode
* @dataProvider data_wp_is_development_mode
*/
public function test_wp_in_development_mode( $current, $given, $expected ) {
public function test_wp_is_development_mode( $current, $given, $expected ) {
global $_wp_tests_development_mode;

$_wp_tests_development_mode = $current;

if ( $expected ) {
$this->assertTrue( wp_in_development_mode( $given ), "{$given} is expected to pass in {$current} mode" );
$this->assertTrue( wp_is_development_mode( $given ), "{$given} is expected to pass in {$current} mode" );
} else {
$this->assertFalse( wp_in_development_mode( $given ), "{$given} is expected to fail in {$current} mode" );
$this->assertFalse( wp_is_development_mode( $given ), "{$given} is expected to fail in {$current} mode" );
}
}

/**
* Data provider that returns test scenarios for the `test_wp_in_development_mode()` method.
* Data provider that returns test scenarios for the `test_wp_is_development_mode()` method.
*
* @return array[]
*/
public function data_wp_in_development_mode() {
public function data_wp_is_development_mode() {
return array(
'core mode, testing for core' => array(
'core',
Expand Down

0 comments on commit be1cb45

Please sign in to comment.