Commit Graph

774 Commits

Author SHA1 Message Date
Pascal Birchler
a4ee712d0d Site Health: fix check name used for REST API permission checks.
Updates the calls to permission validation calls for the `directory-sizes` and `page-cache` routes to actually match the route names.

Follow-up to r54043 and r49154.

Props szepeviktor.
Fixes #59236
Built from https://develop.svn.wordpress.org/trunk@56489


git-svn-id: http://core.svn.wordpress.org/trunk@56001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-29 15:41:17 +00:00
K. Adam White
96cd4c4224 REST API: Remove misleading comment in WP_REST_Blocks_Controller->get_item_schema.
In r56093 schema caching was added above a comment instructing developers not to cache that controller's schema. However, there is no obvious penalty for re-caching schema that is partially derived from a parent.

Caching schema in the same way in every controller is beneficial consistency, and discussion at WCUS2023 contributor day concluded we could remove this comment.

Props ahardyjpl, davidbinda, johnjamesjacoby, TimothyBlynJacobs.

Fixes #59193. See #58657.

Built from https://develop.svn.wordpress.org/trunk@56459


git-svn-id: http://core.svn.wordpress.org/trunk@55971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-24 20:23:16 +00:00
John Blackbourn
3d796edc68 REST API: Correct the docblocks for various permission related methods.
See #58833

Built from https://develop.svn.wordpress.org/trunk@56415


git-svn-id: http://core.svn.wordpress.org/trunk@55927 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-18 17:46:18 +00:00
audrasjb
e992dabb1a Docs: Fix indentation issue in WP_REST_Global_Styles_Revisions_Controller class.
Follow-up to [56082].

See #57840, #58524.



Built from https://develop.svn.wordpress.org/trunk@56272


git-svn-id: http://core.svn.wordpress.org/trunk@55784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-19 22:53:23 +00:00
audrasjb
b5ec731578 REST API: Update Global styles revisions private methods to protected.
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
2023-07-19 07:49:24 +00:00
audrasjb
26395d827e Docs: Various docblocks corrections.
See #57840.



Built from https://develop.svn.wordpress.org/trunk@56257


git-svn-id: http://core.svn.wordpress.org/trunk@55769 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-18 07:37:21 +00:00
audrasjb
114ab18d18 Docs: Fix various incorrect @since mentions.
Props costdev, mukesh27.
Fixes #58834.
See #57840.



Built from https://develop.svn.wordpress.org/trunk@56256


git-svn-id: http://core.svn.wordpress.org/trunk@55768 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-18 07:30:23 +00:00
audrasjb
6ba79df9c4 Editor: Fix a PHP notice appearing when adding a new template part.
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
2023-07-17 14:22:24 +00:00
isabel_brison
4e70f57a0b Editor: fix since annotation in rest blocks controller class.
Changes `6.3` to `6.3.0` in the since annotation for the `filter_response_by_context` function.

Props swissspidy, peterwilsoncc, mukesh27.
Fixes #58677.

Built from https://develop.svn.wordpress.org/trunk@56217


git-svn-id: http://core.svn.wordpress.org/trunk@55729 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-12 04:27:27 +00:00
audrasjb
58ebfc61f1 Docs: Replace multiple single line comments with multi-line comments.
This changeset updates various comments as per WordPress PHP Inline Documentation Standards.
See https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#5-inline-comments.

Follow-up to [56174], [56175], [56176], [56177], [56178], [56179], [56180], [56191], [56192], [56193], [56194].

Props costdev, audrasjb.
See #58459.



Built from https://develop.svn.wordpress.org/trunk@56195


git-svn-id: http://core.svn.wordpress.org/trunk@55707 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-10 23:19:23 +00:00
audrasjb
55b31a92be Docs: Replace multiple single line comments with multi-line comments.
This changeset updates various comments as per WordPress PHP Inline Documentation Standards.
See https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#5-inline-comments.

Follow-up to [56174], [56175], [56176], [56177], [56178], [56179], [56180], [56191], [56192].

