mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- changed a hook for hide restricted post's comments
This commit is contained in:
@@ -52,9 +52,9 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
$this->allow_access = false;
|
||||
|
||||
add_filter( 'pre_get_posts', array( &$this, 'exclude_posts' ), 99, 1 );
|
||||
add_filter( 'pre_get_comments', array( &$this, 'exclude_posts_comments' ), 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
|
||||
@@ -1040,6 +1040,20 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exclude comments from restricted posts in widgets
|
||||
*
|
||||
* @param \WP_Comment_Query $query
|
||||
*
|
||||
*/
|
||||
function exclude_posts_comments( $query ){
|
||||
$exclude_posts = $this->exclude_posts_array();
|
||||
if ( ! empty( $exclude_posts ) ) {
|
||||
$query->query_vars['post__not_in'] = $exclude_posts;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Exclude posts from next, previous navigation
|
||||
*
|
||||
@@ -1062,23 +1076,6 @@ 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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user