Commit Graph

616 Commits

Author SHA1 Message Date
youknowriad
2889f76e92 REST API: Add route for single styles revisions.
Adds a route for single global styles revisions: /wp/v2/global-styles/${ parentId }/revisions/${ revisionsId }
This fixes the `getRevision` actions in the core-data package.

Props ramonopoly, get_dave.
Fixes #59810.
Built from https://develop.svn.wordpress.org/trunk@57494


git-svn-id: http://core.svn.wordpress.org/trunk@56995 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-31 10:41:14 +00:00
gziolo
9eea02e31b Editor: Add viewStyle property to block.json for frontend-only block styles
Related issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/54491.

For block scripts there was already `script`, `viewScript` and `editorScript`. For block styles there was only `style` and `editorStyle`. This brings the parity.

Props gaambo.
Fixes #59673. 


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


git-svn-id: http://core.svn.wordpress.org/trunk@56994 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-31 09:11:17 +00:00
Pascal Birchler
ce230b8742 REST API: Support assigning terms when creating attachments.
Props mukesh27, Dharm1025, Ankit K Gupta, swissspidy, dharm1025, tanjimtc71, timothyblynjacobs, spacedmonkey.
Fixes #57897.
Built from https://develop.svn.wordpress.org/trunk@57380


git-svn-id: http://core.svn.wordpress.org/trunk@56886 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-30 08:39:16 +00:00
jorgefilipecosta
b3958d342b Coding Standards: Remove unnecessary access and internal annotations from two functions in WP_REST_Templates_Controller.
This commit removes unnecessary access and internal annotations from two functions that are private and as such don't require the annotation. It also adds the since annotation with the 6.5 release given that the annotation may be useful.

Props swissspidy.
See #60358.
Built from https://develop.svn.wordpress.org/trunk@57374


git-svn-id: http://core.svn.wordpress.org/trunk@56880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-29 12:34:18 +00:00
jorgefilipecosta
5c928b8d0f Editor: Add original_source and author_text to the templates REST API.
For the new "All templates" UI to work properly we need the REST API to provide to additional fields original_source, and author_text.

Props ntsekouras, get_dave.
Fixes #60358.
Built from https://develop.svn.wordpress.org/trunk@57366


git-svn-id: http://core.svn.wordpress.org/trunk@56872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-27 00:07:18 +00:00
Felix Arntz
e19c18cba9 Bootstrap/Load: Introduce functions to check whether WordPress is serving a REST API request.
This changeset introduces two functions:
* `wp_is_serving_rest_request()` returns a boolean for whether WordPress is serving an actual REST API request.
* `wp_is_rest_endpoint()` returns a boolean for whether a WordPress REST API endpoint is currently being used. While this is always the case if `wp_is_serving_rest_request()` returns `true`, the function additionally covers the scenario of internal REST API requests, i.e. where WordPress calls a REST API endpoint within the same request.

Both functions should only be used after the `parse_request` action.

All relevant manual checks have been adjusted to use one of the new functions, depending on the use-case. They were all using the same constant check so far, while in fact some of them were intending to check for an actual REST API request while others were intending to check for REST endpoint usage.

A new filter `wp_is_rest_endpoint` can be used to alter the return value of the `wp_is_rest_endpoint()` function.

Props lots.0.logs, TimothyBlynJacobs, flixos90, joehoyle, peterwilsoncc, swissspidy, SergeyBiryukov, pento, mikejolley, iandunn, hellofromTonya, Cybr, petitphp.
Fixes #42061.

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


git-svn-id: http://core.svn.wordpress.org/trunk@56818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-19 17:40:09 +00:00
Sergey Biryukov
a0b82585ab Docs: Document the $post global in REST API posts and revisions controllers.
Follow-up to [38832], [40601].

Props viralsampat.
See #60021.
Built from https://develop.svn.wordpress.org/trunk@57230


