Commit Graph

928 Commits

Author SHA1 Message Date
Sergey Biryukov
2d72e07779 Docs: Update description for some method parameters in WP_REST_Server class.
Follow-up to [47224], [59032].

Props dilipbheda, mukesh27, kirasong, shailu25, khushdoms, welcher, audrasjb, SergeyBiryukov.
Fixes #63249.
Built from https://develop.svn.wordpress.org/trunk@61114


git-svn-id: http://core.svn.wordpress.org/trunk@60450 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-11-03 16:49:39 +00:00
Sergey Biryukov
fabb94e505 Docs: Correct the type for some method parameters in WP_REST_Server class.
Follow-up to [34928].

Props dilipbheda, mukesh27, kirasong, shailu25, khushdoms, welcher, audrasjb, SergeyBiryukov.
See #63249.
Built from https://develop.svn.wordpress.org/trunk@61113


git-svn-id: http://core.svn.wordpress.org/trunk@60449 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-11-02 17:29:34 +00:00
Sergey Biryukov
6d7766478e Docs: Correct @return type for WP_REST_Response::remove_link().
Follow-up to [34928].

Props dilipbheda, mukesh27, kirasong, shailu25, khushdoms, welcher, audrasjb, SergeyBiryukov.
See #63249.
Built from https://develop.svn.wordpress.org/trunk@61112


git-svn-id: http://core.svn.wordpress.org/trunk@60448 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-11-01 22:52:34 +00:00
Adam Silverstein
59991fff9b Editor: Notes should not appear in the context of comments.
Prevent notes from inadvertently showing up in the context of comments - including on the Dashboard recent comments widget and the “Mine” count on the Comments page. Notes are stored as a custom ‘note’ comment type and this change ensures the note type is only returned when explicitly requested, or when ‘all’ types are requested.

The query for note children is modified to return all child notes. This fixes an issue where children were no longer being returned for the ‘note’ type.

Also fixes https://github.com/WordPress/gutenberg/issues/72548.


Props adamsilverstein, timothyblynjacobs, shailu25, peterwilsoncc, westonruter, mamaduka, kadamwhite.
Fixes #64145.
Fixes #64152.


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


git-svn-id: http://core.svn.wordpress.org/trunk@60441 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-31 18:57:30 +00:00
johnjamesjacoby
e697855dd3 Docs: minor white-space correction.
This commit adds a missing space to the `@return` array of `WP_REST_Post_Format_Search_Handler::prepare_item()`.

Props audrasjb, jigar-bhanushali, rollybueno.

See #63166.

Fixes #63218.
Built from https://develop.svn.wordpress.org/trunk@61087


git-svn-id: http://core.svn.wordpress.org/trunk@60423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-29 18:35:34 +00:00
ellatrix
ead0b93afd Template activation: merge changes for Beta 2.
Developed in https://github.com/WordPress/wordpress-develop/pull/10425.
See https://core.trac.wordpress.org/ticket/62755.

* Rename new endpoints, https://github.com/WordPress/gutenberg/pull/72700.
* Remove fake post type for registered templates, https://github.com/WordPress/gutenberg/pull/72674.
* Remove the ability to deactivate registered templates, https://github.com/WordPress/gutenberg/pull/72636,
* Fix undefined array key PHP warning, https://github.com/WordPress/gutenberg/pull/72729.
* Add migration logic (to be refined), see https://core.trac.wordpress.org/ticket/64133 and https://github.com/WordPress/wordpress-develop/pull/10418.

Fixes #62755.
Props ellatrix, priethor.
Built from https://develop.svn.wordpress.org/trunk@61078


git-svn-id: http://core.svn.wordpress.org/trunk@60414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-28 13:35:28 +00:00
ramonopoly
9297bdec0e Media / Attachments REST API endpoint: cast args to array before sending to wp_slash > wp_insert_attachment
This commit casts the object returned by `prepare_item_for_database()` to an array. Without doing so, `wp_slash()` returns the object unchanged, meaning string values within the object wouldn't be properly escaped for database insertion.

Follow-up to [64035]

Props ramonopoly, westonruter, mukesh27, justlevine.

Fixes #64149.


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


