diff --git a/includes/collection/class-followers.php b/includes/collection/class-followers.php index 16a55a2..e73ee1b 100644 --- a/includes/collection/class-followers.php +++ b/includes/collection/class-followers.php @@ -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; } /** diff --git a/includes/table/class-followers.php b/includes/table/class-followers.php index b83403f..2bece58 100644 --- a/includes/table/class-followers.php +++ b/includes/table/class-followers.php @@ -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; } }