git-svn-id: http://core.svn.wordpress.org/trunk@56736 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-12-28 15:19:20 +00:00
isabel_brison
6e1fe93a1c REST API: check parent and revision ids match before retrieving revision.
Adds a condition to check that parent id matches revision parent id in `WP_REST_Revisions_Controller` `get_item` method.

Props ramonopoly, adamsilverstein, danielbachhuber, spacedmonkey, andrewserong.
Fixes #59875.

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


git-svn-id: http://core.svn.wordpress.org/trunk@56728 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-12-22 02:12:21 +00:00
Sergey Biryukov
a192ed1ae1 REST API: Pass correct number of arguments to the comment_text filter.
This ensures that `WP_REST_Comments_Controller::prepare_item_for_response()` passes three arguments to the `comment_text` filter, for consistency with all the other instances in core.

Follow-up to [15957], [16357], [25555], [38832], [40664].

Props sjregan, SergeyBiryukov.
Fixes #58238.
Built from https://develop.svn.wordpress.org/trunk@57176


git-svn-id: http://core.svn.wordpress.org/trunk@56687 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-12-09 22:13:34 +00:00
Sergey Biryukov
0abdf83aaf Coding Standards: Remove extra space in a comment in WP_REST_Blocks_Controller.
This fixes a WPCS error: `Whitespace found at end of line`.

Follow-up to [57032].

Props hellofromTonya.
See #59388.
Built from https://develop.svn.wordpress.org/trunk@57033


