From 8f439e75576f1e329bc6ed68ecf0fbb7ad5b57aa Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 29 Jan 2018 18:18:08 -0200 Subject: [PATCH] using read and not read_post, check if cap has been initialized --- src/classes/repositories/class-tainacan-repository.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/classes/repositories/class-tainacan-repository.php b/src/classes/repositories/class-tainacan-repository.php index 8ae11ffb4..6aeb60167 100644 --- a/src/classes/repositories/class-tainacan-repository.php +++ b/src/classes/repositories/class-tainacan-repository.php @@ -403,7 +403,7 @@ abstract class Repository { $entity = self::get_entity_by_post($entity); $post_type = $entity::get_post_type(); - if($post_type === false || $entity instanceof Entities\Entity ) { // There is no post + if( ($post_type === false && ! ($entity instanceof Entities\Item)) || is_null($entity->cap) ) { // There is no post return user_can($user, 'edit_posts'); } return user_can($user, $entity->cap->edit_post, $entity->get_id()); @@ -428,11 +428,11 @@ abstract class Repository { $entity = self::get_entity_by_post($entity); $post_type = $entity::get_post_type(); - if($post_type === false || $entity instanceof Entities\Entity ) { // There is no post + if( ($post_type === false && ! ($entity instanceof Entities\Item)) || is_null($entity->cap) ) { // There is no post return user_can($user, 'read'); } - return user_can($user, $entity->cap->read_post, $entity->get_id()); + return user_can($user, $entity->cap->read, $entity->get_id()); } /** @@ -453,7 +453,7 @@ abstract class Repository { } $entity = self::get_entity_by_post($entity); $post_type = $entity::get_post_type(); - if($post_type === false || $entity instanceof Entities\Entity ) { // There is no post + if( ($post_type === false && ! ($entity instanceof Entities\Item)) || is_null($entity->cap) ) { // There is no post return user_can($user, 'delete_posts'); } @@ -478,7 +478,7 @@ abstract class Repository { } $entity = self::get_entity_by_post($entity); $post_type = $entity::get_post_type(); - if($post_type === false || $entity instanceof Entities\Entity ) { // There is no post + if( ($post_type === false && ! ($entity instanceof Entities\Item)) || is_null($entity->cap) ) { // There is no post return user_can($user, 'publish_posts'); } return user_can($user, $entity->cap->publish_posts, $entity->get_id());