WP_REST_Post_Statuses_Controller::check_read_permission( object $status ): bool

In this article

Checks whether a given post status should be visible.

Parameters

$statusobjectrequired
Post status.

Return

bool True if the post status is visible, otherwise false.

Source

protected function check_read_permission( $status ) {
	if ( true === $status->public ) {
		return true;
	}

	if ( false === $status->internal || 'trash' === $status->name ) {
		$types = get_post_types( array( 'show_in_rest' => true ), 'objects' );

		foreach ( $types as $type ) {
			if ( current_user_can( $type->cap->edit_posts ) ) {
				return true;
			}
		}
	}

	return false;
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

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