git-svn-id: http://core.svn.wordpress.org/trunk@56544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-31 14:23:21 +00:00
Sergey Biryukov
ac2b1a56d2 Docs: Update some reusable block references to synced patterns.
In WordPress 6.3, [https://wordpress.org/documentation/article/reusable-blocks/ Reusable Blocks were renamed to Patterns]. A synced pattern will behave in exactly the same way as a reusable block.

This commit updates some references in DocBlocks and inline comments to use the new name.

Follow-up to [56030].

Props benjaminknox, oglekler, hellofromTonya, marybaum, nicolefurlan.
Fixes #59388.
Built from https://develop.svn.wordpress.org/trunk@57032


git-svn-id: http://core.svn.wordpress.org/trunk@56543 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-31 12:58:23 +00:00
Felix Arntz
41cf4f1521 General: Remove discouraged @return void annotations.
Such `@return void` annotations must not be used in WordPress core's PHP code, except bundled themes, third-party libraries, and PHP compatibility shims.

Props isabel_brison, swissspidy.
Fixes #59619.

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


git-svn-id: http://core.svn.wordpress.org/trunk@56454 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-16 15:17:23 +00:00
audrasjb
4cfb52760f REST API: Limit search_columns for users without list_users.
Props Vortfu, jorbin, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis.




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


git-svn-id: http://core.svn.wordpress.org/trunk@56345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-12 12:30:20 +00:00
spacedmonkey
6e774df98c REST API: Fix issue with Template and Template Part Revision/Autosave REST API controllers.
The Template and Template Part REST API controllers have unique characteristics compared to other post type REST API controllers. They do not rely on integer IDs to reference objects; instead, they use a combination of the theme name and slug of the template, like 'twentytwentyfour//home.' Consequently, when the post types template and template part were introduced in [52062], it led to the registration of REST API endpoints for autosaves and revisions with invalid URL structures.

In this commit, we introduce new functionality to enable custom autosave and revisions endpoints to be registered at the post type level. Similar to the 'rest_controller_class' parameter, developers can now define 'revisions_rest_controller' and 'autosave_rest_controller.' This empowers developers to create custom controllers for these functionalities. Additionally, we introduce a 'late_route_registration' parameter, which proves helpful when dealing with custom URL patterns and regex pattern matching issues.
This commit registers new classes for template and template part autosave and revisions controllers, differentiating them from standard controllers in the following ways:
* The response shape now matches that of the template controller.
* Permission checks align with the template controller.
* A custom URL pattern is introduced to support slug-based identification of templates.

Furthermore, we've updated the utility function '_build_block_template_result_from_post' to support passing revision post objects. This enhancement ensures compatibility with the custom revisions controller.

Props spacedmonkey, revgeorge, andraganescu, hellofromTonya, antonvlasenko, kadamwhite, ironprogrammer, costdev, mukesh27, timothyblynjacobs, adamsilverstein. 
Fixes 56922.
Built from https://develop.svn.wordpress.org/trunk@56819


git-svn-id: http://core.svn.wordpress.org/trunk@56331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-10 14:05:21 +00:00
Sergey Biryukov
ffd72aac28 Coding Standards: Remove redundant ignore annotations, take 5.
The `VariableAnalysis` standard is not used by WP Core.

Follow-up to [50958], [51003], [52049], [52051], [52069], [53072], [54132], [55132], [56363], [56738], [56743], [56751], [56752].

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


git-svn-id: http://core.svn.wordpress.org/trunk@56265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-02 11:27:24 +00:00
spacedmonkey
8aca3fdc68 Comments: Improve WP_Comment_Query count query performance by setting 'order by' to 'none'.
In cases where `WP_Comment_Query` or `get_comments` is employed with the 'count' parameter set to true, specify 'order by' as 'none'. Since these queries serve solely to determine the count of comments matching specific query parameters, the 'order by' clause becomes redundant and places unnecessary strain on the database server, resulting in slower query execution. Given that count queries are executed on every admin request to retrieve comment counts, this change enhances the performance of the wp-admin interface.

Props guss77, davidbaumwald, SergeyBiryukov, westonruter, peterwilsoncc, foliovision, hareesh-pillai, spacedmonkey.
Fixes #58368
Built from https://develop.svn.wordpress.org/trunk@56747


git-svn-id: http://core.svn.wordpress.org/trunk@56259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-29 17:13:24 +00:00
Adam Silverstein
472f1ec59d Revisions: slash meta values for autosave (preview) revisions.
Correct an issue where meta values containing characters like quote `”` could not be previewed on published posts. The function `update_metadata` expects data to be slashed.

Also, add a test to confirm that storing JSON data which requires slashing in autosave meta works as expected, and improve naming for a data provider added in [56714].

Follow up to [56714].

Props mukesh27, spacedmonkey.
Fixes #20564.


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


git-svn-id: http://core.svn.wordpress.org/trunk@56257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-29 15:07:26 +00:00
Adam Silverstein
89a99dba2f Revisions: framework for storing post meta revisions.
Enable the storing of post meta in revisions including autosaves and previews:

Add a new argument `revisions_enabled` to the `register_meta` function which enables storing meta in revisions.

Add a new `wp_post_revision_meta_keys` filter which developers can use to control which meta is revisioned - it passes an array of the meta keys with revisions enabled as well as the post type.

Meta keys with revisions enabled are also stored for autosaves, and are restored when a revision or autosave is restored. In addition, meta values are now stored with the autosave revision used for previews. Changes to meta can now be previewed correctly without overwriting the published meta (see #20299) or passing data as a query variable, as the editor currently does to preview changes to the featured image.

Changes to meta with revisions enabled are considered when determining if a new revision should be created. A new revision is created if the meta value has changed since the last revision.

Revisions are now saved on the `wp_after_insert_post` hook instead of `post_updated`. The `wp_after_insert_post` action is fired after post meta has been saved by the REST API which enables attaching meta to the revision. To ensure backwards compatibility with existing action uses, `wp_save_post_revision_on_insert` function exits early if plugins have removed the previous `do_action( 'post_updated', 'wp_save_post_revision' )` call.

Props: alexkingorg, johnbillion, markjaquith, WraithKenny, kovshenin, azaozz, tv-productions, p51labs, mattheu, mikeschroder, Mamaduka, ellatrix, timothyblynjacobs, jakemgold, bookwyrm, ryanduff, mintindeed, wonderboymusic, sanchothefat, westonruter, spacedmonkey, hellofromTonya, drewapicture, adamsilverstein, swisspiddy.
Fixes #20564, #20299.



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


git-svn-id: http://core.svn.wordpress.org/trunk@56226 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 15:32:19 +00:00
gziolo
158f4a8fcc REST API: Improve the block type schema for the name field
Align the schema between `block.json` defined in Gutenberg and the REST API endpoint for block types. It looks like the `name` field isn't validated in all places and when it uses pattern matching in the REST API code, then it was slightly different.

Props spacedmonkey, ockham.
See #59346.


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


git-svn-id: http://core.svn.wordpress.org/trunk@56188 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-25 10:03:38 +00:00
costdev
464026afbc REST API: Correct spelling error in block_hooks field documentation.
In [56587], a spelling error was introduced in the documentation of the new `block_hooks` field in `WP_REST_Block_Types_Controller`.

This fixes the spelling error.

Follow-up to [56587].

Props kebbet, mukesh27, tahmina1du.
Fixes #59426. See #59346.
Built from https://develop.svn.wordpress.org/trunk@56668


git-svn-id: http://core.svn.wordpress.org/trunk@56180 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-23 15:37:22 +00:00
Bernhard Reiter
0b79362805 General: Add block_hooks field to block type registration, REST API.
In order to implement Block Hooks, we need to add a new `block_hooks` field to the `WP_Block_Type` class, as well as to block registration related functions, the block types REST API controller, etc.

Props gziolo.
Fixes #59346. See #59313.
Built from https://develop.svn.wordpress.org/trunk@56587


git-svn-id: http://core.svn.wordpress.org/trunk@56099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-14 13:25:18 +00:00
Sergey Biryukov
1aca5e48e5 Coding Standards: Restore more descriptive variable names in a few class methods.
When various methods parameters in child classes were renamed to `$item` to match the parent class for PHP 8 named parameter support, most of the methods restored the more descriptive, specific name at the beginning for better readability, with several exceptions for methods consisting only of a few lines.

To avoid confusion about why some methods do that and some don't, this commit aims to bring more consistency to the code, specifically in list tables' `::column_default()` methods.

Follow-up to [51728], [51737], [51786].

See #58831.
Built from https://develop.svn.wordpress.org/trunk@56586


git-svn-id: http://core.svn.wordpress.org/trunk@56098 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-14 12:46:20 +00:00
isabel_brison
e1b622244d REST API: quality tweaks to WP_REST_Global_Styles_Controller.
Removes redundant local variable and changes validate_custom_css() access modifier from private to protected.

Props ramonopoly, spacedmonkey.
Fixes #59296.


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


git-svn-id: http://core.svn.wordpress.org/trunk@56087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-14 05:13:17 +00:00
Sergey Biryukov
e5490118af Coding Standards: Include one space after function keyword for closures.
Note: This is enforced by WPCS 3.0.0.

Reference: [https://github.com/WordPress/WordPress-Coding-Standards/pull/2328 WPCS: PR #2328 Core: properly check formatting of function declaration statements].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56559


git-svn-id: http://core.svn.wordpress.org/trunk@56071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-12 15:23:18 +00:00
Sergey Biryukov
d8936a9fe7 Coding Standards: Remove superfluous blank lines at the end of various functions.
Note: This is enforced by WPCS 3.0.0.

Follow-up to [56536], [56547].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56548


git-svn-id: http://core.svn.wordpress.org/trunk@56060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-08 10:03:21 +00:00
Sergey Biryukov
9a49b70239 Coding Standards: Remove superfluous blank lines at the end of various classes.
Note: This is enforced by WPCS 3.0.0.

Follow-up to [56536].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56547


git-svn-id: http://core.svn.wordpress.org/trunk@56059 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-08 09:32:23 +00:00
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
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
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
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