Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * BP Follow Widgets
- *
- * @package BP-Follow
- * @subpackage Widgets
- */
- // Exit if accessed directly
- if ( !defined( 'ABSPATH' ) ) exit;
- /**
- * Add a "Users I'm following" widget for the logged-in user
- *
- * @subpackage Widgets
- */
- class BP_Follow_Following_Widget extends WP_Widget {
- function bp_follow_following_widget() {
- parent::WP_Widget( false, $name = __( "BP Follow - Following", 'bp-follow' ) );
- }
- function widget( $args, $instance ) {
- extract( $args );
- if ( empty( $instance['max_users'] ) )
- $instance['max_users'] = 25;
- if ( !$following = bp_get_following_ids( $displayed_user->id ) )
- {
- do_action( 'bp_before_follower_widget' );
- echo $before_widget;
- echo $before_title
- . __( 'Following', 'bp-follow' )
- . $after_title; ?>
- <div class="avatar-block">
- <?php echo bp_get_displayed_user_fullname() . " " . __('is not following anyone yet.', 'bp-follow'); ?>
- </div>
- <?php echo $after_widget; ?>
- <?php do_action( 'bp_after_follower_widget' ); ?>
- <?php } ?>
- <?php
- if ( bp_has_members( 'include=' . $following . '&max=' . $instance['max_users'] ) ) {
- do_action( 'bp_before_following_widget' );
- echo $before_widget;
- echo $before_title
- . __( 'Following', 'bp-follow' )
- . $after_title; ?>
- <div class="avatar-block">
- <?php while ( bp_members() ) : bp_the_member(); ?>
- <div class="item-avatar">
- <a title="<?php bp_member_name() ?>" href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
- </div>
- <?php endwhile; ?>
- </div>
- <?php echo $after_widget; ?>
- <?php do_action( 'bp_after_following_widget' ); ?>
- <?php } ?>
- <?php
- }
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['max_users'] = strip_tags( $new_instance['max_users'] );
- return $instance;
- }
- function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array( 'max_users' => 25 ) );
- $max_users = strip_tags( $instance['max_users'] );
- ?>
- <p><label for="bp-follow-widget-users-max"><?php _e('Max users to show:', 'bp-follow'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_users' ); ?>" name="<?php echo $this->get_field_name( 'max_users' ); ?>" type="text" value="<?php echo attribute_escape( $max_users ); ?>" style="width: 30%" /></label></p>
- <?php
- }
- }
- add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Follow_Following_Widget");' ) );
- /**
- * Add a "Users following me" widget for the logged-in user
- *
- * @subpackage Widgets
- */
- class BP_Follow_Follower_Widget extends WP_Widget {
- function bp_follow_follower_widget() {
- parent::WP_Widget( false, $name = __( "BP Follow - Followers", 'bp-follow' ) );
- }
- function widget( $args, $instance ) {
- extract( $args );
- if ( empty( $instance['max_users'] ) )
- $instance['max_users'] = 25;
- if ( !$follower = bp_get_follower_ids( $displayed_user->id ) )
- {
- do_action( 'bp_before_follower_widget' );
- echo $before_widget;
- echo $before_title
- . __( 'Followers', 'bp-follow' )
- . $after_title; ?>
- <div class="avatar-block">
- <?php echo bp_get_displayed_user_fullname() . " " . __('has no followers yet.', 'bp-follow'); ?>
- </div>
- <?php echo $after_widget; ?>
- <?php do_action( 'bp_after_follower_widget' ); ?>
- <?php } ?>
- <?php
- if ( bp_has_members( 'include=' . $follower . '&max=' . $instance['max_users'] ) ) {
- do_action( 'bp_before_follower_widget' );
- echo $before_widget;
- echo $before_title
- . __( 'Followers', 'bp-follow' )
- . $after_title; ?>
- <div class="avatar-block">
- <?php while ( bp_members() ) : bp_the_member(); ?>
- <div class="item-avatar">
- <a title="<?php bp_member_name() ?>" href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a>
- </div>
- <?php endwhile; ?>
- </div>
- <?php echo $after_widget; ?>
- <?php do_action( 'bp_after_follower_widget' ); ?>
- <?php } ?>
- <?php
- }
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['max_users'] = strip_tags( $new_instance['max_users'] );
- return $instance;
- }
- function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array( 'max_users' => 25 ) );
- $max_users = strip_tags( $instance['max_users'] );
- ?>
- <p><label for="bp-follow-widget-users-max"><?php _e('Max users to show:', 'bp-follow'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_users' ); ?>" name="<?php echo $this->get_field_name( 'max_users' ); ?>" type="text" value="<?php echo attribute_escape( $max_users ); ?>" style="width: 30%" /></label></p>
- <?php
- }
- }
- add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Follow_Follower_Widget");' ) );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement