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

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


Parameters

$post_type WP_Post_Type|string Required
Post type name or object.

Top ↑

Return

bool Whether the post type is allowed in REST.


Top ↑

Source

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

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


Top ↑

Changelog

Changelog
Version Description
4.7.0 Introduced.

Top ↑

User Contributed Notes

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