diff --git a/includes/core/class-access.php b/includes/core/class-access.php index ebaceb87..c09bef14 100644 --- a/includes/core/class-access.php +++ b/includes/core/class-access.php @@ -54,6 +54,8 @@ if ( ! class_exists( 'um\core\Access' ) ) { add_filter( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 ); add_filter( 'get_next_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); add_filter( 'get_previous_post_where', array( &$this, 'exclude_navigation_posts' ), 99, 5 ); + add_filter( 'widget_comments_args', array( &$this, 'exclude_comments_resticted_posts_widget' ), 99, 1 ); + add_filter( 'widget_posts_args', array( &$this, 'exclude_resticted_posts_widget' ), 99, 1 ); //there is posts (Posts/Page/CPT) filtration if site is accessible //there also will be redirects if they need @@ -1049,7 +1051,7 @@ if ( ! class_exists( 'um\core\Access' ) ) { * * @return string */ - function exclude_navigation_posts( $where, $in_same_term, $excluded_terms, $taxonomy, $post ){ + function exclude_navigation_posts( $where, $in_same_term, $excluded_terms, $taxonomy, $post ) { $exclude_posts = $this->exclude_posts_array(); if ( ! empty( $exclude_posts ) ) { $exclude_string = implode(',', $exclude_posts); @@ -1060,6 +1062,40 @@ if ( ! class_exists( 'um\core\Access' ) ) { } + /** + * Exclude comments from restricted posts in widgets + * + * @param array $array + * + * @return array + */ + function exclude_comments_resticted_posts_widget( $array ) { + $exclude_posts = $this->exclude_posts_array(); + if ( ! empty( $exclude_posts ) ) { + $array['post__not_in'] = $exclude_posts; + } + + return $array; + } + + + /** + * Exclude restricted posts in widgets + * + * @param array $array + * + * @return array + */ + function exclude_resticted_posts_widget( $array ) { + $exclude_posts = $this->exclude_posts_array(); + if ( ! empty( $exclude_posts ) ) { + $array['post__not_in'] = $exclude_posts; + } + + return $array; + } + + /** * get array with restricted posts *