W3cubDocs

/WordPress

WP_REST_Posts_Controller::check_is_post_type_allowed( WP_Post_Type|string $post_type )

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

Parameters

$post_type

(WP_Post_Type|string) (Required) Post type name or object.

Return

(bool) Whether the post type is allowed in REST.

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.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;
	}

Changelog

Version Description
4.7.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/check_is_post_type_allowed