Commit Graph

21 Commits

Author SHA1 Message Date
TimothyBlynJacobs
fa473014dc REST API: Support subdirectory themes in the Themes controller.
This allows for themes that are included inside of a subdirectory, for example `subdir/my-theme`, to be accessed via the single item route of the `/wp/v2/themes` controller.

Fixes #54349.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-05 02:30:57 +00:00
hellofromTonya
41307cd4e6 Code Modernization: Fix parameter name mismatches for parent/child classes in WP_REST_Controller::prepare_item_for_response().
In each child and grandchild class, renames the first parameter to match the parent's method signature.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

Follow-up to [38832], [39011], [39015], [39021], [39024], [39025], [39031], [39036], [43519], [43735], [43739], [43768], [46821], [48173], [48242], [49088], [50995], [51003], [51021].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51786


git-svn-id: http://core.svn.wordpress.org/trunk@51393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 18:36:57 +00:00
Sergey Biryukov
1b749d971a Docs: Remove an empty line between @param and @return tags in some newly added REST API methods, per the documentation standards.
Follow-up to [48242], [49925], [51003], [51021].

See #52628, #53461.
Built from https://develop.svn.wordpress.org/trunk@51289


git-svn-id: http://core.svn.wordpress.org/trunk@50898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-30 18:43:58 +00:00
Sergey Biryukov
cc95428f75 REST API: Update “object” strings to use the appropriate nouns.
This updates route arguments and schema descriptions to use more specific object types for clarity.

Follow-up to [39342].

Props lephleg, jnylen0.
Fixes #40720.
Built from https://develop.svn.wordpress.org/trunk@51000


git-svn-id: http://core.svn.wordpress.org/trunk@50609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 13:12:58 +00:00
John Blackbourn
35e1b34f8e REST API: Corrections and improvements to docblocks for REST API filters.
See #51800

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


git-svn-id: http://core.svn.wordpress.org/trunk@49654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-10 22:23:09 +00:00
TimothyBlynJacobs
bf51961e7e REST API: Expose all themes in the themes controller.
Previously, only the active theme was made available. This commit allows for all themes to be queried if the user has the `switch_themes` or `manage_network_themes` capabilities.

This commit also no longer exposes the `page`, `per_page`, `search` and `context` query parameters since they are not supported by this controller.

Props spacedmonkey, lpawlik, TimothyBlynJacobs.
Fixes #50152.

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


git-svn-id: http://core.svn.wordpress.org/trunk@49624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-03 21:47:05 +00:00
Sergey Biryukov
1f85e7484f Docs: Consistently use third-person singular verbs for various filter descriptions, per the documentation standards.
See #50768.
Built from https://develop.svn.wordpress.org/trunk@48782


git-svn-id: http://core.svn.wordpress.org/trunk@48544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-11 00:34:08 +00:00
Sergey Biryukov
aa22457754 REST API: Use a consistent description for the textdomain schema property between plugins and themes controllers.
Follow-up to [48242], [48627].

Props audrasjb.
Fixes #50776. See #50321.
Built from https://develop.svn.wordpress.org/trunk@48628


git-svn-id: http://core.svn.wordpress.org/trunk@48390 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-26 21:54:03 +00:00
TimothyBlynJacobs
0386c0ae6c REST API: Remove specific multi-type schema handling from the themes controller.
Multi-type schema handling was improved in [48306]. In particular, it now allows for sanitizing a multi-typed value that wouldn't validate. Removing this handling will make 3rd party registered theme features more robust.

Fixes #50562.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-05 01:06:02 +00:00
Sergey Biryukov
5aa7f46a4f Docs: Improve DocBlocks in wp-includes/theme.php per the documentation standards.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48189


git-svn-id: http://core.svn.wordpress.org/trunk@47958 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-27 12:02:03 +00:00
TimothyBlynJacobs
9dc7058be9 Themes: Introduce register_theme_feature API.
Currently themes can declare support for a given feature by using add_theme_support(). This commit adds a register_theme_feature() API that allows plugins and WordPress Core to declare a list of available features that themes can support.