git-svn-id: http://core.svn.wordpress.org/trunk@60401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-26 21:08:28 +00:00
gziolo
7aa1b7ef5b Abilities API: Normalize input from schema
Without this patch REST API would require a weird empty `?input` field for optional input given how the current controller works with input schema when it defines the expected shape. This patch normalizes the input for the ability, applying the default value from the input schema when needed.

Developed in https://github.com/WordPress/wordpress-develop/pull/10395.

Follow-up [61032], [61045].

Props gziolo, jorgefilipecosta, mukesh27.
Fixes #64139.



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


git-svn-id: http://core.svn.wordpress.org/trunk@60383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-22 15:04:30 +00:00
gziolo
4ede839674 Abilities API: Add Ability Categories REST API controller
Introduces a new REST API endpoint at `wp-abilities/v1/categories` to expose
ability categories through the WordPress REST API.

The new `WP_REST_Abilities_V1_Categories_Controller` provides:

- GET `/wp-abilities/v1/categories` - Lists all ability categories with pagination
- GET `/wp-abilities/v1/categories/{slug}` - Retrieves a single category by slug

Both endpoints require the `read` capability and return category data including
slug, label, description, and metadata. The collection endpoint supports pagination
with `page` and `per_page` parameters (default: 50, max: 100).

Developed in https://github.com/WordPress/wordpress-develop/pull/10380.

Follow-up [61032].

Props gziolo, jason_the_adams, timothyblynjacobs.
Fixes #64098.


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


git-svn-id: http://core.svn.wordpress.org/trunk@60381 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-22 07:07:28 +00:00
ellatrix
d17bae0e95 Templates: add missing file after [61029].
See #62755.
Built from https://develop.svn.wordpress.org/trunk@61033


git-svn-id: http://core.svn.wordpress.org/trunk@60369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-21 13:54:22 +00:00
gziolo
d3fe16afc4 Abilities API: Introduce server-side registry and REST API endpoints
Feature proposal at https://make.wordpress.org/ai/2025/07/17/abilities-api/.
Project developed in https://github.com/WordPress/abilities-api.

Introduces a new Abilities API that allows WordPress plugins and themes to register and execute custom abilities with built-in permission checking, input/output validation via JSON Schema, and REST API integration.

## Public Functions

### Ability Management
- `wp_register_ability( string $name, array $args ): ?WP_Ability` - Registers a new ability (must be called on `wp_abilities_api_init` hook)
- `wp_unregister_ability( string $name ): ?WP_Ability` - Unregisters an ability
- `wp_has_ability( string $name ): bool` - Checks if an ability is registered
- `wp_get_ability( string $name ): ?WP_Ability` - Retrieves a registered ability
- `wp_get_abilities(): array` - Retrieves all registered abilities

### Ability Category Management
- `wp_register_ability_category( string $slug, array $args ): ?WP_Ability_Category` - Registers an ability category (must be called on `wp_abilities_api_categories_init` hook)
- `wp_unregister_ability_category( string $slug ): ?WP_Ability_Category` - Unregisters an ability category
- `wp_has_ability_category( string $slug ): bool` - Checks if an ability category is registered
- `wp_get_ability_category( string $slug ): ?WP_Ability_Category` - Retrieves a registered ability category
- `wp_get_ability_categories(): array` - Retrieves all registered ability categories

## Public Classes

- `WP_Ability` - Encapsulates ability properties and methods (execute, check_permission, validate_input, etc.)
- `WP_Ability_Category` - Encapsulates ability category properties
- `WP_Abilities_Registry` - Manages ability registration and lookup (private, accessed via functions)
- `WP_Ability_Categories_Registry` - Manages ability category registration (private, accessed via functions)
- `WP_REST_Abilities_V1_List_Controller` - REST controller for listing abilities
- `WP_REST_Abilities_V1_Run_Controller` - REST controller for executing abilities

## REST API Endpoints

### Namespace: `wp-abilities/v1`

#### List Abilities
- `GET /wp-abilities/v1/abilities` - Retrieve all registered abilities
  - Query parameters: `page`, `per_page`, `category`

