',
esc_html__( 'Following', 'feature-request-system' ),
esc_attr( Subscriptions::META_AUTO_FOLLOW ),
checked( Subscriptions::wants_automatic( $user->ID ), true, false ),
$own
? esc_html__( 'Follow the requests I vote for or suggest', 'feature-request-system' )
: esc_html__( 'Follow the requests this user votes for or suggests', 'feature-request-system' ),
esc_html__( 'A follower of a request gets an email when its status changes.', 'feature-request-system' )
);
}
echo '
';
}
/**
* Saves the section, when the profile form was submitted by someone who may edit the user.
*
* @param int $user_id User whose profile is saved.
*/
public static function save( int $user_id ): void {
if ( ! current_user_can( 'edit_user', $user_id ) || ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'update-user_' . $user_id ) ) {
return;
}
// The choice is only on the form while the site emails followers.
if ( isset( $_POST[ Subscriptions::META_AUTO_FOLLOW ] ) ) {
Subscriptions::set_automatic( $user_id, '1' === $_POST[ Subscriptions::META_AUTO_FOLLOW ] );
}
$unfollow = isset( $_POST[ self::FIELD_UNFOLLOW ] ) && is_array( $_POST[ self::FIELD_UNFOLLOW ] ) ? array_map( 'absint', $_POST[ self::FIELD_UNFOLLOW ] ) : [];
foreach ( $unfollow as $request_id ) {
SubscriptionRepository::remove( $request_id, $user_id );
}
}
/**
* Prints the requests a user follows, each with a box to stop following it.
*
* @param array> $subscriptions The user's newest subscriptions.
* @param int $total How many requests the user follows.
*/
private static function render_list( array $subscriptions, int $total ): void {
if ( ! $subscriptions ) {
echo '