The REST API uses this to expose a theme's supported features if the feature has been registered with "show_in_rest" set to true.

Props kadamwhite, spacedmonkey, williampatton, desrosj, TimothyBlynJacobs.
Fixes #49406.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47940 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-25 22:13:10 +00:00
desrosj
784908ae5f Coding Standards: PHP short ternary operator syntax is not allowed.
WPCS 2.2.0 added a sniff for detecting short ternary operator syntax, which is not allowed per the Core handbook.

Follow up of [47927].
Fixes #50258.
Built from https://develop.svn.wordpress.org/trunk@47929


git-svn-id: http://core.svn.wordpress.org/trunk@47702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-08 21:27:10 +00:00
TimothyBlynJacobs
171356a890 REST API: Add additional fields to the themes controller.
When the themes controller was introduced it only returned a theme's supported features. This adds the majority of a theme's header information to the response.

Props ockham, spacedmonkey.
Fixes #49906.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-07 06:46:10 +00:00
Sergey Biryukov
d6178e1dcf REST API: Fix typo in disable-custom-gradients theme feature description.
Props Ipstenu, tobifjellner, pixelverbieger.
Reviewed by ocean90, johnbillion, SergeyBiryukov.
Fixes #49585.
Built from https://develop.svn.wordpress.org/trunk@47432


git-svn-id: http://core.svn.wordpress.org/trunk@47219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-03-06 00:17:05 +00:00
K. Adam White
a5f16272dd REST API: Permit access to the themes controller if user can edit any post type.
Check a more exhaustive list of post type editing caps beyond "edit_post" to ensure custom user roles with access to to specific post types may still use block editor functionality depending on theme features.

Props miyauchi, TimothyBlynJacobs.
Fixes #46723.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-25 15:20:08 +00:00
K. Adam White
25d8f7240e REST API: List all core theme feature support details in /themes endpoint response.
Fully list which first-party core theme features are supported in the /themes endpoint response. This brings the REST API themes controller's response more in line with the output of get_theme_support().

Props adamboro, apieschel, koke, spacedmonkey, TimothyBlynJacobs.
See #49037.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47058 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-11 02:00:07 +00:00
Sergey Biryukov
001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov
65747e3c91 Docs: Remove extra spaces in various REST API DocBlocks.
See #47110.
Built from https://develop.svn.wordpress.org/trunk@46069


git-svn-id: http://core.svn.wordpress.org/trunk@45881 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-05 23:05:55 +00:00
K. Adam White
5dbb64d0dd REST API: Cache results of get_item_schema on controller instances for performance.
Caches the output of get_item_schema() to avoid redundant recomputation of translatable strings and other computed values. This method is called many times per item in each REST request, and the results of the method should not vary between calls.
Additional schema fields are not cached.

Props kadamwhite, joehoyle, TimothyBlynJacobs.
Fixes #47871.

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


git-svn-id: http://core.svn.wordpress.org/trunk@45622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-15 21:09:55 +00:00
Jeremy Felt
c339798b49 Themes: Introduce responsive embeds support.
Responsive embeds is a way for a theme to opt in to WordPress dynamically scaling the width/height of an embed. When a theme supports responsive embeds, a `wp-embed-responsive` class is added to the `<body>` tag. This information is also presented through the REST API for clients to respect.

Merges [43790] and [43791] from the 5.0 branch to trunk.

Props desrosj, danielbachhuber, ocean90.
Fixes #45125.

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


git-svn-id: http://core.svn.wordpress.org/trunk@43968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 01:50:37 +00:00
Jeremy Felt
c108cbfa52 REST API: Introduce themes endpoint to expose theme-supports values for the active theme.
In order to correctly render parts of its UI, the new editor needs to be aware of the active theme's post-formats and post-thumbnails support. This data is exposed by querying for the active theme on a new /wp/v2/themes endpoint for sufficiently privileged users.

Merges [43734], [43735] to trunk.

props desrosj.
Fixes #45016.

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


git-svn-id: http://core.svn.wordpress.org/trunk@43817 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-12 03:33:24 +00:00