Skip to content

Commit

Permalink
Don't check if constants set by wp_initial_constants() are defined (#…
Browse files Browse the repository at this point in the history
…45979)

`wp_initial_constants()` makes sure that all the default constants are set.
  • Loading branch information
ocean90 authored Nov 24, 2022
1 parent 5cf5068 commit 7df3687
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/block-supports/duotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function gutenberg_get_duotone_filter_svg( $preset ) {

$svg = ob_get_clean();

if ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) {
if ( ! SCRIPT_DEBUG ) {
// Clean up the whitespace.
$svg = preg_replace( "/[\r\n\t ]+/", ' ', $svg );
$svg = str_replace( '> <', '><', $svg );
Expand Down Expand Up @@ -464,7 +464,7 @@ function gutenberg_render_duotone_support( $block_content, $block ) {

// !important is needed because these styles render before global styles,
// and they should be overriding the duotone filters set by global styles.
$filter_style = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG
$filter_style = SCRIPT_DEBUG
? $selector . " {\n\tfilter: " . $filter_property . " !important;\n}\n"
: $selector . '{filter:' . $filter_property . ' !important;}';

Expand Down
2 changes: 1 addition & 1 deletion lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function gutenberg_register_core_block_assets( $block_name ) {

// When in production, use the plugin's version as the default asset version;
// else (for development or test) default to use the current time.
$default_version = defined( 'GUTENBERG_VERSION' ) && ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? GUTENBERG_VERSION : time();
$default_version = defined( 'GUTENBERG_VERSION' ) && ! SCRIPT_DEBUG ? GUTENBERG_VERSION : time();

$style_path = "build/block-library/blocks/$block_name/";
$stylesheet_url = gutenberg_url( $style_path . 'style.css' );
Expand Down
6 changes: 3 additions & 3 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function gutenberg_override_style( $styles, $handle, $src, $deps = array(), $ver
function gutenberg_register_packages_scripts( $scripts ) {
// When in production, use the plugin's version as the default asset version;
// else (for development or test) default to use the current time.
$default_version = defined( 'GUTENBERG_VERSION' ) && ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? GUTENBERG_VERSION : time();
$default_version = defined( 'GUTENBERG_VERSION' ) && ! SCRIPT_DEBUG ? GUTENBERG_VERSION : time();

foreach ( glob( gutenberg_dir_path() . 'build/*/index.min.js' ) as $path ) {
// Prefix `wp-` to package directory to get script handle.
Expand Down Expand Up @@ -249,7 +249,7 @@ function gutenberg_register_packages_scripts( $scripts ) {
function gutenberg_register_packages_styles( $styles ) {
// When in production, use the plugin's version as the asset version;
// else (for development or test) default to use the current time.
$version = defined( 'GUTENBERG_VERSION' ) && ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? GUTENBERG_VERSION : time();
$version = defined( 'GUTENBERG_VERSION' ) && ! SCRIPT_DEBUG ? GUTENBERG_VERSION : time();

// Editor Styles.
gutenberg_override_style(
Expand Down Expand Up @@ -486,7 +486,7 @@ function gutenberg_enqueue_stored_styles( $options = array() ) {
$style_tag_id = 'core';
foreach ( $core_styles_keys as $style_key ) {
// Adds comment if code is prettified to identify core styles sections in debugging.
$should_prettify = isset( $options['prettify'] ) ? true === $options['prettify'] : defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
$should_prettify = isset( $options['prettify'] ) ? true === $options['prettify'] : SCRIPT_DEBUG;
if ( $should_prettify ) {
$compiled_core_stylesheet .= "/**\n * Core styles: $style_key\n */\n";
}
Expand Down
4 changes: 2 additions & 2 deletions lib/compat/wordpress-6.0/get-global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function gutenberg_get_global_styles_svg_filters() {
// It's cached by theme to make sure that theme switching clears the cache.
$transient_name = 'gutenberg_global_styles_svg_filters_' . get_stylesheet();
$can_use_cached = (
( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) &&
( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) &&
! WP_DEBUG &&
! SCRIPT_DEBUG &&
( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) &&
! is_admin()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function _wp_theme_has_theme_json_clean_cache_upon_upgrading_active_theme( $upgr
*/
function gutenberg_get_global_stylesheet( $types = array() ) {
// Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme developers workflow.
$can_use_cached = empty( $types ) && ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG );
$can_use_cached = empty( $types ) && ! WP_DEBUG;
$cache_key = 'gutenberg_get_global_stylesheet';
$cache_group = 'theme_json';
if ( $can_use_cached ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/experimental/html/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ public function set_attribute( $name, $value ) {
']~Ssu',
$name
) ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
if ( WP_DEBUG ) {
throw new Exception( 'Invalid attribute name' );
}

Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/block/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ function render_block_core_block( $attributes ) {
if ( isset( $seen_refs[ $attributes['ref'] ] ) ) {
// WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent
// is set in `wp_debug_mode()`.
$is_debug = defined( 'WP_DEBUG' ) && WP_DEBUG &&
defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY;
$is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;

return $is_debug ?
// translators: Visible only in the front end, this warning takes the place of a faulty block.
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/post-content/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ function render_block_core_post_content( $attributes, $content, $block ) {
if ( isset( $seen_ids[ $post_id ] ) ) {
// WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent
// is set in `wp_debug_mode()`.
$is_debug = defined( 'WP_DEBUG' ) && WP_DEBUG &&
defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY;
$is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;

return $is_debug ?
// translators: Visible only in the front end, this warning takes the place of a faulty block.
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/template-part/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ function render_block_core_template_part( $attributes ) {

// WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent
// is set in `wp_debug_mode()`.
$is_debug = defined( 'WP_DEBUG' ) && WP_DEBUG &&
defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY;
$is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;

if ( is_null( $content ) && $is_debug ) {
if ( ! isset( $attributes['slug'] ) ) {
Expand Down
2 changes: 1 addition & 1 deletion packages/style-engine/class-wp-style-engine-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function add_rules( $css_rules ) {
public function get_css( $options = array() ) {
$defaults = array(
'optimize' => true,
'prettify' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG,
'prettify' => SCRIPT_DEBUG,
);
$options = wp_parse_args( $options, $defaults );

Expand Down

0 comments on commit 7df3687

Please sign in to comment.