Props costdev, audrasjb.
See #58459.



Built from https://develop.svn.wordpress.org/trunk@56193


git-svn-id: http://core.svn.wordpress.org/trunk@55705 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-10 23:00:22 +00:00
audrasjb
92ab411bb5 Docs: Docblock correction in WP_REST_Attachments_Controller::upload_from_data().
The `$data` parameter in `WP_REST_Attachments_Controller::upload_from_data()` is passed and treated only as `string`, not `array`.

Props costdev.
See #57840.



Built from https://develop.svn.wordpress.org/trunk@56168


git-svn-id: http://core.svn.wordpress.org/trunk@55680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-08 21:59:23 +00:00
Adam Silverstein
ea399e28a9 Revisions: return existing autosave after saving with unchanged data.
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
2023-07-07 17:53:23 +00:00
isabel_brison
ab8c2bd924 Editor: rename sync_status and move it to top level.
Renames sync_status to wp_pattern_sync_status and moves it to top level field of wp_block post type.

Props glendaviesnz, aaronrobertshaw, mukesh27, peterwilsoncc.
Fixes 58677.

Built from https://develop.svn.wordpress.org/trunk@56160


git-svn-id: http://core.svn.wordpress.org/trunk@55672 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-07 07:29:23 +00:00
John Blackbourn
bf9257de5f REST API: Correct some filter docblocks.
See #57752

Built from https://develop.svn.wordpress.org/trunk@56156


git-svn-id: http://core.svn.wordpress.org/trunk@55668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-06 23:23:22 +00:00
isabel_brison
3d5263c642 REST API: updates test annotations for global styles revisions
Adds `@covers` annotations to tests and fixes incorrect spacing.

Props ramonopoly, mukesh27.
See #58524.

Built from https://develop.svn.wordpress.org/trunk@56105


git-svn-id: http://core.svn.wordpress.org/trunk@55617 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-29 06:50:20 +00:00
K. Adam White
f028b4e781 REST API: Expose current $request object to cors_header filters in WP_REST_SERVER->serve_request().
Allows headers to be more easily set on a per-response basis when more or less security is needed on a specific route.

Props bor0, rachelbaker, spacedmonkey, chaion07, oglekler, SergeyBiryukov.
Fixes #57752.


Built from https://develop.svn.wordpress.org/trunk@56096


git-svn-id: http://core.svn.wordpress.org/trunk@55608 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-28 17:39:29 +00:00
K. Adam White
d72667d737 REST API: Cache schema in block pattern and menu item endpoints.
Performance improvement to add schema caching to pattern and menu item REST endpoints, so identical schema object are not needlessly regenerated.

Props spacedmonkey.
Fixes #58657. See [45811].


Built from https://develop.svn.wordpress.org/trunk@56093


git-svn-id: http://core.svn.wordpress.org/trunk@55605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-28 15:53:26 +00:00
isabel_brison
1c1f68fbab REST API: add revisions endpoint for global styles.
Adds an endpoint that returns revisions to the global styles custom post.

Props ramonopoly, peterwilsoncc, spacedmonkey, mukesh27, timothyblynjacobs.
Fixes #58524.

Built from https://develop.svn.wordpress.org/trunk@56082


git-svn-id: http://core.svn.wordpress.org/trunk@55594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-28 03:35:25 +00:00
K. Adam White
0d9723a44e REST API: Check post meta update authorization only when value is changed.
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
2023-06-27 17:26:27 +00:00
isabel_brison
d7bda1a6be Editor: allow filtering block patterns by source.
Extends the REST API endpoint for block patterns to provide a source attribute that can be used to filter patterns.

Props aaronrobertshaw, mukesh27, talldanwp, ramonopoly.
Fixes 58622.

Built from https://develop.svn.wordpress.org/trunk@56063


git-svn-id: http://core.svn.wordpress.org/trunk@55575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-27 11:13:27 +00:00
isabel_brison
161b471f0b Editor: add navigation fallback.
Creates a fallback menu for the Navigation block including an API endpoint to retrieve it.

