[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Members Widgets. 4 * 5 * @package BuddyPress 6 * @subpackage MembersWidgets 7 * @since 2.2.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 /** 14 * Registers the Members Legacy Widget. 15 * 16 * @since 10.0.0 17 */ 18 function bp_members_register_members_widget() { 19 register_widget( 'BP_Core_Members_Widget' ); 20 } 21 22 /** 23 * Registers the "Who's online?" Legacy Widget. 24 * 25 * @since 10.0.0 26 */ 27 function bp_members_register_whos_online_widget() { 28 register_widget( 'BP_Core_Whos_Online_Widget' ); 29 } 30 31 /** 32 * Registers the "Recently Active" Legacy Widget. 33 * 34 * @since 10.0.0 35 */ 36 function bp_members_register_recently_active_widget() { 37 register_widget( 'BP_Core_Recently_Active_Widget' ); 38 } 39 40 /** 41 * Register bp-members widgets. 42 * 43 * Previously, these widgets were registered in bp-core. 44 * 45 * @since 2.2.0 46 */ 47 function bp_members_register_widgets() { 48 add_action( 'widgets_init', 'bp_members_register_members_widget' ); 49 add_action( 'widgets_init', 'bp_members_register_whos_online_widget' ); 50 add_action( 'widgets_init', 'bp_members_register_recently_active_widget' ); 51 } 52 add_action( 'bp_register_widgets', 'bp_members_register_widgets' ); 53 54 /** 55 * AJAX request handler for Members widgets. 56 * 57 * @since 1.0.0 58 * 59 * @see BP_Core_Members_Widget 60 */ 61 function bp_core_ajax_widget_members() { 62 63 check_ajax_referer( 'bp_core_widget_members' ); 64 65 // Setup some variables to check. 66 $filter = ! empty( $_POST['filter'] ) ? $_POST['filter'] : 'recently-active-members'; 67 $max_members = ! empty( $_POST['max-members'] ) ? absint( $_POST['max-members'] ) : 5; 68 69 // Determine the type of members query to perform. 70 switch ( $filter ) { 71 72 // Newest activated. 73 case 'newest-members' : 74 $type = 'newest'; 75 break; 76 77 // Popular by friends. 78 case 'popular-members' : 79 if ( bp_is_active( 'friends' ) ) { 80 $type = 'popular'; 81 } else { 82 $type = 'active'; 83 } 84 break; 85 86 // Default. 87 case 'recently-active-members' : 88 default : 89 $type = 'active'; 90 break; 91 } 92 93 // Setup args for querying members. 94 $members_args = array( 95 'user_id' => 0, 96 'type' => $type, 97 'per_page' => $max_members, 98 'max' => $max_members, 99 'populate_extras' => true, 100 'search_terms' => false, 101 ); 102 103 // Query for members. 104 if ( bp_has_members( $members_args ) ) : ?> 105 <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?> 106 <?php while ( bp_members() ) : bp_the_member(); ?> 107 <li class="vcard"> 108 <div class="item-avatar"> 109 <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> 110 </div> 111 112 <div class="item"> 113 <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a></div> 114 <?php if ( 'active' === $type ) : ?> 115 <div class="item-meta"><span class="activity"><?php bp_member_last_active(); ?></span></div> 116 <?php elseif ( 'newest' === $type ) : ?> 117 <div class="item-meta"><span class="activity"><?php bp_member_registered(); ?></span></div> 118 <?php elseif ( bp_is_active( 'friends' ) ) : ?> 119 <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count(); ?></span></div> 120 <?php endif; ?> 121 </div> 122 </li> 123 124 <?php endwhile; ?> 125 126 <?php else: ?> 127 <?php echo "-1[[SPLIT]]<li>"; ?> 128 <?php esc_html_e( 'There were no members found, please try another filter.', 'buddypress' ) ?> 129 <?php echo "</li>"; ?> 130 <?php endif; 131 } 132 add_action( 'wp_ajax_widget_members', 'bp_core_ajax_widget_members' ); 133 add_action( 'wp_ajax_nopriv_widget_members', 'bp_core_ajax_widget_members' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |