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
*
* @since 1.0.0-beta.1
*
* @param LLMS_Post_Model $object The LLMS_Post_model object.
* @return bool Whether the post can be deleted.
*/
protected function check_delete_permission( $object ) {
$post_type = get_post_type_object( $this->post_type );
return current_user_can( $post_type->cap->delete_post, $object->get( 'id' ) );
}
/**
* Checks if an llms post can be read.
*
* @since 1.0.0-beta.1
* @since [version] Fix fatals when searching for llms post type based resources
* but the query post type parameter is forced to be something else.
*
* @param LLMS_Post_Model $object The LLMS_Post_model object.
* @return bool Whether the post can be read.
*/
protected function check_read_permission( $object ) {
if ( is_wp_error( $object ) ) {
return false;
}
$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 ) ) {
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0-beta.1 | Introduced. |