revert to capability_type config

This commit is contained in:
Jacson Passold 2018-01-12 18:35:01 -02:00
parent ae8f2f7dde
commit 181c5b493f
7 changed files with 17 additions and 101 deletions

View File

@ -78,23 +78,7 @@ class Collection extends Entity {
'slug' => $this->get_slug()
],
'map_meta_cap' => true,
'capabilities' => [
'edit_post' => 'edit_'.$this->get_db_identifier(),
'read_post' => 'read_'.$this->get_db_identifier(),
'delete_post' => 'delete_'.$this->get_db_identifier(),
'edit_posts' => 'edit_'.$this->get_db_identifier().'s',
'edit_others_posts' => 'edit_others_'.$this->get_db_identifier().'s',
'publish_posts' => 'publish_'.$this->get_db_identifier().'s',
'read_private_posts' => 'read_private_'.$this->get_db_identifier().'s',
'create_posts' => 'create_'.$this->get_db_identifier().'s',
'read' => 'read_'.$this->get_db_identifier(),
'delete_posts' => 'delete_'.$this->get_db_identifier().'s',
'delete_private_posts' => 'delete_private_'.$this->get_db_identifier().'s',
'delete_published_posts'=> 'delete_published_'.$this->get_db_identifier().'s',
'delete_others_posts' => 'delete_others_'.$this->get_db_identifier().'s',
'edit_private_posts' => 'edit_private_'.$this->get_db_identifier().'s',
'edit_published_posts' => 'edit_published_'.$this->get_db_identifier().'s'
],
'capability_type' => $this->get_db_identifier(),
'supports' => [
'title',
'editor',

View File

@ -135,24 +135,8 @@ class Collections extends Repository {
'query_var' => true,
'can_export' => true,
'rewrite' => true,
//'capability_type' => Entities\Collection::get_post_type(),
'capability_type' => 'tainacan-collection', // hardcode because post_type is in plural
'map_meta_cap' => true,
'capabilities' => [
'read_post' => 'read_tainacan-collection',
'read_private_posts' => 'read_private_tainacan-collections',
'create_posts' => 'create_tainacan-collections',
'publish_posts' => 'publish_tainacan-collections',
'delete_post' => 'delete_tainacan-collection',
'delete_posts' => 'delete_tainacan-collections',
'delete_private_posts' => 'delete_private_tainacan-collections',
'delete_published_posts'=> 'delete_published_tainacan-collections',
'delete_others_posts' => 'delete_others_tainacan-collections',
'edit_post' => 'edit_tainacan-collection',
'edit_posts' => 'edit_tainacan-collections',
'edit_others_posts' => 'edit_others_tainacan-collections',
'edit_private_posts' => 'edit_private_tainacan-collections',
'edit_published_posts' => 'edit_published_tainacan-collections'
],
'supports' => [
'title',
'editor',
@ -248,7 +232,6 @@ class Collections extends Repository {
'read_private_'.$name.'s',
'delete_published_'.$name.'s',
'edit_published_'.$name.'s',
'edit_published_'.$name,
'edit_others_'.$name.'s',
'delete_others_'.$name.'s',
'read_'.$name.'s',
@ -278,7 +261,6 @@ class Collections extends Repository {
'read_private_'.$name.'s',
'delete_published_'.$name.'s',
'edit_published_'.$name.'s',
'edit_published_'.$name,
'edit_others_'.$name.'s',
'delete_others_'.$name.'s',
'read_'.$name.'s',

View File

@ -103,7 +103,7 @@ class Filters extends Repository {
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post',
'capability_type' => Entities\Filter::get_post_type(),
'supports' => [
'title',
'editor',

View File

@ -132,23 +132,7 @@ class Logs extends Repository {
'can_export' => true,
'rewrite' => true,
'map_meta_cap' => true,
'capabilities' => [
'edit_post' => 'edit_tainacan-log',
'read_post' => 'read_tainacan-log',
'delete_post' => 'delete_tainacan-log',
'edit_posts' => 'edit_tainacan-logs',
'edit_others_posts' => 'edit_others_tainacan-logs',
'publish_posts' => 'publish_tainacan-logs',
'read_private_posts' => 'read_private_tainacan-logs',
'create_posts' => 'create_tainacan-logs',
'read' => 'read_tainacan-log',
'delete_posts' => 'delete_tainacan-logs',
'delete_private_posts' => 'delete_private_tainacan-logs',
'delete_published_posts'=> 'delete_published_tainacan-logs',
'delete_others_posts' => 'delete_others_tainacan-logs',
'edit_private_posts' => 'edit_private_tainacan-logs',
'edit_published_posts' => 'edit_published_tainacan-logs'
],
'capability_type' => Entities\Log::get_post_type(),
'supports' => [
'title',
'editor',

View File

@ -167,23 +167,7 @@ class Metadatas extends Repository {
'can_export' => true,
'rewrite' => true,
'map_meta_cap' => true,
'capabilities' => [
'edit_post' => 'edit_tainacan-metadata',
'read_post' => 'read_tainacan-metadata',
'delete_post' => 'delete_tainacan-metadata',
'edit_posts' => 'edit_tainacan-metadatas',
'edit_others_posts' => 'edit_others_tainacan-metadatas',
'publish_posts' => 'publish_tainacan-metadatas',
'read_private_posts' => 'read_private_tainacan-metadatas',
'create_posts' => 'create_tainacan-metadatas',
'read' => 'read_tainacan-metadata',
'delete_posts' => 'delete_tainacan-metadatas',
'delete_private_posts' => 'delete_private_tainacan-metadatas',
'delete_published_posts'=> 'delete_published_tainacan-metadatas',
'delete_others_posts' => 'delete_others_tainacan-metadatas',
'edit_private_posts' => 'edit_private_tainacan-metadatas',
'edit_published_posts' => 'edit_published_tainacan-metadatas'
],
'capability_type' => Entities\Metadata::get_post_type(),
'supports' => [
'title',
'editor',

View File

@ -457,12 +457,12 @@ abstract class Repository {
}
$entity = self::get_entity_by_post($entity);
$name = $entity::get_post_type();
if($name === false) {
$post_type = $entity::get_post_type();
if($post_type === false) { // There is no post
return user_can($user, 'edit_posts');
}
return user_can($user, 'edit_post', $entity);
return user_can($user, $entity->cap->edit_post, $entity);
}
/**
@ -480,9 +480,8 @@ abstract class Repository {
}
$entity = self::get_entity_by_post($entity);
$name = $entity::get_post_type();
if($name === false)
{
$post_type = $entity::get_post_type();
if($post_type === false) { // There is no post
return user_can($user, 'read');
}
@ -503,12 +502,12 @@ abstract class Repository {
$user = $user->ID;
}
$entity = self::get_entity_by_post($entity);
$name = $entity::get_post_type();
if($name === false) {
$post_type = $entity::get_post_type();
if($post_type === false) { // There is no post
return user_can($user, 'delete_posts');
}
return user_can($user, 'delete_post', $entity);
return user_can($user, $entity->cap->delete_post, $entity);
}
/**
@ -525,12 +524,11 @@ abstract class Repository {
$user = $user->ID;
}
$entity = self::get_entity_by_post($entity);
$name = $entity::get_post_type();
if($name === false) {
$post_type = $entity::get_post_type();
if($post_type === false) { // There is no post
return user_can($user, 'publish_posts');
}
return user_can($user, 'publish_post', $entity);
return user_can($user, $entity->cap->publish_posts, $entity);
}
}

View File

@ -97,23 +97,7 @@ class Taxonomies extends Repository {
'can_export' => true,
'rewrite' => true,
'map_meta_cap' => true,
'capabilities' => [
'edit_post' => 'edit_tainacan-taxonomy',
'read_post' => 'read_tainacan-taxonomy',
'delete_post' => 'delete_tainacan-taxonomy',
'edit_posts' => 'edit_tainacan-taxonomies',
'edit_others_posts' => 'edit_others_tainacan-taxonomies',
'publish_posts' => 'publish_tainacan-taxonomies',
'read_private_posts' => 'read_private_tainacan-taxonomies',
'create_posts' => 'create_tainacan-taxonomies',
'read' => 'read_tainacan-taxonomy',
'delete_posts' => 'delete_tainacan-taxonomies',
'delete_private_posts' => 'delete_private_tainacan-taxonomies',
'delete_published_posts'=> 'delete_published_tainacan-taxonomies',
'delete_others_posts' => 'delete_others_tainacan-taxonomies',
'edit_private_posts' => 'edit_private_tainacan-taxonomies',
'edit_published_posts' => 'edit_published_tainacan-taxonomies'
],
'capability_type' => Entities\Taxonomy::get_post_type(),
'supports' => [
'title',
'editor',