function widget($args, $instance) { global $bp; extract( $args ); echo $before_widget; echo $before_title . $widget_name . $after_title; ?> <?php if ( bp_has_members( 'user_id=0&type=newest&max=' . $instance['max_members'] . '&populate_extras=0' ) ) : ?> <div class="item-options" id="members-list-options"> <span class="ajax-loader" id="ajax-loader-members"></span> <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> | <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> <?php if ( bp_is_active( 'friends' ) ) : ?> | <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a> <?php endif; ?> </div> <ul id="members-list" class="item-list"> <?php while ( bp_members() ) : bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink() ?>"><?php bp_member_avatar() ?></a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name() ?>"><?php bp_member_name() ?></a></div> <div class="item-meta"><span class="activity"><?php bp_member_registered() ?></span></div> </div> </li> <?php endwhile; ?> </ul> <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?> <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr( $instance['max_members'] ); ?>" /> <?php else: ?> <div class="widget-error"> <?php _e('No one has signed up yet!', 'buddypress') ?> </div> <?php endif; ?> <?php echo $after_widget; ?> <?php }
/** * Process AJAX pagination or filtering for the Friends widget. * * @since 1.9.0 */ function bp_core_ajax_widget_friends() { check_ajax_referer('bp_core_widget_friends'); switch ($_POST['filter']) { case 'newest-friends': $type = 'newest'; break; case 'recently-active-friends': $type = 'active'; break; case 'popular-friends': $type = 'popular'; break; } $members_args = array('user_id' => bp_displayed_user_id(), 'type' => $type, 'max' => absint($_POST['max-friends']), 'populate_extras' => 1); if (bp_has_members($members_args)) { ?> <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?> <?php while (bp_members()) { bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?> "><?php bp_member_avatar(); ?> </a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_name(); ?> </a></div> <?php if ('active' == $type) { ?> <div class="item-meta"><span class="activity"><?php bp_member_last_active(); ?> </span></div> <?php } elseif ('newest' == $type) { ?> <div class="item-meta"><span class="activity"><?php bp_member_registered(); ?> </span></div> <?php } elseif (bp_is_active('friends')) { ?> <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count(); ?> </span></div> <?php } ?> </div> </li> <?php } ?> <?php } else { ?> <?php echo "-1[[SPLIT]]<li>"; ?> <?php _e('There were no members found, please try another filter.', 'buddypress'); ?> <?php echo "</li>"; ?> <?php } }
/** * Display the widget. * * @param array $args Widget arguments. * @param array $instance The widget settings, as saved by the user. */ function widget($args, $instance) { extract($args); if (!bp_displayed_user_id()) { return; } $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script('bp_core_widget_friends-js', buddypress()->plugin_url . "bp-friends/js/widget-friends{$min}.js", array('jquery'), bp_get_version()); $user_id = bp_displayed_user_id(); $link = trailingslashit(bp_displayed_user_domain() . bp_get_friends_slug()); $instance['title'] = sprintf(__('%s’s Friends', 'buddypress'), bp_get_displayed_user_fullname()); if (empty($instance['friend_default'])) { $instance['friend_default'] = 'active'; } $title = apply_filters('widget_title', $instance['title']); echo $before_widget; $title = $instance['link_title'] ? '<a href="' . esc_url($link) . '">' . esc_html($title) . '</a>' : esc_html($title); echo $before_title . $title . $after_title; $members_args = array('user_id' => absint($user_id), 'type' => sanitize_text_field($instance['friend_default']), 'max' => absint($instance['max_friends']), 'populate_extras' => 1); ?> <?php if (bp_has_members($members_args)) { ?> <div class="item-options" id="friends-list-options"> <a href="<?php bp_members_directory_permalink(); ?> " id="newest-friends" <?php if ($instance['friend_default'] == 'newest') { ?> class="selected"<?php } ?> ><?php _e('Newest', 'buddypress'); ?> </a> | <a href="<?php bp_members_directory_permalink(); ?> " id="recently-active-friends" <?php if ($instance['friend_default'] == 'active') { ?> class="selected"<?php } ?> ><?php _e('Active', 'buddypress'); ?> </a> | <a href="<?php bp_members_directory_permalink(); ?> " id="popular-friends" <?php if ($instance['friend_default'] == 'popular') { ?> class="selected"<?php } ?> ><?php _e('Popular', 'buddypress'); ?> </a> </div> <ul id="friends-list" class="item-list"> <?php while (bp_members()) { bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_avatar(); ?> </a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_name(); ?> </a></div> <div class="item-meta"> <span class="activity"> <?php if ('newest' == $instance['friend_default']) { bp_member_registered(); } if ('active' == $instance['friend_default']) { bp_member_last_active(); } if ('popular' == $instance['friend_default']) { bp_member_total_friend_count(); } ?> </span> </div> </div> </li> <?php } ?> </ul> <?php wp_nonce_field('bp_core_widget_friends', '_wpnonce-friends'); ?> <input type="hidden" name="friends_widget_max" id="friends_widget_max" value="<?php echo absint($instance['max_friends']); ?> " /> <?php } else { ?> <div class="widget-error"> <?php _e('Sorry, no members were found.', 'buddypress'); ?> </div> <?php } ?> <?php echo $after_widget; ?> <?php }
/** * Display the Members widget. * * @see WP_Widget::widget() for description of parameters. * * @param array $args Widget arguments. * @param array $instance Widget settings, as saved by the user. */ function widget($args, $instance) { extract($args); if (!$instance['member_default']) { $instance['member_default'] = 'active'; } $title = apply_filters('widget_title', $instance['title']); echo $before_widget; $title = $instance['link_title'] ? '<a href="' . trailingslashit(bp_get_root_domain() . '/' . bp_get_members_root_slug()) . '">' . $title . '</a>' : $title; echo $before_title . $title . $after_title; $members_args = array('user_id' => 0, 'type' => $instance['member_default'], 'per_page' => $instance['max_members'], 'max' => $instance['max_members'], 'populate_extras' => true, 'search_terms' => false); ?> <?php if (bp_has_members($members_args)) { ?> <div class="item-options" id="members-list-options"> <a href="<?php bp_members_directory_permalink(); ?> " id="newest-members" <?php if ($instance['member_default'] == 'newest') { ?> class="selected"<?php } ?> ><?php _e('Newest', 'buddypress'); ?> </a> | <a href="<?php bp_members_directory_permalink(); ?> " id="recently-active-members" <?php if ($instance['member_default'] == 'active') { ?> class="selected"<?php } ?> ><?php _e('Active', 'buddypress'); ?> </a> <?php if (bp_is_active('friends')) { ?> | <a href="<?php bp_members_directory_permalink(); ?> " id="popular-members" <?php if ($instance['member_default'] == 'popular') { ?> class="selected"<?php } ?> ><?php _e('Popular', 'buddypress'); ?> </a> <?php } ?> </div> <ul id="members-list" class="item-list"> <?php while (bp_members()) { bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_avatar(); ?> </a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_name(); ?> </a></div> <div class="item-meta"> <span class="activity"> <?php if ('newest' == $instance['member_default']) { bp_member_registered(); } if ('active' == $instance['member_default']) { bp_member_last_active(); } if ('popular' == $instance['member_default']) { bp_member_total_friend_count(); } ?> </span> </div> </div> </li> <?php } ?> </ul> <?php wp_nonce_field('bp_core_widget_members', '_wpnonce-members'); ?> <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr($instance['max_members']); ?> " /> <?php } else { ?> <div class="widget-error"> <?php _e('No one has signed up yet!', 'buddypress'); ?> </div> <?php } ?> <?php echo $after_widget; ?> <?php }
/** * Display the Members widget. * * @since 1.0.3 * * @see WP_Widget::widget() for description of parameters. * * @param array $args Widget arguments. * @param array $instance Widget settings, as saved by the user. */ public function widget($args, $instance) { global $members_template; // Get widget settings. $settings = $this->parse_settings($instance); /** * Filters the title of the Members widget. * * @since 1.8.0 * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter. * * @param string $title The widget title. * @param array $settings The settings for the particular instance of the widget. * @param string $id_base Root ID for all widgets of this type. */ $title = apply_filters('widget_title', $settings['title'], $settings, $this->id_base); $title = $settings['link_title'] ? '<a href="' . bp_get_members_directory_permalink() . '">' . $title . '</a>' : $title; /** * Filters the separator of the member widget links. * * @since 2.4.0 * * @param string $separator Separator string. Default '|'. */ $separator = apply_filters('bp_members_widget_separator', '|'); // Output before widget HTMl, title (and maybe content before & after it). echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title']; // Setup args for querying members. $members_args = array('user_id' => 0, 'type' => $settings['member_default'], 'per_page' => $settings['max_members'], 'max' => $settings['max_members'], 'populate_extras' => true, 'search_terms' => false); // Back up the global. $old_members_template = $members_template; ?> <?php if (bp_has_members($members_args)) { ?> <div class="item-options" id="members-list-options"> <a href="<?php bp_members_directory_permalink(); ?> " id="newest-members" <?php if ('newest' === $settings['member_default']) { ?> class="selected"<?php } ?> ><?php esc_html_e('Newest', 'buddypress'); ?> </a> <span class="bp-separator" role="separator"><?php echo esc_html($separator); ?> </span> <a href="<?php bp_members_directory_permalink(); ?> " id="recently-active-members" <?php if ('active' === $settings['member_default']) { ?> class="selected"<?php } ?> ><?php esc_html_e('Active', 'buddypress'); ?> </a> <?php if (bp_is_active('friends')) { ?> <span class="bp-separator" role="separator"><?php echo esc_html($separator); ?> </span> <a href="<?php bp_members_directory_permalink(); ?> " id="popular-members" <?php if ('popular' === $settings['member_default']) { ?> class="selected"<?php } ?> ><?php esc_html_e('Popular', 'buddypress'); ?> </a> <?php } ?> </div> <ul id="members-list" class="item-list" aria-live="polite" aria-relevant="all" aria-atomic="true"> <?php while (bp_members()) { bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_avatar(); ?> </a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_name(); ?> </a></div> <div class="item-meta"> <?php if ('newest' == $settings['member_default']) { ?> <span class="activity" data-livestamp="<?php bp_core_iso8601_date(bp_get_member_registered(array('relative' => false))); ?> "><?php bp_member_registered(); ?> </span> <?php } elseif ('active' == $settings['member_default']) { ?> <span class="activity" data-livestamp="<?php bp_core_iso8601_date(bp_get_member_last_active(array('relative' => false))); ?> "><?php bp_member_last_active(); ?> </span> <?php } else { ?> <span class="activity"><?php bp_member_total_friend_count(); ?> </span> <?php } ?> </div> </div> </li> <?php } ?> </ul> <?php wp_nonce_field('bp_core_widget_members', '_wpnonce-members', false); ?> <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr($settings['max_members']); ?> " /> <?php } else { ?> <div class="widget-error"> <?php esc_html_e('No one has signed up yet!', 'buddypress'); ?> </div> <?php } ?> <?php echo $args['after_widget']; // Restore the global. $members_template = $old_members_template; }
/** * AJAX request handler for Members widgets. * * @since 1.0.0 * * @see BP_Core_Members_Widget */ function bp_core_ajax_widget_members() { check_ajax_referer('bp_core_widget_members'); // Setup some variables to check. $filter = !empty($_POST['filter']) ? $_POST['filter'] : 'recently-active-members'; $max_members = !empty($_POST['max-members']) ? absint($_POST['max-members']) : 5; // Determine the type of members query to perform. switch ($filter) { // Newest activated. case 'newest-members': $type = 'newest'; break; // Popular by friends. // Popular by friends. case 'popular-members': if (bp_is_active('friends')) { $type = 'popular'; } else { $type = 'active'; } break; // Default. // Default. case 'recently-active-members': default: $type = 'active'; break; } // Setup args for querying members. $members_args = array('user_id' => 0, 'type' => $type, 'per_page' => $max_members, 'max' => $max_members, 'populate_extras' => true, 'search_terms' => false); // Query for members. if (bp_has_members($members_args)) { ?> <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?> <?php while (bp_members()) { bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?> "><?php bp_member_avatar(); ?> </a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_name(); ?> </a></div> <?php if ('active' === $type) { ?> <div class="item-meta"><span class="activity"><?php bp_member_last_active(); ?> </span></div> <?php } elseif ('newest' === $type) { ?> <div class="item-meta"><span class="activity"><?php bp_member_registered(); ?> </span></div> <?php } elseif (bp_is_active('friends')) { ?> <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count(); ?> </span></div> <?php } ?> </div> </li> <?php } ?> <?php } else { ?> <?php echo "-1[[SPLIT]]<li>"; ?> <?php esc_html_e('There were no members found, please try another filter.', 'buddypress'); ?> <?php echo "</li>"; ?> <?php } }
/** * Display the widget. * * @since 1.9.0 * * @param array $args Widget arguments. * @param array $instance The widget settings, as saved by the user. */ function widget($args, $instance) { global $members_template; extract($args); if (!bp_displayed_user_id()) { return; } $user_id = bp_displayed_user_id(); $link = trailingslashit(bp_displayed_user_domain() . bp_get_friends_slug()); $instance['title'] = sprintf(__("%s's Friends", 'buddypress'), bp_get_displayed_user_fullname()); if (empty($instance['friend_default'])) { $instance['friend_default'] = 'active'; } /** * Filters the Friends widget title. * * @since 1.8.0 * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter. * * @param string $title The widget title. * @param array $instance The settings for the particular instance of the widget. * @param string $id_base Root ID for all widgets of this type. */ $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); echo $before_widget; $title = $instance['link_title'] ? '<a href="' . esc_url($link) . '">' . esc_html($title) . '</a>' : esc_html($title); echo $before_title . $title . $after_title; $members_args = array('user_id' => absint($user_id), 'type' => sanitize_text_field($instance['friend_default']), 'max' => absint($instance['max_friends']), 'populate_extras' => 1); // Back up the global. $old_members_template = $members_template; ?> <?php if (bp_has_members($members_args)) { ?> <div class="item-options" id="friends-list-options"> <a href="<?php bp_members_directory_permalink(); ?> " id="newest-friends" <?php if ($instance['friend_default'] == 'newest') { ?> class="selected"<?php } ?> ><?php _e('Newest', 'buddypress'); ?> </a> | <a href="<?php bp_members_directory_permalink(); ?> " id="recently-active-friends" <?php if ($instance['friend_default'] == 'active') { ?> class="selected"<?php } ?> ><?php _e('Active', 'buddypress'); ?> </a> | <a href="<?php bp_members_directory_permalink(); ?> " id="popular-friends" <?php if ($instance['friend_default'] == 'popular') { ?> class="selected"<?php } ?> ><?php _e('Popular', 'buddypress'); ?> </a> </div> <ul id="friends-list" class="item-list"> <?php while (bp_members()) { bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_avatar(); ?> </a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_name(); ?> </a></div> <div class="item-meta"> <?php if ('newest' == $instance['friend_default']) { ?> <span class="activity" data-livestamp="<?php bp_core_iso8601_date(bp_get_member_registered(array('relative' => false))); ?> "><?php bp_member_registered(); ?> </span> <?php } elseif ('active' == $instance['friend_default']) { ?> <span class="activity" data-livestamp="<?php bp_core_iso8601_date(bp_get_member_last_active(array('relative' => false))); ?> "><?php bp_member_last_active(); ?> </span> <?php } else { ?> <span class="activity"><?php bp_member_total_friend_count(); ?> </span> <?php } ?> </div> </div> </li> <?php } ?> </ul> <?php wp_nonce_field('bp_core_widget_friends', '_wpnonce-friends'); ?> <input type="hidden" name="friends_widget_max" id="friends_widget_max" value="<?php echo absint($instance['max_friends']); ?> " /> <?php } else { ?> <div class="widget-error"> <?php _e('Sorry, no members were found.', 'buddypress'); ?> </div> <?php } ?> <?php echo $after_widget; // Restore the global. $members_template = $old_members_template; }
function widget($args, $instance) { global $bp; extract($args); if (!$instance['member_default']) { $instance['member_default'] = 'active'; } echo $before_widget; echo $before_title . $instance['title'] . $after_title; ?> <?php if (bp_has_members('user_id=0&type=' . $instance['member_default'] . '&max=' . $instance['max_members'] . '&populate_extras=0')) { ?> <div class="item-options" id="members-list-options"> <a href="<?php echo site_url(bp_get_members_root_slug()); ?> " id="newest-members" <?php if ($instance['member_default'] == 'newest') { ?> class="selected"<?php } ?> ><?php _e('Newest', 'buddypress'); ?> </a> | <a href="<?php echo site_url(bp_get_members_root_slug()); ?> " id="recently-active-members" <?php if ($instance['member_default'] == 'active') { ?> class="selected"<?php } ?> ><?php _e('Active', 'buddypress'); ?> </a> <?php if (bp_is_active('friends')) { ?> | <a href="<?php echo site_url(bp_get_members_root_slug()); ?> " id="popular-members" <?php if ($instance['member_default'] == 'popular') { ?> class="selected"<?php } ?> ><?php _e('Popular', 'buddypress'); ?> </a> <?php } ?> </div> <ul id="members-list" class="item-list"> <?php while (bp_members()) { bp_the_member(); ?> <li class="vcard"> <div class="item-avatar"> <a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_avatar(); ?> </a> </div> <div class="item"> <div class="item-title fn"><a href="<?php bp_member_permalink(); ?> " title="<?php bp_member_name(); ?> "><?php bp_member_name(); ?> </a></div> <div class="item-meta"> <span class="activity"> <?php if ('newest' == $instance['member_default']) { bp_member_registered(); } if ('active' == $instance['member_default']) { bp_member_last_active(); } if ('popular' == $instance['member_default']) { bp_member_total_friend_count(); } ?> </span> </div> </div> </li> <?php } ?> </ul> <?php nxt_nonce_field('bp_core_widget_members', '_nxtnonce-members'); ?> <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr($instance['max_members']); ?> " /> <?php } else { ?> <div class="widget-error"> <?php _e('No one has signed up yet!', 'buddypress'); ?> </div> <?php } ?> <?php echo $after_widget; ?> <?php }