Changeset 3778
- Timestamp:
- 01/21/2011 12:03:25 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-loader.php
r3764 r3778 44 44 $this->table_name = $bp->table_prefix . 'bp_activity'; 45 45 $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' ); 46 52 } 47 53 … … 69 75 bp_core_new_nav_item( array( 70 76 'name' => __( 'Activity', 'buddypress' ), 71 'slug' => $ bp->activity->slug,77 'slug' => $this->slug, 72 78 'position' => 10, 73 79 'screen_function' => 'bp_activity_screen_my_activity', 74 80 'default_subnav_slug' => 'just-me', 75 'item_css_id' => $ bp->activity->id )81 'item_css_id' => $this->id ) 76 82 ); 77 83 … … 83 89 $user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain; 84 90 $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 . '/'; 86 92 87 93 // Add the subnav items to the activity nav item if we are using a theme that supports this … … 90 96 'slug' => 'just-me', 91 97 'parent_url' => $activity_link, 92 'parent_slug' => $ bp->activity->slug,98 'parent_slug' => $this->slug, 93 99 'screen_function' => 'bp_activity_screen_my_activity', 94 100 'position' => 10 … … 101 107 'slug' => BP_FRIENDS_SLUG, 102 108 'parent_url' => $activity_link, 103 'parent_slug' => $ bp->activity->slug,109 'parent_slug' => $this->slug, 104 110 'screen_function' => 'bp_activity_screen_friends', 105 111 'position' => 20, … … 114 120 'slug' => BP_GROUPS_SLUG, 115 121 'parent_url' => $activity_link, 116 'parent_slug' => $ bp->activity->slug,122 'parent_slug' => $this->slug, 117 123 'screen_function' => 'bp_activity_screen_groups', 118 124 'position' => 30, … … 126 132 'slug' => 'favorites', 127 133 'parent_url' => $activity_link, 128 'parent_slug' => $ bp->activity->slug,134 'parent_slug' => $this->slug, 129 135 'screen_function' => 'bp_activity_screen_favorites', 130 136 'position' => 40, … … 137 143 'slug' => 'mentions', 138 144 'parent_url' => $activity_link, 139 'parent_slug' => $ bp->activity->slug,145 'parent_slug' => $this->slug, 140 146 'screen_function' => 'bp_activity_screen_mentions', 141 147 'position' => 50, -
trunk/bp-activity/bp-activity-template.php
r3755 r3778 218 218 * pass their parameters directly to the loop. 219 219 */ 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; 224 224 $show_hidden = false; 225 $object = false;226 $primary_id = false;225 $object = false; 226 $primary_id = false; 227 227 228 228 // User filtering … … 309 309 $primary_id = implode( ',', (array)$groups['groups'] ); 310 310 311 $user_id = false;311 $user_id = 0; 312 312 } 313 313 break; … … 324 324 $search_terms = '@' . bp_core_get_username( $user_id, $user_nicename, $user_login ) . '<'; // Start search at @ symbol and stop search at closing tag delimiter. 325 325 $display_comments = 'stream'; 326 $user_id = false;326 $user_id = 0; 327 327 break; 328 328 } … … 330 330 } 331 331 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; 336 335 337 336 // Support for basic filters in earlier BP versions. … … 365 364 366 365 $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 ); 370 369 371 370 return sprintf( __( 'Viewing item %1$s to %2$s (of %3$s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' <span class="ajax-loader"></span>'; … … 393 392 394 393 $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; 397 395 398 396 return apply_filters( 'bp_activity_has_more_items', $has_more_items ); … … 646 644 647 645 $action = $activities_template->activity->action; 648 649 646 $action = apply_filters( 'bp_get_activity_action_pre_meta', $action, &$activities_template->activity ); 650 647 … … 661 658 global $activities_template; 662 659 663 / * Backwards compatibility if action is not being used */660 // Backwards compatibility if action is not being used 664 661 if ( empty( $activities_template->activity->action ) && !empty( $activities_template->activity->content ) ) 665 662 $activities_template->activity->content = bp_insert_activity_meta( $activities_template->activity->content ); … … 744 741 extract( $r, EXTR_SKIP ); 745 742 746 / * Get the ID of the parent activity content */743 // Get the ID of the parent activity content 747 744 if ( !$parent_id = $activities_template->activity->item_id ) 748 745 return false; 749 746 750 / * Get the content of the parent */747 // Get the content of the parent 751 748 if ( empty( $activities_template->activity_parents[$parent_id] ) ) 752 749 return false; … … 757 754 $content = $activities_template->activity_parents[$parent_id]->action . ' ' . $activities_template->activity_parents[$parent_id]->content; 758 755 759 / * Remove the time since content for backwards compatibility */756 // Remove the time since content for backwards compatibility 760 757 $content = str_replace( '<span class="time-since">%s</span>', '', $content ); 761 758 762 / * Remove images */759 // Remove images 763 760 $content = preg_replace( '/<img[^>]*>/Ui', '', $content ); 764 761 … … 788 785 return apply_filters( 'bp_activity_get_comments', $comments_html ); 789 786 } 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 791 789 function bp_activity_recurse_comments( $comment ) { 792 790 global $activities_template, $bp; … … 804 802 $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> · ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $comment->date_recorded ) ); 805 803 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. 807 806 if ( is_user_logged_in() && bp_activity_can_comment_reply( $comment ) ) 808 807 $content .= apply_filters( 'bp_activity_comment_reply_link', '<span class="acomment-replylink"> · <a href="#acomment-' . $comment->id . '" class="acomment-reply" id="acomment-reply-' . $activities_template->activity->id . '">' . __( 'Reply', 'buddypress' ) . '</a></span>', $comment ); 809 808 810 / * Delete link */809 // Delete link 811 810 if ( $bp->loggedin_user->is_super_admin || $bp->loggedin_user->id == $comment->user_id ) { 812 811 $delete_url = wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/?cid=' . $comment->id, 'bp_activity_delete_link' ); … … 950 949 } 951 950 952 function bp_activity_latest_update( $user_id = false) {951 function bp_activity_latest_update( $user_id = 0 ) { 953 952 echo bp_get_activity_latest_update( $user_id ); 954 953 } 955 function bp_get_activity_latest_update( $user_id = false) {954 function bp_get_activity_latest_update( $user_id = 0 ) { 956 955 global $bp; 957 956 … … 981 980 extract( $r, EXTR_SKIP ); 982 981 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 984 983 $components = BP_Activity_Activity::get_recorded_components(); 985 984 … … 1022 1021 $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component ); 1023 1022 1024 / * Make sure all core internal component names are translatable */1023 // Make sure all core internal component names are translatable 1025 1024 $translatable_components = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) ); 1026 1025 … … 1064 1063 } 1065 1064 1066 function bp_total_favorite_count_for_user( $user_id = false) {1065 function bp_total_favorite_count_for_user( $user_id = 0 ) { 1067 1066 echo bp_get_total_favorite_count_for_user( $user_id ); 1068 1067 } 1069 function bp_get_total_favorite_count_for_user( $user_id = false) {1068 function bp_get_total_favorite_count_for_user( $user_id = 0 ) { 1070 1069 return apply_filters( 'bp_get_total_favorite_count_for_user', bp_activity_total_favorites_for_user( $user_id ) ); 1071 1070 } 1072 1071 1073 function bp_total_mention_count_for_user( $user_id = false) {1072 function bp_total_mention_count_for_user( $user_id = 0 ) { 1074 1073 echo bp_get_total_favorite_count_for_user( $user_id ); 1075 1074 } 1076 function bp_get_total_mention_count_for_user( $user_id = false) {1075 function bp_get_total_mention_count_for_user( $user_id = 0 ) { 1077 1076 return apply_filters( 'bp_get_total_mention_count_for_user', get_user_meta( $user_id, 'bp_new_mention_count', true ) ); 1078 1077 } … … 1088 1087 1089 1088 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 1091 function 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 ); 1090 1099 } 1091 1100 … … 1153 1162 global $bp; 1154 1163 1155 $link = '';1156 1157 1164 if ( $bp->current_component == $bp->profile->slug || 'just-me' == $bp->current_action ) 1158 1165 $link = $bp->displayed_user->domain . $bp->activity->slug . '/feed/'; … … 1165 1172 elseif ( 'mentions' == $bp->current_action ) 1166 1173 $link = $bp->displayed_user->domain . $bp->activity->slug . '/mentions/feed/'; 1174 else 1175 $link = ''; 1167 1176 1168 1177 return apply_filters( 'bp_get_activities_member_rss_link', $link ); … … 1171 1180 1172 1181 1173 /* Template tags for RSS feed output*/1182 /** Template tags for RSS feed output *****************************************/ 1174 1183 1175 1184 function bp_activity_feed_item_guid() { … … 1242 1251 * @since 1.3 1243 1252 */ 1244 function bp_ dtheme_sitewide_feed() {1253 function bp_activity_sitewide_feed() { 1245 1254 ?> 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 1247 1258 <?php 1248 1259 } 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; 1260 add_action( 'bp_head', 'bp_activity_sitewide_feed' ); 1261 1259 1262 ?> 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 <?php1262 }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.31269 */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 <?php1276 }1277 add_action( 'bp_head', 'bp_dtheme_group_feed' );1278 ?> -
trunk/bp-blogs/bp-blogs-classes.php
r3592 r3778 69 69 /* Static Functions */ 70 70 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 ) { 72 72 global $bp, $wpdb; 73 73 … … 154 154 } 155 155 156 function get_blogs_for_user( $user_id = false, $show_hidden = false ) {156 function get_blogs_for_user( $user_id = 0, $show_hidden = false ) { 157 157 global $bp, $wpdb; 158 158 … … 183 183 } 184 184 185 function get_blog_ids_for_user( $user_id = false) {185 function get_blog_ids_for_user( $user_id = 0 ) { 186 186 global $bp, $wpdb; 187 187 -
trunk/bp-blogs/bp-blogs-functions.php
r3761 r3778 129 129 add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescription', 10, 2 ); 130 130 131 function bp_blogs_record_post( $post_id, $post, $user_id = false) {131 function bp_blogs_record_post( $post_id, $post, $user_id = 0 ) { 132 132 global $bp, $wpdb; 133 133 … … 328 328 add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 ); 329 329 330 function bp_blogs_remove_post( $post_id, $blog_id = false, $user_id = false) {330 function bp_blogs_remove_post( $post_id, $blog_id = false, $user_id = 0 ) { 331 331 global $current_blog, $bp; 332 332 … … 368 368 } 369 369 370 function bp_blogs_total_blogs_for_user( $user_id = false) {370 function bp_blogs_total_blogs_for_user( $user_id = 0 ) { 371 371 global $bp; 372 372 -
trunk/bp-blogs/bp-blogs-loader.php
r3763 r3778 45 45 46 46 // Notifications 47 $ bp->blogs->notification_callback = 'bp_blogs_format_notifications';47 $this->notification_callback = 'bp_blogs_format_notifications'; 48 48 49 49 // Register this in the active components array 50 $bp->active_components[$this-> slug] = $this->id;50 $bp->active_components[$this->id] = $this->id; 51 51 52 52 // 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' ); 54 54 } 55 55 … … 89 89 bp_core_new_nav_item( array( 90 90 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 91 'slug' => $ bp->blogs->slug,91 'slug' => $this->slug, 92 92 'position' => 30, 93 93 'screen_function' => 'bp_blogs_screen_my_blogs', 94 94 'default_subnav_slug' => 'my-blogs', 95 'item_css_id' => $ bp->blogs->id95 'item_css_id' => $this->id 96 96 ) ); 97 97 -
trunk/bp-blogs/bp-blogs-template.php
r3761 r3778 119 119 */ 120 120 $type = 'active'; 121 $user_id = false;121 $user_id = 0; 122 122 $search_terms = null; 123 123 … … 295 295 add_filter( 'bp_get_total_blog_count', 'bp_core_number_format' ); 296 296 297 function bp_total_blog_count_for_user( $user_id = false) {297 function bp_total_blog_count_for_user( $user_id = 0 ) { 298 298 echo bp_get_total_blog_count_for_user( $user_id ); 299 299 } 300 function bp_get_total_blog_count_for_user( $user_id = false) {300 function bp_get_total_blog_count_for_user( $user_id = 0 ) { 301 301 return apply_filters( 'bp_get_total_blog_count_for_user', bp_blogs_total_blogs_for_user( $user_id ) ); 302 302 } -
trunk/bp-core/bp-core-classes.php
r3685 r3778 107 107 /* Static Functions */ 108 108 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 ) { 110 110 global $wpdb, $bp; 111 111 -
trunk/bp-core/bp-core-template.php
r3767 r3778 1 1 <?php 2 /***3 * Members template loop that will allow you to loop all members or friends of a member4 * 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 else35 $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 else40 $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' => '←',61 'next_text' => '→',62 'mid_size' => 163 ) );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 loop94 $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 started108 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 overridden123 * if arguments are directly passed into the loop. Custom plugins should always124 * 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 filtering132 if ( !empty( $bp->displayed_user->id ) )133 $user_id = $bp->displayed_user->id;134 135 // type: active ( default ) | random | newest | popular | online | alphabetical136 $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 users143 'exclude' => false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users144 145 'user_id' => $user_id, // Pass a user_id to only show friends of this user146 'search_terms' => $search_terms, // Pass search_terms to filter users by their profile data147 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 else159 $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 else203 $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 loop231 *232 * @global object $members_template233 * @return string Members id234 */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 loop255 *256 * @global object $members_template257 * @return string Members nicename258 */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 loop278 *279 * @global object $members_template280 * @return string Members login281 */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 loop301 *302 * @global object $members_template303 * @return string Members email address304 */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' => 70381 );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 .= ' · <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 name408 );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 <?php469 }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 TAG484 *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 whether492 * or not to highlight a particular nav item.493 *494 * @package BuddyPress Core495 * @todo Move to a back-compat file?496 * @deprecated Does not seem to be called anywhere in the core497 * @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 else508 $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 class512 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&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 than540 * yourself.541 *542 * @package BuddyPress Core543 * @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 else555 $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 else560 $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 }565 2 566 3 /** … … 591 28 return false; 592 29 593 / * Loop through each navigation item */30 // Loop through each navigation item 594 31 foreach ( (array)$bp->bp_options_nav[$component_index] as $subnav_item ) { 595 32 if ( !$subnav_item['user_has_access'] ) 596 33 continue; 597 34 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. 599 36 if ( $subnav_item['slug'] == $bp->current_action ) { 600 37 $selected = ' class="current selected"'; … … 603 40 } 604 41 605 / * echo out the final list item */42 // echo out the final list item 606 43 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 ); 607 44 } … … 648 85 global $comment; 649 86 650 if ( function_exists( 'bp_core_fetch_avatar') ) {87 if ( function_exists( 'bp_core_fetch_avatar' ) ) 651 88 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') ) 653 90 get_avatar(); 654 }655 91 } 656 92 … … 658 94 global $post; 659 95 660 if ( function_exists( 'bp_core_fetch_avatar') ) {96 if ( function_exists( 'bp_core_fetch_avatar' ) ) 661 97 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') ) 663 99 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 } 706 101 707 102 function bp_avatar_admin_step() { … … 832 227 833 228 function bp_exists( $component_name ) { 834 if ( function_exists( $component_name . '_install') )229 if ( function_exists( $component_name . '_install' ) ) 835 230 return true; 836 231 … … 945 340 wp_print_styles(); 946 341 } 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 else964 $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 else985 $page = trailingslashit( $bp->root_domain ) . 'wp-activate.php';986 987 return apply_filters( 'bp_get_activation_page', $page );988 }989 342 990 343 /** … … 1194 547 add_filter( 'bp_get_total_member_count', 'bp_core_number_format' ); 1195 548 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 . '&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 1337 549 function bp_blog_signup_allowed() { 1338 550 echo bp_get_blog_signup_allowed(); … … 1362 574 return apply_filters( 'bp_registration_needs_activation', true ); 1363 575 } 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 }1374 576 1375 577 function bp_get_option( $option_name ) { … … 1403 605 } 1404 606 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 ****************************************/ 1538 608 1539 609 function bp_current_component() { -
trunk/bp-forums/bp-forums-loader.php
r3769 r3778 389 389 } 390 390 391 function bp_forums_total_topic_count_for_user( $user_id = false) {391 function bp_forums_total_topic_count_for_user( $user_id = 0 ) { 392 392 global $bp; 393 393 -
trunk/bp-forums/bp-forums-template.php
r3757 r3778 170 170 */ 171 171 $type = 'newest'; 172 $user_id = false;172 $user_id = 0; 173 173 $forum_id = false; 174 174 $search_terms = false; … … 1098 1098 } 1099 1099 1100 function bp_forum_topic_count_for_user( $user_id = false) {1100 function bp_forum_topic_count_for_user( $user_id = 0 ) { 1101 1101 echo bp_get_forum_topic_count_for_user( $user_id ); 1102 1102 } 1103 function bp_get_forum_topic_count_for_user( $user_id = false) {1103 function bp_get_forum_topic_count_for_user( $user_id = 0 ) { 1104 1104 return apply_filters( 'bp_get_forum_topic_count_for_user', bp_forums_total_topic_count_for_user( $user_id ) ); 1105 1105 } 1106 1106 1107 function bp_forum_topic_count( $user_id = false) {1107 function bp_forum_topic_count( $user_id = 0 ) { 1108 1108 echo bp_get_forum_topic_count( $user_id ); 1109 1109 } 1110 function bp_get_forum_topic_count( $user_id = false) {1110 function bp_get_forum_topic_count( $user_id = 0 ) { 1111 1111 return apply_filters( 'bp_get_forum_topic_count', bp_forums_total_topic_count( $user_id ) ); 1112 1112 } -
trunk/bp-friends/bp-friends-classes.php
r3369 r3778 117 117 } 118 118 119 function total_friend_count( $user_id = false) {119 function total_friend_count( $user_id = 0 ) { 120 120 global $wpdb, $bp; 121 121 -
trunk/bp-friends/bp-friends-template.php
r3757 r3778 266 266 } 267 267 268 function bp_get_friend_ids( $user_id = false) {268 function bp_get_friend_ids( $user_id = 0 ) { 269 269 global $bp; 270 270 -
trunk/bp-groups/bp-groups-classes.php
r3648 r3778 166 166 } 167 167 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 ) { 169 169 global $wpdb, $bp; 170 170 … … 256 256 } 257 257 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 ) { 259 259 global $wpdb, $bp; 260 260 … … 361 361 } 362 362 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 ) { 364 364 global $wpdb, $bp, $bbdb; 365 365 … … 483 483 } 484 484 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 ) { 486 486 global $wpdb, $bp; 487 487 … … 600 600 var $user; 601 601 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 ) { 603 603 if ( $user_id && $group_id && !$id ) { 604 604 $this->user_id = $user_id; … … 852 852 } 853 853 854 function total_group_count( $user_id = false) {854 function total_group_count( $user_id = 0 ) { 855 855 global $bp, $wpdb; 856 856 -
trunk/bp-groups/bp-groups-loader.php
r3757 r3778 2202 2202 /*** Group Invitations *********************************************************/ 2203 2203 2204 function groups_get_invites_for_user( $user_id = false, $limit = false, $page = false, $exclude = false ) {2204 function groups_get_invites_for_user( $user_id = 0, $limit = false, $page = false, $exclude = false ) { 2205 2205 global $bp; 2206 2206 … … 2445 2445 } 2446 2446 2447 function groups_accept_membership_request( $membership_id, $user_id = false, $group_id = false ) {2447 function groups_accept_membership_request( $membership_id, $user_id = 0, $group_id = false ) { 2448 2448 global $bp; 2449 2449 … … 2484 2484 } 2485 2485 2486 function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) {2486 function groups_reject_membership_request( $membership_id, $user_id = 0, $group_id = false ) { 2487 2487 if ( !$membership = groups_delete_membership_request( $membership_id, $user_id, $group_id ) ) 2488 2488 return false; … … 2497 2497 } 2498 2498 2499 function groups_delete_membership_request( $membership_id, $user_id = false, $group_id = false ) {2499 function groups_delete_membership_request( $membership_id, $user_id = 0, $group_id = false ) { 2500 2500 if ( $user_id && $group_id ) 2501 2501 $membership = new BP_Groups_Member( $user_id, $group_id ); -
trunk/bp-groups/bp-groups-template.php
r3757 r3778 895 895 } 896 896 897 function bp_group_member_demote_link( $user_id = false) {897 function bp_group_member_demote_link( $user_id = 0 ) { 898 898 global $members_template; 899 899 … … 903 903 echo bp_get_group_member_demote_link( $user_id ); 904 904 } 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 ) { 906 906 global $members_template, $groups_template, $bp; 907 907 … … 915 915 } 916 916 917 function bp_group_member_ban_link( $user_id = false) {917 function bp_group_member_ban_link( $user_id = 0 ) { 918 918 global $members_template; 919 919 … … 923 923 echo bp_get_group_member_ban_link( $user_id ); 924 924 } 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 ) { 926 926 global $members_template, $groups_template, $bp; 927 927 … … 932 932 } 933 933 934 function bp_group_member_unban_link( $user_id = false) {934 function bp_group_member_unban_link( $user_id = 0 ) { 935 935 global $members_template; 936 936 … … 940 940 echo bp_get_group_member_unban_link( $user_id ); 941 941 } 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 ) { 943 943 global $members_template, $groups_template; 944 944 … … 953 953 954 954 955 function bp_group_member_remove_link( $user_id = false) {955 function bp_group_member_remove_link( $user_id = 0 ) { 956 956 global $members_template; 957 957 … … 961 961 echo bp_get_group_member_remove_link( $user_id ); 962 962 } 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 ) { 964 964 global $members_template, $groups_template; 965 965 … … 1352 1352 } 1353 1353 1354 function bp_total_group_count_for_user( $user_id = false) {1354 function bp_total_group_count_for_user( $user_id = 0 ) { 1355 1355 echo bp_get_total_group_count_for_user( $user_id ); 1356 1356 } 1357 function bp_get_total_group_count_for_user( $user_id = false) {1357 function bp_get_total_group_count_for_user( $user_id = 0 ) { 1358 1358 return apply_filters( 'bp_get_total_group_count_for_user', groups_total_groups_for_user( $user_id ) ); 1359 1359 } … … 2375 2375 */ 2376 2376 2377 /** 2378 * Hook group activity feed to <head> 2379 * 2380 * @since 1.3 2381 */ 2382 function 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 } 2390 add_action( 'bp_head', 'bp_groups_activity_feed' ); 2391 2377 2392 function bp_group_activity_feed_link() { 2378 2393 echo bp_get_group_activity_feed_link(); -
trunk/bp-settings/bp-settings-loader.php
r3757 r3778 31 31 $this->slug = BP_SETTINGS_SLUG; 32 32 $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; 33 36 } 34 37 … … 56 59 bp_core_new_nav_item( array( 57 60 'name' => __( 'Settings', 'buddypress' ), 58 'slug' => $ bp->settings->slug,61 'slug' => $this->slug, 59 62 'position' => 100, 60 63 'show_for_displayed_user' => bp_users_can_edit_settings(), … … 70 73 'slug' => 'general', 71 74 'parent_url' => $settings_link, 72 'parent_slug' => $ bp->settings->slug,75 'parent_slug' => $this->slug, 73 76 'screen_function' => 'bp_settings_screen_general_settings', 74 77 'position' => 10, … … 81 84 'slug' => 'notifications', 82 85 'parent_url' => $settings_link, 83 'parent_slug' => $ bp->settings->slug,86 'parent_slug' => $this->slug, 84 87 'screen_function' => 'bp_settings_screen_notification_settings', 85 88 'position' => 20, … … 93 96 'slug' => 'delete-account', 94 97 'parent_url' => $settings_link, 95 'parent_slug' => $ bp->settings->slug,98 'parent_slug' => $this->slug, 96 99 'screen_function' => 'bp_settings_screen_delete_account', 97 100 'position' => 90, … … 101 104 } 102 105 } 106 // Create the settingss component 103 107 $bp->settings = new BP_Settings_Component(); 104 108 105 function bp_users_add_settings_nav() {106 global $bp;107 108 // Register this in the active components array109 $bp->active_components[$bp->settings->slug] = $bp->settings->id;110 111 do_action( 'bp_core_settings_setup_nav' );112 }113 114 109 ?> -
trunk/bp-users/bp-users-functions.php
r3767 r3778 447 447 * @uses get_site_option Checks if account deletion is allowed 448 448 */ 449 function bp_core_delete_account( $user_id = false) {449 function bp_core_delete_account( $user_id = 0 ) { 450 450 global $bp, $wp_version; 451 451 -
trunk/bp-users/bp-users-loader.php
r3767 r3778 99 99 100 100 // Users is active 101 $bp->active_components[$this-> slug] = $this->id;101 $bp->active_components[$this->id] = $this->id; 102 102 103 103 /** Default Profile Component *****************************************/ … … 135 135 bp_core_new_nav_item( array( 136 136 'name' => __( 'User', 'buddypress' ), 137 'slug' => $ bp->users->slug,137 'slug' => $this->slug, 138 138 'position' => 10, 139 139 'screen_function' => 'bp_users_screen_my_users', 140 140 'default_subnav_slug' => 'just-me', 141 'item_css_id' => $ bp->users->id )142 ) ;141 'item_css_id' => $this->id 142 ) ); 143 143 144 144 // Stop if there is no user displayed or logged in … … 149 149 $user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain; 150 150 $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 . '/'; 152 152 153 153 // Add the subnav items to the users nav item if we are using a theme that supports this … … 156 156 'slug' => 'just-me', 157 157 'parent_url' => $users_link, 158 'parent_slug' => $ bp->users->slug,158 'parent_slug' => $this->slug, 159 159 'screen_function' => 'bp_users_screen_my_users', 160 160 'position' => 10 … … 167 167 'slug' => BP_FRIENDS_SLUG, 168 168 'parent_url' => $users_link, 169 'parent_slug' => $ bp->users->slug,169 'parent_slug' => $this->slug, 170 170 'screen_function' => 'bp_users_screen_friends', 171 171 'position' => 20, … … 180 180 'slug' => BP_GROUPS_SLUG, 181 181 'parent_url' => $users_link, 182 'parent_slug' => $ bp->users->slug,182 'parent_slug' => $this->slug, 183 183 'screen_function' => 'bp_users_screen_groups', 184 184 'position' => 30, … … 192 192 'slug' => 'favorites', 193 193 'parent_url' => $users_link, 194 'parent_slug' => $ bp->users->slug,194 'parent_slug' => $this->slug, 195 195 'screen_function' => 'bp_users_screen_favorites', 196 196 'position' => 40, … … 203 203 'slug' => 'mentions', 204 204 'parent_url' => $users_link, 205 'parent_slug' => $ bp->users->slug,205 'parent_slug' => $this->slug, 206 206 'screen_function' => 'bp_users_screen_mentions', 207 207 'position' => 50, -
trunk/bp-users/bp-users-template.php
r3767 r3778 1 1 <?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 9 class 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' => '←', 63 'next_text' => '→', 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 114 function bp_rewind_members() { 115 global $members_template; 116 117 return $members_template->rewind_members(); 118 } 119 120 function 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 177 function bp_the_member() { 178 global $members_template; 179 return $members_template->the_member(); 180 } 181 182 function bp_members() { 183 global $members_template; 184 return $members_template->members(); 185 } 186 187 function 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 210 function 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 */ 226 function 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 */ 250 function 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 */ 273 function 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 */ 296 function 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 312 function 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 317 function 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 338 function 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 349 function 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 364 function 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 375 function 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 .= ' · <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 399 function 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 424 function 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 435 function 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 445 function 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 456 function 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 470 function 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 */ 498 function 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&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 */ 543 function 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 566 function 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 586 function 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 } 2 605 3 606 function bp_displayed_user_email() { … … 16 619 } 17 620 621 function 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 635 function 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 646 function 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 665 function 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? */ 675 function 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 682 function 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 692 function 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 698 function bp_loggedin_user_id() { 699 global $bp; 700 return apply_filters( 'bp_loggedin_user_id', $bp->loggedin_user->id ); 701 } 702 703 function bp_displayed_user_domain() { 704 global $bp; 705 return apply_filters( 'bp_displayed_user_domain', $bp->displayed_user->domain ); 706 } 707 708 function bp_loggedin_user_domain() { 709 global $bp; 710 return apply_filters( 'bp_loggedin_user_domain', $bp->loggedin_user->domain ); 711 } 712 713 function 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 724 function 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 732 function 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 740 function 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 750 function 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 757 function 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 771 function 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 778 function 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 792 function 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 803 function 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 814 function 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 825 function 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 836 function 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 847 function 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 858 function 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 867 function 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 876 function 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 . '&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 915 function 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 */ 936 function 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 } 944 add_action( 'bp_head', 'bp_users_activity_feed' ); 945 18 946 ?> -
trunk/bp-xprofile/bp-xprofile-classes.php
r3592 r3778 957 957 } 958 958 959 function get_fullname( $user_id = false) {959 function get_fullname( $user_id = 0 ) { 960 960 global $bp; 961 961
Note: See TracChangeset
for help on using the changeset viewer.