Hi.
Sorry for answering my own post but maybe somebody will make a use of it.
I managed to change this behaviour myself. It seems to work fine. It requires only few changes in core\queries.php:
/**
* Checks whether a post is using a protected term.
*
* @param int $post_id The pos to check.
* @return bool Returns true if post contains a protected term.
*/
public static function check_post_term_protection($post_id){
//initialize variables
$terms = self::get_post_terms($post_id);
//return false if no terms assigned
if(empty($terms)) {
return false;
}
//wp_die(print_r($terms,true)); //TEST
//$ancestor_protected = false; //DISABLED
foreach($terms as $term){
if(!get_metadata('term',$term->term_id,'ctx_ps_security')){
return false;
}else{
if( $term->parent!=0 ){
if(!self::check_term_protection($term->parent))
//$ancestor_protected = true; //DISABLED
return false;
}
}
}
//If any ancestor terms are protected, return true
//if($ancestor_protected) //DISABLED
// return true; //DISABLED
//If no protection flags were triggered, return false
return true;
}
and:
/**
* Recursively checks security for this term and it's ancestors. Returns true
* if any of them are protected or false if none of them are protected.
*
* @global wpdb $wpdb
* @param int $term_id The id of the term to check security for.
* @param string $taxonomy The name of the taxonomy the term belongs to.
* @param bool $recursive Set to false to disable the checking of ancestors. (Default: true)
*
* @return bool If this page or it's ancestors has the "protected page" flag
*/
public static function check_term_protection($term_id,$taxonomy=null,$recursive=true){
global $wpdb;
if(!get_metadata('term',$term_id,'ctx_ps_security')){
return false;
} else if($recursive) {
//If taxonomy isnt set and we're using term id, try to get it
if(empty($taxonomy) && is_numeric($term_id))
$taxonomy = self::get_term_taxonomy($term_id);
//If term has no protection, check parents
$parent_id = get_term($term_id,$taxonomy);
$parent_id = $parent_id->parent;
if ($parent_id != 0)
return self::check_term_protection($parent_id,$taxonomy);
else
return true;
}else{
//Recursive is false and no protection
return true;
}
}
It’s opposite to original behaviour. As long as any of category is available for reading user can see content.
Would You consider including a switch that can be used, to define expected behaviour? Ty in advance.
Regards.
Micha?