Commit Graph

763 Commits

Author SHA1 Message Date
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
hellofromTonya
16b9fdfc34 Editor: Adds pagination and ordering support to WP_REST_Pattern_Directory_Controller.
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
2023-01-24 16:54:11 +00:00
hellofromTonya
45ef4c0623 Editor: Migrate old to the new pattern categories.
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
2023-01-24 14:36:12 +00:00
Sergey Biryukov
c5297203d6 Code Modernization: Rename parameters that use reserved keywords in phpunit/tests/rest-api/rest-*-controller.php.
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 `$object` parameter to `$response_data` in:
 * `WP_Test_REST_Attachments_Controller::additional_field_get_callback()`
 * `WP_Test_REST_Autosaves_Controller::additional_field_get_callback()`
 * `WP_Test_REST_Categories_Controller::additional_field_get_callback()`
 * `WP_Test_REST_Comments_Controller::additional_field_get_callback()`
 * `WP_Test_REST_Post_Statuses_Controller::additional_field_get_callback()`
 * `WP_Test_REST_Post_Types_Controller::additional_field_get_callback()`
 * `WP_Test_REST_Posts_Controller::additional_field_get_callback()`
 * `WP_Test_REST_Revisions_Controller::additional_field_get_callback()`
 * `WP_Test_REST_Tags_Controller::additional_field_get_callback()`
 * `WP_Test_REST_Users_Controller::additional_field_get_callback()`
* Amends the `$data` and `$prepared` parameters for consistency in:
 * `WP_REST_Controller::add_additional_fields_to_object()`
 * `WP_REST_Controller::filter_response_by_context()`
 * `rest_filter_response_by_context()`

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969], [54970], [54971], [54972], [54996], [55000], [55011], [55013], [55014], [55015], [55016], [55017], [55020], [55021], [55023], [55027], [55028], [55034], [55036], [55037], [55038], [55039], [55049], [55050], [55060], [55062], [55064], [55065], [55076], [55077], [55078], [55081], [55090], [55100].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55104


git-svn-id: http://core.svn.wordpress.org/trunk@54637 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-20 00:21:15 +00:00
youknowriad
0831f905f0 Editor: Allow block pattern categories to have descriptions.
Updates the corresponding REST API endpoint and unit test.

Fixes #57478.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-19 12:13:14 +00:00
Sergey Biryukov
835378abe1 Code Modernization: Rename parameters that use reserved keywords in phpunit/includes/class-wp-unittest-factory-for-attachment.php.
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 `$parent` parameter to `$parent_post_id` in `WP_UnitTest_Factory_For_Attachment::create_upload_object()`.
* Amends the `$parent_post` parameter in `wp_insert_attachment()` and `WP_REST_Revisions_Controller::get_parent()` for consistency.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969], [54970], [54971], [54972], [54996], [55000], [55011], [55013], [55014], [55015], [55016], [55017], [55020].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55021


git-svn-id: http://core.svn.wordpress.org/trunk@54554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-30 02:38:17 +00:00
Sergey Biryukov
95c797463d Code Modernization: Rename parameters that use reserved keywords in wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php.
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 `$string` parameter to `$form_data` in a closure in `WP_REST_Widgets_Controller::get_item_schema()`.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969], [54970], [54971].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@54972


git-svn-id: http://core.svn.wordpress.org/trunk@54524 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-14 14:31:11 +00:00
Sergey Biryukov
b3a7c69ac5 Code Modernization: Rename parameters that use reserved keywords in wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php.
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 `$string` parameter to `$form_data` in a closure in `WP_REST_Widget_Types_Controller::register_routes()`.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969], [54970].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@54971


git-svn-id: http://core.svn.wordpress.org/trunk@54523 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-14 14:28:12 +00:00
Sergey Biryukov
1d9e308c67 Code Modernization: Rename parameters that use reserved keywords in wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php.
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 `$parent` to `$parent_post` in `WP_REST_Revisions_Controller::get_parent()`.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@54970


git-svn-id: http://core.svn.wordpress.org/trunk@54522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-14 13:52:14 +00:00
Sergey Biryukov
e623438f68 Code Modernization: Rename parameters that use reserved keywords in wp-includes/rest-api/endpoints/class-wp-rest-controller.php.
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 `$object` to `$data_object` in `WP_REST_Controller::update_additional_fields_for_object()`.
* Includes a minor code layout fix for better readability.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@54969


git-svn-id: http://core.svn.wordpress.org/trunk@54521 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-14 13:41:13 +00:00
Sergey Biryukov
0230731505 Code Modernization: Rename parameters that use reserved keywords in wp-includes/rest-api/class-wp-rest-server.php.
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 `$namespace` parameter to `$route_namespace` in:
* `WP_REST_Server::register_route()`
* `WP_REST_Server::get_routes()`

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@54965


git-svn-id: http://core.svn.wordpress.org/trunk@54517 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-13 18:34:12 +00:00
Sergey Biryukov
3ba44120d0 Coding Standards: Always use parentheses when instantiating an object.
Note: This will be enforced by WPCS 3.0.0.

Props jrf.
See #56791.
Built from https://develop.svn.wordpress.org/trunk@54891


git-svn-id: http://core.svn.wordpress.org/trunk@54443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-29 15:51:14 +00:00