From 3c86e94d9a79603aac2b809fbc54cb677c87928a Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Fri, 21 Apr 2023 16:25:15 +0200 Subject: [PATCH] remove followers --- includes/collection/class-followers.php | 6 +++++- includes/table/class-followers.php | 15 ++++++++++++--- templates/followers-list.php | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/includes/collection/class-followers.php b/includes/collection/class-followers.php index e583b313..9848c5e0 100644 --- a/includes/collection/class-followers.php +++ b/includes/collection/class-followers.php @@ -199,6 +199,10 @@ class Followers { wp_set_object_terms( $user_id, $actor, self::TAXONOMY, true ); } + public static function remove_follower( $user_id, $actor ) { + wp_remove_object_terms( $user_id, $actor, self::TAXONOMY ); + } + /** * Undocumented function * @@ -225,7 +229,7 @@ class Followers { * @param int $user_id * @param int $number * @param int $offset - * @return array The Term list of followers + * @return array The Term list of Followers */ public static function get_followers( $user_id, $number = null, $offset = null ) { //self::migrate_followers( $user_id ); diff --git a/includes/table/class-followers.php b/includes/table/class-followers.php index bba32088..dbd26470 100644 --- a/includes/table/class-followers.php +++ b/includes/table/class-followers.php @@ -59,8 +59,7 @@ class Followers extends WP_List_Table { public function get_bulk_actions() { return array( - 'revoke' => __( 'Revoke', 'activitypub' ), - 'verify' => __( 'Verify', 'activitypub' ), + 'delete' => __( 'Delete', 'activitypub' ), ); } @@ -79,6 +78,16 @@ class Followers extends WP_List_Table { } public function column_cb( $item ) { - return sprintf( '', esc_attr( $item['identifier'] ) ); + return sprintf( '', esc_attr( $item['identifier'] ) ); + } + + public function process_action() { + $followers = isset( $_REQUEST['followers'] ) ? $_REQUEST['followers'] : array(); // phpcs:ignore + + switch ( $this->current_action() ) { + case 'delete': + FollowerCollection::remove_follower( \get_current_user_id(), $followers ); + break; + } } } diff --git a/templates/followers-list.php b/templates/followers-list.php index 261808f1..e76a45d6 100644 --- a/templates/followers-list.php +++ b/templates/followers-list.php @@ -7,7 +7,7 @@
- + prepare_items(); $token_table->display();