Skip to content

Commit 6aca60d

Browse files
committed
REST API: Corrections and improvements to docblocks for REST API filters.
See #51800 git-svn-id: https://develop.svn.wordpress.org/trunk@49955 602fd350-edb4-49c9-b593-d223f7449a82
1 parent fcaf51b commit 6aca60d

12 files changed

Lines changed: 49 additions & 41 deletions

src/wp-includes/rest-api/class-wp-rest-request.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public function is_json_content_type() {
339339
/**
340340
* Retrieves the parameter priority order.
341341
*
342-
* Used when checking parameters in get_param().
342+
* Used when checking parameters in WP_REST_Request::get_param().
343343
*
344344
* @since 4.4.0
345345
*
@@ -371,10 +371,10 @@ protected function get_parameter_order() {
371371
$order[] = 'defaults';
372372

373373
/**
374-
* Filters the parameter order.
374+
* Filters the parameter priority order for a REST API request.
375375
*
376-
* The order affects which parameters are checked when using get_param() and family.
377-
* This acts similarly to PHP's `request_order` setting.
376+
* The order affects which parameters are checked when using WP_REST_Request::get_param()
377+
* and family. This acts similarly to PHP's `request_order` setting.
378378
*
379379
* @since 4.4.0
380380
*
@@ -1035,7 +1035,7 @@ public static function from_url( $url ) {
10351035
}
10361036

10371037
/**
1038-
* Filters the request generated from a URL.
1038+
* Filters the REST API request generated from a URL.
10391039
*
10401040
* @since 4.5.0
10411041
*

src/wp-includes/rest-api/class-wp-rest-server.php

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function __construct() {
162162
*/
163163
public function check_authentication() {
164164
/**
165-
* Filters REST authentication errors.
165+
* Filters REST API authentication errors.
166166
*
167167
* This is used to pass a WP_Error from an authentication method back to
168168
* the API.
@@ -310,11 +310,11 @@ public function serve_request( $path = null ) {
310310
$expose_headers = array( 'X-WP-Total', 'X-WP-TotalPages', 'Link' );
311311

312312
/**
313-
* Filters the list of response headers that are exposed to CORS requests.
313+
* Filters the list of response headers that are exposed to REST API CORS requests.
314314
*
315315
* @since 5.5.0
316316
*
317-
* @param string[] $expose_headers The list of headers to expose.
317+
* @param string[] $expose_headers The list of response headers to expose.
318318
*/
319319
$expose_headers = apply_filters( 'rest_exposed_cors_headers', $expose_headers );
320320

@@ -329,7 +329,7 @@ public function serve_request( $path = null ) {
329329
);
330330

331331
/**
332-
* Filters the list of request headers that are allowed for CORS requests.
332+
* Filters the list of request headers that are allowed for REST API CORS requests.
333333
*
334334
* The allowed headers are passed to the browser to specify which
335335
* headers can be passed to the REST API. By default, we allow the
@@ -338,14 +338,14 @@ public function serve_request( $path = null ) {
338338
*
339339
* @since 5.5.0
340340
*
341-
* @param string[] $allow_headers The list of headers to allow.
341+
* @param string[] $allow_headers The list of request headers to allow.
342342
*/
343343
$allow_headers = apply_filters( 'rest_allowed_cors_headers', $allow_headers );
344344

345345
$this->send_header( 'Access-Control-Allow-Headers', implode( ', ', $allow_headers ) );
346346

347347
/**
348-
* Send nocache headers on authenticated requests.
348+
* Filters whether to send nocache headers on a REST API request.
349349
*
350350
* @since 4.4.0
351351
*
@@ -384,11 +384,11 @@ public function serve_request( $path = null ) {
384384
);
385385

386386
/**
387-
* Filters whether jsonp is enabled.
387+
* Filters whether JSONP is enabled for the REST API.
388388
*
389389
* @since 4.4.0
390390
*
391-
* @param bool $jsonp_enabled Whether jsonp is enabled. Default true.
391+
* @param bool $jsonp_enabled Whether JSONP is enabled. Default true.
392392
*/
393393
$jsonp_enabled = apply_filters( 'rest_jsonp_enabled', true );
394394

@@ -768,11 +768,17 @@ public function envelope_response( $response, $embed ) {
768768
);
769769

770770
/**
771-
* Filters the enveloped form of a response.
771+
* Filters the enveloped form of a REST API response.
772772
*
773773
* @since 4.4.0
774774
*
775-
* @param array $envelope Envelope data.
775+
* @param array $envelope {
776+
* Envelope data.
777+
*
778+
* @type array $body Response data.
779+
* @type int $status The 3-digit HTTP status code.
780+
* @type array $headers Map of header name to header value.
781+
* }
776782
* @param WP_REST_Response $response Original response data.
777783
*/
778784
$envelope = apply_filters( 'rest_envelope_response', $envelope, $response );
@@ -857,7 +863,7 @@ public function get_routes( $namespace = '' ) {
857863
}
858864

859865
/**
860-
* Filters the array of available endpoints.
866+
* Filters the array of available REST API endpoints.
861867
*
862868
* @since 4.4.0
863869
*
@@ -957,7 +963,7 @@ public function get_route_options( $route ) {
957963
*/
958964
public function dispatch( $request ) {
959965
/**
960-
* Filters the pre-calculated result of a REST dispatch request.
966+
* Filters the pre-calculated result of a REST API dispatch request.
961967
*
962968
* Allow hijacking the request before dispatching by returning a non-empty. The returned value
963969
* will be used to serve the request instead.
@@ -1116,7 +1122,8 @@ protected function respond_to_request( $request, $route, $handler, $response ) {
11161122
*
11171123
* @since 4.7.0
11181124
*
1119-
* @param WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response Result to send to the client. Usually a WP_REST_Response or WP_Error.
1125+
* @param WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response Result to send to the client.
1126+
* Usually a WP_REST_Response or WP_Error.
11201127
* @param array $handler Route handler used for the request.
11211128
* @param WP_REST_Request $request Request used to generate the response.
11221129
*/
@@ -1139,7 +1146,7 @@ protected function respond_to_request( $request, $route, $handler, $response ) {
11391146

11401147
if ( ! is_wp_error( $response ) ) {
11411148
/**
1142-
* Filters the REST dispatch request result.
1149+
* Filters the REST API dispatch request result.
11431150
*
11441151
* Allow plugins to override dispatching the request.
11451152
*
@@ -1177,7 +1184,8 @@ protected function respond_to_request( $request, $route, $handler, $response ) {
11771184
*
11781185
* @since 4.7.0
11791186
*
1180-
* @param WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response Result to send to the client. Usually a WP_REST_Response or WP_Error.
1187+
* @param WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response Result to send to the client.
1188+
* Usually a WP_REST_Response or WP_Error.
11811189
* @param array $handler Route handler used for the request.
11821190
* @param WP_REST_Request $request Request used to generate the response.
11831191
*/
@@ -1323,7 +1331,7 @@ public function get_namespace_index( $request ) {
13231331
$response->add_link( 'up', rest_url( '/' ) );
13241332

13251333
/**
1326-
* Filters the namespace index data.
1334+
* Filters the REST API namespace index data.
13271335
*
13281336
* This typically is just the route data for the namespace, but you can
13291337
* add any data you'd like here.
@@ -1356,7 +1364,7 @@ public function get_data_for_routes( $routes, $context = 'view' ) {
13561364
}
13571365

13581366
/**
1359-
* Filters the REST endpoint data.
1367+
* Filters the REST API endpoint data.
13601368
*
13611369
* @since 4.4.0
13621370
*
@@ -1366,7 +1374,7 @@ public function get_data_for_routes( $routes, $context = 'view' ) {
13661374
}
13671375

13681376
/**
1369-
* Filters the publicly-visible data for routes.
1377+
* Filters the publicly-visible data for REST API routes.
13701378
*
13711379
* This data is exposed on indexes and can be used by clients or
13721380
* developers to investigate the site and find out how to use it. It
@@ -1466,7 +1474,7 @@ public function get_data_for_route( $route, $callbacks, $context = 'view' ) {
14661474
*/
14671475
protected function get_max_batch_size() {
14681476
/**
1469-
* Filters the maximum number of requests that can be included in a batch.
1477+
* Filters the maximum number of REST API requests that can be included in a batch.
14701478
*
14711479
* @since 5.6.0
14721480
*

src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public function get_collection_params() {
313313
unset( $query_params['search'] );
314314

315315
/**
316-
* Filters collection parameters for the block directory controller.
316+
* Filters REST API collection parameters for the block directory controller.
317317
*
318318
* @since 5.5.0
319319
*

src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public function create_item_permissions_check( $request ) {
449449
}
450450

451451
/**
452-
* Filters whether comments can be created without authentication.
452+
* Filters whether comments can be created via the REST API without authentication.
453453
*
454454
* Enables creating comments for anonymous users.
455455
*
@@ -955,14 +955,14 @@ public function delete_item( $request ) {
955955
$force = isset( $request['force'] ) ? (bool) $request['force'] : false;
956956

957957
/**
958-
* Filters whether a comment can be trashed.
958+
* Filters whether a comment can be trashed via the REST API.
959959
*
960-
* Return false to disable Trash support for the post.
960+
* Return false to disable trash support for the comment.
961961
*
962962
* @since 4.7.0
963963
*
964-
* @param bool $supports_trash Whether the post type support trashing.
965-
* @param WP_Post $comment The comment object being considered for trashing support.
964+
* @param bool $supports_trash Whether the comment supports trashing.
965+
* @param WP_Comment $comment The comment object being considered for trashing support.
966966
*/
967967
$supports_trash = apply_filters( 'rest_comment_trashable', ( EMPTY_TRASH_DAYS > 0 ), $comment );
968968

@@ -1351,7 +1351,7 @@ protected function prepare_item_for_database( $request ) {
13511351
}
13521352

13531353
/**
1354-
* Filters a comment after it is prepared for the database.
1354+
* Filters a comment added via the REST API after it is prepared for insertion into the database.
13551355
*
13561356
* Allows modification of the comment right after it is prepared for the database.
13571357
*
@@ -1674,7 +1674,7 @@ public function get_collection_params() {
16741674
);
16751675

16761676
/**
1677-
* Filters collection parameters for the comments controller.
1677+
* Filters REST API collection parameters for the comments controller.
16781678
*
16791679
* This filter registers the collection parameter, but does not map the
16801680
* collection parameter to an internal WP_Comment_Query parameter. Use the

src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public function prepare_item_for_response( $item, $request ) {
586586
$response->add_links( $this->prepare_links( $item ) );
587587

588588
/**
589-
* Filters the plugin data for a response.
589+
* Filters plugin data for a REST API response.
590590
*
591591
* @since 5.5.0
592592
*

src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,14 @@ public function prepare_item_for_response( $status, $request ) {
268268
}
269269

270270
/**
271-
* Filters a status returned from the REST API.
271+
* Filters a post status returned from the REST API.
272272
*
273273
* Allows modification of the status data right before it is returned.
274274
*
275275
* @since 4.7.0
276276
*
277277
* @param WP_REST_Response $response The response object.
278-
* @param object $status The original status object.
278+
* @param object $status The original post status object.
279279
* @param WP_REST_Request $request Request used to generate the response.
280280
*/
281281
return apply_filters( 'rest_prepare_status', $response, $status, $request );

src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function update_item( $request ) {
154154
}
155155

156156
/**
157-
* Filters whether to preempt a setting value update.
157+
* Filters whether to preempt a setting value update via the REST API.
158158
*
159159
* Allows hijacking the setting update logic and overriding the built-in behavior by
160160
* returning true.

src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ public function get_collection_params() {
580580
);
581581

582582
/**
583-
* Filters collection parameters for the themes controller.
583+
* Filters REST API collection parameters for the themes controller.
584584
*
585585
* @since 5.0.0
586586
*

src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ public function get_collection_params() {
15591559
);
15601560

15611561
/**
1562-
* Filters collection parameters for the users controller.
1562+
* Filters REST API collection parameters for the users controller.
15631563
*
15641564
* This filter registers the collection parameter, but does not map the
15651565
* collection parameter to an internal WP_User_Query parameter. Use the

src/wp-includes/rest-api/search/class-wp-rest-post-format-search-handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function search_items( WP_REST_Request $request ) {
4646
}
4747

4848
/**
49-
* Filters the query arguments for a search request.
49+
* Filters the query arguments for a REST API search request.
5050
*
5151
* Enables adding extra arguments or setting defaults for a post format search request.
5252
*

0 commit comments

Comments
 (0)