#### Get Single Ability
- `GET /wp-abilities/v1/abilities/(?P<name>[a-zA-Z0-9\-\/]+)` - Retrieve a specific ability by name

#### Execute Ability
- `GET|POST|DELETE /wp-abilities/v1/abilities/(?P<name>[a-zA-Z0-9\-\/]+)/run` - Execute an ability
  - Supports multiple HTTP methods based on ability annotations
  - Validates input against ability's input schema
  - Validates output against ability's output schema
  - Performs permission checks via ability's permission callback

## Hooks

### Actions
- `wp_abilities_api_categories_init` - Fired when ability categories registry is initialized (register categories here)
- `wp_abilities_api_init` - Fired when abilities registry is initialized (register abilities here)
- `wp_before_execute_ability` - Fired before an ability gets executed, after input validation and permissions check

- `wp_after_execute_ability` - Fires immediately after an ability finished executing

### Filters
- `wp_register_ability_category_args` - Filters ability category arguments before registration
- `wp_register_ability_args` - Filters ability arguments before registration

Developed in https://github.com/WordPress/wordpress-develop/pull/9410.

Props gziolo, jorbin, justlevine, westonruter, jason_the_adams, flixos90, karmatosed, timothyblynjacobs.
Fixes #64098.



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


git-svn-id: http://core.svn.wordpress.org/trunk@60368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-21 13:52:27 +00:00
Peter Wilson
79199e848e REST API: Improve performance of X-WP-Total/X-WP-TotalPages queries.
Improve the performance of fallback queries to determine the total number of objects available on various REST endpoints for out of bounds queries.

The database queries are modified to return the minimum amount of data required for determining the count and bypass priming of meta a term caches where appropriate.

Props adamsilverstein, joehoyle, johnbillion, jorbin, kadamwhite, spacedmonkey, sukhendu2002, westonruter.
Fixes #62801.

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


git-svn-id: http://core.svn.wordpress.org/trunk@60338 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-21 03:33:30 +00:00
Adam Silverstein
956747c6e8 Editor: Introduce the PHP-related code for Notes.
Bring the PHP part of the new Notes feature into core for the 6.9 release. See related Gutenberg Issue: https://github.com/WordPress/gutenberg/issues/71826. These changes do not impact any user facing functionality, they simply prepare core for the JavaScript functionality that will come over in a separate sync.

Overview of changes:
- Ensure Notes are not included in comment counts
- Enable the note type  (REST API)
- Adjust capabilities so edit_post cap implies ability to edit notes  
- Enable empty and duplicate notes for resolve/re-open actions  
- Add control over notes with post type supports check
- Register new note resolution status meta

Props: ristojovanovic, adamsilverstein, jeffpaul, wildworks, mamaduka, swissspidy, timothyblynjacobs, kadamwhite.
Fixes #64096.


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


git-svn-id: http://core.svn.wordpress.org/trunk@60323 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-20 19:22:33 +00:00
Mamaduka
5c2f0f4407 REST API: Add export rel link for active theme response.
The `targetHints.allow` value is used by the Site Editor to enable/disable the theme export feature.

Props mamaduka, wildworks.
Fixes #57379.
Built from https://develop.svn.wordpress.org/trunk@60984


git-svn-id: http://core.svn.wordpress.org/trunk@60320 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-20 12:30:29 +00:00
K. Adam White
b7b8b2080e REST API: Allow comment content to be updated to empty when allow_empty_comment filter returns true
This filter was already respected during comment creation, but not updates. This was inconsistent between POST and PUT, and prevented erasing content of moderated comments via the API without deleting the entire object.

Props adamsilverstein, kadamwhite, davidbaumwald, mukesh27, timothyblynjacobs.
Fixes #64049.


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


git-svn-id: http://core.svn.wordpress.org/trunk@60273 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-15 20:30:29 +00:00
ramonopoly
c8208ae651 Attachments REST API endpoint: add support for filtering attachments by multiple media types
This patch enhances the REST API media endpoint to allow filtering by multiple values for the media_type and mime_type parameters. String, comma-separated values and array are supported.

Props abcd95, ramonopoly, andrewserong, mukesh27, adamsilverstein, timothyblynjacobs, swissspidy.

