WordPress at a glance
function is not described

WP_REST_Posts_Controller::check_is_post_type_allowed() protected WP 4.7.0

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

{} It's a method of the class: WP_REST_Posts_Controller{}

No Hooks.

Return

true/false. Whether the post type is allowed in REST.

Usage

// protected - for code of main (parent) or child class
$result = $this->check_is_post_type_allowed( $post_type );
$post_type(WP_Post_Type/string) (required)
Post type name or object.

Changelog

Since 4.7.0 Introduced.

Code of WP_REST_Posts_Controller::check_is_post_type_allowed() WP 5.5.3

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