LLMS_REST_Posts_Controller::check_read_permission( LLMS_Post_Model $object )
Checks if an llms post can be read.
Parameters Parameters
- $object
-
(LLMS_Post_Model) (Required) The LLMS_Post_model object.
Return Return
(bool) Whether the post can be read.
Source Source
File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-posts-controller.php
protected function check_read_permission( $object ) { $post_type = get_post_type_object( $this->post_type ); $status = $object->get( 'status' ); $id = $object->get( 'id' ); $wp_post = $object->get( 'post' ); // Is the post readable? if ( 'publish' === $status || current_user_can( $post_type->cap->read_post, $id ) ) { return true; } $post_status_obj = get_post_status_object( $status ); if ( $post_status_obj && $post_status_obj->public ) { return true; } // Can we read the parent if we're inheriting? if ( 'inherit' === $status && $wp_post->post_parent > 0 ) { $parent = get_post( $wp_post->post_parent ); if ( $parent ) { return $this->check_read_permission( $parent ); } } /* * If there isn't a parent, but the status is set to inherit, assume * it's published (as per get_post_status()). */ if ( 'inherit' === $status ) { return true; } return false; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.1 | Introduced. |