This changeset updates the private vars and methods in the Global styles revisions rest API controller to be protected, so class entities that inherit
from the base can use them, and to allow iterating on 6.3 features without having to copy over private methods to new classes.
Props ramonopoly.
Fixes#58846.
Built from https://develop.svn.wordpress.org/trunk@56268
git-svn-id: http://core.svn.wordpress.org/trunk@55780 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset fixes a PHP notice appearing when a template part is created in the site editor. It also adds a unit test case to cover
`WP_REST_Templates_Controller::prepare_item_for_database`.
Props wildworks, dunhakdis, Rahmohn, oglekler, audrasjb, mukesh27, costdev, dunhakdis.
Fixes#57851.
Built from https://develop.svn.wordpress.org/trunk@56248
git-svn-id: http://core.svn.wordpress.org/trunk@55760 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Correctly return the existing autosave when an unchanged autosave is saved, instead of returning an error.
Fix regressions after r55154 where an error and not the original autosave was returned when saving with unchanged data (for example, clicking the preview button repeatedly). Returning the autosave (ID) is the expected behavior for the endpoint.
Follow up to [55154]
Props Mamaduka, jeroenrotty, mrfoxtalbot.
Fixes#58739.
Built from https://develop.svn.wordpress.org/trunk@56163
git-svn-id: http://core.svn.wordpress.org/trunk@55675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Resolves a bug where a post save will be reported as failed if the post includes any meta keys the current user does not have authorization to update, even when those meta values are unchanged.
Write authorization is now checked for a meta key only when the value of that key has changed, so that passing a REST response back unchanged will not cause failures.
Authorization is only needed when data will be updated.
Props ckoerner, TimothyBlynJacobs, spacedmonkey
Built from https://develop.svn.wordpress.org/trunk@56075
git-svn-id: http://core.svn.wordpress.org/trunk@55587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).
WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.
Follow-up to [55988], [56021].
See #58206.
Built from https://develop.svn.wordpress.org/trunk@56031
git-svn-id: http://core.svn.wordpress.org/trunk@55543 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`str_starts_with()` and `str_ends_with()` were introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins or ends with the given substring (needle).
WordPress core includes a polyfill for these functions on PHP < 8.0 as of WordPress 5.9.
Follow-up to [55990], [56014].
See #58220.
Built from https://develop.svn.wordpress.org/trunk@56019
git-svn-id: http://core.svn.wordpress.org/trunk@55531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).
WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.
Follow-up to [52039], [52040], [52326], [55703], [55710], [55987].
Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes#58206.
Built from https://develop.svn.wordpress.org/trunk@55988
git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset adds a `is_block_theme` property to each theme in the `wp/v2/themes` API response, which uses `WP_Theme::is_block_theme` to determinate whether
the theme is block theme or not.
Props grantmkin, ironprogrammer, zunaid321, azaozz, spacedmonkey, audrasjb, costdev.
Fixes#58123.
Built from https://develop.svn.wordpress.org/trunk@55951
git-svn-id: http://core.svn.wordpress.org/trunk@55463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).
WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.
While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.
Follow-up to [52039], [52040], [52326].
Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes#58012.
Built from https://develop.svn.wordpress.org/trunk@55703
git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The autosaves and revisions controllers used to set the same class properties in a slightly different order.
This commit makes the `::__construct()` methods of both classes more consistent to simplify future maintenance.
Follow-up to [46272], [51962].
See #57839.
Built from https://develop.svn.wordpress.org/trunk@55697
git-svn-id: http://core.svn.wordpress.org/trunk@55209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds support for the new selectors property for block types. It adds it to the allowed metadata when registering a block type, makes the WP_Block_Type class aware of it, exposes it through the block types REST API, and the get_block_editor_server_block_settings function.
Corresponding work in the Gutenberg plugin: https://github.com/WordPress/gutenberg/pull/46496.
Fixes#57585.
Props aaronrobertshaw, hellofromTonya.
Built from https://develop.svn.wordpress.org/trunk@55673
git-svn-id: http://core.svn.wordpress.org/trunk@55185 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This fixes a few WPCS warnings along the lines of:
* Array double arrow not aligned correctly
* Equals sign not aligned with surrounding statements
* Usage of ELSE IF is discouraged; use ELSEIF instead
Follow-up to [55099], [55192], [55194], [55271].
Props davidbaumwald, jrf, SergeyBiryukov.
Fixes#57994.
Built from https://develop.svn.wordpress.org/trunk@55606
git-svn-id: http://core.svn.wordpress.org/trunk@55118 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, the `rest_pre_dispatch` filter could be used to return a `WP_Error` instance. This would cause a fatal error for `rest_post_dispath`
filters that were rightly expecting a `WP_REST_Response` object to be passed instead.
Props DaveFX, felipeelia.
Fixes#56566.
Built from https://develop.svn.wordpress.org/trunk@55361
git-svn-id: http://core.svn.wordpress.org/trunk@54894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Removes the `WP_Error` code for `'Invalid user ID.'`. Why?
tl;dr
This branch will never be entered as the `$user` will never be falsey.
Longer reasoning:
[39954] introduced `WP_REST_Users_Controller::get_user()` method to encapsulate getting the user and handling the `'Invalid user ID.'` `WP_Error`. It replaced `get_userdata()` in `WP_REST_Users_Controller::update_item()` but left the existing `'Invalid user ID.'` `WP_Error` introduced in [38832].
The code removed in this changeset will never be reached because `$user` will never be falsey. Rather, `WP_REST_Users_Controller::get_user()` will always return an instance of `WP_Error` or `WP_User`.
Could the user's ID be falsey?
No. Why? `WP_REST_Users_Controller::get_user()` checks that the user exists, which checks if the ID is falsey.
Therefore, the code can safely be removed.
Follow-up to [39954], [38832].
Props jrf, costdev, hellofromTonya, SergeyBiryukov.
Fixes#56662.
Built from https://develop.svn.wordpress.org/trunk@55325
git-svn-id: http://core.svn.wordpress.org/trunk@54858 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, the `s` argument of the `WP_Query::parse_query()` method searched the `post_title`, `post_excerpt`, and `post_content` fields, with no way of controlling this apart from using the `posts_search` filter and adjusting the SQL manually. This changeset adds the ability to specify which fields are searched when performing a query, using the `search_columns` argument.
Props johnbillion, birgire, petitphp, audrasjb, costdev, mukesh27.
Fixes#43867.
Built from https://develop.svn.wordpress.org/trunk@55248
git-svn-id: http://core.svn.wordpress.org/trunk@54781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset improves the consistency in capitalization of fetching and outputting of request headers. It also updates occurrences found in some docblocks.
Props johnjamesjacoby, costdev, audrasjb, petitphp, mhkuu, SergeyBiryukov.
Fixes#54225.
Built from https://develop.svn.wordpress.org/trunk@55210
git-svn-id: http://core.svn.wordpress.org/trunk@54743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When switching to a block theme, classic sidebars were orphaned and their widgets remapping to the `'wp_inactive_widgets'` sidebar . This changeset preserves the sidebars and their widgets, providing a migration path to a block theme without losing the widgets.
Classic sidebars are now:
* Stored in a new theme mod called `'wp_classic_sidebars'`;
* Restored to the `$wp_registered_sidebars` global variable when the `'widgets_init'` action fires (via a new internal function called `_wp_block_theme_register_classic_sidebars()`);
* And marked as `'inactive'` when interacting with sidebars REST API endpoint.
References:
* [https://github.com/WordPress/gutenberg/pull/45509 Gutenberg PR 45509] which adds an option for importing widgets from sidebars into template parts.
Follow-up to [50995], [6334].
Props mamaduka, audrasjb, hellofromTonya, ironprogrammer, jameskoster, joen, matveb, mukesh27, noisysocks, poena, youknowriad.
Fixes#57531.
Built from https://develop.svn.wordpress.org/trunk@55200
git-svn-id: http://core.svn.wordpress.org/trunk@54733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset introduces functions `wp_get_global_styles_custom_css()` and `wp_enqueue_global_styles_custom_css()`, which allow accessing and enqueuing custom CSS added via global styles.
Custom CSS via global styles is handled separately from custom CSS via the Customizer. If a site uses both features, the custom CSS from both sources will be loaded. The global styles custom CSS is then loaded after the Customizer custom CSS, so if there are any conflicts between the rules, the global styles take precedence.
Similarly to e.g. [55185], the result is cached in a non-persistent cache, except when `WP_DEBUG` is on to avoid interrupting the theme developer's workflow.
Props glendaviesnz, oandregal, ntsekouras, mamaduka, davidbaumwald, hellofromtonya, flixos90.
Fixes#57536.
Built from https://develop.svn.wordpress.org/trunk@55192
git-svn-id: http://core.svn.wordpress.org/trunk@54725 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Includes:
* Adding the `templateTypes` property to the `WP_Block_Patterns_Registry::register()` DocBlock.
* Adding `@since` notes for the `postTypes` and `templateTypes` properties to:
* `_register_theme_block_patterns()`
* `WP_Block_Patterns_Registry::register()`
* Bringing some consistency to the order of properties between:
* `_register_theme_block_patterns()`
* `WP_Block_Patterns_Registry::register()`
* `WP_REST_Block_Patterns_Controller::prepare_item_for_response()`
* `WP_REST_Block_Patterns_Controller::get_item_schema()`
Follow-up to [52943], [53152], [54263], [55168].
See #56792.
Built from https://develop.svn.wordpress.org/trunk@55173
git-svn-id: http://core.svn.wordpress.org/trunk@54706 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
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
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