remove followers

This commit is contained in:
Matthias Pfefferle 2023-04-21 16:25:15 +02:00
parent 32194c31df
commit 3c86e94d9a
3 changed files with 18 additions and 5 deletions

View file

@ -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 );

View file

@ -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( '<input type="checkbox" name="tokens[]" value="%s" />', esc_attr( $item['identifier'] ) );
return sprintf( '<input type="checkbox" name="followers[]" value="%s" />', 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;
}
}
}

View file

@ -7,7 +7,7 @@
<?php $token_table = new \Activitypub\Table\Followers(); ?>
<form method="get">
<input type="hidden" name="page" value="indieauth_user_token" />
<input type="hidden" name="page" value="activitypub-followers-list" />
<?php
$token_table->prepare_items();
$token_table->display();