__( 'Shows a list of your friends.', 'friends' ), ) ); } /** * Render the widget. * * @param array $args Sidebar arguments. * @param array $instance Widget instance settings. */ public function widget( $args, $instance ) { $instance = wp_parse_args( $instance, $this->defaults() ); echo $args['before_widget']; $all_friends = User_Query::all_friends(); $friend_requests = User_Query::all_friend_requests(); $subscriptions = User_Query::all_subscriptions(); // translators: %s is the number of your friends. $friends_title = sprintf( _n( '%s Friend', '%s Friends', $all_friends->get_total(), 'friends' ), '' . $all_friends->get_total() . '' ); if ( $all_friends->get_total() > 0 || ( ! $friend_requests->get_total() && ! $subscriptions->get_total() ) ) { $this->list_friends( $args, $friends_title, $all_friends ); if ( ! $all_friends->get_total() ) { ?> get_total() > 0 ) { $this->list_friends( $args, // translators: %1$s is the string "%s Friend", %2$s is a URL, %3$s is the number of open friend requests. sprintf( _n( '%1$s (%3$s request)', '%1$s (%3$s requests)', $friend_requests->get_total(), 'friends' ), $friends_title, '"' . esc_attr( self_admin_url( 'users.php?role=friend_request' ) ) . '" class="open-requests"', '' . $friend_requests->get_total() . '' ), $friend_requests ); } if ( 0 !== $subscriptions->get_total() ) { $this->list_friends( $args, sprintf( // translators: %s is the number of subscriptions. _n( '%s Subscription', '%s Subscriptions', $subscriptions->get_total(), 'friends' ), '' . $subscriptions->get_total() . '' ), $subscriptions ); } do_action( 'friends_widget_friend_list_after', $this, $args ); echo $args['after_widget']; } }