WordPress at Your Fingertips
function is not described

WP_REST_Posts_Controller::check_status() public WP 5.6.0

Checks whether the status is valid for the given post.

Allows for sending an update request with the current status, even if that status would not be acceptable.

{} It's a method of the class: WP_REST_Posts_Controller{}

No Hooks.

Return

true|WP_Error. True if the status is valid, or WP_Error if not.

Usage

$WP_REST_Posts_Controller = new WP_REST_Posts_Controller();
$WP_REST_Posts_Controller->check_status( $status, $request, $param );
$status(string) (required)
The provided status.
$request(WP_REST_Request) (required)
The request object.
$param(string) (required)
The parameter name.

Changelog

Since 5.6.0 Introduced.

Code of WP_REST_Posts_Controller::check_status() WP 5.7.2

<?php
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 );
}