Fixes #63668.


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


git-svn-id: http://core.svn.wordpress.org/trunk@60253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-09 05:23:33 +00:00
andrewserong
7804c5dc01 REST API: Rename post link relation in media endpoint to wp:attached-to
By adding the https://api.w.org/ prefix and using a more descriptive name for the link relation, this change creates greater clarity for this part of the API. Note that the renaming of this property is safe, as the API change has not yet made it into a final release.

Follow-up to [60893].

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


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


git-svn-id: http://core.svn.wordpress.org/trunk@60252 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-08 22:51:32 +00:00
ramonopoly
434404c863 Attachments REST API endpoint: update attachments controller to support flip and to customize attachment fields
This commit enhances media editor capabilities pursuant to the Phase 3: Collaboration > Media Library. See https://make.wordpress.org/core/2023/07/07/media-library/

It adds the following functionality:

- the ability to flip an image horizontally and vertically
- the ability to send arguments to update the new image's `caption`, `description`, and `title`, `post` and `alt_text` fields.

Props ramonopoly, mukesh27, isabel_brison, andrewserong.
Fixes #64035.



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


git-svn-id: http://core.svn.wordpress.org/trunk@60244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-06 23:51:25 +00:00
andrewserong
1615954762 REST API: Add an embeddable post to the media endpoint within links
Allows consumers to more easily fetch details of the post a media item is linked to, i.e. to more easily display the uploaded to / attached to status of media items.

Props andrewserong, ramonopoly, mukesh27, adamsilverstein.
Fixes #64034.

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


git-svn-id: http://core.svn.wordpress.org/trunk@60229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-03 01:39:35 +00:00
John Blackbourn
27784ed960 REST API: Increase the specificity of capability checks for collections when the edit context is in use.
The edit access in now taken into account for each individual post, term, or user in the response.

Props andraganescu, desrosj, ehti, hurayraiit, iandunn, joehoyle, johnbillion, jorbin, mnelson4, noisysocks, peterwilsoncc, rmccue, timothyblynjacobs, vortfu, whyisjake, zieladam.
Built from https://develop.svn.wordpress.org/trunk@60814


git-svn-id: http://core.svn.wordpress.org/trunk@60150 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-09-30 15:51:28 +00:00
Sergey Biryukov
1c777979ed REST API: Correct error handling in WP_REST_Server::serve_batch_request_v1().
This aims to avoid a fatal error when hitting the batch request endpoint with a malformed URL.

Follow-up to [49252].

Props bor0, SirLouen, SergeyBiryukov.
Fixes #63502.
Built from https://develop.svn.wordpress.org/trunk@60635


git-svn-id: http://core.svn.wordpress.org/trunk@59971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-08-14 21:16:35 +00:00
audrasjb
d18c1ab57d Docs: Docblock improvement in WP_REST_Font_Collections_Controller.
Props viralsampat , mukesh27.
Fixes #63744.
See #63166.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59861 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-07-31 17:28:37 +00:00
John Blackbourn
c2ca912e5e Application Passwords: Correct the schema of the app_id property of the application passwords REST API endpoint.
This property can contain either a UUID or an empty string.

Props sukhendu2002, johnbillion.

Fixes #53692
Built from https://develop.svn.wordpress.org/trunk@60404


git-svn-id: http://core.svn.wordpress.org/trunk@59740 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-07-02 12:00:37 +00:00
John Blackbourn
71d59053cd Posts, Post Types: Correct the schema for the id property of the global styles REST API endpoint.
This property is an integer as it corresponds to a post ID.

Props narenin, TimothyBlynJacobs, audrasjb, johnbillion, mikinc860, abcd95

Fixes #61911
Built from https://develop.svn.wordpress.org/trunk@60359


git-svn-id: http://core.svn.wordpress.org/trunk@59695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-06-27 20:47:34 +00:00
John Blackbourn
142a068815 Options, Meta APIs: Account for URL query parameters when checking the validity of requests to the /wp/v2/settings REST API route.
Follow-up to [60301].

Props sheldorofazeroth, Mamaduka, wildworks, johnbillion

Fixes #41604
Built from https://develop.svn.wordpress.org/trunk@60357


