mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-14 04:06:36 +09:00
- hide restricted posts in widgets
- hide comments from restricted posts in widgets
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user