On this page
WP_REST_Posts_Controller::check_status( string $status, WP_REST_Request $request, string $param ): true|WP_Error
Checks whether the status is valid for the given post.
Description
Allows for sending an update request with the current status, even if that status would not be acceptable.
Parameters
$statusstring Required-
The provided status.
$requestWP_REST_Request Required-
The request object.
$paramstring Required-
The parameter name.
Return
true|WP_Error True if the status is valid, or WP_Error if not.
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php. View all references
public function check_status( $status, $request, $param ) {
if ( $request['id'] ) {
$post = $this->get_post( $request['id'] );
if ( ! is_wp_error( $post ) && $post->post_status === $status ) {
return true;
}
}
$args = $request->get_attributes()['args'][ $param ];
return rest_validate_value_from_schema( $status, $args, $param );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_REST_Posts_Controller::get_post() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Gets the post, if the ID is valid. |
| rest_validate_value_from_schema() wp-includes/rest-api.php | Validate a value based on a schema. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 5.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/check_status