Props get_dave, spacedmonkey, kebbet, flixos90, mikeschroder, ramonopoly, audrasjb.
Fixes 58557.

Built from https://develop.svn.wordpress.org/trunk@56052


git-svn-id: http://core.svn.wordpress.org/trunk@55564 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-27 05:54:19 +00:00
isabel_brison
54c97ab015 REST API: ignore empty templates.
Ignore empty templates when using the `/lookup` endpoint in the `WP_REST_Templates_Controller` class.

Props ramonopoly, jorgefilipecosta, spacedmonkey, youknowriad, mukesh27.
Fixes #58615.


Built from https://develop.svn.wordpress.org/trunk@56051


git-svn-id: http://core.svn.wordpress.org/trunk@55563 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-27 05:36:22 +00:00
Sergey Biryukov
ad16732d27 Code Modernization: Use str_contains() in a few more places.
`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
2023-06-26 10:17:25 +00:00
Sergey Biryukov
32e94b4de1 Code Modernization: Use str_starts_with() and str_ends_with() in a few more places.
`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
2023-06-24 16:50:24 +00:00
isabel_brison
19dda6b262 REST API: return post modified datetime for Templates.
Adds a `modified` field to the template and template part objects in the rest response for `WP_REST_Templates_Controller`.

Props ramonopoly, andrewserong, mukesh27, timothyblynjacobs.
Fixes #58540.

Built from https://develop.svn.wordpress.org/trunk@55992


git-svn-id: http://core.svn.wordpress.org/trunk@55504 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-23 06:29:23 +00:00
Sergey Biryukov
1ce5dc7444 Code Modernization: Replace usage of strpos() with str_contains().
`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
2023-06-22 14:36:26 +00:00
audrasjb
c19c30b00d REST API: Indicate when a theme supports the Site editor in the Themes REST API response.
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
2023-06-20 22:17:27 +00:00
Weston Ruter
4c2394eed5 General: Use static on closures whenever $this is not used to avoid memory leaks.
Props westonruter, jrf, spacedmonkey.
Fixes #58323.

Built from https://develop.svn.wordpress.org/trunk@55822


git-svn-id: http://core.svn.wordpress.org/trunk@55334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-17 22:46:24 +00:00
Sergey Biryukov
8b53b81183 Docs: Remove @return void from various DocBlocks.
Per the documentation standards, it should not be used outside of the default bundled themes.

Follow-up to [52049], [52051], [53331], [54156], [54214], [55203], [55719].

See #57840.
Built from https://develop.svn.wordpress.org/trunk@55725


git-svn-id: http://core.svn.wordpress.org/trunk@55237 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-06 11:40:24 +00:00
Sergey Biryukov
2ec23a82ed Code Modernization: Replace usage of strpos() with str_starts_with().
`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
2023-05-02 15:45:22 +00:00
Sergey Biryukov
225fe28e9f Coding Standards: Bring some consistency to REST API revisions initialization.
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
2023-04-28 15:06:21 +00:00
Sergey Biryukov
19b456f9f8 REST API: Remove unused variable from the permissions check for deleting a revision.
`WP_REST_Revisions_Controller::delete_item_permissions_check()` no longer uses the value of the `$parent_post_type` variable anywhere. 

Follow-up to [45812], [47547], [47850].

Props Soean, mukesh27.
Fixes #58218.
Built from https://develop.svn.wordpress.org/trunk@55696


git-svn-id: http://core.svn.wordpress.org/trunk@55208 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-28 10:05:21 +00:00
John Blackbourn
cc24b047eb Docs: Correct and improve various documented types for properties, functions, and hooks.
See #57840

Built from https://develop.svn.wordpress.org/trunk@55693


git-svn-id: http://core.svn.wordpress.org/trunk@55205 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-27 22:29:18 +00:00
audrasjb
4c8a5d8d28 Docs: Typo fix in WP_REST_Block_Pattern_Categories_Controller docblock.
Props Soean.
Fixes #58204.

Built from https://develop.svn.wordpress.org/trunk@55692


