Filter hook 'rest_prepare_status'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php at line 285

View Source

rest_prepare_status

Filter Hook
Description
Filters a post status returned from the REST API. Allows modification of the status data right before it is returned.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php View on GitHub
Hook Type Filter
Line Number 285

Hook Parameters

Type Name Description
WP_REST_Response $response The response object.
object $status The original post status object.
WP_REST_Request $request Request used to generate the response.

Usage Examples

Basic Usage
<?php
// Hook into rest_prepare_status
add_filter('rest_prepare_status', 'my_custom_filter', 10, 3);

function my_custom_filter($response, $status, $request) {
    // Your custom filtering logic here
    return $response;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php:285 - How this hook is used in WordPress core
<?php
 280  		 *
 281  		 * @param WP_REST_Response $response The response object.
 282  		 * @param object           $status   The original post status object.
 283  		 * @param WP_REST_Request  $request  Request used to generate the response.
 284  		 */
 285  		return apply_filters( 'rest_prepare_status', $response, $status, $request );
 286  	}
 287  
 288  	/**
 289  	 * Retrieves the post status' schema, conforming to JSON Schema.
 290  	 *

PHP Documentation

<?php
/**
		 * Filters a post status returned from the REST API.
		 *
		 * Allows modification of the status data right before it is returned.
		 *
		 * @since 4.7.0
		 *
		 * @param WP_REST_Response $response The response object.
		 * @param object           $status   The original post status object.
		 * @param WP_REST_Request  $request  Request used to generate the response.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php
Related Hooks

Related hooks will be displayed here in future updates.