WP_REST_Posts_Controller::check_is_post_type_allowed

Advertisement

Summery Summery

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

Syntax Syntax

WP_REST_Posts_Controller::check_is_post_type_allowed( WP_Post_Type|string $post_type )

Parameters Parameters

$post_type

(Required) Post type name or object.

Return Return

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

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

Advertisement

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Advertisement

Leave a Reply