git-svn-id: http://core.svn.wordpress.org/trunk@59693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-06-27 14:27:29 +00:00
John Blackbourn
56afb62f6b REST API: Return a more appropriate HTTP 400 response code when attempting to create or update a non-existent setting.
This switches the response from a 200, which is not appropriate for invalid requests.

Props sheldorofazeroth, johnbillion

Fixes #41604
Built from https://develop.svn.wordpress.org/trunk@60301


git-svn-id: http://core.svn.wordpress.org/trunk@59637 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-06-11 17:42:39 +00:00
John Blackbourn
53331b1e7a Docs: Switch some @internal tags to the inline format so the corresponding function or method is not treated by IDEs and static scanning tools as internal use only.
See #63166
Built from https://develop.svn.wordpress.org/trunk@60249


git-svn-id: http://core.svn.wordpress.org/trunk@59585 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-05-26 11:20:35 +00:00
Aaron Jorbin
605d7f9539 REST API: Change posts endpoint to ignore_sticky=true by default
This restores the 6.7 and below behavior for the posts endpoint which did not include sticky posts by default.

Follow-up to [59801].

Props nikunj8866, SirLouen, ankitmaru, wildworks, karthikeya01, Mamaduka, spacedmonkey, jorbin.
Fixes #63307. See #35907.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59533 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-28 16:05:22 +00:00
Aaron Jorbin
c428ba7cba Media: Don't try to resize image formats which can't be resized
While having a mime type with an "image" prefix, SVG images are in fact "Scalable Vector Graphics" that can be scaled directly.

Follow-up to [60084].

Props sirlouen, adamsilverstein, audrasjb, pbiron, sainathpoojary, dilipbheda, pratiklondhe.
Fixes #63302. See #61167.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-28 15:39:24 +00:00
Sergey Biryukov
4faa2950fe Docs: Correct $request parameter type in WP_REST_Server::get_index().
Follow-up to [34928], [52796].

Props justlevine.
See #63268.
Built from https://develop.svn.wordpress.org/trunk@60177


git-svn-id: http://core.svn.wordpress.org/trunk@59513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-21 09:31:30 +00:00
Sergey Biryukov
f581a7f5b3 Docs: Correct parameter name for rest_menu_read_access filter.
The filter's third parameter was incorrectly named `$this`, which is not a valid parameter name.

Follow-up to [59718], [59734].

Props justlevine.
See #63268.
Built from https://develop.svn.wordpress.org/trunk@60172


git-svn-id: http://core.svn.wordpress.org/trunk@59508 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-17 12:10:36 +00:00
Sergey Biryukov
d9a3cdbe01 Coding Standards: Remove extra check in WP_REST_Server::get_json_last_error().
`json_last_error()` can only return an integer, and the `JSON_ERROR_NONE` constant has the value of `0`, so the `empty()` check is redundant here.

Follow-up to [34928], [46206].

Props dilipbheda, audrasjb, SergeyBiryukov.
See #63249.
Built from https://develop.svn.wordpress.org/trunk@60151


git-svn-id: http://core.svn.wordpress.org/trunk@59487 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-04-11 19:38:33 +00:00
Adam Silverstein
6fd9b34405 Media: prevent uploading image types the server doesn’t support.
Normalize behavior between uploading in the media library and uploading directly to the block editor.  Now, when uploading an image with a mime type the server does not support (either in the media library or the block editor), the user will see an error message “This image cannot be processed by the web server. Convert it to JPEG or PNG before uploading”.

Alos, add a new filter `wp_prevent_unsupported_mime_type_uploads` which determines whether the server should prevent uploads for image types it doesn't support. The default value is true and the filter also receives the uploaded image mime type.

Props: joomskys, adamsilverstein, azaozz, swissspidy, joemcgill, flixos90, audrasjb. 

Fixes #61167


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


git-svn-id: http://core.svn.wordpress.org/trunk@59420 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-25 14:07:53 +00:00
audrasjb
5beb28bd39 Coding Standards: Fix a trailing indentation issue after [60073].
Follow-up to [60073].

