- github fixes code review;

This commit is contained in:
nikitasinelnikov
2019-03-12 18:21:21 +02:00
parent aea6e783bc
commit 243fa46fdc
11 changed files with 3889 additions and 986 deletions
+11 -11
View File
@@ -1008,57 +1008,57 @@ if ( ! class_exists( 'um\core\Access' ) ) {
/**
* Disable comments if user has not permission to access this post
*
* @param mixed $open
* @param int $count
* @param int $post_id
* @return boolean
*/
public function disable_comments_open_number( $open, $post_id ) {
public function disable_comments_open_number( $count, $post_id ) {
static $cache_number = array();
if ( isset( $cache_number[ $post_id ] ) ) {
return $cache_number[ $post_id ] ? $open : false;
return $cache_number[ $post_id ];
}
$post = get_post( $post_id );
$restriction = $this->get_post_privacy_settings( $post );
if ( ! $restriction ) {
$cache_number[ $post_id ] = $open;
return $open;
$cache_number[ $post_id ] = $count;
return $count;
}
if ( '1' == $restriction['_um_accessible'] ) {
if ( is_user_logged_in() ) {
if ( ! current_user_can( 'administrator' ) ) {
$open = false;
$count = 0;
}
}
} elseif ( '2' == $restriction['_um_accessible'] ) {
if ( ! is_user_logged_in() ) {
$open = false;
$count = 0;
} else {
if ( ! current_user_can( 'administrator' ) ) {
$custom_restrict = $this->um_custom_restriction( $restriction );
if ( empty( $restriction['_um_access_roles'] ) || false === array_search( '1', $restriction['_um_access_roles'] ) ) {
if ( ! $custom_restrict ) {
$open = false;
$count = 0;
}
} else {
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
if ( ! isset( $user_can ) || ! $user_can || ! $custom_restrict ) {
$open = false;
$count = 0;
}
}
}
}
}
$cache_number[ $post_id ] = $open;
return $open;
$cache_number[ $post_id ] = $count;
return $count;
}
+12 -4
View File
@@ -376,7 +376,6 @@ function um_prepare_user_query_args( $query_args, $args ) {
if ( isset( $sortby ) ) {
if ( $sortby == 'other' && $sortby_custom ) {
$query_args['meta_key'] = $sortby_custom;
@@ -448,9 +447,18 @@ add_filter( 'um_prepare_user_query_args', 'um_prepare_user_query_args', 10, 2 );
*/
function um_sortby_last_login( $query_args, $sortby ) {
if ( $sortby == 'last_login' ) {
$query_args['orderby'] = 'meta_value_num';
$query_args['order'] = 'desc';
$query_args['meta_key'] = '_um_last_login';
$query_args['orderby'] = array( 'um_last_login' => 'DESC' );
$query_args['meta_query']['um_last_login'] = array(
'relation' => 'OR',
array(
'key' => '_um_last_login',
'compare' => 'EXISTS',
),
array(
'key' => '_um_last_login',
'compare' => 'NOT EXISTS',
),
);
}
return $query_args;
}