Fix follower list
This commit is contained in:
parent
daf7acb1b0
commit
28922d51dd
2 changed files with 20 additions and 4 deletions
|
@ -368,9 +368,20 @@ class Followers {
|
||||||
* @return int The number of Followers
|
* @return int The number of Followers
|
||||||
*/
|
*/
|
||||||
public static function count_followers( $user_id ) {
|
public static function count_followers( $user_id ) {
|
||||||
// todo: rethink this. Don't we already get a total_posts count out of WP_Query?
|
$query = new WP_Query(
|
||||||
// in the absence of that: caching.
|
array(
|
||||||
return count( self::get_followers( $user_id ) );
|
'post_type' => self::POST_TYPE,
|
||||||
|
'fields' => 'ids',
|
||||||
|
'meta_query' => array(
|
||||||
|
array(
|
||||||
|
'key' => 'user_id',
|
||||||
|
'value' => $user_id,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $query->found_posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -112,7 +112,12 @@ class Followers extends WP_List_Table {
|
||||||
|
|
||||||
switch ( $this->current_action() ) {
|
switch ( $this->current_action() ) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
FollowerCollection::remove_follower( \get_current_user_id(), $followers );
|
if ( ! is_array( $followers ) ) {
|
||||||
|
$followers = array( $followers );
|
||||||
|
}
|
||||||
|
foreach ( $followers as $follower ) {
|
||||||
|
FollowerCollection::remove_follower( \get_current_user_id(), $follower );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue