Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/05/2016 04:37:45 AM (8 years ago)
Author:
boonebgorges
Message:

Move bp-friends classes to their own files.

See #6870.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/classes/class-bp-friends-widget.php

    r10515 r10519  
    11<?php
    22/**
    3  * BuddyPress Widgets.
     3 * BuddyPress Friends Widget.
    44 *
    55 * @package BuddyPress
     
    1010// Exit if accessed directly.
    1111defined( 'ABSPATH' ) || exit;
    12 
    13 /**
    14  * Register the friends widget.
    15  *
    16  * @since 1.9.0
    17  */
    18 function bp_friends_register_widgets() {
    19     if ( ! bp_is_active( 'friends' ) ) {
    20         return;
    21     }
    22 
    23     // The Friends widget works only when looking an a displayed user,
    24     // and the concept of "displayed user" doesn't exist on non-root blogs,
    25     // so we don't register the widget there.
    26     if ( ! bp_is_root_blog() ) {
    27         return;
    28     }
    29 
    30     add_action( 'widgets_init', create_function( '', 'return register_widget("BP_Core_Friends_Widget");' ) );
    31 }
    32 add_action( 'bp_register_widgets', 'bp_friends_register_widgets' );
    33 
    34 /*** MEMBER FRIENDS WIDGET *****************/
    3512
    3613/**
     
    204181    }
    205182}
    206 
    207 /** Widget AJAX ***************************************************************/
    208 
    209 /**
    210  * Process AJAX pagination or filtering for the Friends widget.
    211  *
    212  * @since 1.9.0
    213  */
    214 function bp_core_ajax_widget_friends() {
    215 
    216     check_ajax_referer( 'bp_core_widget_friends' );
    217 
    218     switch ( $_POST['filter'] ) {
    219         case 'newest-friends':
    220             $type = 'newest';
    221             break;
    222 
    223         case 'recently-active-friends':
    224             $type = 'active';
    225             break;
    226 
    227         case 'popular-friends':
    228             $type = 'popular';
    229             break;
    230     }
    231 
    232     $members_args = array(
    233         'user_id'         => bp_displayed_user_id(),
    234         'type'            => $type,
    235         'max'             => absint( $_POST['max-friends'] ),
    236         'populate_extras' => 1,
    237     );
    238 
    239     if ( bp_has_members( $members_args ) ) : ?>
    240         <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?>
    241         <?php while ( bp_members() ) : bp_the_member(); ?>
    242             <li class="vcard">
    243                 <div class="item-avatar">
    244                     <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
    245                 </div>
    246 
    247                 <div class="item">
    248                     <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>" title="<?php bp_member_name(); ?>"><?php bp_member_name(); ?></a></div>
    249                     <?php if ( 'active' == $type ) : ?>
    250                         <div class="item-meta"><span class="activity"><?php bp_member_last_active(); ?></span></div>
    251                     <?php elseif ( 'newest' == $type ) : ?>
    252                         <div class="item-meta"><span class="activity"><?php bp_member_registered(); ?></span></div>
    253                     <?php elseif ( bp_is_active( 'friends' ) ) : ?>
    254                         <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count(); ?></span></div>
    255                     <?php endif; ?>
    256                 </div>
    257             </li>
    258         <?php endwhile; ?>
    259 
    260     <?php else: ?>
    261         <?php echo "-1[[SPLIT]]<li>"; ?>
    262         <?php _e( 'There were no members found, please try another filter.', 'buddypress' ); ?>
    263         <?php echo "</li>"; ?>
    264     <?php endif;
    265 }
    266 add_action( 'wp_ajax_widget_friends', 'bp_core_ajax_widget_friends' );
    267 add_action( 'wp_ajax_nopriv_widget_friends', 'bp_core_ajax_widget_friends' );
Note: See TracChangeset for help on using the changeset viewer.