Backports https://github.com/WordPress/gutenberg/pull/46074 into the core.
render_layout_support_flag is run per block, and inside we called get_global_settings three times. get_global_settings calls get_merged_data, which is costly. render_layout_support_flag is a filter called during the block render. When the blocks start rendering, there is no expectation that the theme.json settings change during the block render, so the settings and their derived information should all be static information of this function.
This simple change removes 3*NUMBER_OF_BLOCKS calls of get_merged_data to just one call.
Props oandregal, aristath, felixarntz, tellthemachines, andrewserong, aaronrobertshaw, aaronrobertshaw.
Built from https://develop.svn.wordpress.org/trunk@55167
git-svn-id: http://core.svn.wordpress.org/trunk@54700 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset adds `$user_id`, `$expire`, `$expiration` and `$token` parameters to provide context to `send_auth_cookies` hook, which allows the filter to skip sending auth cookies.
Props dd32, mukesh27, costdev, peterwilsoncc, audrasjb.
Fixes#56971.
See #39367.
Built from https://develop.svn.wordpress.org/trunk@55164
git-svn-id: http://core.svn.wordpress.org/trunk@54697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit adds inline comments instructing PHPCS to ignore parameters with reserved keywords in the affected methods that should not be renamed:
* `$string` parameter in `WP_Text_Diff_Renderer_inline::_splitOnWords()`
* `$final` parameter in `WP_Text_Diff_Renderer_Table::_changed()` and `::interleave_changed_lines()`
This resolves a few WPCS warnings along the lines of:
{{{
It is recommended not to use reserved keyword "string" as function parameter name. Found: $string
It is recommended not to use reserved keyword "final" as function parameter name. Found: $final
}}}
The two `WP_Text_Diff_Renderer_*` classes in question extend the `Text_Diff_Renderer_inline` and `Text_Diff_Renderer` classes from the `Text_Diff` package and should have the same parameters as the parent class methods, per the Task 1 section of ticket #51553.
The `Text_Diff` library currently included in WordPress core is no longer kept in sync with the upstream project and can be considered “adopted”, so the `$string` and `$final` parameters in the parent class methods can technically be renamed, e.g. to `$input_string` and `$modified`, respectively.
However, the “final” wording is also used to represent modified content in other parts the library, so it is more internally consistent to keep these parameters as is for now.
Follow-up to [7747], [38352], [55136].
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55163
git-svn-id: http://core.svn.wordpress.org/trunk@54696 1a063a9b-81f0-0310-95a4-ce76da25c4cd
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.
This commit renames the `$class` parameter to `$classname` in `sanitize_html_class()`.
Follow-up to [54927].
See also: [search:?q=code+modernization+rename+parameters+that+use+reserved+keywords&changeset=on equivalent commits for other files].
Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55162
git-svn-id: http://core.svn.wordpress.org/trunk@54695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This new function makes it easier to switch to a specific user’s locale by reducing duplicate code and storing the user’s ID as additional context for plugins to consume. Existing usage of `switch_to_locale()` in core has been replaced with `switch_to_user_locale()` where appropriate.
Also, this change ensures `WP_Locale_Switcher` properly filters `determine_locale` so that anyyone using the `determine_locale()` function will get the correct locale information when switching is in effect.
Props costdev.
Fixes#57123.
See #26511.
Built from https://develop.svn.wordpress.org/trunk@55161
git-svn-id: http://core.svn.wordpress.org/trunk@54694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Introduced along with the `did_filter()` function, the `$wp_filters` global stores the number of times each filter has been applied during the current request.
This commit adds `$wp_filters` to the list of globals that are saved in `WP_UnitTestCase_Base::_backup_hooks()` and restored in `::_restore_hooks()` so that hooks set by the current test do not accidentally affect future tests.
Additionally, this commit brings some consistency by backing up and restoring the hook-related globals in the same order they are defined in `wp-includes/plugin.php`.
Follow-up to [29251], [53803].
Props sanjucta, SergeyBiryukov.
Fixes#57236.
Built from https://develop.svn.wordpress.org/trunk@55160
git-svn-id: http://core.svn.wordpress.org/trunk@54693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This amends the previous commit to avoid a warning on PHP < 7.2.18 if haystack is an empty string:
{{{
Warning: substr_compare(): The start position cannot exceed initial string length
}}}
Follow-up to [55151], [55157].
See #52506.
Built from https://develop.svn.wordpress.org/trunk@55158
git-svn-id: http://core.svn.wordpress.org/trunk@54691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This avoids a fatal error if the file is included directly outside of WordPress core, e.g. by HyperDB.
While WordPress core does include a polyfill function, it is not directly loaded in the `wpdb` class.
This commit replaces the `str_ends_with()` calls with `substr_compare()` for now.
Follow-up to [55151].
Props Otto42.
See #52506.
Built from https://develop.svn.wordpress.org/trunk@55157
git-svn-id: http://core.svn.wordpress.org/trunk@54690 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset is part of a greater effort to enhance the caching strategy for `theme.json` based data. Similar to [55138] and [55148], the cache is currently ignored when `WP_DEBUG` is on to avoid interrupting the theme developer's workflow.
This addition of a non-persistent cache results in a significant performance improvement for the overall load time of WordPress, with the Server-Timing load metric being ~8% faster and Time to First Byte being 25+% faster than before.
Props oandregal, spacedmonkey, hellofromtonya, flixos90, azaozz, aristath.
Fixes#57502.
Built from https://develop.svn.wordpress.org/trunk@55155
git-svn-id: http://core.svn.wordpress.org/trunk@54688 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In the autosave REST API endpoint, avoid excessive database writes when an autosave is sent with content that is unchanged from the saved post.
Before this fix, clicking "preview" in the editor (which uses the autosave feature) multiple times would cause an identical autosave entry to be deleted and re-created repeatedly.
Props inwerpsel, aduth, mukesh27, ironprogrammer.
Fixes#49532.
Built from https://develop.svn.wordpress.org/trunk@55154
git-svn-id: http://core.svn.wordpress.org/trunk@54687 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates the following third-party GitHub Actions to their latest versions.
- `actions/cache`
- `actions/checkout`
- `actions/upload-artifact`
- `actions/setup-node`
- `actions/setup-php`
- `actions/github-script`
See #57572.
Built from https://develop.svn.wordpress.org/trunk@55152
git-svn-id: http://core.svn.wordpress.org/trunk@54685 1a063a9b-81f0-0310-95a4-ce76da25c4cd
[53575] during the 6.1 cycle was reverted in [54734] to address issues around multiple `%` placeholders not being properly quoted as reported in #56933. Since then, this issue has been resolved and the underlying code improved significantly. Additionally, the unit tests have been expanded and the inline docs have been improved as well.
This change reintroduces `%i` placeholder support in `$wpdb->prepare()` to give extenders the ability to safely escape table and column names in database queries.
Follow-up to [53575] and [54734].
Props craigfrancis, jrf, xknown, costdev, ironprogrammer, SergeyBiryukov.
Fixes#52506.
Built from https://develop.svn.wordpress.org/trunk@55151
git-svn-id: http://core.svn.wordpress.org/trunk@54684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates PostCSS related dependencies for the main Core build process to versions that use the latest major version of PostCSS, 8.x.
There were no changes to any versioned CSS files as a result of this update directly. However, two occurrences of `-o-tab-size` have been removed due to the version of `caniuse-lite` used being updated in the process.
See #57554, #57555.
Built from https://develop.svn.wordpress.org/trunk@55150
git-svn-id: http://core.svn.wordpress.org/trunk@54683 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset is part of a greater effort to enhance the caching strategy for `theme.json` based data. Similar to [55138], the cache is currently ignored when `WP_DEBUG` is on to avoid interrupting the theme developer's workflow.
Props oandregal, spacedmonkey, hellofromtonya, flixos90, ironprogrammer, azaozz, aristath, costdev, mcsf.
Fixes#56910.
Built from https://develop.svn.wordpress.org/trunk@55148
git-svn-id: http://core.svn.wordpress.org/trunk@54681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `get_default_block_editor_settings()` function included several pieces of data that are irrelevant for the purpose that `WP_Theme_JSON_Resolver` was calling it for, yet resulted in three database queries on page load that can be avoided.
This changeset introduces a new function `get_classic_theme_supports_block_editor_settings()` to takes responsibility of only the data needed in `WP_Theme_JSON_Resolver`, which now uses that function. This leads to a reduction of database queries and accordingly a performance improvement.
Props mamaduka, spacedmonkey, oandregal, flixos90, audrasjb, mukesh27.
Fixes#57547.
Built from https://develop.svn.wordpress.org/trunk@55146
git-svn-id: http://core.svn.wordpress.org/trunk@54679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The WordPress recovery mode only works in combination with the fatal error handler that works as the entry mode for recovery mode. The fatal error handler can be disabled using the `WP_DISABLE_FATAL_ERROR_HANDLER` constant, but so far the logic in the `WP_Recovery_Mode` class was still being initialized even when that constant was set to `true`, which is unnecessary.
This changeset updates the WordPress bootstrap process to only initialize `WP_Recovery_Mode` when needed.
Props costdev.
Fixes#56848.
Built from https://develop.svn.wordpress.org/trunk@55143
git-svn-id: http://core.svn.wordpress.org/trunk@54676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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:
* https://github.com/WordPress/gutenberg/pull/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
For performance, a static variable is added to `wp_theme_has_theme_json()` to cache the boolean result of determining if a theme (or its parent) has a `theme.json` file.
This cache avoids the overhead of calling `get_stylesheet_directory()` and `get_template_directory()` each time `wp_theme_has_theme_json()` is invoked.
The cache is lean, non-persistent, and encapsulated within the function (i.e. function scope and not available externally).
The cache is ignored when:
* `WP_DEBUG` is on to avoid interrupting theme developer's workflow and for extender automated test suites.
* `WP_RUN_CORE_TESTS` is on to ensure each Core test exercises the checking code.
Follow-up to [55092], [55086].
Props oandregal, azaozz, costdev, dmsnell, flixos90, hellofromTonya, Otto42, spacedmonkey.
Fixes#56975.
Built from https://develop.svn.wordpress.org/trunk@55138
git-svn-id: http://core.svn.wordpress.org/trunk@54671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates the `caniuse-lite` database from `1.0.30001407` to `1.0.30001448` and applies the resulting changes to generated WP Admin CSS.
This removes two occurrences of `-o-tab-size`, which was required for partial support of the `tab-size` property in Opera Mini. Usage has dropped below 1%, hence this vendor prefix being removed.
See #57555.
Built from https://develop.svn.wordpress.org/trunk@55137
git-svn-id: http://core.svn.wordpress.org/trunk@54670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Parameter names for PHP polyfills in WordPress core need to 100% match the native PHP parameter names. Otherwise using named parameters with those functions could cause fatal errors for installations where the polyfills kick in.
This commit adds inline comments instructing PHPCS to ignore parameters with reserved keywords in the affected functions that should not be renamed:
* `$string` parameter in `mb_substr()` and `mb_strlen()`
* `$array` parameter in `array_key_first()` and `array_key_last()`
This resolves a few WPCS warnings along the lines of:
{{{
It is recommended not to use reserved keyword "string" as function parameter name. Found: $string
}}}
Follow-up to [7140], [10707], [17603], [17621], [32114], [52038], [53365].
Props jrf.
See #56788, #56791.
Built from https://develop.svn.wordpress.org/trunk@55136
git-svn-id: http://core.svn.wordpress.org/trunk@54669 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset replaces `this.element._trigger('focus');` with `this.element.trigger('focus');` in `wpdialog` to fix a JS error introduced in [55052].
Indeed, `this` inside the `open()` function of `wpdialog` refers to the jQuery UI widget, whereas `this.element` is the jQuery object of the DOM element. Thus, native jQuery methods need to be used, as `_trigger` is only defined on the jQuery UI widget.
Follow-up to [55052].
Props TobiasBg, audrasjb, shubham1gupta.
Fixes#56830.
Built from https://develop.svn.wordpress.org/trunk@55134
git-svn-id: http://core.svn.wordpress.org/trunk@54667 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds pagination and ordering support to `WP_REST_Pattern_Directory_Controller` by allow listing `'per_page'`, `'page'`, `'offset'`, `'order'`, and `'orderby'` query parameters. This change enables pagination and ordering features in the pattern directory explorer by using the same sort as wordpress.org/patterns.
Reference:
* [https://github.com/WordPress/gutenberg/pull/45293 Gutenberg PR 45293]
Follow-up to [55098], [51206], [51021].
Props ntsekouras, ryelle, arrasel403, hellofromTonya, ironprogrammer, mukesh27, robinwpdeveloper.
Fixes#57501.
Built from https://develop.svn.wordpress.org/trunk@55132
git-svn-id: http://core.svn.wordpress.org/trunk@54665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.
This commit renames the `$global` parameter to `$global_name` in `Tests_Kses::test_kses_globals_are_defined()`.
Follow-up to [52229], [54203], [55090].
Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55131
git-svn-id: http://core.svn.wordpress.org/trunk@54664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.
This commit renames the `$echo` parameter to `$display` in `Tests_Functions_wpRefererField::test_wp_referer_field_should_respect_display_arg()`.
Follow-up to [54420], [54929].
Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55130
git-svn-id: http://core.svn.wordpress.org/trunk@54663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds a new non-public `WP_REST_Block_Patterns_Controller::migrate_pattern_categories()` method to automatically migrate existing content's pattern categories to the new ones introduced in [55098].
Old to New
`'buttons'` to `'call-to-action'`
`'columns'` to `'text'`
`'query'` to `'posts'`
Reference:
* Part of [https://github.com/WordPress/gutenberg/pull/46144 Gutenberg PR 46144]
Follow-up to [55098], [53152].
Props ntsekouras, annezazu, jameskoster, joen, hellofromTonya, mcsf, paaljoachim, ryelle.
Fixes#57532.
Built from https://develop.svn.wordpress.org/trunk@55125
git-svn-id: http://core.svn.wordpress.org/trunk@54658 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset fixes a bug where clicking on an anchor link in the content changes the state of the button that opens and closes the responsive menu. It adds a conditional to check if the clicked anchor link is inside the primary navigation menu (`#site-navigation`), in order to prevent content anchor links from changing the state of the button.
Known limitations: The state of the button is not reset when the browser is resized. If a menu anchor link is first clicked while on desktop width, and the browser width is reduced, the menu button will show the text "Close" even though the menu is not opened.
Props andreaboe, sabernhardt, poena, afercia, chaion07, cu121, mukesh27.
Fixes#53331.
Built from https://develop.svn.wordpress.org/trunk@55124
git-svn-id: http://core.svn.wordpress.org/trunk@54657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset removes color names from pattern names to make them less opinionated, and avoid mismatching when the user changes related colors. It does not update filenames for now, as they are not directly exposed to end users.
Props poena, mukesh27.
Fixes#56720.
Built from https://develop.svn.wordpress.org/trunk@55122
git-svn-id: http://core.svn.wordpress.org/trunk@54655 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset adds support for `:link` and `:any-link` in `theme.json`, using the `VALID_ELEMENT_PSEUDO_SELECTORS` array. `:link` can be used to style unvisited links and `:any-link` can be used to style any link containing an `href` attribute.
Props peterwilsoncc, whaze, audrasjb, costdev, mukesh27.
Fixes#57053.
Built from https://develop.svn.wordpress.org/trunk@55121
git-svn-id: http://core.svn.wordpress.org/trunk@54654 1a063a9b-81f0-0310-95a4-ce76da25c4cd