wordpress-activitypub/includes/class-db-activitypub-followers.php

35 lines
854 B
PHP
Raw Normal View History

2018-12-07 23:02:18 +00:00
<?php
2018-12-09 21:20:30 +00:00
class Db_Activitypub_Followers {
2018-12-07 23:02:18 +00:00
public static function get_followers( $author_id ) {
return get_user_option( 'activitypub_followers', $author_id );
2018-12-07 23:02:18 +00:00
}
public static function add_follower( $actor, $author_id ) {
$followers = get_user_option( 'activitypub_followers', $author_id );
if ( ! is_array( $followers ) ) {
$followers = array( $actor );
} else {
$followers[] = $actor;
}
$followers = array_unique( $followers );
update_user_meta( $author_id, 'activitypub_followers', $followers );
}
public static function remove_follower( $actor, $author_id ) {
$followers = get_user_option( 'activitypub_followers', $author_id );
foreach ( $followers as $key => $value ) {
if ( $value === $actor) {
unset( $followers[$key] );
}
}
update_user_meta( $author_id, 'activitypub_followers', $followers );
}
}