WP_REST_Posts_Controller::check_is_post_type_allowed()
Checks if a given post type can be viewed or managed.
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. |
WP_REST_Posts_Controller::check_is_post_type_allowed() WP REST Posts Controller::check is post type allowed code WP 6.6.2
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; }