See #62163.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59410 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-25 00:04:25 +00:00
audrasjb
46cb039f26 REST API: exclude rest_route from get_params() if pretty permalinks are disabled.
This changeset introduces a modification to the `get_params()` method within the WordPress REST API. The change ensures that the `rest_route` parameter is excluded from the parameters returned when pretty permalinks are not enabled. This update enhances the developer experience by ensuring that the parameters returned by `get_params()` are relevant and do not include unnecessary values, thereby reducing potential confusion and errors.

Props westonruter, TimothyBlynJacobs, audrasjb, debarghyabanerjee, dilip2615, shanemuir, peterwilsoncc.
Fixes #62163.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59409 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-24 23:59:35 +00:00
Aaron Jorbin
b6e009f4dd Coding Standards: Fix alignment in WP_REST_Widgets_Controller::prepare_item_for_response.
Follow-up to [59899].

See #56481, 62279.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59380 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-18 20:39:23 +00:00
TimothyBlynJacobs
448ffcdaa4 REST API: Fix fatal error when making HEAD requests with _fields filter.
In [59889] the REST API controllers were adjusted to perform less work when responding to HEAD requests. The WP_REST_Response body would now be `null`, which caused issues with filters that expected the response body to be an array.

This commit sets the response body to be an empty array when preparing the response instead. The body will still be discarded, but this provides better backward comppatibility with code that assumes an array will be used.

See #56481.
Props antonvlasenko, timothyblynjacobs, mamaduka, wildworks.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59312 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-11 14:19:20 +00:00
Mamaduka
c5bd4c18b4 REST API: Add additional default template data fields for the active theme.
The active theme(s) now return two additional properties, `default_template_types` and `default_template_part_areas`, in the REST response.

Props mamaduka, joemcgill, timothyblynjacobs, audrasjb, gigitux, peterwilsoncc, youknowriad, jorbin.
Fixes #62574.
Built from https://develop.svn.wordpress.org/trunk@59965


git-svn-id: http://core.svn.wordpress.org/trunk@59307 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-11 06:15:23 +00:00
audrasjb
a9ea0e8be5 Editor: Use the export cap to determine whether users can export themes.
This changeset replaces `edit_theme_options` with the `export` capability to determine whether the current user can export themes. That condition determines whether to show the Export Theme button in the Site Editor. Using `export` capability makes it more consistent with general export capabilities across the administration.

Props unsalkorkmaz, rajinsharwar, audrasjb, peterwilsoncc, desrosj, Mamaduka, TimothyBlynJacobs.
Fixes #57379.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-04 06:07:22 +00:00
TimothyBlynJacobs
48128ad56d REST API: Improve performance for HEAD requests.
By default, the REST API responds to HEAD rqeuests by calling the GET handler and omitting the body from the response. While convenient, this ends up performing needless work that slows down the API response time.

This commit adjusts the Core controllers to specifically handle HEAD requests by not preparing the response body.

Fixes #56481.
Props antonvlasenko, janusdev, ironprogrammer, swissspidy, spacedmonkey, mukesh27, mamaduka, timothyblynjacobs.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-03-02 22:07:25 +00:00
Joe McGill
b024026e81 REST API: Add support for search_columns to the user endpoint.
This adds support for passing a `search_columns` argument to the user controller so that users with `list_users` caps can specify which field is being searched.

Props youknowriad, joemcgill, ntsekouras, mreishus, mamaduka.
Fixes 62596.

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


git-svn-id: http://core.svn.wordpress.org/trunk@59234 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-28 18:21:26 +00:00
Sergey Biryukov
f37de3c6ac Docs: Correct the type for ::prepare_status_response() parameter in WP_REST_Comments_Controller.
The accepted value is `WP_Comment::$comment_approved`, which is documented as a string.

Follow-up to [38832], [33891], [39015], [59805], [59871].

See #62281.
Built from https://develop.svn.wordpress.org/trunk@59882


git-svn-id: http://core.svn.wordpress.org/trunk@59224 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-27 22:41:24 +00:00
Mamaduka
b6a0684402 REST API: Add the site reading options to the index.
Exposes `page_for_posts`, `page_on_front` and `show_on_front` reading settings via REST API index.

