fix: get metadata on private section #184
This commit is contained in:
parent
00a9fc0cbb
commit
32c8aea7ff
|
@ -464,6 +464,26 @@ class Metadata extends Repository {
|
|||
$args['meta_query'] = $original_meta_q;
|
||||
$args['meta_query'][] = $meta_query;
|
||||
|
||||
if ($this->get_default_metadata_attribute() != $parent_id) {
|
||||
$read_private_metasection_cap = "tnc_col_{$parent_id}_read_private_metasection";
|
||||
if ( !current_user_can($read_private_metasection_cap) ) {
|
||||
$private_metadata_sections_ids = \tainacan_metadata_sections()->fetch_ids(
|
||||
array(
|
||||
'post_status' => get_post_stati( array( 'private' => true ) ),
|
||||
'meta_query' => array(
|
||||
'key' => 'collection_id',
|
||||
'value' => $parent_id,
|
||||
)
|
||||
));
|
||||
|
||||
$args['meta_query'][] = array(
|
||||
'key' => 'metadata_section_id',
|
||||
'value' => $private_metadata_sections_ids,
|
||||
'compare' => 'NOT IN'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$results = array_merge($results, $this->fetch( $args, 'OBJECT' ));
|
||||
}
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ function tainacan_roles() {
|
|||
|
||||
|
||||
/**
|
||||
* Retrieve the singleton Metadata Repository instance
|
||||
* @return \Tainacan\Repositories\Metadata The Tainacan Metadata Repository
|
||||
* Retrieve the singleton Metadata Sections Repository instance
|
||||
* @return \Tainacan\Repositories\Metadata_Sections The Tainacan Metadata Repository
|
||||
*/
|
||||
function tainacan_metadata_sections() {
|
||||
return \Tainacan\Repositories\Metadata_Sections::get_instance();
|
||||
|
|
Loading…
Reference in New Issue