bp_core_ajax_widget_friends

Process AJAX pagination or filtering for the Friends widget.

Description

bp_core_ajax_widget_friends(); 

Usage

  1. if ( !function_exists( 'bp_core_ajax_widget_friends' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-friends/bp-friends-widgets.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_core_ajax_widget_friends(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-friends/bp-friends-widgets.php  
  1. function bp_core_ajax_widget_friends() { 
  2.  
  3. check_ajax_referer( 'bp_core_widget_friends' ); 
  4.  
  5. switch ( $_POST['filter'] ) { 
  6. case 'newest-friends': 
  7. $type = 'newest'; 
  8. break; 
  9.  
  10. case 'recently-active-friends': 
  11. $type = 'active'; 
  12. break; 
  13.  
  14. case 'popular-friends': 
  15. $type = 'popular'; 
  16. break; 
  17.  
  18. $members_args = array( 
  19. 'user_id' => bp_displayed_user_id(),  
  20. 'type' => $type,  
  21. 'max' => absint( $_POST['max-friends'] ),  
  22. 'populate_extras' => 1,  
  23. ); 
  24.  
  25. if ( bp_has_members( $members_args ) ) : ?> 
  26. <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?> 
  27. <?php while ( bp_members() ) : bp_the_member(); ?> 
  28. <li class="vcard"> 
  29. <div class="item-avatar"> 
  30. <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a> 
  31. </div> 
  32.  
  33. <div class="item"> 
  34. <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a></div> 
  35. <?php if ( 'active' == $type ) : ?> 
  36. <div class="item-meta"><span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_last_active( array( 'relative' => false ) ) ); ?>"><?php bp_member_last_active(); ?></span></div> 
  37. <?php elseif ( 'newest' == $type ) : ?> 
  38. <div class="item-meta"><span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_registered( array( 'relative' => false ) ) ); ?>"><?php bp_member_registered(); ?></span></div> 
  39. <?php elseif ( bp_is_active( 'friends' ) ) : ?> 
  40. <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count(); ?></span></div> 
  41. <?php endif; ?> 
  42. </div> 
  43. </li> 
  44. <?php endwhile; ?> 
  45.  
  46. <?php else: ?> 
  47. <?php echo "-1[[SPLIT]]<li>"; ?> 
  48. <?php _e( 'There were no members found, please try another filter.', buddypress ); ?> 
  49. <?php echo "</li>"; ?> 
  50. <?php endif;