WP_REST_Posts_Controller::check_is_post_type_allowed( WP_Post_Type|string $post_type ): bool

In this article

Checks if a given post type can be viewed or managed.

Parameters

$post_typeWP_Post_Type|stringrequired
Post type name or object.

Return

bool Whether the post type is allowed in REST.

Source

protected function check_is_post_type_allowed( $post_type ) {
	if ( ! is_object( $post_type ) ) {
		$post_type = get_post_type_object( $post_type );
	}

	if ( ! empty( $post_type ) && ! empty( $post_type->show_in_rest ) ) {
		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.