Props mamaduka, audrasjb, spacedmonkey, timothyblynjacobs.
Fixes #63023.
Built from https://develop.svn.wordpress.org/trunk@59880


git-svn-id: http://core.svn.wordpress.org/trunk@59222 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-27 03:39:25 +00:00
Peter Wilson
d4822bd3c5 REST API: Add support for the ignore_sticky_posts argument.
Introduce `ignore_sticky` as a boolean argument for the posts endpoint for requests without the sticky posts being stuck. The new argument defaults to `false` with the value of the argument passed to `WP_Query`'s `ignore_sticky_posts` parameter.

Props audrasjb, danielbachhuber, joemcgill, johnbillion, jorbin, mamaduka, rmccue.
Fixes #35907.


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


git-svn-id: http://core.svn.wordpress.org/trunk@59143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-10 22:23:23 +00:00
John Blackbourn
b765f8b44c Security: Add the SensitiveParameter attribute to sensitive parameters.
Values passed to parameters with this attribute will be redacted if present in a stack trace when using PHP 8.2 or later. This reduces the chance that passwords and security keys get accidentally exposed in debug logs and bug reports.

Props petitphp, TobiasBg, jrf, johnbillion.

Fixes #57304
Built from https://develop.svn.wordpress.org/trunk@59754


git-svn-id: http://core.svn.wordpress.org/trunk@59096 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-02-03 19:52:24 +00:00
audrasjb
ac5aaad84e Docs: Improve docblock for rest_menu_read_access filter.
Follow-up to [59718].

See #62281, #54304.



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


git-svn-id: http://core.svn.wordpress.org/trunk@59076 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-29 23:15:23 +00:00
spacedmonkey
12a2275de7 REST API: Introduce filter for controlling menu read access.
The menu, menu item, and menu location endpoints were added to the REST API in [52079]. In that commit, menu data was treated as private and restricted to logged-in users with the edit_theme_options capability. However, in many cases, this data can be considered public. Previously, there was no simple way for developers to allow this data to be exposed via the REST API.

This commit introduces the rest_menu_read_access filter, enabling developers to control read access to menus, menu items, and menu locations in the REST API. The same filter is applied across all three REST API classes, simplifying the process of opting into exposing this data.

Each instance of the filter provides the current request and the relevant class instance as context, allowing developers to selectively or globally enable access to the data.

Props spacedmonkey, antonvlasenko, kadamwhite, julianmar, masteradhoc.
Fixes #54304.
Built from https://develop.svn.wordpress.org/trunk@59718


git-svn-id: http://core.svn.wordpress.org/trunk@59060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-28 04:09:22 +00:00
Felix Arntz
b742570d1b REST API: Fix PHP warning about undefined paged argument in various REST API endpoints.
This bug could occur in `WP_REST_Posts_Controller`, `WP_REST_Global_Styles_Revisions_Controller`, `WP_REST_Revisions_Controller`, and any of their child classes. This changeset fixes it throughout.

Props apermo, pbearne, hemant-ahir, flixos90.
Fixes #62292.

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


git-svn-id: http://core.svn.wordpress.org/trunk@58993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-15 18:36:24 +00:00
Pascal Birchler
7dcc7f8d32 REST API: Improve autosave and revision endpoints for templates and template parts.
Fixes those endpoints for file-based templates and template parts, as templates based on theme files can't be revisioned or autosaved.

Props antonvlasenko, swissspidy, spacedmonkey, kadamwhite.
Fixes #61970.
Built from https://develop.svn.wordpress.org/trunk@59605


git-svn-id: http://core.svn.wordpress.org/trunk@58990 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-01-15 12:46:25 +00:00
Peter Wilson
20621484e8 REST API: Protect against fatal error for post types without format support.
Ignore the `format` parameter introduced in WordPress 6.7 for post types that do not support post formats. This protects against a fatal error being thrown in later version of PHP or a warning in earlier versions of PHP.

Follow up to r59115.

Props dd32, sergeybiryukov, yogeshbhutkar.
Fixes #62646.
See #62014.

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


git-svn-id: http://core.svn.wordpress.org/trunk@58930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-12-19 21:43:24 +00:00