Skip to:
Content

BuddyPress.org

Changeset 3778


Ignore:
Timestamp:
01/21/2011 12:03:25 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Move more user functions out of core component and into user component. Fixes to loaders. More code clean-up.

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-loader.php

    r3764 r3778  
    4444        $this->table_name      = $bp->table_prefix . 'bp_activity';
    4545        $this->table_name_meta = $bp->table_prefix . 'bp_activity_meta';
     46       
     47        // Register this in the active components array
     48        $bp->active_components[$this->id] = $this->id;
     49
     50        // The default text for the blogs directory search box
     51        $bp->default_search_strings[$this->id] = __( 'Search Activity...', 'buddypress' );     
    4652    }
    4753
     
    6975        bp_core_new_nav_item( array(
    7076            'name'                => __( 'Activity', 'buddypress' ),
    71             'slug'                => $bp->activity->slug,
     77            'slug'                => $this->slug,
    7278            'position'            => 10,
    7379            'screen_function'     => 'bp_activity_screen_my_activity',
    7480            'default_subnav_slug' => 'just-me',
    75             'item_css_id'         => $bp->activity->id )
     81            'item_css_id'         => $this->id )
    7682        );
    7783
     
    8389        $user_domain   = ( isset( $bp->displayed_user->domain ) )               ? $bp->displayed_user->domain               : $bp->loggedin_user->domain;
    8490        $user_login    = ( isset( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
    85         $activity_link = $user_domain . $bp->activity->slug . '/';
     91        $activity_link = $user_domain . $this->slug . '/';
    8692
    8793        // Add the subnav items to the activity nav item if we are using a theme that supports this
     
    9096            'slug'            => 'just-me',
    9197            'parent_url'      => $activity_link,
    92             'parent_slug'     => $bp->activity->slug,
     98            'parent_slug'     => $this->slug,
    9399            'screen_function' => 'bp_activity_screen_my_activity',
    94100            'position'        => 10
     
    101107                'slug'            => BP_FRIENDS_SLUG,
    102108                'parent_url'      => $activity_link,
    103                 'parent_slug'     => $bp->activity->slug,
     109                'parent_slug'     => $this->slug,
    104110                'screen_function' => 'bp_activity_screen_friends',
    105111                'position'        => 20,
     
    114120                'slug'            => BP_GROUPS_SLUG,
    115121                'parent_url'      => $activity_link,
    116                 'parent_slug'     => $bp->activity->slug,
     122                'parent_slug'     => $this->slug,
    117123                'screen_function' => 'bp_activity_screen_groups',
    118124                'position'        => 30,
     
    126132            'slug'            => 'favorites',
    127133            'parent_url'      => $activity_link,
    128             'parent_slug'     => $bp->activity->slug,
     134            'parent_slug'     => $this->slug,
    129135            'screen_function' => 'bp_activity_screen_favorites',
    130136            'position'        => 40,
     
    137143            'slug'            => 'mentions',
    138144            'parent_url'      => $activity_link,
    139             'parent_slug'     => $bp->activity->slug,
     145            'parent_slug'     => $this->slug,
    140146            'screen_function' => 'bp_activity_screen_mentions',
    141147            'position'        => 50,
  • trunk/bp-activity/bp-activity-template.php

    r3755 r3778  
    218218     * pass their parameters directly to the loop.
    219219     */
    220     $user_id = false;
    221     $include = false;
    222     $exclude = false;
    223     $in = false;
     220    $user_id     = false;
     221    $include     = false;
     222    $exclude     = false;
     223    $in          = false;
    224224    $show_hidden = false;
    225     $object = false;
    226     $primary_id = false;
     225    $object      = false;
     226    $primary_id  = false;
    227227
    228228    // User filtering
     
    309309                        $primary_id = implode( ',', (array)$groups['groups'] );
    310310
    311                         $user_id = false;
     311                        $user_id = 0;
    312312                    }
    313313                    break;
     
    324324                    $search_terms = '@' . bp_core_get_username( $user_id, $user_nicename, $user_login ) . '<'; // Start search at @ symbol and stop search at closing tag delimiter.
    325325                    $display_comments = 'stream';
    326                     $user_id = false;
     326                    $user_id = 0;
    327327                    break;
    328328            }
     
    330330    }
    331331
    332     if ( $max ) {
    333         if ( $per_page > $max )
    334             $per_page = $max;
    335     }
     332    // Do not exceed the maximum per page
     333    if ( !empty( $max ) && ( (int)$per_page > (int)$max ) )
     334        $per_page = $max;
    336335
    337336    // Support for basic filters in earlier BP versions.
     
    365364
    366365        $start_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
    367         $from_num = bp_core_number_format( $start_num );
    368         $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
    369         $total = bp_core_number_format( $activities_template->total_activity_count );
     366        $from_num  = bp_core_number_format( $start_num );
     367        $to_num    = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
     368        $total     = bp_core_number_format( $activities_template->total_activity_count );
    370369
    371370        return sprintf( __( 'Viewing item %1$s to %2$s (of %3$s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' &nbsp; <span class="ajax-loader"></span>';
     
    393392   
    394393    $remaining_pages = floor( ( $activities_template->total_activity_count - 1 ) / ( $activities_template->pag_num * $activities_template->pag_page ) );
    395    
    396     $has_more_items = (int)$remaining_pages ? true : false;
     394    $has_more_items  = (int)$remaining_pages ? true : false;
    397395   
    398396    return apply_filters( 'bp_activity_has_more_items', $has_more_items );
     
    646644
    647645        $action = $activities_template->activity->action;
    648 
    649646        $action = apply_filters( 'bp_get_activity_action_pre_meta', $action, &$activities_template->activity );
    650647
     
    661658        global $activities_template;
    662659
    663         /* Backwards compatibility if action is not being used */
     660        // Backwards compatibility if action is not being used
    664661        if ( empty( $activities_template->activity->action ) && !empty( $activities_template->activity->content ) )
    665662            $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content );
     
    744741        extract( $r, EXTR_SKIP );
    745742
    746         /* Get the ID of the parent activity content */
     743        // Get the ID of the parent activity content
    747744        if ( !$parent_id = $activities_template->activity->item_id )
    748745            return false;
    749746
    750         /* Get the content of the parent */
     747        // Get the content of the parent
    751748        if ( empty( $activities_template->activity_parents[$parent_id] ) )
    752749            return false;
     
    757754            $content = $activities_template->activity_parents[$parent_id]->action . ' ' . $activities_template->activity_parents[$parent_id]->content;
    758755
    759         /* Remove the time since content for backwards compatibility */
     756        // Remove the time since content for backwards compatibility
    760757        $content = str_replace( '<span class="time-since">%s</span>', '', $content );
    761758
    762         /* Remove images */
     759        // Remove images
    763760        $content = preg_replace( '/<img[^>]*>/Ui', '', $content );
    764761
     
    788785        return apply_filters( 'bp_activity_get_comments', $comments_html );
    789786    }
    790         /* TODO: The HTML in this function is temporary and will be moved to the template in a future version. */
     787        // TODO: The HTML in this function is temporary and will be moved
     788        // to the template in a future version
    791789        function bp_activity_recurse_comments( $comment ) {
    792790            global $activities_template, $bp;
     
    804802                $content .= '<div class="acomment-meta"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . apply_filters( 'bp_acomment_name', $comment->user_fullname, $comment ) . '</a> &middot; ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $comment->date_recorded ) );
    805803
    806                 /* Reply link - the span is so that threaded reply links can be hidden when JS is off. */
     804                // Reply link - the span is so that threaded reply links can be
     805                // hidden when JS is off.
    807806                if ( is_user_logged_in() && bp_activity_can_comment_reply( $comment ) )
    808807                    $content .= apply_filters( 'bp_activity_comment_reply_link', '<span class="acomment-replylink"> &middot; <a href="#acomment-' . $comment->id . '" class="acomment-reply" id="acomment-reply-' . $activities_template->activity->id . '">' . __( 'Reply', 'buddypress' ) . '</a></span>', $comment );
    809808
    810                 /* Delete link */
     809                // Delete link
    811810                if ( $bp->loggedin_user->is_super_admin || $bp->loggedin_user->id == $comment->user_id ) {
    812811                    $delete_url = wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/?cid=' . $comment->id, 'bp_activity_delete_link' );
     
    950949    }
    951950
    952 function bp_activity_latest_update( $user_id = false ) {
     951function bp_activity_latest_update( $user_id = 0 ) {
    953952    echo bp_get_activity_latest_update( $user_id );
    954953}
    955     function bp_get_activity_latest_update( $user_id = false ) {
     954    function bp_get_activity_latest_update( $user_id = 0 ) {
    956955        global $bp;
    957956
     
    981980        extract( $r, EXTR_SKIP );
    982981
    983         /* Fetch the names of components that have activity recorded in the DB */
     982        // Fetch the names of components that have activity recorded in the DB
    984983        $components = BP_Activity_Activity::get_recorded_components();
    985984
     
    10221021            $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component );
    10231022
    1024             /* Make sure all core internal component names are translatable */
     1023            // Make sure all core internal component names are translatable
    10251024            $translatable_components = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
    10261025
     
    10641063}
    10651064
    1066 function bp_total_favorite_count_for_user( $user_id = false ) {
     1065function bp_total_favorite_count_for_user( $user_id = 0 ) {
    10671066    echo bp_get_total_favorite_count_for_user( $user_id );
    10681067}
    1069     function bp_get_total_favorite_count_for_user( $user_id = false ) {
     1068    function bp_get_total_favorite_count_for_user( $user_id = 0 ) {
    10701069        return apply_filters( 'bp_get_total_favorite_count_for_user', bp_activity_total_favorites_for_user( $user_id ) );
    10711070    }
    10721071
    1073 function bp_total_mention_count_for_user( $user_id = false ) {
     1072function bp_total_mention_count_for_user( $user_id = 0 ) {
    10741073    echo bp_get_total_favorite_count_for_user( $user_id );
    10751074}
    1076     function bp_get_total_mention_count_for_user( $user_id = false ) {
     1075    function bp_get_total_mention_count_for_user( $user_id = 0 ) {
    10771076        return apply_filters( 'bp_get_total_mention_count_for_user', get_user_meta( $user_id, 'bp_new_mention_count', true ) );
    10781077    }
     
    10881087
    10891088        return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) );
     1089    }
     1090
     1091function bp_mentioned_user_display_name( $user_id_or_username ) {
     1092    echo bp_get_mentioned_user_display_name( $user_id_or_username );
     1093}
     1094    function bp_get_mentioned_user_display_name( $user_id_or_username ) {
     1095        if ( !$name = bp_core_get_user_displayname( $user_id_or_username ) )
     1096            $name = __( 'a user', 'buddypress' );
     1097
     1098        return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
    10901099    }
    10911100
     
    11531162        global $bp;
    11541163
    1155         $link = '';
    1156 
    11571164        if ( $bp->current_component == $bp->profile->slug || 'just-me' == $bp->current_action )
    11581165            $link = $bp->displayed_user->domain . $bp->activity->slug . '/feed/';
     
    11651172        elseif ( 'mentions' == $bp->current_action )
    11661173            $link = $bp->displayed_user->domain . $bp->activity->slug . '/mentions/feed/';
     1174        else
     1175            $link = '';
    11671176
    11681177        return apply_filters( 'bp_get_activities_member_rss_link', $link );
     
    11711180
    11721181
    1173 /* Template tags for RSS feed output */
     1182/** Template tags for RSS feed output *****************************************/
    11741183
    11751184function bp_activity_feed_item_guid() {
     
    12421251 * @since 1.3
    12431252 */
    1244 function bp_dtheme_sitewide_feed() {
     1253function bp_activity_sitewide_feed() {
    12451254?>
    1246 <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php _e( 'Site Wide Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_sitewide_activity_feed_link() ?>" />
     1255
     1256    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php _e( 'Site Wide Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_sitewide_activity_feed_link() ?>" />
     1257
    12471258<?php
    12481259}
    1249 add_action( 'bp_head', 'bp_dtheme_sitewide_feed' );
    1250 
    1251 /**
    1252  * Template tag so we can hook member activity feed to <head>
    1253  *
    1254  * @since 1.3
    1255  */
    1256 function bp_dtheme_member_feed() {
    1257     if ( !bp_is_member() )
    1258         return;
     1260add_action( 'bp_head', 'bp_activity_sitewide_feed' );
     1261
    12591262?>
    1260         <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php bp_displayed_user_fullname() ?> | <?php _e( 'Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_member_activity_feed_link() ?>" />
    1261 <?php
    1262 }
    1263 add_action( 'bp_head', 'bp_dtheme_member_feed' );
    1264 
    1265 /**
    1266  * Template tag so we can hook group activity feed to <head>
    1267  *
    1268  * @since 1.3
    1269  */
    1270 function bp_dtheme_group_feed() {
    1271     if ( !bp_is_active( 'groups' ) || !bp_is_group() )
    1272         return;
    1273 ?>
    1274         <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php bp_current_group_name() ?> | <?php _e( 'Group Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_group_activity_feed_link() ?>" />
    1275 <?php
    1276 }
    1277 add_action( 'bp_head', 'bp_dtheme_group_feed' );
    1278 ?>
  • trunk/bp-blogs/bp-blogs-classes.php

    r3592 r3778  
    6969    /* Static Functions */
    7070
    71     function get( $type, $limit = false, $page = false, $user_id = false, $search_terms = false ) {
     71    function get( $type, $limit = false, $page = false, $user_id = 0, $search_terms = false ) {
    7272        global $bp, $wpdb;
    7373
     
    154154    }
    155155
    156     function get_blogs_for_user( $user_id = false, $show_hidden = false ) {
     156    function get_blogs_for_user( $user_id = 0, $show_hidden = false ) {
    157157        global $bp, $wpdb;
    158158
     
    183183    }
    184184
    185     function get_blog_ids_for_user( $user_id = false ) {
     185    function get_blog_ids_for_user( $user_id = 0 ) {
    186186        global $bp, $wpdb;
    187187
  • trunk/bp-blogs/bp-blogs-functions.php

    r3761 r3778  
    129129add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescription', 10, 2 );
    130130
    131 function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
     131function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) {
    132132    global $bp, $wpdb;
    133133
     
    328328add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
    329329
    330 function bp_blogs_remove_post( $post_id, $blog_id = false, $user_id = false ) {
     330function bp_blogs_remove_post( $post_id, $blog_id = false, $user_id = 0 ) {
    331331    global $current_blog, $bp;
    332332
     
    368368}
    369369
    370 function bp_blogs_total_blogs_for_user( $user_id = false ) {
     370function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
    371371    global $bp;
    372372
  • trunk/bp-blogs/bp-blogs-loader.php

    r3763 r3778  
    4545
    4646        // Notifications
    47         $bp->blogs->notification_callback = 'bp_blogs_format_notifications';
     47        $this->notification_callback = 'bp_blogs_format_notifications';
    4848
    4949        // Register this in the active components array
    50         $bp->active_components[$this->slug] = $this->id;
     50        $bp->active_components[$this->id] = $this->id;
    5151
    5252        // The default text for the blogs directory search box
    53         $bp->default_search_strings[$this->slug] = __( 'Search Blogs...', 'buddypress' );
     53        $bp->default_search_strings[$this->id] = __( 'Search Blogs...', 'buddypress' );
    5454    }
    5555
     
    8989        bp_core_new_nav_item( array(
    9090            'name'                => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ),
    91             'slug'                => $bp->blogs->slug,
     91            'slug'                => $this->slug,
    9292            'position'            => 30,
    9393            'screen_function'     => 'bp_blogs_screen_my_blogs',
    9494            'default_subnav_slug' => 'my-blogs',
    95             'item_css_id'         => $bp->blogs->id
     95            'item_css_id'         => $this->id
    9696        ) );
    9797
  • trunk/bp-blogs/bp-blogs-template.php

    r3761 r3778  
    119119     */
    120120    $type = 'active';
    121     $user_id = false;
     121    $user_id = 0;
    122122    $search_terms = null;
    123123
     
    295295    add_filter( 'bp_get_total_blog_count', 'bp_core_number_format' );
    296296
    297 function bp_total_blog_count_for_user( $user_id = false ) {
     297function bp_total_blog_count_for_user( $user_id = 0 ) {
    298298    echo bp_get_total_blog_count_for_user( $user_id );
    299299}
    300     function bp_get_total_blog_count_for_user( $user_id = false ) {
     300    function bp_get_total_blog_count_for_user( $user_id = 0 ) {
    301301        return apply_filters( 'bp_get_total_blog_count_for_user', bp_blogs_total_blogs_for_user( $user_id ) );
    302302    }
  • trunk/bp-core/bp-core-classes.php

    r3685 r3778  
    107107    /* Static Functions */
    108108
    109     function get_users( $type, $limit = null, $page = 1, $user_id = false, $include = false, $search_terms = false, $populate_extras = true, $exclude = false ) {
     109    function get_users( $type, $limit = null, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false ) {
    110110        global $wpdb, $bp;
    111111
  • trunk/bp-core/bp-core-template.php

    r3767 r3778  
    11<?php
    2 /***
    3  * Members template loop that will allow you to loop all members or friends of a member
    4  * if you pass a user_id.
    5  */
    6 
    7 class BP_Core_Members_Template {
    8     var $current_member = -1;
    9     var $member_count;
    10     var $members;
    11     var $member;
    12 
    13     var $in_the_loop;
    14 
    15     var $pag_page;
    16     var $pag_num;
    17     var $pag_links;
    18     var $total_member_count;
    19 
    20     function bp_core_members_template( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude ) {
    21         global $bp;
    22 
    23         $this->pag_page  = !empty( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : (int)$page_number;
    24         $this->pag_num   = !empty( $_REQUEST['num'] )   ? intval( $_REQUEST['num'] )   : (int)$per_page;
    25         $this->type      = $type;
    26 
    27         if ( !$this->pag_num )
    28             $this->pag_num = 1;
    29 
    30         if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] )
    31             $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras, $exclude );
    32         else if ( false !== $include )
    33             $this->members = BP_Core_User::get_specific_users( $include, $this->pag_num, $this->pag_page, $populate_extras );
    34         else
    35             $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras, 'exclude' => $exclude ) );
    36 
    37         if ( !$max || $max >= (int)$this->members['total'] )
    38             $this->total_member_count = (int)$this->members['total'];
    39         else
    40             $this->total_member_count = (int)$max;
    41 
    42         $this->members = $this->members['users'];
    43 
    44         if ( $max ) {
    45             if ( $max >= count( $this->members ) ) {
    46                 $this->member_count = count( $this->members );
    47             } else {
    48                 $this->member_count = (int)$max;
    49             }
    50         } else {
    51             $this->member_count = count( $this->members );
    52         }
    53 
    54         if ( (int)$this->total_member_count && (int)$this->pag_num ) {
    55             $this->pag_links = paginate_links( array(
    56                 'base'      => add_query_arg( 'upage', '%#%' ),
    57                 'format'    => '',
    58                 'total'     => ceil( (int)$this->total_member_count / (int)$this->pag_num ),
    59                 'current'   => (int) $this->pag_page,
    60                 'prev_text' => '&larr;',
    61                 'next_text' => '&rarr;',
    62                 'mid_size'   => 1
    63             ) );
    64         }
    65     }
    66 
    67     function has_members() {
    68         if ( $this->member_count )
    69             return true;
    70 
    71         return false;
    72     }
    73 
    74     function next_member() {
    75         $this->current_member++;
    76         $this->member = $this->members[$this->current_member];
    77 
    78         return $this->member;
    79     }
    80 
    81     function rewind_members() {
    82         $this->current_member = -1;
    83         if ( $this->member_count > 0 ) {
    84             $this->member = $this->members[0];
    85         }
    86     }
    87 
    88     function members() {
    89         if ( $this->current_member + 1 < $this->member_count ) {
    90             return true;
    91         } elseif ( $this->current_member + 1 == $this->member_count ) {
    92             do_action('member_loop_end');
    93             // Do some cleaning up after the loop
    94             $this->rewind_members();
    95         }
    96 
    97         $this->in_the_loop = false;
    98         return false;
    99     }
    100 
    101     function the_member() {
    102         global $member, $bp;
    103 
    104         $this->in_the_loop = true;
    105         $this->member = $this->next_member();
    106 
    107         if ( 0 == $this->current_member ) // loop has just started
    108             do_action('member_loop_start');
    109     }
    110 }
    111 
    112 function bp_rewind_members() {
    113     global $members_template;
    114 
    115     return $members_template->rewind_members();
    116 }
    117 
    118 function bp_has_members( $args = '' ) {
    119     global $bp, $members_template;
    120 
    121     /***
    122      * Set the defaults based on the current page. Any of these will be overridden
    123      * if arguments are directly passed into the loop. Custom plugins should always
    124      * pass their parameters directly to the loop.
    125      */
    126     $type = 'active';
    127     $user_id = false;
    128     $page = 1;
    129     $search_terms = null;
    130 
    131     // User filtering
    132     if ( !empty( $bp->displayed_user->id ) )
    133         $user_id = $bp->displayed_user->id;
    134 
    135     // type: active ( default ) | random | newest | popular | online | alphabetical
    136     $defaults = array(
    137         'type' => $type,
    138         'page' => $page,
    139         'per_page' => 20,
    140         'max' => false,
    141 
    142         'include' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users
    143         'exclude' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users
    144 
    145         'user_id' => $user_id, // Pass a user_id to only show friends of this user
    146         'search_terms' => $search_terms, // Pass search_terms to filter users by their profile data
    147 
    148         'populate_extras' => true // Fetch usermeta? Friend count, last active etc.
    149     );
    150 
    151     $r = wp_parse_args( $args, $defaults );
    152     extract( $r );
    153 
    154     // Pass a filter if ?s= is set.
    155     if ( is_null( $search_terms ) ) {
    156         if ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) )
    157             $search_terms = $_REQUEST['s'];
    158         else
    159             $search_terms = false;
    160     }
    161 
    162     if ( $max ) {
    163         if ( $per_page > $max )
    164             $per_page = $max;
    165     }
    166 
    167     // Make sure we return no members if we looking at friendship requests and there are none.
    168     if ( empty( $include ) && bp_is_current_component( $bp->friends->slug ) && 'requests' == $bp->current_action )
    169         return false;
    170 
    171     $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras, $exclude );
    172     return apply_filters( 'bp_has_members', $members_template->has_members(), $members_template );
    173 }
    174 
    175 function bp_the_member() {
    176     global $members_template;
    177     return $members_template->the_member();
    178 }
    179 
    180 function bp_members() {
    181     global $members_template;
    182     return $members_template->members();
    183 }
    184 
    185 function bp_members_pagination_count() {
    186     echo bp_get_members_pagination_count();
    187 }
    188     function bp_get_members_pagination_count() {
    189         global $bp, $members_template;
    190 
    191         $start_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
    192         $from_num = bp_core_number_format( $start_num );
    193         $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
    194         $total = bp_core_number_format( $members_template->total_member_count );
    195 
    196         if ( 'active' == $members_template->type )
    197             $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s active members)', 'buddypress' ), $from_num, $to_num, $total );
    198         else if ( 'popular' == $members_template->type )
    199             $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s members with friends)', 'buddypress' ), $from_num, $to_num, $total );
    200         else if ( 'online' == $members_template->type )
    201             $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s members online)', 'buddypress' ), $from_num, $to_num, $total );
    202         else
    203             $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s members)', 'buddypress' ), $from_num, $to_num, $total );
    204 
    205         return apply_filters( 'bp_members_pagination_count', $pag . '<span class="ajax-loader"></span>' );
    206     }
    207 
    208 function bp_members_pagination_links() {
    209     echo bp_get_members_pagination_links();
    210 }
    211     function bp_get_members_pagination_links() {
    212         global $members_template;
    213 
    214         return apply_filters( 'bp_get_members_pagination_links', $members_template->pag_links );
    215     }
    216 
    217 /**
    218  * bp_member_user_id()
    219  *
    220  * Echo id from bp_get_member_user_id()
    221  *
    222  * @uses bp_get_member_user_id()
    223  */
    224 function bp_member_user_id() {
    225     echo bp_get_member_user_id();
    226 }
    227     /**
    228      * bp_get_member_user_id()
    229      *
    230      * Get the id of the user in a members loop
    231      *
    232      * @global object $members_template
    233      * @return string Members id
    234      */
    235     function bp_get_member_user_id() {
    236         global $members_template;
    237 
    238         return apply_filters( 'bp_get_member_user_id', $members_template->member->id );
    239     }
    240 
    241 /**
    242  * bp_member_user_nicename()
    243  *
    244  * Echo nicename from bp_get_member_user_nicename()
    245  *
    246  * @uses bp_get_member_user_nicename()
    247  */
    248 function bp_member_user_nicename() {
    249     echo bp_get_member_user_nicename();
    250 }
    251     /**
    252      * bp_get_member_user_nicename()
    253      *
    254      * Get the nicename of the user in a members loop
    255      *
    256      * @global object $members_template
    257      * @return string Members nicename
    258      */
    259     function bp_get_member_user_nicename() {
    260         global $members_template;
    261         return apply_filters( 'bp_get_member_user_nicename', $members_template->member->user_nicename );
    262     }
    263 
    264 /**
    265  * bp_member_user_login()
    266  *
    267  * Echo login from bp_get_member_user_login()
    268  *
    269  * @uses bp_get_member_user_login()
    270  */
    271 function bp_member_user_login() {
    272     echo bp_get_member_user_login();
    273 }
    274     /**
    275      * bp_get_member_user_login()
    276      *
    277      * Get the login of the user in a members loop
    278      *
    279      * @global object $members_template
    280      * @return string Members login
    281      */
    282     function bp_get_member_user_login() {
    283         global $members_template;
    284         return apply_filters( 'bp_get_member_user_login', $members_template->member->user_login );
    285     }
    286 
    287 /**
    288  * bp_member_user_email()
    289  *
    290  * Echo email address from bp_get_member_user_email()
    291  *
    292  * @uses bp_get_member_user_email()
    293  */
    294 function bp_member_user_email() {
    295     echo bp_get_member_user_email();
    296 }
    297     /**
    298      * bp_get_member_user_email()
    299      *
    300      * Get the email address of the user in a members loop
    301      *
    302      * @global object $members_template
    303      * @return string Members email address
    304      */
    305     function bp_get_member_user_email() {
    306         global $members_template;
    307         return apply_filters( 'bp_get_member_user_email', $members_template->member->user_email );
    308     }
    309 
    310 function bp_member_is_loggedin_user() {
    311     global $bp, $members_template;
    312     return apply_filters( 'bp_member_is_loggedin_user', $bp->loggedin_user->id == $members_template->member->id ? true : false );
    313 }
    314 
    315 function bp_member_avatar( $args = '' ) {
    316     echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) );
    317 }
    318     function bp_get_member_avatar( $args = '' ) {
    319         global $bp, $members_template;
    320 
    321         $defaults = array(
    322             'type' => 'thumb',
    323             'width' => false,
    324             'height' => false,
    325             'class' => 'avatar',
    326             'id' => false,
    327             'alt' => __( 'Profile picture of %s', 'buddypress' )
    328         );
    329 
    330         $r = wp_parse_args( $args, $defaults );
    331         extract( $r, EXTR_SKIP );
    332 
    333         return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
    334     }
    335 
    336 function bp_member_permalink() {
    337     echo bp_get_member_permalink();
    338 }
    339     function bp_get_member_permalink() {
    340         global $members_template;
    341 
    342         return apply_filters( 'bp_get_member_permalink', bp_core_get_user_domain( $members_template->member->id, $members_template->member->user_nicename, $members_template->member->user_login ) );
    343     }
    344     function bp_member_link() { echo bp_get_member_permalink(); }
    345     function bp_get_member_link() { return bp_get_member_permalink(); }
    346 
    347 function bp_member_name() {
    348     echo apply_filters( 'bp_member_name', bp_get_member_name() );
    349 }
    350     function bp_get_member_name() {
    351         global $members_template;
    352 
    353         if ( empty($members_template->member->fullname) )
    354             $members_template->member->fullname = $members_template->member->display_name;
    355 
    356         return apply_filters( 'bp_get_member_name', $members_template->member->fullname );
    357     }
    358     add_filter( 'bp_get_member_name', 'wp_filter_kses' );
    359     add_filter( 'bp_get_member_name', 'stripslashes' );
    360     add_filter( 'bp_get_member_name', 'strip_tags' );
    361 
    362 function bp_member_last_active() {
    363     echo bp_get_member_last_active();
    364 }
    365     function bp_get_member_last_active() {
    366         global $members_template;
    367 
    368         $last_activity = bp_core_get_last_activity( $members_template->member->last_activity, __( 'active %s ago', 'buddypress' ) );
    369 
    370         return apply_filters( 'bp_member_last_active', $last_activity );
    371     }
    372 
    373 function bp_member_latest_update( $args = '' ) {
    374     echo bp_get_member_latest_update( $args );
    375 }
    376     function bp_get_member_latest_update( $args = '' ) {
    377         global $members_template, $bp;
    378 
    379         $defaults = array(
    380             'length' => 70
    381         );
    382 
    383         $r = wp_parse_args( $args, $defaults );
    384         extract( $r, EXTR_SKIP );
    385 
    386         if ( !isset( $members_template->member->latest_update ) || !$update = maybe_unserialize( $members_template->member->latest_update ) )
    387             return false;
    388 
    389         $update_content = apply_filters( 'bp_get_activity_latest_update', strip_tags( bp_create_excerpt( $update['content'], $length ) ) );
    390 
    391         if ( !empty( $update['id'] ) )
    392             $update_content .= ' &middot; <a href="' . $bp->root_domain . '/' . $bp->activity->root_slug . '/p/' . $update['id'] . '">' . __( 'View', 'buddypress' ) . '</a>';
    393 
    394         return apply_filters( 'bp_get_member_latest_update', $update_content );
    395     }
    396 
    397 function bp_member_profile_data( $args = '' ) {
    398     echo bp_get_member_profile_data( $args );
    399 }
    400     function bp_get_member_profile_data( $args = '' ) {
    401         global $members_template;
    402 
    403         if ( !bp_is_active( 'xprofile' ) )
    404             return false;
    405 
    406         $defaults = array(
    407             'field' => false, // Field name
    408         );
    409 
    410         $r = wp_parse_args( $args, $defaults );
    411         extract( $r, EXTR_SKIP );
    412 
    413         // Populate the user if it hasn't been already.
    414         if ( empty( $members_template->member->profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) )
    415             $members_template->member->profile_data = BP_XProfile_ProfileData::get_all_for_user( $members_template->member->id );
    416 
    417         $data = xprofile_format_profile_field( $members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data'] );
    418 
    419         return apply_filters( 'bp_get_member_profile_data', $data );
    420     }
    421 
    422 function bp_member_registered() {
    423     echo bp_get_member_registered();
    424 }
    425     function bp_get_member_registered() {
    426         global $members_template;
    427 
    428         $registered = esc_attr( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) );
    429 
    430         return apply_filters( 'bp_member_last_active', $registered );
    431     }
    432 
    433 function bp_member_random_profile_data() {
    434     global $members_template;
    435 
    436     if ( function_exists( 'xprofile_get_random_profile_data' ) ) { ?>
    437         <?php $random_data = xprofile_get_random_profile_data( $members_template->member->id, true ); ?>
    438             <strong><?php echo wp_filter_kses( $random_data[0]->name ) ?></strong>
    439             <?php echo wp_filter_kses( $random_data[0]->value ) ?>
    440     <?php }
    441 }
    442 
    443 function bp_member_hidden_fields() {
    444     if ( isset( $_REQUEST['s'] ) ) {
    445         echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ) . '" name="search_terms" />';
    446     }
    447 
    448     if ( isset( $_REQUEST['letter'] ) ) {
    449         echo '<input type="hidden" id="selected_letter" value="' . esc_attr( $_REQUEST['letter'] ) . '" name="selected_letter" />';
    450     }
    451 
    452     if ( isset( $_REQUEST['members_search'] ) ) {
    453         echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['members_search'] ) . '" name="search_terms" />';
    454     }
    455 }
    456 
    457 function bp_directory_members_search_form() {
    458     global $bp;
    459 
    460     $default_search_value = bp_get_search_default_text();
    461     $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value;
    462 
    463     ?>
    464     <form action="" method="get" id="search-members-form">
    465         <label><input type="text" name="s" id="members_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php echo $default_search_value ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $default_search_value ?>';}" /></label>
    466         <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    467     </form>
    468 <?php
    469 }
    470 
    471 function bp_total_site_member_count() {
    472     echo bp_get_total_site_member_count();
    473 }
    474     function bp_get_total_site_member_count() {
    475         return apply_filters( 'bp_get_total_site_member_count', bp_core_number_format( bp_core_get_total_member_count() ) );
    476     }
    477 
    478 
    479 /** Navigation and other misc template tags **/
    480 
    481 /**
    482  * bp_get_nav()
    483  * TEMPLATE TAG
    484  *
    485  * Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install.
    486  * Each component adds to this navigation array within its own [component_name]_setup_nav() function.
    487  *
    488  * This navigation array is the top level navigation, so it contains items such as:
    489  *      [Blog, Profile, Messages, Groups, Friends] ...
    490  *
    491  * The function will also analyze the current component the user is in, to determine whether
    492  * or not to highlight a particular nav item.
    493  *
    494  * @package BuddyPress Core
    495  * @todo Move to a back-compat file?
    496  * @deprecated Does not seem to be called anywhere in the core
    497  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    498  */
    499 function bp_get_loggedin_user_nav() {
    500     global $bp, $current_blog;
    501 
    502     /* Loop through each navigation item */
    503     foreach( (array) $bp->bp_nav as $nav_item ) {
    504         /* If the current component matches the nav item id, then add a highlight CSS class. */
    505         if ( !bp_is_directory() && $bp->active_components[$bp->current_component] == $nav_item['css_id'] )
    506             $selected = ' class="current selected"';
    507         else
    508             $selected = '';
    509 
    510         /* If we are viewing another person (current_userid does not equal loggedin_user->id)
    511            then check to see if the two users are friends. if they are, add a highlight CSS class
    512            to the friends nav item if it exists. */
    513         if ( !bp_is_my_profile() && $bp->displayed_user->id ) {
    514             $selected = '';
    515 
    516             if ( bp_is_active( 'friends' ) ) {
    517                 if ( $nav_item['css_id'] == $bp->friends->id ) {
    518                     if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
    519                         $selected = ' class="current selected"';
    520                 }
    521             }
    522         }
    523 
    524         /* echo out the final list item */
    525         echo apply_filters( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item );
    526     }
    527 
    528     /* Always add a log out list item to the end of the navigation */
    529     if ( function_exists( 'wp_logout_url' ) ) {
    530         $logout_link = '<li><a id="wp-logout" href="' .  wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
    531     } else {
    532         $logout_link = '<li><a id="wp-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
    533     }
    534 
    535     echo apply_filters( 'bp_logout_nav_link', $logout_link );
    536 }
    537 
    538 /**
    539  * Uses the $bp->bp_nav global to render out the user navigation when viewing another user other than
    540  * yourself.
    541  *
    542  * @package BuddyPress Core
    543  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    544  */
    545 function bp_get_displayed_user_nav() {
    546     global $bp;
    547 
    548     foreach ( (array)$bp->bp_nav as $user_nav_item ) {
    549         if ( !$user_nav_item['show_for_displayed_user'] && !bp_is_my_profile() )
    550             continue;
    551 
    552         if ( $bp->current_component == $user_nav_item['slug'] )
    553             $selected = ' class="current selected"';
    554         else
    555             $selected = '';
    556 
    557         if ( $bp->loggedin_user->domain )
    558             $link = str_replace( $bp->loggedin_user->domain, $bp->displayed_user->domain, $user_nav_item['link'] );
    559         else
    560             $link = $bp->displayed_user->domain . $user_nav_item['link'];
    561 
    562         echo apply_filters( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item );
    563     }
    564 }
    5652
    5663/**
     
    59128        return false;
    59229
    593     /* Loop through each navigation item */
     30    // Loop through each navigation item
    59431    foreach ( (array)$bp->bp_options_nav[$component_index] as $subnav_item ) {
    59532        if ( !$subnav_item['user_has_access'] )
    59633            continue;
    59734
    598         /* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */
     35        // If the current action or an action variable matches the nav item id, then add a highlight CSS class.
    59936        if ( $subnav_item['slug'] == $bp->current_action ) {
    60037            $selected = ' class="current selected"';
     
    60340        }
    60441
    605         /* echo out the final list item */
     42        // echo out the final list item
    60643        echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . $subnav_item['css_id'] . '-personal-li" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item );
    60744    }
     
    64885    global $comment;
    64986
    650     if ( function_exists('bp_core_fetch_avatar') ) {
     87    if ( function_exists( 'bp_core_fetch_avatar' ) )
    65188        echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb' ) ) );
    652     } else if ( function_exists('get_avatar') ) {
     89    else if ( function_exists('get_avatar') )
    65390        get_avatar();
    654     }
    65591}
    65692
     
    65894    global $post;
    65995
    660     if ( function_exists('bp_core_fetch_avatar') ) {
     96    if ( function_exists( 'bp_core_fetch_avatar' ) )
    66197        echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) );
    662     } else if ( function_exists('get_avatar') ) {
     98    else if ( function_exists('get_avatar') )
    66399        get_avatar();
    664     }
    665 }
    666 
    667 function bp_loggedin_user_avatar( $args = '' ) {
    668     echo bp_get_loggedin_user_avatar( $args );
    669 }
    670     function bp_get_loggedin_user_avatar( $args = '' ) {
    671         global $bp;
    672 
    673         $defaults = array(
    674             'type'      => 'thumb',
    675             'width'     => false,
    676             'height'    => false,
    677             'html'      => true,
    678             'alt' => __( 'Profile picture of %s', 'buddypress' )
    679         );
    680 
    681         $r = wp_parse_args( $args, $defaults );
    682         extract( $r, EXTR_SKIP );
    683 
    684         return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
    685     }
    686 
    687 function bp_displayed_user_avatar( $args = '' ) {
    688     echo bp_get_displayed_user_avatar( $args );
    689 }
    690     function bp_get_displayed_user_avatar( $args = '' ) {
    691         global $bp;
    692 
    693         $defaults = array(
    694             'type'      => 'thumb',
    695             'width'     => false,
    696             'height'    => false,
    697             'html'      => true,
    698             'alt' => __( 'Profile picture of %s', 'buddypress' )
    699         );
    700 
    701         $r = wp_parse_args( $args, $defaults );
    702         extract( $r, EXTR_SKIP );
    703 
    704         return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
    705     }
     100}
    706101
    707102function bp_avatar_admin_step() {
     
    832227
    833228function bp_exists( $component_name ) {
    834     if ( function_exists($component_name . '_install') )
     229    if ( function_exists( $component_name . '_install' ) )
    835230        return true;
    836231
     
    945340    wp_print_styles();
    946341}
    947 
    948 function bp_has_custom_signup_page() {
    949     if ( locate_template( array( 'register.php' ), false ) || locate_template( array( '/registration/register.php' ), false ) )
    950         return true;
    951 
    952     return false;
    953 }
    954 
    955 function bp_signup_page() {
    956     echo bp_get_signup_page();
    957 }
    958     function bp_get_signup_page() {
    959         global $bp;
    960 
    961         if ( bp_has_custom_signup_page() )
    962             $page = $bp->root_domain . '/' . BP_REGISTER_SLUG;
    963         else
    964             $page = $bp->root_domain . '/wp-signup.php';
    965 
    966         return apply_filters( 'bp_get_signup_page', $page );
    967     }
    968 
    969 function bp_has_custom_activation_page() {
    970     if ( locate_template( array( 'activate.php' ), false ) || locate_template( array( '/registration/activate.php' ), false ) )
    971         return true;
    972 
    973     return false;
    974 }
    975 
    976 function bp_activation_page() {
    977     echo bp_get_activation_page();
    978 }
    979     function bp_get_activation_page() {
    980         global $bp;
    981 
    982         if ( bp_has_custom_activation_page() )
    983             $page = trailingslashit( $bp->root_domain ) . BP_ACTIVATION_SLUG;
    984         else
    985             $page = trailingslashit( $bp->root_domain ) . 'wp-activate.php';
    986 
    987         return apply_filters( 'bp_get_activation_page', $page );
    988     }
    989342
    990343/**
     
    1194547    add_filter( 'bp_get_total_member_count', 'bp_core_number_format' );
    1195548
    1196 /*** Signup form template tags **********************/
    1197 
    1198 function bp_signup_username_value() {
    1199     echo bp_get_signup_username_value();
    1200 }
    1201     function bp_get_signup_username_value() {
    1202         $value = '';
    1203         if ( isset( $_POST['signup_username'] ) )
    1204             $value = $_POST['signup_username'];
    1205 
    1206         return apply_filters( 'bp_get_signup_username_value', $value );
    1207     }
    1208 
    1209 function bp_signup_email_value() {
    1210     echo bp_get_signup_email_value();
    1211 }
    1212     function bp_get_signup_email_value() {
    1213         $value = '';
    1214         if ( isset( $_POST['signup_email'] ) )
    1215             $value = $_POST['signup_email'];
    1216 
    1217         return apply_filters( 'bp_get_signup_email_value', $value );
    1218     }
    1219 
    1220 function bp_signup_with_blog_value() {
    1221     echo bp_get_signup_with_blog_value();
    1222 }
    1223     function bp_get_signup_with_blog_value() {
    1224         $value = '';
    1225         if ( isset( $_POST['signup_with_blog'] ) )
    1226             $value = $_POST['signup_with_blog'];
    1227 
    1228         return apply_filters( 'bp_get_signup_with_blog_value', $value );
    1229     }
    1230 
    1231 function bp_signup_blog_url_value() {
    1232     echo bp_get_signup_blog_url_value();
    1233 }
    1234     function bp_get_signup_blog_url_value() {
    1235         $value = '';
    1236         if ( isset( $_POST['signup_blog_url'] ) )
    1237             $value = $_POST['signup_blog_url'];
    1238 
    1239         return apply_filters( 'bp_get_signup_blog_url_value', $value );
    1240     }
    1241 
    1242 function bp_signup_blog_title_value() {
    1243     echo bp_get_signup_blog_title_value();
    1244 }
    1245     function bp_get_signup_blog_title_value() {
    1246         $value = '';
    1247         if ( isset( $_POST['signup_blog_title'] ) )
    1248             $value = $_POST['signup_blog_title'];
    1249 
    1250         return apply_filters( 'bp_get_signup_blog_title_value', $value );
    1251     }
    1252 
    1253 function bp_signup_blog_privacy_value() {
    1254     echo bp_get_signup_blog_privacy_value();
    1255 }
    1256     function bp_get_signup_blog_privacy_value() {
    1257         $value = '';
    1258         if ( isset( $_POST['signup_blog_privacy'] ) )
    1259             $value = $_POST['signup_blog_privacy'];
    1260 
    1261         return apply_filters( 'bp_get_signup_blog_privacy_value', $value );
    1262     }
    1263 
    1264 function bp_signup_avatar_dir_value() {
    1265     echo bp_get_signup_avatar_dir_value();
    1266 }
    1267     function bp_get_signup_avatar_dir_value() {
    1268         global $bp;
    1269 
    1270         return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
    1271     }
    1272 
    1273 function bp_current_signup_step() {
    1274     echo bp_get_current_signup_step();
    1275 }
    1276     function bp_get_current_signup_step() {
    1277         global $bp;
    1278 
    1279         return $bp->signup->step;
    1280     }
    1281 
    1282 function bp_signup_avatar( $args = '' ) {
    1283     echo bp_get_signup_avatar( $args );
    1284 }
    1285     function bp_get_signup_avatar( $args = '' ) {
    1286         global $bp;
    1287 
    1288         $defaults = array(
    1289             'size' => BP_AVATAR_FULL_WIDTH,
    1290             'class' => 'avatar',
    1291             'alt' => __( 'Your Avatar', 'buddypress' )
    1292         );
    1293 
    1294         $r = wp_parse_args( $args, $defaults );
    1295         extract( $r, EXTR_SKIP );
    1296 
    1297         if ( !empty( $_POST['signup_avatar_dir'] ) ) {
    1298             $signup_avatar_dir = $_POST['signup_avatar_dir'];
    1299         } else if ( !empty( $bp->signup->avatar_dir ) ) {
    1300             $signup_avatar_dir = $bp->signup->avatar_dir;
    1301         }
    1302 
    1303         if ( empty( $signup_avatar_dir ) ) {
    1304             if ( empty( $bp->grav_default->user ) ) {
    1305                 $default_grav = 'wavatar';
    1306             } else if ( 'mystery' == $bp->grav_default->user ) {
    1307                 $default_grav = apply_filters( 'bp_core_mysteryman_src', BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg' );
    1308             } else {
    1309                 $default_grav = $bp->grav_default->user;
    1310             }
    1311 
    1312             $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
    1313             $gravatar_img = '<img src="' . $gravatar_url . md5( strtolower( $_POST['signup_email'] ) ) . '?d=' . $default_grav . '&amp;s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
    1314         } else {
    1315             $gravatar_img = bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) );
    1316         }
    1317 
    1318         return apply_filters( 'bp_get_signup_avatar', $gravatar_img );
    1319     }
    1320 
    1321 function bp_signup_allowed() {
    1322     echo bp_get_signup_allowed();
    1323 }
    1324     function bp_get_signup_allowed() {
    1325         global $bp;
    1326 
    1327         if ( is_multisite() ) {
    1328             if ( in_array( $bp->site_options['registration'], array( 'all', 'user' ) ) )
    1329                 return true;
    1330         } else {
    1331             if ( (int)get_option( 'users_can_register') )
    1332                 return true;
    1333         }
    1334         return false;
    1335     }
    1336 
    1337549function bp_blog_signup_allowed() {
    1338550    echo bp_get_blog_signup_allowed();
     
    1362574    return apply_filters( 'bp_registration_needs_activation', true );
    1363575}
    1364 
    1365 function bp_mentioned_user_display_name( $user_id_or_username ) {
    1366     echo bp_get_mentioned_user_display_name( $user_id_or_username );
    1367 }
    1368     function bp_get_mentioned_user_display_name( $user_id_or_username ) {
    1369         if ( !$name = bp_core_get_user_displayname( $user_id_or_username ) )
    1370             $name = __( 'a user' );
    1371 
    1372         return apply_filters( 'bp_get_mentioned_user_display_name', $name, $user_id_or_username );
    1373     }
    1374576
    1375577function bp_get_option( $option_name ) {
     
    1403605}
    1404606
    1405 
    1406 /*** CUSTOM LOOP TEMPLATE CLASSES *******************/
    1407 
    1408 
    1409 /* Template functions for fetching globals, without querying the DB again
    1410    also means we dont have to use the $bp variable in the template (looks messy) */
    1411 
    1412 function bp_last_activity( $user_id = false, $echo = true ) {
    1413     global $bp;
    1414 
    1415     if ( !$user_id )
    1416         $user_id = $bp->displayed_user->id;
    1417 
    1418     $last_activity = bp_core_get_last_activity( get_user_meta( $user_id, 'last_activity', true ), __('active %s ago', 'buddypress') );
    1419 
    1420     if ( $echo )
    1421         echo apply_filters( 'bp_last_activity', $last_activity );
    1422     else
    1423         return apply_filters( 'bp_last_activity', $last_activity );
    1424 }
    1425 
    1426 function bp_user_has_access() {
    1427     global $bp;
    1428 
    1429     if ( is_super_admin() || is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
    1430         $has_access = true;
    1431     else
    1432         $has_access = false;
    1433 
    1434     return apply_filters( 'bp_user_has_access', $has_access );
    1435 }
    1436 
    1437 function bp_user_firstname() {
    1438     echo bp_get_user_firstname();
    1439 }
    1440     function bp_get_user_firstname( $name = false ) {
    1441         global $bp;
    1442 
    1443         // Try to get displayed user
    1444         if ( empty( $name ) )
    1445             $name = $bp->displayed_user->fullname;
    1446 
    1447         // Fall back on logged in user
    1448         if ( empty( $name ) )
    1449             $name = $bp->loggedin_user->fullname;
    1450 
    1451         $fullname = (array)explode( ' ', $name );
    1452 
    1453         return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );
    1454     }
    1455 
    1456 function bp_loggedin_user_link() {
    1457     echo bp_get_loggedin_user_link();
    1458 }
    1459     function bp_get_loggedin_user_link() {
    1460         global $bp;
    1461 
    1462         return apply_filters( 'bp_get_loggedin_user_link', $bp->loggedin_user->domain );
    1463     }
    1464 
    1465 /* @todo Deprecate incorrectly named function? */
    1466 function bp_loggedinuser_link() {
    1467     global $bp;
    1468 
    1469     if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) )
    1470         echo apply_filters( 'bp_loggedin_user_link', $link );
    1471 }
    1472 
    1473 function bp_displayed_user_link() {
    1474     echo bp_get_displayed_user_link();
    1475 }
    1476     function bp_get_displayed_user_link() {
    1477         global $bp;
    1478 
    1479         return apply_filters( 'bp_get_displayed_user_link', $bp->displayed_user->domain );
    1480     }
    1481     function bp_user_link() { bp_displayed_user_link(); } // Deprecated.
    1482 
    1483 function bp_displayed_user_id() {
    1484     global $bp;
    1485     return apply_filters( 'bp_displayed_user_id', $bp->displayed_user->id );
    1486 }
    1487     function bp_current_user_id() { return bp_displayed_user_id(); }
    1488 
    1489 function bp_loggedin_user_id() {
    1490     global $bp;
    1491     return apply_filters( 'bp_loggedin_user_id', $bp->loggedin_user->id );
    1492 }
    1493 
    1494 function bp_displayed_user_domain() {
    1495     global $bp;
    1496     return apply_filters( 'bp_displayed_user_domain', $bp->displayed_user->domain );
    1497 }
    1498 
    1499 function bp_loggedin_user_domain() {
    1500     global $bp;
    1501     return apply_filters( 'bp_loggedin_user_domain', $bp->loggedin_user->domain );
    1502 }
    1503 
    1504 function bp_displayed_user_fullname() {
    1505     echo bp_get_displayed_user_fullname();
    1506 }
    1507     function bp_get_displayed_user_fullname() {
    1508         global $bp;
    1509 
    1510         return apply_filters( 'bp_displayed_user_fullname', $bp->displayed_user->fullname );
    1511     }
    1512     function bp_user_fullname() { echo bp_get_displayed_user_fullname(); }
    1513 
    1514 
    1515 function bp_loggedin_user_fullname() {
    1516     echo bp_get_loggedin_user_fullname();
    1517 }
    1518     function bp_get_loggedin_user_fullname() {
    1519         global $bp;
    1520         return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname );
    1521     }
    1522 
    1523 function bp_displayed_user_username() {
    1524     echo bp_get_displayed_user_username();
    1525 }
    1526     function bp_get_displayed_user_username() {
    1527         global $bp;
    1528         return apply_filters( 'bp_get_displayed_user_username', bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
    1529     }
    1530 
    1531 function bp_loggedin_user_username() {
    1532     echo bp_get_loggedin_user_username();
    1533 }
    1534     function bp_get_loggedin_user_username() {
    1535         global $bp;
    1536         return apply_filters( 'bp_get_loggedin_user_username', bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ) );
    1537     }
     607/** Template Classes and _is functions ****************************************/
    1538608
    1539609function bp_current_component() {
  • trunk/bp-forums/bp-forums-loader.php

    r3769 r3778  
    389389}
    390390
    391 function bp_forums_total_topic_count_for_user( $user_id = false ) {
     391function bp_forums_total_topic_count_for_user( $user_id = 0 ) {
    392392    global $bp;
    393393
  • trunk/bp-forums/bp-forums-template.php

    r3757 r3778  
    170170     */
    171171    $type = 'newest';
    172     $user_id = false;
     172    $user_id = 0;
    173173    $forum_id = false;
    174174    $search_terms = false;
     
    10981098    }
    10991099
    1100 function bp_forum_topic_count_for_user( $user_id = false ) {
     1100function bp_forum_topic_count_for_user( $user_id = 0 ) {
    11011101    echo bp_get_forum_topic_count_for_user( $user_id );
    11021102}
    1103     function bp_get_forum_topic_count_for_user( $user_id = false ) {
     1103    function bp_get_forum_topic_count_for_user( $user_id = 0 ) {
    11041104        return apply_filters( 'bp_get_forum_topic_count_for_user', bp_forums_total_topic_count_for_user( $user_id ) );
    11051105    }
    11061106
    1107 function bp_forum_topic_count( $user_id = false ) {
     1107function bp_forum_topic_count( $user_id = 0 ) {
    11081108    echo bp_get_forum_topic_count( $user_id );
    11091109}
    1110     function bp_get_forum_topic_count( $user_id = false ) {
     1110    function bp_get_forum_topic_count( $user_id = 0 ) {
    11111111        return apply_filters( 'bp_get_forum_topic_count', bp_forums_total_topic_count( $user_id ) );
    11121112    }
  • trunk/bp-friends/bp-friends-classes.php

    r3369 r3778  
    117117    }
    118118
    119     function total_friend_count( $user_id = false ) {
     119    function total_friend_count( $user_id = 0 ) {
    120120        global $wpdb, $bp;
    121121
  • trunk/bp-friends/bp-friends-template.php

    r3757 r3778  
    266266    }
    267267
    268 function bp_get_friend_ids( $user_id = false ) {
     268function bp_get_friend_ids( $user_id = 0 ) {
    269269    global $bp;
    270270
  • trunk/bp-groups/bp-groups-classes.php

    r3648 r3778  
    166166    }
    167167
    168     function filter_user_groups( $filter, $user_id = false, $order = false, $limit = null, $page = null ) {
     168    function filter_user_groups( $filter, $user_id = 0, $order = false, $limit = null, $page = null ) {
    169169        global $wpdb, $bp;
    170170
     
    256256    }
    257257
    258     function get( $type = 'newest', $per_page = null, $page = null, $user_id = false, $search_terms = false, $include = false, $populate_extras = true, $exclude = false, $show_hidden = false ) {
     258    function get( $type = 'newest', $per_page = null, $page = null, $user_id = 0, $search_terms = false, $include = false, $populate_extras = true, $exclude = false, $show_hidden = false ) {
    259259        global $wpdb, $bp;
    260260
     
    361361    }
    362362
    363     function get_by_most_forum_topics( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true, $exclude = false ) {
     363    function get_by_most_forum_topics( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
    364364        global $wpdb, $bp, $bbdb;
    365365
     
    483483    }
    484484
    485     function get_random( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true, $exclude = false ) {
     485    function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) {
    486486        global $wpdb, $bp;
    487487
     
    600600    var $user;
    601601
    602     function bp_groups_member( $user_id = false, $group_id = false, $id = false, $populate = true ) {
     602    function bp_groups_member( $user_id = 0, $group_id = false, $id = false, $populate = true ) {
    603603        if ( $user_id && $group_id && !$id ) {
    604604            $this->user_id = $user_id;
     
    852852    }
    853853
    854     function total_group_count( $user_id = false ) {
     854    function total_group_count( $user_id = 0 ) {
    855855        global $bp, $wpdb;
    856856
  • trunk/bp-groups/bp-groups-loader.php

    r3757 r3778  
    22022202/*** Group Invitations *********************************************************/
    22032203
    2204 function groups_get_invites_for_user( $user_id = false, $limit = false, $page = false, $exclude = false ) {
     2204function groups_get_invites_for_user( $user_id = 0, $limit = false, $page = false, $exclude = false ) {
    22052205    global $bp;
    22062206
     
    24452445}
    24462446
    2447 function groups_accept_membership_request( $membership_id, $user_id = false, $group_id = false ) {
     2447function groups_accept_membership_request( $membership_id, $user_id = 0, $group_id = false ) {
    24482448    global $bp;
    24492449
     
    24842484}
    24852485
    2486 function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) {
     2486function groups_reject_membership_request( $membership_id, $user_id = 0, $group_id = false ) {
    24872487    if ( !$membership = groups_delete_membership_request( $membership_id, $user_id, $group_id ) )
    24882488        return false;
     
    24972497}
    24982498
    2499 function groups_delete_membership_request( $membership_id, $user_id = false, $group_id = false ) {
     2499function groups_delete_membership_request( $membership_id, $user_id = 0, $group_id = false ) {
    25002500    if ( $user_id && $group_id )
    25012501        $membership = new BP_Groups_Member( $user_id, $group_id );
  • trunk/bp-groups/bp-groups-template.php

    r3757 r3778  
    895895    }
    896896
    897 function bp_group_member_demote_link( $user_id = false ) {
     897function bp_group_member_demote_link( $user_id = 0 ) {
    898898    global $members_template;
    899899
     
    903903    echo bp_get_group_member_demote_link( $user_id );
    904904}
    905     function bp_get_group_member_demote_link( $user_id = false, $group = false ) {
     905    function bp_get_group_member_demote_link( $user_id = 0, $group = false ) {
    906906        global $members_template, $groups_template, $bp;
    907907
     
    915915    }
    916916
    917 function bp_group_member_ban_link( $user_id = false ) {
     917function bp_group_member_ban_link( $user_id = 0 ) {
    918918    global $members_template;
    919919
     
    923923    echo bp_get_group_member_ban_link( $user_id );
    924924}
    925     function bp_get_group_member_ban_link( $user_id = false, $group = false ) {
     925    function bp_get_group_member_ban_link( $user_id = 0, $group = false ) {
    926926        global $members_template, $groups_template, $bp;
    927927
     
    932932    }
    933933
    934 function bp_group_member_unban_link( $user_id = false ) {
     934function bp_group_member_unban_link( $user_id = 0 ) {
    935935    global $members_template;
    936936
     
    940940    echo bp_get_group_member_unban_link( $user_id );
    941941}
    942     function bp_get_group_member_unban_link( $user_id = false, $group = false ) {
     942    function bp_get_group_member_unban_link( $user_id = 0, $group = false ) {
    943943        global $members_template, $groups_template;
    944944
     
    953953
    954954
    955 function bp_group_member_remove_link( $user_id = false ) {
     955function bp_group_member_remove_link( $user_id = 0 ) {
    956956    global $members_template;
    957957
     
    961961    echo bp_get_group_member_remove_link( $user_id );
    962962}
    963     function bp_get_group_member_remove_link( $user_id = false, $group = false ) {
     963    function bp_get_group_member_remove_link( $user_id = 0, $group = false ) {
    964964        global $members_template, $groups_template;
    965965
     
    13521352    }
    13531353
    1354 function bp_total_group_count_for_user( $user_id = false ) {
     1354function bp_total_group_count_for_user( $user_id = 0 ) {
    13551355    echo bp_get_total_group_count_for_user( $user_id );
    13561356}
    1357     function bp_get_total_group_count_for_user( $user_id = false ) {
     1357    function bp_get_total_group_count_for_user( $user_id = 0 ) {
    13581358        return apply_filters( 'bp_get_total_group_count_for_user', groups_total_groups_for_user( $user_id ) );
    13591359    }
     
    23752375 */
    23762376
     2377/**
     2378 * Hook group activity feed to <head>
     2379 *
     2380 * @since 1.3
     2381 */
     2382function bp_groups_activity_feed() {
     2383    if ( !bp_is_active( 'groups' ) || !bp_is_active( 'activity' ) || !bp_is_group() )
     2384        return; ?>
     2385
     2386    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php bp_current_group_name() ?> | <?php _e( 'Group Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_group_activity_feed_link() ?>" />
     2387
     2388<?php
     2389}
     2390add_action( 'bp_head', 'bp_groups_activity_feed' );
     2391
    23772392function bp_group_activity_feed_link() {
    23782393    echo bp_get_group_activity_feed_link();
  • trunk/bp-settings/bp-settings-loader.php

    r3757 r3778  
    3131        $this->slug      = BP_SETTINGS_SLUG;
    3232        $this->root_slug = isset( $bp->pages->settings->slug ) ? $bp->pages->settings->slug : $this->slug;
     33       
     34        // Register this in the active components array
     35        $bp->active_components[$this->id] = $this->id;
    3336    }
    3437
     
    5659        bp_core_new_nav_item( array(
    5760            'name'                    => __( 'Settings', 'buddypress' ),
    58             'slug'                    => $bp->settings->slug,
     61            'slug'                    => $this->slug,
    5962            'position'                => 100,
    6063            'show_for_displayed_user' => bp_users_can_edit_settings(),
     
    7073            'slug'            => 'general',
    7174            'parent_url'      => $settings_link,
    72             'parent_slug'     => $bp->settings->slug,
     75            'parent_slug'     => $this->slug,
    7376            'screen_function' => 'bp_settings_screen_general_settings',
    7477            'position'        => 10,
     
    8184            'slug'            => 'notifications',
    8285            'parent_url'      => $settings_link,
    83             'parent_slug'     => $bp->settings->slug,
     86            'parent_slug'     => $this->slug,
    8487            'screen_function' => 'bp_settings_screen_notification_settings',
    8588            'position'        => 20,
     
    9396                'slug'            => 'delete-account',
    9497                'parent_url'      => $settings_link,
    95                 'parent_slug'     => $bp->settings->slug,
     98                'parent_slug'     => $this->slug,
    9699                'screen_function' => 'bp_settings_screen_delete_account',
    97100                'position'        => 90,
     
    101104    }
    102105}
     106// Create the settingss component
    103107$bp->settings = new BP_Settings_Component();
    104108
    105 function bp_users_add_settings_nav() {
    106     global $bp;
    107 
    108     // Register this in the active components array
    109     $bp->active_components[$bp->settings->slug] = $bp->settings->id;
    110 
    111     do_action( 'bp_core_settings_setup_nav' );
    112 }
    113 
    114109?>
  • trunk/bp-users/bp-users-functions.php

    r3767 r3778  
    447447 * @uses get_site_option Checks if account deletion is allowed
    448448 */
    449 function bp_core_delete_account( $user_id = false ) {
     449function bp_core_delete_account( $user_id = 0 ) {
    450450    global $bp, $wp_version;
    451451
  • trunk/bp-users/bp-users-loader.php

    r3767 r3778  
    9999
    100100        // Users is active
    101         $bp->active_components[$this->slug] = $this->id;
     101        $bp->active_components[$this->id] = $this->id;
    102102       
    103103        /** Default Profile Component *****************************************/
     
    135135        bp_core_new_nav_item( array(
    136136            'name'                => __( 'User', 'buddypress' ),
    137             'slug'                => $bp->users->slug,
     137            'slug'                => $this->slug,
    138138            'position'            => 10,
    139139            'screen_function'     => 'bp_users_screen_my_users',
    140140            'default_subnav_slug' => 'just-me',
    141             'item_css_id'         => $bp->users->id )
    142         );
     141            'item_css_id'         => $this->id
     142        ) );
    143143
    144144        // Stop if there is no user displayed or logged in
     
    149149        $user_domain   = ( isset( $bp->displayed_user->domain ) )               ? $bp->displayed_user->domain               : $bp->loggedin_user->domain;
    150150        $user_login    = ( isset( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;
    151         $users_link = $user_domain . $bp->users->slug . '/';
     151        $users_link    = $user_domain . $this->slug . '/';
    152152
    153153        // Add the subnav items to the users nav item if we are using a theme that supports this
     
    156156            'slug'            => 'just-me',
    157157            'parent_url'      => $users_link,
    158             'parent_slug'     => $bp->users->slug,
     158            'parent_slug'     => $this->slug,
    159159            'screen_function' => 'bp_users_screen_my_users',
    160160            'position'        => 10
     
    167167                'slug'            => BP_FRIENDS_SLUG,
    168168                'parent_url'      => $users_link,
    169                 'parent_slug'     => $bp->users->slug,
     169                'parent_slug'     => $this->slug,
    170170                'screen_function' => 'bp_users_screen_friends',
    171171                'position'        => 20,
     
    180180                'slug'            => BP_GROUPS_SLUG,
    181181                'parent_url'      => $users_link,
    182                 'parent_slug'     => $bp->users->slug,
     182                'parent_slug'     => $this->slug,
    183183                'screen_function' => 'bp_users_screen_groups',
    184184                'position'        => 30,
     
    192192            'slug'            => 'favorites',
    193193            'parent_url'      => $users_link,
    194             'parent_slug'     => $bp->users->slug,
     194            'parent_slug'     => $this->slug,
    195195            'screen_function' => 'bp_users_screen_favorites',
    196196            'position'        => 40,
     
    203203            'slug'            => 'mentions',
    204204            'parent_url'      => $users_link,
    205             'parent_slug'     => $bp->users->slug,
     205            'parent_slug'     => $this->slug,
    206206            'screen_function' => 'bp_users_screen_mentions',
    207207            'position'        => 50,
  • trunk/bp-users/bp-users-template.php

    r3767 r3778  
    11<?php
     2
     3
     4/***
     5 * Members template loop that will allow you to loop all members or friends of a member
     6 * if you pass a user_id.
     7 */
     8
     9class BP_Core_Members_Template {
     10    var $current_member = -1;
     11    var $member_count;
     12    var $members;
     13    var $member;
     14
     15    var $in_the_loop;
     16
     17    var $pag_page;
     18    var $pag_num;
     19    var $pag_links;
     20    var $total_member_count;
     21
     22    function bp_core_members_template( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude ) {
     23        global $bp;
     24
     25        $this->pag_page  = !empty( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : (int)$page_number;
     26        $this->pag_num   = !empty( $_REQUEST['num'] )   ? intval( $_REQUEST['num'] )   : (int)$per_page;
     27        $this->type      = $type;
     28
     29        if ( !$this->pag_num )
     30            $this->pag_num = 1;
     31
     32        if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] )
     33            $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras, $exclude );
     34        else if ( false !== $include )
     35            $this->members = BP_Core_User::get_specific_users( $include, $this->pag_num, $this->pag_page, $populate_extras );
     36        else
     37            $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras, 'exclude' => $exclude ) );
     38
     39        if ( !$max || $max >= (int)$this->members['total'] )
     40            $this->total_member_count = (int)$this->members['total'];
     41        else
     42            $this->total_member_count = (int)$max;
     43
     44        $this->members = $this->members['users'];
     45
     46        if ( $max ) {
     47            if ( $max >= count( $this->members ) ) {
     48                $this->member_count = count( $this->members );
     49            } else {
     50                $this->member_count = (int)$max;
     51            }
     52        } else {
     53            $this->member_count = count( $this->members );
     54        }
     55
     56        if ( (int)$this->total_member_count && (int)$this->pag_num ) {
     57            $this->pag_links = paginate_links( array(
     58                'base'      => add_query_arg( 'upage', '%#%' ),
     59                'format'    => '',
     60                'total'     => ceil( (int)$this->total_member_count / (int)$this->pag_num ),
     61                'current'   => (int) $this->pag_page,
     62                'prev_text' => '&larr;',
     63                'next_text' => '&rarr;',
     64                'mid_size'   => 1
     65            ) );
     66        }
     67    }
     68
     69    function has_members() {
     70        if ( $this->member_count )
     71            return true;
     72
     73        return false;
     74    }
     75
     76    function next_member() {
     77        $this->current_member++;
     78        $this->member = $this->members[$this->current_member];
     79
     80        return $this->member;
     81    }
     82
     83    function rewind_members() {
     84        $this->current_member = -1;
     85        if ( $this->member_count > 0 ) {
     86            $this->member = $this->members[0];
     87        }
     88    }
     89
     90    function members() {
     91        if ( $this->current_member + 1 < $this->member_count ) {
     92            return true;
     93        } elseif ( $this->current_member + 1 == $this->member_count ) {
     94            do_action('member_loop_end');
     95            // Do some cleaning up after the loop
     96            $this->rewind_members();
     97        }
     98
     99        $this->in_the_loop = false;
     100        return false;
     101    }
     102
     103    function the_member() {
     104        global $member, $bp;
     105
     106        $this->in_the_loop = true;
     107        $this->member = $this->next_member();
     108
     109        if ( 0 == $this->current_member ) // loop has just started
     110            do_action('member_loop_start');
     111    }
     112}
     113
     114function bp_rewind_members() {
     115    global $members_template;
     116
     117    return $members_template->rewind_members();
     118}
     119
     120function bp_has_members( $args = '' ) {
     121    global $bp, $members_template;
     122
     123    /***
     124     * Set the defaults based on the current page. Any of these will be overridden
     125     * if arguments are directly passed into the loop. Custom plugins should always
     126     * pass their parameters directly to the loop.
     127     */
     128    $type = 'active';
     129    $user_id = 0;
     130    $page = 1;
     131    $search_terms = null;
     132
     133    // User filtering
     134    if ( !empty( $bp->displayed_user->id ) )
     135        $user_id = $bp->displayed_user->id;
     136
     137    // type: active ( default ) | random | newest | popular | online | alphabetical
     138    $defaults = array(
     139        'type' => $type,
     140        'page' => $page,
     141        'per_page' => 20,
     142        'max' => false,
     143
     144        'include' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users
     145        'exclude' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users
     146
     147        'user_id' => $user_id, // Pass a user_id to only show friends of this user
     148        'search_terms' => $search_terms, // Pass search_terms to filter users by their profile data
     149
     150        'populate_extras' => true // Fetch usermeta? Friend count, last active etc.
     151    );
     152
     153    $r = wp_parse_args( $args, $defaults );
     154    extract( $r );
     155
     156    // Pass a filter if ?s= is set.
     157    if ( is_null( $search_terms ) ) {
     158        if ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) )
     159            $search_terms = $_REQUEST['s'];
     160        else
     161            $search_terms = false;
     162    }
     163
     164    if ( $max ) {
     165        if ( $per_page > $max )
     166            $per_page = $max;
     167    }
     168
     169    // Make sure we return no members if we looking at friendship requests and there are none.
     170    if ( empty( $include ) && bp_is_current_component( $bp->friends->slug ) && 'requests' == $bp->current_action )
     171        return false;
     172
     173    $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras, $exclude );
     174    return apply_filters( 'bp_has_members', $members_template->has_members(), $members_template );
     175}
     176
     177function bp_the_member() {
     178    global $members_template;
     179    return $members_template->the_member();
     180}
     181
     182function bp_members() {
     183    global $members_template;
     184    return $members_template->members();
     185}
     186
     187function bp_members_pagination_count() {
     188    echo bp_get_members_pagination_count();
     189}
     190    function bp_get_members_pagination_count() {
     191        global $bp, $members_template;
     192
     193        $start_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
     194        $from_num = bp_core_number_format( $start_num );
     195        $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
     196        $total = bp_core_number_format( $members_template->total_member_count );
     197
     198        if ( 'active' == $members_template->type )
     199            $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s active members)', 'buddypress' ), $from_num, $to_num, $total );
     200        else if ( 'popular' == $members_template->type )
     201            $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s members with friends)', 'buddypress' ), $from_num, $to_num, $total );
     202        else if ( 'online' == $members_template->type )
     203            $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s members online)', 'buddypress' ), $from_num, $to_num, $total );
     204        else
     205            $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s members)', 'buddypress' ), $from_num, $to_num, $total );
     206
     207        return apply_filters( 'bp_members_pagination_count', $pag . '<span class="ajax-loader"></span>' );
     208    }
     209
     210function bp_members_pagination_links() {
     211    echo bp_get_members_pagination_links();
     212}
     213    function bp_get_members_pagination_links() {
     214        global $members_template;
     215
     216        return apply_filters( 'bp_get_members_pagination_links', $members_template->pag_links );
     217    }
     218
     219/**
     220 * bp_member_user_id()
     221 *
     222 * Echo id from bp_get_member_user_id()
     223 *
     224 * @uses bp_get_member_user_id()
     225 */
     226function bp_member_user_id() {
     227    echo bp_get_member_user_id();
     228}
     229    /**
     230     * bp_get_member_user_id()
     231     *
     232     * Get the id of the user in a members loop
     233     *
     234     * @global object $members_template
     235     * @return string Members id
     236     */
     237    function bp_get_member_user_id() {
     238        global $members_template;
     239
     240        return apply_filters( 'bp_get_member_user_id', $members_template->member->id );
     241    }
     242
     243/**
     244 * bp_member_user_nicename()
     245 *
     246 * Echo nicename from bp_get_member_user_nicename()
     247 *
     248 * @uses bp_get_member_user_nicename()
     249 */
     250function bp_member_user_nicename() {
     251    echo bp_get_member_user_nicename();
     252}
     253    /**
     254     * bp_get_member_user_nicename()
     255     *
     256     * Get the nicename of the user in a members loop
     257     *
     258     * @global object $members_template
     259     * @return string Members nicename
     260     */
     261    function bp_get_member_user_nicename() {
     262        global $members_template;
     263        return apply_filters( 'bp_get_member_user_nicename', $members_template->member->user_nicename );
     264    }
     265
     266/**
     267 * bp_member_user_login()
     268 *
     269 * Echo login from bp_get_member_user_login()
     270 *
     271 * @uses bp_get_member_user_login()
     272 */
     273function bp_member_user_login() {
     274    echo bp_get_member_user_login();
     275}
     276    /**
     277     * bp_get_member_user_login()
     278     *
     279     * Get the login of the user in a members loop
     280     *
     281     * @global object $members_template
     282     * @return string Members login
     283     */
     284    function bp_get_member_user_login() {
     285        global $members_template;
     286        return apply_filters( 'bp_get_member_user_login', $members_template->member->user_login );
     287    }
     288
     289/**
     290 * bp_member_user_email()
     291 *
     292 * Echo email address from bp_get_member_user_email()
     293 *
     294 * @uses bp_get_member_user_email()
     295 */
     296function bp_member_user_email() {
     297    echo bp_get_member_user_email();
     298}
     299    /**
     300     * bp_get_member_user_email()
     301     *
     302     * Get the email address of the user in a members loop
     303     *
     304     * @global object $members_template
     305     * @return string Members email address
     306     */
     307    function bp_get_member_user_email() {
     308        global $members_template;
     309        return apply_filters( 'bp_get_member_user_email', $members_template->member->user_email );
     310    }
     311
     312function bp_member_is_loggedin_user() {
     313    global $bp, $members_template;
     314    return apply_filters( 'bp_member_is_loggedin_user', $bp->loggedin_user->id == $members_template->member->id ? true : false );
     315}
     316
     317function bp_member_avatar( $args = '' ) {
     318    echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) );
     319}
     320    function bp_get_member_avatar( $args = '' ) {
     321        global $bp, $members_template;
     322
     323        $defaults = array(
     324            'type' => 'thumb',
     325            'width' => false,
     326            'height' => false,
     327            'class' => 'avatar',
     328            'id' => false,
     329            'alt' => __( 'Profile picture of %s', 'buddypress' )
     330        );
     331
     332        $r = wp_parse_args( $args, $defaults );
     333        extract( $r, EXTR_SKIP );
     334
     335        return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
     336    }
     337
     338function bp_member_permalink() {
     339    echo bp_get_member_permalink();
     340}
     341    function bp_get_member_permalink() {
     342        global $members_template;
     343
     344        return apply_filters( 'bp_get_member_permalink', bp_core_get_user_domain( $members_template->member->id, $members_template->member->user_nicename, $members_template->member->user_login ) );
     345    }
     346    function bp_member_link() { echo bp_get_member_permalink(); }
     347    function bp_get_member_link() { return bp_get_member_permalink(); }
     348
     349function bp_member_name() {
     350    echo apply_filters( 'bp_member_name', bp_get_member_name() );
     351}
     352    function bp_get_member_name() {
     353        global $members_template;
     354
     355        if ( empty($members_template->member->fullname) )
     356            $members_template->member->fullname = $members_template->member->display_name;
     357
     358        return apply_filters( 'bp_get_member_name', $members_template->member->fullname );
     359    }
     360    add_filter( 'bp_get_member_name', 'wp_filter_kses' );
     361    add_filter( 'bp_get_member_name', 'stripslashes' );
     362    add_filter( 'bp_get_member_name', 'strip_tags' );
     363
     364function bp_member_last_active() {
     365    echo bp_get_member_last_active();
     366}
     367    function bp_get_member_last_active() {
     368        global $members_template;
     369
     370        $last_activity = bp_core_get_last_activity( $members_template->member->last_activity, __( 'active %s ago', 'buddypress' ) );
     371
     372        return apply_filters( 'bp_member_last_active', $last_activity );
     373    }
     374
     375function bp_member_latest_update( $args = '' ) {
     376    echo bp_get_member_latest_update( $args );
     377}
     378    function bp_get_member_latest_update( $args = '' ) {
     379        global $members_template, $bp;
     380
     381        $defaults = array(
     382            'length' => 70
     383        );
     384
     385        $r = wp_parse_args( $args, $defaults );
     386        extract( $r, EXTR_SKIP );
     387
     388        if ( !isset( $members_template->member->latest_update ) || !$update = maybe_unserialize( $members_template->member->latest_update ) )
     389            return false;
     390
     391        $update_content = apply_filters( 'bp_get_activity_latest_update', strip_tags( bp_create_excerpt( $update['content'], $length ) ) );
     392
     393        if ( !empty( $update['id'] ) )
     394            $update_content .= ' &middot; <a href="' . $bp->root_domain . '/' . $bp->activity->root_slug . '/p/' . $update['id'] . '">' . __( 'View', 'buddypress' ) . '</a>';
     395
     396        return apply_filters( 'bp_get_member_latest_update', $update_content );
     397    }
     398
     399function bp_member_profile_data( $args = '' ) {
     400    echo bp_get_member_profile_data( $args );
     401}
     402    function bp_get_member_profile_data( $args = '' ) {
     403        global $members_template;
     404
     405        if ( !bp_is_active( 'xprofile' ) )
     406            return false;
     407
     408        $defaults = array(
     409            'field' => false, // Field name
     410        );
     411
     412        $r = wp_parse_args( $args, $defaults );
     413        extract( $r, EXTR_SKIP );
     414
     415        // Populate the user if it hasn't been already.
     416        if ( empty( $members_template->member->profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) )
     417            $members_template->member->profile_data = BP_XProfile_ProfileData::get_all_for_user( $members_template->member->id );
     418
     419        $data = xprofile_format_profile_field( $members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data'] );
     420
     421        return apply_filters( 'bp_get_member_profile_data', $data );
     422    }
     423
     424function bp_member_registered() {
     425    echo bp_get_member_registered();
     426}
     427    function bp_get_member_registered() {
     428        global $members_template;
     429
     430        $registered = esc_attr( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) );
     431
     432        return apply_filters( 'bp_member_last_active', $registered );
     433    }
     434
     435function bp_member_random_profile_data() {
     436    global $members_template;
     437
     438    if ( function_exists( 'xprofile_get_random_profile_data' ) ) { ?>
     439        <?php $random_data = xprofile_get_random_profile_data( $members_template->member->id, true ); ?>
     440            <strong><?php echo wp_filter_kses( $random_data[0]->name ) ?></strong>
     441            <?php echo wp_filter_kses( $random_data[0]->value ) ?>
     442    <?php }
     443}
     444
     445function bp_member_hidden_fields() {
     446    if ( isset( $_REQUEST['s'] ) )
     447        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ) . '" name="search_terms" />';
     448
     449    if ( isset( $_REQUEST['letter'] ) )
     450        echo '<input type="hidden" id="selected_letter" value="' . esc_attr( $_REQUEST['letter'] ) . '" name="selected_letter" />';
     451
     452    if ( isset( $_REQUEST['members_search'] ) )
     453        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['members_search'] ) . '" name="search_terms" />';
     454}
     455
     456function bp_directory_members_search_form() {
     457    global $bp;
     458
     459    $default_search_value = bp_get_search_default_text();
     460    $search_value = !empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : $default_search_value; ?>
     461
     462    <form action="" method="get" id="search-members-form">
     463        <label><input type="text" name="s" id="members_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php echo $default_search_value ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $default_search_value ?>';}" /></label>
     464        <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
     465    </form>
     466
     467<?php
     468}
     469
     470function bp_total_site_member_count() {
     471    echo bp_get_total_site_member_count();
     472}
     473    function bp_get_total_site_member_count() {
     474        return apply_filters( 'bp_get_total_site_member_count', bp_core_number_format( bp_core_get_total_member_count() ) );
     475    }
     476
     477
     478/** Navigation and other misc template tags **/
     479
     480/**
     481 * bp_get_nav()
     482 * TEMPLATE TAG
     483 *
     484 * Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install.
     485 * Each component adds to this navigation array within its own [component_name]_setup_nav() function.
     486 *
     487 * This navigation array is the top level navigation, so it contains items such as:
     488 *      [Blog, Profile, Messages, Groups, Friends] ...
     489 *
     490 * The function will also analyze the current component the user is in, to determine whether
     491 * or not to highlight a particular nav item.
     492 *
     493 * @package BuddyPress Core
     494 * @todo Move to a back-compat file?
     495 * @deprecated Does not seem to be called anywhere in the core
     496 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     497 */
     498function bp_get_loggedin_user_nav() {
     499    global $bp, $current_blog;
     500
     501    // Loop through each navigation item
     502    foreach( (array) $bp->bp_nav as $nav_item ) {
     503        // If the current component matches the nav item id, then add a highlight CSS class.
     504        if ( !bp_is_directory() && $bp->active_components[$bp->current_component] == $nav_item['css_id'] )
     505            $selected = ' class="current selected"';
     506        else
     507            $selected = '';
     508
     509        /* If we are viewing another person (current_userid does not equal loggedin_user->id)
     510           then check to see if the two users are friends. if they are, add a highlight CSS class
     511           to the friends nav item if it exists. */
     512        if ( !bp_is_my_profile() && $bp->displayed_user->id ) {
     513            $selected = '';
     514
     515            if ( bp_is_active( 'friends' ) ) {
     516                if ( $nav_item['css_id'] == $bp->friends->id ) {
     517                    if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
     518                        $selected = ' class="current selected"';
     519                }
     520            }
     521        }
     522
     523        // echo out the final list item
     524        echo apply_filters( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item );
     525    }
     526
     527    // Always add a log out list item to the end of the navigation
     528    if ( function_exists( 'wp_logout_url' ) )
     529        $logout_link = '<li><a id="wp-logout" href="' .  wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
     530    else
     531        $logout_link = '<li><a id="wp-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
     532
     533    echo apply_filters( 'bp_logout_nav_link', $logout_link );
     534}
     535
     536/**
     537 * Uses the $bp->bp_nav global to render out the user navigation when viewing another user other than
     538 * yourself.
     539 *
     540 * @package BuddyPress Core
     541 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     542 */
     543function bp_get_displayed_user_nav() {
     544    global $bp;
     545
     546    foreach ( (array)$bp->bp_nav as $user_nav_item ) {
     547        if ( !$user_nav_item['show_for_displayed_user'] && !bp_is_my_profile() )
     548            continue;
     549
     550        if ( $bp->current_component == $user_nav_item['slug'] )
     551            $selected = ' class="current selected"';
     552        else
     553            $selected = '';
     554
     555        if ( $bp->loggedin_user->domain )
     556            $link = str_replace( $bp->loggedin_user->domain, $bp->displayed_user->domain, $user_nav_item['link'] );
     557        else
     558            $link = $bp->displayed_user->domain . $user_nav_item['link'];
     559
     560        echo apply_filters( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item );
     561    }
     562}
     563
     564/** Avatars *******************************************************************/
     565
     566function bp_loggedin_user_avatar( $args = '' ) {
     567    echo bp_get_loggedin_user_avatar( $args );
     568}
     569    function bp_get_loggedin_user_avatar( $args = '' ) {
     570        global $bp;
     571
     572        $defaults = array(
     573            'type'   => 'thumb',
     574            'width'  => false,
     575            'height' => false,
     576            'html'   => true,
     577            'alt'    => __( 'Profile picture of %s', 'buddypress' )
     578        );
     579
     580        $r = wp_parse_args( $args, $defaults );
     581        extract( $r, EXTR_SKIP );
     582
     583        return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
     584    }
     585
     586function bp_displayed_user_avatar( $args = '' ) {
     587    echo bp_get_displayed_user_avatar( $args );
     588}
     589    function bp_get_displayed_user_avatar( $args = '' ) {
     590        global $bp;
     591
     592        $defaults = array(
     593            'type'   => 'thumb',
     594            'width'  => false,
     595            'height' => false,
     596            'html'   => true,
     597            'alt'    => __( 'Profile picture of %s', 'buddypress' )
     598        );
     599
     600        $r = wp_parse_args( $args, $defaults );
     601        extract( $r, EXTR_SKIP );
     602
     603        return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
     604    }
    2605
    3606function bp_displayed_user_email() {
     
    16619    }
    17620
     621function bp_last_activity( $user_id = 0 ) {
     622    echo apply_filters( 'bp_last_activity', bp_get_last_activity( $user_id ) );
     623}
     624    function bp_get_last_activity( $user_id = 0 ) {
     625        global $bp;
     626
     627        if ( empty( $user_id ) )
     628            $user_id = $bp->displayed_user->id;
     629
     630        $last_activity = bp_core_get_last_activity( get_user_meta( $user_id, 'last_activity', true ), __('active %s ago', 'buddypress') );
     631
     632        return apply_filters( 'bp_get_last_activity', $last_activity );
     633    }   
     634
     635function bp_user_has_access() {
     636    global $bp;
     637
     638    if ( is_super_admin() || is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
     639        $has_access = true;
     640    else
     641        $has_access = false;
     642
     643    return apply_filters( 'bp_user_has_access', $has_access );
     644}
     645
     646function bp_user_firstname() {
     647    echo bp_get_user_firstname();
     648}
     649    function bp_get_user_firstname( $name = false ) {
     650        global $bp;
     651
     652        // Try to get displayed user
     653        if ( empty( $name ) )
     654            $name = $bp->displayed_user->fullname;
     655
     656        // Fall back on logged in user
     657        if ( empty( $name ) )
     658            $name = $bp->loggedin_user->fullname;
     659
     660        $fullname = (array)explode( ' ', $name );
     661
     662        return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );
     663    }
     664
     665function bp_loggedin_user_link() {
     666    echo bp_get_loggedin_user_link();
     667}
     668    function bp_get_loggedin_user_link() {
     669        global $bp;
     670
     671        return apply_filters( 'bp_get_loggedin_user_link', $bp->loggedin_user->domain );
     672    }
     673
     674/* @todo Deprecate incorrectly named function? */
     675function bp_loggedinuser_link() {
     676    global $bp;
     677
     678    if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) )
     679        echo apply_filters( 'bp_loggedin_user_link', $link );
     680}
     681
     682function bp_displayed_user_link() {
     683    echo bp_get_displayed_user_link();
     684}
     685    function bp_get_displayed_user_link() {
     686        global $bp;
     687
     688        return apply_filters( 'bp_get_displayed_user_link', $bp->displayed_user->domain );
     689    }
     690    function bp_user_link() { bp_displayed_user_link(); } // Deprecated.
     691
     692function bp_displayed_user_id() {
     693    global $bp;
     694    return apply_filters( 'bp_displayed_user_id', $bp->displayed_user->id );
     695}
     696    function bp_current_user_id() { return bp_displayed_user_id(); }
     697
     698function bp_loggedin_user_id() {
     699    global $bp;
     700    return apply_filters( 'bp_loggedin_user_id', $bp->loggedin_user->id );
     701}
     702
     703function bp_displayed_user_domain() {
     704    global $bp;
     705    return apply_filters( 'bp_displayed_user_domain', $bp->displayed_user->domain );
     706}
     707
     708function bp_loggedin_user_domain() {
     709    global $bp;
     710    return apply_filters( 'bp_loggedin_user_domain', $bp->loggedin_user->domain );
     711}
     712
     713function bp_displayed_user_fullname() {
     714    echo bp_get_displayed_user_fullname();
     715}
     716    function bp_get_displayed_user_fullname() {
     717        global $bp;
     718
     719        return apply_filters( 'bp_displayed_user_fullname', $bp->displayed_user->fullname );
     720    }
     721    function bp_user_fullname() { echo bp_get_displayed_user_fullname(); }
     722
     723
     724function bp_loggedin_user_fullname() {
     725    echo bp_get_loggedin_user_fullname();
     726}
     727    function bp_get_loggedin_user_fullname() {
     728        global $bp;
     729        return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname );
     730    }
     731
     732function bp_displayed_user_username() {
     733    echo bp_get_displayed_user_username();
     734}
     735    function bp_get_displayed_user_username() {
     736        global $bp;
     737        return apply_filters( 'bp_get_displayed_user_username', bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
     738    }
     739
     740function bp_loggedin_user_username() {
     741    echo bp_get_loggedin_user_username();
     742}
     743    function bp_get_loggedin_user_username() {
     744        global $bp;
     745        return apply_filters( 'bp_get_loggedin_user_username', bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ) );
     746    }
     747
     748/** Signup Form ***************************************************************/
     749
     750function bp_has_custom_signup_page() {
     751    if ( locate_template( array( 'register.php' ), false ) || locate_template( array( '/registration/register.php' ), false ) )
     752        return true;
     753
     754    return false;
     755}
     756
     757function bp_signup_page() {
     758    echo bp_get_signup_page();
     759}
     760    function bp_get_signup_page() {
     761        global $bp;
     762
     763        if ( bp_has_custom_signup_page() )
     764            $page = $bp->root_domain . '/' . BP_REGISTER_SLUG;
     765        else
     766            $page = $bp->root_domain . '/wp-signup.php';
     767
     768        return apply_filters( 'bp_get_signup_page', $page );
     769    }
     770
     771function bp_has_custom_activation_page() {
     772    if ( locate_template( array( 'activate.php' ), false ) || locate_template( array( '/registration/activate.php' ), false ) )
     773        return true;
     774
     775    return false;
     776}
     777
     778function bp_activation_page() {
     779    echo bp_get_activation_page();
     780}
     781    function bp_get_activation_page() {
     782        global $bp;
     783
     784        if ( bp_has_custom_activation_page() )
     785            $page = trailingslashit( $bp->root_domain ) . BP_ACTIVATION_SLUG;
     786        else
     787            $page = trailingslashit( $bp->root_domain ) . 'wp-activate.php';
     788
     789        return apply_filters( 'bp_get_activation_page', $page );
     790    }
     791
     792function bp_signup_username_value() {
     793    echo bp_get_signup_username_value();
     794}
     795    function bp_get_signup_username_value() {
     796        $value = '';
     797        if ( isset( $_POST['signup_username'] ) )
     798            $value = $_POST['signup_username'];
     799
     800        return apply_filters( 'bp_get_signup_username_value', $value );
     801    }
     802
     803function bp_signup_email_value() {
     804    echo bp_get_signup_email_value();
     805}
     806    function bp_get_signup_email_value() {
     807        $value = '';
     808        if ( isset( $_POST['signup_email'] ) )
     809            $value = $_POST['signup_email'];
     810
     811        return apply_filters( 'bp_get_signup_email_value', $value );
     812    }
     813
     814function bp_signup_with_blog_value() {
     815    echo bp_get_signup_with_blog_value();
     816}
     817    function bp_get_signup_with_blog_value() {
     818        $value = '';
     819        if ( isset( $_POST['signup_with_blog'] ) )
     820            $value = $_POST['signup_with_blog'];
     821
     822        return apply_filters( 'bp_get_signup_with_blog_value', $value );
     823    }
     824
     825function bp_signup_blog_url_value() {
     826    echo bp_get_signup_blog_url_value();
     827}
     828    function bp_get_signup_blog_url_value() {
     829        $value = '';
     830        if ( isset( $_POST['signup_blog_url'] ) )
     831            $value = $_POST['signup_blog_url'];
     832
     833        return apply_filters( 'bp_get_signup_blog_url_value', $value );
     834    }
     835
     836function bp_signup_blog_title_value() {
     837    echo bp_get_signup_blog_title_value();
     838}
     839    function bp_get_signup_blog_title_value() {
     840        $value = '';
     841        if ( isset( $_POST['signup_blog_title'] ) )
     842            $value = $_POST['signup_blog_title'];
     843
     844        return apply_filters( 'bp_get_signup_blog_title_value', $value );
     845    }
     846
     847function bp_signup_blog_privacy_value() {
     848    echo bp_get_signup_blog_privacy_value();
     849}
     850    function bp_get_signup_blog_privacy_value() {
     851        $value = '';
     852        if ( isset( $_POST['signup_blog_privacy'] ) )
     853            $value = $_POST['signup_blog_privacy'];
     854
     855        return apply_filters( 'bp_get_signup_blog_privacy_value', $value );
     856    }
     857
     858function bp_signup_avatar_dir_value() {
     859    echo bp_get_signup_avatar_dir_value();
     860}
     861    function bp_get_signup_avatar_dir_value() {
     862        global $bp;
     863
     864        return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
     865    }
     866
     867function bp_current_signup_step() {
     868    echo bp_get_current_signup_step();
     869}
     870    function bp_get_current_signup_step() {
     871        global $bp;
     872
     873        return $bp->signup->step;
     874    }
     875
     876function bp_signup_avatar( $args = '' ) {
     877    echo bp_get_signup_avatar( $args );
     878}
     879    function bp_get_signup_avatar( $args = '' ) {
     880        global $bp;
     881
     882        $defaults = array(
     883            'size' => BP_AVATAR_FULL_WIDTH,
     884            'class' => 'avatar',
     885            'alt' => __( 'Your Avatar', 'buddypress' )
     886        );
     887
     888        $r = wp_parse_args( $args, $defaults );
     889        extract( $r, EXTR_SKIP );
     890
     891        if ( !empty( $_POST['signup_avatar_dir'] ) ) {
     892            $signup_avatar_dir = $_POST['signup_avatar_dir'];
     893        } else if ( !empty( $bp->signup->avatar_dir ) ) {
     894            $signup_avatar_dir = $bp->signup->avatar_dir;
     895        }
     896
     897        if ( empty( $signup_avatar_dir ) ) {
     898            if ( empty( $bp->grav_default->user ) ) {
     899                $default_grav = 'wavatar';
     900            } else if ( 'mystery' == $bp->grav_default->user ) {
     901                $default_grav = apply_filters( 'bp_core_mysteryman_src', BP_PLUGIN_URL . '/bp-core/images/mystery-man.jpg' );
     902            } else {
     903                $default_grav = $bp->grav_default->user;
     904            }
     905
     906            $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
     907            $gravatar_img = '<img src="' . $gravatar_url . md5( strtolower( $_POST['signup_email'] ) ) . '?d=' . $default_grav . '&amp;s=' . $size . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
     908        } else {
     909            $gravatar_img = bp_core_fetch_avatar( array( 'item_id' => $signup_avatar_dir, 'object' => 'signup', 'avatar_dir' => 'avatars/signups', 'type' => 'full', 'width' => $size, 'height' => $size, 'alt' => $alt, 'class' => $class ) );
     910        }
     911
     912        return apply_filters( 'bp_get_signup_avatar', $gravatar_img );
     913    }
     914
     915function bp_signup_allowed() {
     916    echo bp_get_signup_allowed();
     917}
     918    function bp_get_signup_allowed() {
     919        global $bp;
     920
     921        if ( is_multisite() ) {
     922            if ( in_array( $bp->site_options['registration'], array( 'all', 'user' ) ) )
     923                return true;
     924        } else {
     925            if ( (int)get_option( 'users_can_register') )
     926                return true;
     927        }
     928        return false;
     929    }
     930
     931/**
     932 * Hook member activity feed to <head>
     933 *
     934 * @since 1.3
     935 */
     936function bp_users_activity_feed() {
     937    if ( !bp_is_active( 'activity' ) || !bp_is_member() )
     938        return; ?>
     939
     940    <link rel="alternate" type="application/rss+xml" title="<?php bloginfo( 'name' ) ?> | <?php bp_displayed_user_fullname() ?> | <?php _e( 'Activity RSS Feed', 'buddypress' ) ?>" href="<?php bp_member_activity_feed_link() ?>" />
     941
     942<?php
     943}
     944add_action( 'bp_head', 'bp_users_activity_feed' );
     945
    18946?>
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r3592 r3778  
    957957    }
    958958
    959     function get_fullname( $user_id = false ) {
     959    function get_fullname( $user_id = 0 ) {
    960960        global $bp;
    961961
Note: See TracChangeset for help on using the changeset viewer.