Fix follower list

This commit is contained in:
Matthias Pfefferle 2023-06-16 16:56:30 +02:00
parent daf7acb1b0
commit 28922d51dd
2 changed files with 20 additions and 4 deletions

View file

@ -368,9 +368,20 @@ class Followers {
* @return int The number of Followers
*/
public static function count_followers( $user_id ) {
// todo: rethink this. Don't we already get a total_posts count out of WP_Query?
// in the absence of that: caching.
return count( self::get_followers( $user_id ) );
$query = new WP_Query(
array(
'post_type' => self::POST_TYPE,
'fields' => 'ids',
'meta_query' => array(
array(
'key' => 'user_id',
'value' => $user_id,
),
),
)
);
return $query->found_posts;
}
/**

View file

@ -112,7 +112,12 @@ class Followers extends WP_List_Table {
switch ( $this->current_action() ) {
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;
}
}