WP_REST_Global_Styles_Controller::get_post( int $id ): WP_Post|WP_Error

Get the post, if the ID is valid.


Parameters

$id int Required
Supplied ID.

Top ↑

Return

WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php. View all references

protected function get_post( $id ) {
	$error = new WP_Error(
		'rest_global_styles_not_found',
		__( 'No global styles config exist with that id.' ),
		array( 'status' => 404 )
	);

	$id = (int) $id;
	if ( $id <= 0 ) {
		return $error;
	}

	$post = get_post( $id );
	if ( empty( $post ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
		return $error;
	}

	return $post;
}


Top ↑

Changelog

Changelog
Version Description
5.9.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.