Make WordPress Core


Ignore:
Timestamp:
06/26/2023 07:55:28 PM (3 years ago)
Author:
flixos90
Message:

General: Introduce WP_DEVELOPMENT_MODE constant to signify context-specific development mode.

In recent releases, WordPress core added several instances of cache usage around specific files. While those caches are safe to use in a production context, in development certain nuances apply for whether or not those caches make sense to use. Initially, WP_DEBUG was used as a temporary workaround, but it was clear that a more granular method to signify a specific development mode was required: For example, caches around theme.json should be disabled when working on a theme as otherwise it would disrupt the theme developer's workflow, but when working on a plugin or WordPress core, this consideration does not apply.

This changeset introduces a WP_DEVELOPMENT_MODE constant which, for now, can be set to either "core", "plugin", "theme", or an empty string, the latter of which means no development mode, which is also the default. A new function wp_get_development_mode() is the recommended way to retrieve that configuration value.

With the new function available, this changeset replaces all existing instances of the aforementioned WP_DEBUG workaround to use wp_get_development_mode() with a more specific check.

Props azaozz, sergeybiryukov, peterwilsoncc, spacedmonkey.
Fixes #57487.

File:
1 edited

Legend:

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

    r56032 r56042  
    7878    }
    7979
     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
    8089    // Add define( 'WP_DEBUG', true ); to wp-config.php to enable display of notices during development.
    8190    if ( ! defined( 'WP_DEBUG' ) ) {
    82         if ( 'development' === wp_get_environment_type() ) {
     91        if ( wp_get_development_mode() || 'development' === wp_get_environment_type() ) {
    8392            define( 'WP_DEBUG', true );
    8493        } else {
Note: See TracChangeset for help on using the changeset viewer.