git-svn-id: http://core.svn.wordpress.org/trunk@55204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-27 22:25:26 +00:00
gziolo
56145f874a Editor: Add selectors field to block type definition
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
2023-04-21 10:43:25 +00:00
Sergey Biryukov
f940bc822d Coding Standards: Apply various alignment corrections from composer format.
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
2023-03-29 07:13:23 +00:00
TimothyBlynJacobs
42b25d58ea REST API: Normalize WP_REST_Server::dispatch() to return a response object.
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
2023-02-17 15:45:24 +00:00
hellofromTonya
5584cf60c0 REST API: Remove 'Invalid user ID' error in WP_REST_Users_Controller::update_item().
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
2023-02-13 23:10:20 +00:00
danielbachhuber
e41af7cdc6 REST API: Support non-Latin characters in template route regex.
Non-Latin characters are URL-encoded (e.g. `%cf%84%ce%b5%cf%83%cf%84`). Matching `%` in the route ensures templates with non-Latin titles can be properly saved.

Props antonyagrios, mburridge.
Fixes #57329.

Built from https://develop.svn.wordpress.org/trunk@55294


git-svn-id: http://core.svn.wordpress.org/trunk@54827 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 23:47:23 +00:00
John Blackbourn
270a3d009d Docs: Miscellaneous improvements and corrections to docblocks.
See #56792

Built from https://develop.svn.wordpress.org/trunk@55293


git-svn-id: http://core.svn.wordpress.org/trunk@54826 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 21:21:18 +00:00
audrasjb
64384b74d8 Query: Add a search_columns argument to control which fields are searched in a search query.
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
2023-02-07 08:55:18 +00:00
Felix Arntz
53c7f7a8a7 Editor: Support the block_types and viewport_width props for remote patterns fetched from Pattern Directory.
Props ntsekouras, ironprogrammer, hellofromtonya, flixos90.
Fixes #57611.

Built from https://develop.svn.wordpress.org/trunk@55234


git-svn-id: http://core.svn.wordpress.org/trunk@54767 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-06 19:40:16 +00:00
audrasjb
28358ab213 HTTP API: Fix request header inconsistencies.
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
2023-02-03 13:35:20 +00:00
hellofromTonya
fbfd2b4372 Widgets: Preserve classic sidebars when switching to a block theme.
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
2023-02-03 00:15:21 +00:00
Felix Arntz
5b4af6125a Editor: Add support for custom CSS in global styles.
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
2023-02-02 18:52:17 +00:00
hellofromTonya
96f54a8132 REST API: Declare 'edit_css' capability in links within WP_REST_Global_Styles_Controller.
Updates the Global Styles endpoint to expose the `'edit_css'` capability via action links.

References:
* [https://github.com/WordPress/gutenberg/pull/46815 Gutenberg PR 46815] Part of an effort to hide custom CSS setting for users without `'edit_css'` capability.

Follow-up to [52342], [52051].

Props mamaduka, dsas, glendaviesnz, mmtr86, talldanwp, timothyblynjacobs.
Fixes #57526.
Built from https://develop.svn.wordpress.org/trunk@55177


git-svn-id: http://core.svn.wordpress.org/trunk@54710 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 18:38:14 +00:00
Sergey Biryukov
d099f2f708 Docs: Improve documentation for block pattern properties.
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
2023-02-01 15:02:14 +00:00
jorgefilipecosta
49c1d2066c Add: Template types to the patterns API.
Backports https://github.com/WordPress/gutenberg/pull/45814 into the core.
This commit adds a new templateType property to the patterns registration API.
This property allows a pattern to specify which template it makes sense on, e.g.: 404, single-post, single-product, category.

Props youknowriad, ntsekouras, 
spacedmonkey.
Built from https://develop.svn.wordpress.org/trunk@55168


git-svn-id: http://core.svn.wordpress.org/trunk@54701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 16:49:16 +00:00
Adam Silverstein
5df3679f34 Revisions: only create autosave when content changed.
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
2023-01-27 22:03:19 +00:00