-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't check if constants set by wp_initial_constants()
are defined
#45979
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
spacedmonkey
approved these changes
Nov 24, 2022
85 tasks
pento
pushed a commit
to WordPress/wordpress-develop
that referenced
this pull request
Jan 18, 2023
Adds `wp_theme_has_theme_json()` for public consumption, to replace the private internal Core-only `WP_Theme_JSON_Resolver::theme_has_support()` method. This new global function checks if a theme or its parent has a `theme.json` file. For performance, results are cached as an integer `1` or `0` in the `'theme_json'` group with `'wp_theme_has_theme_json'` key. This is a non-persistent cache. Why? To make the derived data from `theme.json` is always fresh from the potential modifications done via hooks that can use dynamic data (modify the stylesheet depending on some option, settings depending on user permissions, etc.). Also adds a new public function `wp_clean_theme_json_cache()` to clear the cache on `'switch_theme'` and `start_previewing_theme'`. References: * [WordPress/gutenberg#45168 Gutenberg PR 45168] Add `wp_theme_has_theme_json` as a public API to know whether a theme has a `theme.json`. * [WordPress/gutenberg#45380 Gutenberg PR 45380] Deprecate `WP_Theme_JSON_Resolver:theme_has_support()`. * [WordPress/gutenberg#46150 Gutenberg PR 46150] Make `theme.json` object caches non-persistent. * [WordPress/gutenberg#45979 Gutenberg PR 45979] Don't check if constants set by `wp_initial_constants()` are defined. * [WordPress/gutenberg#45950 Gutenberg PR 45950] Cleaner logic in `wp_theme_has_theme_json`. Follow-up to [54493], [53282], [52744], [52049], [50959]. Props oandregal, afragen, alexstine, aristath, azaozz, costdev, flixos90, hellofromTonya, mamaduka, mcsf, ocean90, spacedmonkey. Fixes #56975. git-svn-id: https://develop.svn.wordpress.org/trunk@55086 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith
pushed a commit
to markjaquith/WordPress
that referenced
this pull request
Jan 18, 2023
Adds `wp_theme_has_theme_json()` for public consumption, to replace the private internal Core-only `WP_Theme_JSON_Resolver::theme_has_support()` method. This new global function checks if a theme or its parent has a `theme.json` file. For performance, results are cached as an integer `1` or `0` in the `'theme_json'` group with `'wp_theme_has_theme_json'` key. This is a non-persistent cache. Why? To make the derived data from `theme.json` is always fresh from the potential modifications done via hooks that can use dynamic data (modify the stylesheet depending on some option, settings depending on user permissions, etc.). Also adds a new public function `wp_clean_theme_json_cache()` to clear the cache on `'switch_theme'` and `start_previewing_theme'`. References: * [WordPress/gutenberg#45168 Gutenberg PR 45168] Add `wp_theme_has_theme_json` as a public API to know whether a theme has a `theme.json`. * [WordPress/gutenberg#45380 Gutenberg PR 45380] Deprecate `WP_Theme_JSON_Resolver:theme_has_support()`. * [WordPress/gutenberg#46150 Gutenberg PR 46150] Make `theme.json` object caches non-persistent. * [WordPress/gutenberg#45979 Gutenberg PR 45979] Don't check if constants set by `wp_initial_constants()` are defined. * [WordPress/gutenberg#45950 Gutenberg PR 45950] Cleaner logic in `wp_theme_has_theme_json`. Follow-up to [54493], [53282], [52744], [52049], [50959]. Props oandregal, afragen, alexstine, aristath, azaozz, costdev, flixos90, hellofromTonya, mamaduka, mcsf, ocean90, spacedmonkey. Fixes #56975. Built from https://develop.svn.wordpress.org/trunk@55086 git-svn-id: http://core.svn.wordpress.org/trunk@54619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot
pushed a commit
to gilzow/wordpress-performance
that referenced
this pull request
Jan 18, 2023
Adds `wp_theme_has_theme_json()` for public consumption, to replace the private internal Core-only `WP_Theme_JSON_Resolver::theme_has_support()` method. This new global function checks if a theme or its parent has a `theme.json` file. For performance, results are cached as an integer `1` or `0` in the `'theme_json'` group with `'wp_theme_has_theme_json'` key. This is a non-persistent cache. Why? To make the derived data from `theme.json` is always fresh from the potential modifications done via hooks that can use dynamic data (modify the stylesheet depending on some option, settings depending on user permissions, etc.). Also adds a new public function `wp_clean_theme_json_cache()` to clear the cache on `'switch_theme'` and `start_previewing_theme'`. References: * [WordPress/gutenberg#45168 Gutenberg PR 45168] Add `wp_theme_has_theme_json` as a public API to know whether a theme has a `theme.json`. * [WordPress/gutenberg#45380 Gutenberg PR 45380] Deprecate `WP_Theme_JSON_Resolver:theme_has_support()`. * [WordPress/gutenberg#46150 Gutenberg PR 46150] Make `theme.json` object caches non-persistent. * [WordPress/gutenberg#45979 Gutenberg PR 45979] Don't check if constants set by `wp_initial_constants()` are defined. * [WordPress/gutenberg#45950 Gutenberg PR 45950] Cleaner logic in `wp_theme_has_theme_json`. Follow-up to [54493], [53282], [52744], [52049], [50959]. Props oandregal, afragen, alexstine, aristath, azaozz, costdev, flixos90, hellofromTonya, mamaduka, mcsf, ocean90, spacedmonkey. Fixes #56975. Built from https://develop.svn.wordpress.org/trunk@55086 git-svn-id: https://core.svn.wordpress.org/trunk@54619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
pento
pushed a commit
to WordPress/wordpress-develop
that referenced
this pull request
Jan 25, 2023
The constant `WP_DEBUG` is a default constant that is set within `wp_initial_constants()` when not defined. This means the constant will always be defined, thus making the `defined( 'WP_DEBUG' )` unnecessary. Removing the `defined()` provides these benefits: * Makes the code more readable. * Tiny performance optimization. References: * WordPress/gutenberg#45979 Follow-up to [52049]. Props ocean90, spacedmonkey, mamaduka. See #57527. git-svn-id: https://develop.svn.wordpress.org/trunk@55141 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith
pushed a commit
to markjaquith/WordPress
that referenced
this pull request
Jan 25, 2023
The constant `WP_DEBUG` is a default constant that is set within `wp_initial_constants()` when not defined. This means the constant will always be defined, thus making the `defined( 'WP_DEBUG' )` unnecessary. Removing the `defined()` provides these benefits: * Makes the code more readable. * Tiny performance optimization. References: * WordPress/gutenberg#45979 Follow-up to [52049]. Props ocean90, spacedmonkey, mamaduka. See #57527. Built from https://develop.svn.wordpress.org/trunk@55141 git-svn-id: http://core.svn.wordpress.org/trunk@54674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot
pushed a commit
to platformsh/wordpress-performance
that referenced
this pull request
Jan 25, 2023
The constant `WP_DEBUG` is a default constant that is set within `wp_initial_constants()` when not defined. This means the constant will always be defined, thus making the `defined( 'WP_DEBUG' )` unnecessary. Removing the `defined()` provides these benefits: * Makes the code more readable. * Tiny performance optimization. References: * WordPress/gutenberg#45979 Follow-up to [52049]. Props ocean90, spacedmonkey, mamaduka. See #57527. Built from https://develop.svn.wordpress.org/trunk@55141 git-svn-id: https://core.svn.wordpress.org/trunk@54674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
VenusPR
added a commit
to VenusPR/Wordpress_Richard
that referenced
this pull request
Mar 9, 2023
Adds `wp_theme_has_theme_json()` for public consumption, to replace the private internal Core-only `WP_Theme_JSON_Resolver::theme_has_support()` method. This new global function checks if a theme or its parent has a `theme.json` file. For performance, results are cached as an integer `1` or `0` in the `'theme_json'` group with `'wp_theme_has_theme_json'` key. This is a non-persistent cache. Why? To make the derived data from `theme.json` is always fresh from the potential modifications done via hooks that can use dynamic data (modify the stylesheet depending on some option, settings depending on user permissions, etc.). Also adds a new public function `wp_clean_theme_json_cache()` to clear the cache on `'switch_theme'` and `start_previewing_theme'`. References: * [WordPress/gutenberg#45168 Gutenberg PR 45168] Add `wp_theme_has_theme_json` as a public API to know whether a theme has a `theme.json`. * [WordPress/gutenberg#45380 Gutenberg PR 45380] Deprecate `WP_Theme_JSON_Resolver:theme_has_support()`. * [WordPress/gutenberg#46150 Gutenberg PR 46150] Make `theme.json` object caches non-persistent. * [WordPress/gutenberg#45979 Gutenberg PR 45979] Don't check if constants set by `wp_initial_constants()` are defined. * [WordPress/gutenberg#45950 Gutenberg PR 45950] Cleaner logic in `wp_theme_has_theme_json`. Follow-up to [54493], [53282], [52744], [52049], [50959]. Props oandregal, afragen, alexstine, aristath, azaozz, costdev, flixos90, hellofromTonya, mamaduka, mcsf, ocean90, spacedmonkey. Fixes #56975. Built from https://develop.svn.wordpress.org/trunk@55086 git-svn-id: http://core.svn.wordpress.org/trunk@54619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
VenusPR
added a commit
to VenusPR/Wordpress_Richard
that referenced
this pull request
Mar 9, 2023
The constant `WP_DEBUG` is a default constant that is set within `wp_initial_constants()` when not defined. This means the constant will always be defined, thus making the `defined( 'WP_DEBUG' )` unnecessary. Removing the `defined()` provides these benefits: * Makes the code more readable. * Tiny performance optimization. References: * WordPress/gutenberg#45979 Follow-up to [52049]. Props ocean90, spacedmonkey, mamaduka. See #57527. Built from https://develop.svn.wordpress.org/trunk@55141 git-svn-id: http://core.svn.wordpress.org/trunk@54674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
This reduces the number of
defined()
calls for constants which are always set.Why?
wp_initial_constants()
makes sure that all the default constants are set.How?
defined()
calls removed forWP_DEBUG
,SCRIPT_DEBUG
, andWP_DEBUG_DISPLAY
.Testing Instructions
Screenshots or screencast