wppaste
WordPress

WP_REST_Posts_Controller::check_status( string $status, WP_REST_Request $request, string $param ): true|WP_Error

Since
5.6.0
Source
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:1546
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
The provided status.
$requestWP_REST_Request
The request object.
$paramstring
The parameter name.

Return

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

Uses · 3

Source

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

History

Introduced in 5.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.