Make WordPress Core


Ignore:
Timestamp:
07/13/2023 12:27:06 AM (19 months ago)
Author:
peterwilsoncc
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r56153 r56223  
    272272 * developing for WordPress.
    273273 *
    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.
    275276 *
    276277 * Developer mode is considered separately from `WP_DEBUG` and {@see wp_get_environment_type()}. It does not affect
    277278 * 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().
    278282 *
    279283 * @since 6.3.0
     
    299303        'plugin',
    300304        'theme',
     305        'all',
    301306        '',
    302307    );
     
    308313
    309314    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 */
     325function 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;
    310338}
    311339
Note: See TracChangeset for help on using the changeset viewer.