Changeset 2076 for branches/1.1/bp-core/bp-core-templatetags.php
- Timestamp:
- 11/02/2009 06:56:42 PM (17 years ago)
- File:
-
- 1 edited
-
branches/1.1/bp-core/bp-core-templatetags.php (modified) (88 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1/bp-core/bp-core-templatetags.php
r2075 r2076 6 6 * Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install. 7 7 * Each component adds to this navigation array within its own [component_name]_setup_nav() function. 8 * 8 * 9 9 * This navigation array is the top level navigation, so it contains items such as: 10 10 * [Blog, Profile, Messages, Groups, Friends] ... … … 18 18 function bp_get_loggedin_user_nav() { 19 19 global $bp, $current_blog; 20 20 21 21 /* Loop through each navigation item */ 22 22 foreach( (array) $bp->bp_nav as $nav_item ) { … … 27 27 $selected = ''; 28 28 } 29 29 30 30 /* If we are viewing another person (current_userid does not equal loggedin_user->id) 31 31 then check to see if the two users are friends. if they are, add a highlight CSS class … … 33 33 if ( !bp_is_home() && $bp->displayed_user->id ) { 34 34 $selected = ''; 35 35 36 36 if ( function_exists('friends_install') ) { 37 37 if ( $nav_item['css_id'] == $bp->friends->id ) { … … 41 41 } 42 42 } 43 43 44 44 /* echo out the final list item */ 45 45 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 ); 46 46 } 47 47 48 48 /* Always add a log out list item to the end of the navigation */ 49 49 if ( function_exists( 'wp_logout_url' ) ) { 50 $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 50 $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 51 51 } else { 52 52 $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>'; 53 53 } 54 54 55 55 echo apply_filters( 'bp_logout_nav_link', $logout_link ); 56 56 } … … 72 72 73 73 foreach ( $bp->bp_nav as $user_nav_item ) { 74 if ( !$user_nav_item['show_for_displayed_user'] ) 74 if ( !$user_nav_item['show_for_displayed_user'] ) 75 75 continue; 76 76 77 77 if ( $bp->current_component == $user_nav_item['css_id'] ) 78 78 $selected = ' class="current"'; 79 79 else 80 80 $selected = ''; 81 81 82 82 if ( $bp->loggedin_user->domain ) 83 83 $link = str_replace( $bp->loggedin_user->domain, $bp->displayed_user->domain, $user_nav_item['link'] ); 84 84 else 85 85 $link = $bp->displayed_user->domain . $user_nav_item['link']; 86 86 87 87 echo apply_filters( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], '<li id="li-subnav-' . $user_nav_item['css_id'] . '" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item ); 88 } 88 } 89 89 } 90 90 /* DEPRECATED - use bp_get_displayed_user_nav() */ 91 91 function bp_get_user_nav() { bp_get_displayed_user_nav(); } 92 92 93 93 /** 94 94 * bp_get_options_nav() … … 97 97 * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component. 98 98 * Each component adds to its sub navigation array within its own [component_name]_setup_nav() function. 99 * 99 * 100 100 * This sub navigation array is the secondary level navigation, so for profile it contains: 101 101 * [Public, Edit Profile, Change Avatar] … … 103 103 * The function will also analyze the current action for the current component to determine whether 104 104 * or not to highlight a particular sub nav item. 105 * 105 * 106 106 * @package BuddyPress Core 107 107 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals() … … 118 118 if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 ) 119 119 return false; 120 120 121 121 /* Loop through each navigation item */ 122 122 foreach ( $bp->bp_options_nav[$bp->current_component] as $subnav_item ) { 123 123 if ( !$subnav_item['user_has_access'] ) 124 124 continue; 125 125 126 126 /* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */ 127 127 if ( $subnav_item['slug'] == $bp->current_action ) { … … 130 130 $selected = ''; 131 131 } 132 132 133 133 /* echo out the final list item */ 134 echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="li-subnav-' . $subnav_item['css_id'] . '" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item ); 134 echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="li-subnav-' . $subnav_item['css_id'] . '" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item ); 135 135 } 136 136 } else { … … 142 142 function bp_get_options_title() { 143 143 global $bp; 144 144 145 145 if ( empty( $bp->bp_options_title ) ) 146 146 $bp->bp_options_title = __( 'Options', 'buddypress' ); 147 147 148 148 echo apply_filters( 'bp_get_options_title', attribute_escape( $bp->bp_options_title ) ); 149 149 } 150 150 151 151 152 152 /** AVATAR TEMPLATE TAGS *******************************************************/ … … 164 164 function bp_has_options_avatar() { 165 165 global $bp; 166 166 167 167 if ( empty( $bp->bp_options_avatar ) ) 168 168 return false; 169 169 170 170 return true; 171 171 } … … 179 179 function bp_comment_author_avatar() { 180 180 global $comment; 181 181 182 182 if ( function_exists('bp_core_fetch_avatar') ) { 183 echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb' ) ) ); 183 echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb' ) ) ); 184 184 } else if ( function_exists('get_avatar') ) { 185 185 get_avatar(); … … 189 189 function bp_post_author_avatar() { 190 190 global $post; 191 191 192 192 if ( function_exists('bp_core_fetch_avatar') ) { 193 echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) ); 193 echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) ); 194 194 } else if ( function_exists('get_avatar') ) { 195 195 get_avatar(); … … 211 211 $r = wp_parse_args( $args, $defaults ); 212 212 extract( $r, EXTR_SKIP ); 213 213 214 214 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 ) ) ); 215 } 215 } 216 216 217 217 function bp_displayed_user_avatar( $args = '' ) { … … 229 229 $r = wp_parse_args( $args, $defaults ); 230 230 extract( $r, EXTR_SKIP ); 231 231 232 232 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 ) ) ); 233 } 233 } 234 234 235 235 function bp_avatar_admin_step() { … … 256 256 function bp_get_avatar_to_crop_src() { 257 257 global $bp; 258 258 259 259 return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) ); 260 260 } 261 261 262 262 function bp_avatar_cropper() { 263 263 global $bp; 264 264 265 265 echo '<img id="avatar-to-crop" class="avatar" src="' . $bp->avatar_admin->image . '" />'; 266 266 } … … 272 272 function bp_is_home() { 273 273 global $bp; 274 274 275 275 if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id ) 276 276 return true; 277 277 278 278 return false; 279 279 } … … 281 281 function bp_last_activity( $user_id = false, $echo = true ) { 282 282 global $bp; 283 283 284 284 if ( !$user_id ) 285 285 $user_id = $bp->displayed_user->id; 286 286 287 287 $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') ); 288 288 … … 295 295 function bp_user_link() { 296 296 global $bp; 297 297 298 298 echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain ); 299 299 } … … 301 301 function bp_get_loggedin_user_link() { 302 302 global $bp; 303 303 304 304 return $bp->loggedin_user->domain; 305 305 } … … 307 307 function bp_get_displayed_user_link() { 308 308 global $bp; 309 309 310 310 return $bp->displayed_user->domain; 311 311 } … … 313 313 function bp_core_get_wp_profile() { 314 314 global $bp; 315 315 316 316 $ud = get_userdata( $bp->displayed_user->id ); 317 317 ?> … … 393 393 if ( function_exists($component_name . '_install') ) 394 394 return true; 395 395 396 396 return false; 397 397 } … … 399 399 function bp_format_time( $time, $just_date = false ) { 400 400 $date = date( get_option('date_format'), $time ); 401 401 402 402 if ( !$just_date ) { 403 403 $date .= ' ' . __( 'at', 'buddypress' ) . date( ' ' . get_option('time_format'), $time ); 404 404 } 405 405 406 406 return apply_filters( 'bp_format_time', $date ); 407 407 } … … 409 409 function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) { 410 410 global $bp; 411 411 412 412 if ( $capitalize ) 413 413 $youtext = bp_core_ucfirst($youtext); 414 414 415 415 if ( $bp->displayed_user->id == $bp->loggedin_user->id ) { 416 416 if ( $echo ) … … 429 429 function bp_your_or_their( $capitalize = true, $echo = true ) { 430 430 global $bp; 431 431 432 432 if ( $capitalize ) 433 433 $yourtext = bp_core_ucfirst($yourtext); 434 434 435 435 if ( $bp->displayed_user->id == $bp->loggedin_user->id ) { 436 436 if ( $echo ) … … 448 448 function bp_loggedinuser_link() { 449 449 global $bp; 450 450 451 451 if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) { 452 452 echo apply_filters( 'bp_loggedinuser_link', $link ); … … 483 483 $title = __( 'Blog — ' . $post->post_title, 'buddypress' ); 484 484 } else if ( is_category() ) { 485 $title = __( 'Blog — Categories — ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' ); 485 $title = __( 'Blog — Categories — ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' ); 486 486 } else if ( is_tag() ) { 487 $title = __( 'Blog — Tags — ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' ); 487 $title = __( 'Blog — Tags — ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' ); 488 488 } else 489 489 $title = __( 'Blog', 'buddypress' ); … … 502 502 $title = get_the_title($post->ID); 503 503 } 504 504 505 505 if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) { 506 506 $blog_title = get_blog_option( $current_blog->blog_id, 'blogname' ); 507 507 } else { 508 $blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 509 } 510 508 $blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 509 } 510 511 511 return apply_filters( 'bp_page_title', $blog_title . ' — ' . attribute_escape( $title ), attribute_escape( $title ) ); 512 512 } … … 519 519 function bp_is_page($page) { 520 520 global $bp; 521 521 522 522 if ( $bp->displayed_user->id || $bp->is_single_item ) 523 523 return false; 524 524 525 525 if ( $page == $bp->current_component || ( is_home() && $page == 'home' && $bp->current_component == $bp->default_component ) || ( $page == BP_MEMBERS_SLUG && !$bp->current_component ) ) 526 526 return true; 527 527 528 528 return false; 529 529 } … … 535 535 if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/register.php') ) 536 536 return true; 537 537 538 538 return false; 539 539 } … … 547 547 function bp_get_signup_page() { 548 548 global $bp; 549 549 550 550 if ( bp_has_custom_signup_page() ) { 551 551 return apply_filters( 'bp_get_signup_page', $bp->root_domain . '/' . BP_REGISTER_SLUG ); … … 561 561 if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/activate.php') ) 562 562 return true; 563 563 564 564 return false; 565 565 } … … 567 567 function bp_activation_page( $echo = true ) { 568 568 global $bp; 569 569 570 570 if ( bp_has_custom_activation_page() ) { 571 571 if ( $echo ) … … 583 583 function bp_search_form_action() { 584 584 global $bp; 585 585 586 586 return apply_filters( 'bp_search_form_action', $bp->root_domain . '/search' ); 587 587 } … … 590 590 // Eventually this won't be needed and a page will be built to integrate all search results. 591 591 $selection_box = '<select name="search-which" id="search-which" style="width: auto">'; 592 592 593 593 if ( function_exists( 'xprofile_install' ) ) { 594 594 $selection_box .= '<option value="members">' . __( 'Members', 'buddypress' ) . '</option>'; 595 595 } 596 596 597 597 if ( function_exists( 'groups_install' ) ) { 598 598 $selection_box .= '<option value="groups">' . __( 'Groups', 'buddypress' ) . '</option>'; … … 602 602 $selection_box .= '<option value="forums">' . __( 'Forums', 'buddypress' ) . '</option>'; 603 603 } 604 604 605 605 if ( function_exists( 'bp_blogs_install' ) ) { 606 606 $selection_box .= '<option value="blogs">' . __( 'Blogs', 'buddypress' ) . '</option>'; 607 607 } 608 608 609 609 $selection_box .= '</select>'; 610 610 611 611 return apply_filters( 'bp_search_form_type_select', $selection_box ); 612 612 } … … 615 615 $form = ' 616 616 <form action="' . bp_search_form_action() . '" method="post" id="search-form"> 617 <input type="text" id="search-terms" name="search-terms" value="" /> 617 <input type="text" id="search-terms" name="search-terms" value="" /> 618 618 ' . bp_search_form_type_select() . ' 619 619 620 620 <input type="submit" name="search-submit" id="search-submit" value="' . __( 'Search', 'buddypress' ) . '" /> 621 621 ' . wp_nonce_field( 'bp_search_form' ) . ' 622 622 </form> 623 623 '; 624 624 625 625 echo apply_filters( 'bp_search_form', $form ); 626 626 } … … 631 631 $logout_link = '<a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>'; 632 632 else 633 $logout_link = '<a href="' . $bp->root_domain . '/wp-login.php?action=logout&redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>'; 633 $logout_link = '<a href="' . $bp->root_domain . '/wp-login.php?action=logout&redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>'; 634 634 635 635 echo apply_filters( 'bp_logout_link', $logout_link ); … … 638 638 function bp_profile_wire_can_post() { 639 639 global $bp; 640 640 641 641 if ( bp_is_home() ) 642 642 return true; 643 643 644 644 if ( function_exists('friends_install') ) { 645 645 if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) ) … … 647 647 else 648 648 return false; 649 } 650 649 } 650 651 651 return true; 652 652 } … … 659 659 <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a></li> 660 660 <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a></li> 661 661 662 662 <?php if ( function_exists( 'groups_install' ) ) { ?> 663 663 <li<?php if ( bp_is_page( $bp->groups->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->groups->slug ?>" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a></li> 664 664 <?php } ?> 665 665 666 666 <?php if ( function_exists( 'bp_blogs_install' ) ) { ?> 667 667 <li<?php if ( bp_is_page( $bp->blogs->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->blogs->slug ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a></li> … … 681 681 function bp_is_directory() { 682 682 global $bp; 683 683 684 684 return $bp->is_directory; 685 685 } … … 689 689 * 690 690 * Fakes an excerpt on any content. Will not truncate words. 691 * 691 * 692 692 * @package BuddyPress Core 693 693 * @param $text str The text to create the excerpt from … … 707 707 $text = implode(' ', $words); 708 708 } 709 709 710 710 return apply_filters( 'bp_create_excerpt', $text ); 711 711 } … … 722 722 * 723 723 * Checks to see if the data passed has been serialized. 724 * 724 * 725 725 * @package BuddyPress Core 726 726 * @param $data str The data that will be checked … … 762 762 return apply_filters( 'bp_get_signup_with_blog_value', $_POST['signup_with_blog'] ); 763 763 } 764 764 765 765 function bp_signup_blog_url_value() { 766 766 echo bp_get_signup_blog_url_value(); … … 789 789 function bp_get_signup_avatar_dir_value() { 790 790 global $bp; 791 791 792 792 return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir ); 793 793 } … … 798 798 function bp_get_current_signup_step() { 799 799 global $bp; 800 800 801 801 return $bp->signup->step; 802 802 } … … 807 807 function bp_get_signup_avatar( $args = '' ) { 808 808 global $bp; 809 809 810 810 $defaults = array( 811 811 'size' => BP_AVATAR_FULL_WIDTH, 812 812 'class' => 'avatar', 813 'alt' => __( 'Your Avatar', 'buddypress' ) 813 'alt' => __( 'Your Avatar', 'buddypress' ) 814 814 ); 815 815 816 816 $r = wp_parse_args( $args, $defaults ); 817 817 extract( $r, EXTR_SKIP ); 818 818 819 819 $signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir; 820 820 … … 827 827 $default_grav = $bp->grav_default->user; 828 828 } 829 829 830 830 $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ); 831 831 return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />'; … … 844 844 function bp_account_was_activated() { 845 845 global $bp; 846 846 847 847 return $bp->activation_complete; 848 848 } … … 863 863 var $pag_links; 864 864 var $total_member_count; 865 865 866 866 function bp_core_members_template( $type, $per_page, $max ) { 867 867 global $bp, $bp_the_member_query; … … 869 869 $this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : 1; 870 870 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 871 871 872 872 if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) { 873 873 $this->members = BP_Core_User::search_users( $_REQUEST['s'], $this->pag_num, $this->pag_page ); … … 879 879 $this->members = BP_Core_User::get_random_users( $this->pag_num, $this->pag_page ); 880 880 break; 881 881 882 882 case 'newest': 883 883 $this->members = BP_Core_User::get_newest_users( $this->pag_num, $this->pag_page ); … … 886 886 case 'popular': 887 887 $this->members = BP_Core_User::get_popular_users( $this->pag_num, $this->pag_page ); 888 break; 888 break; 889 889 890 890 case 'online': 891 891 $this->members = BP_Core_User::get_online_users( $this->pag_num, $this->pag_page ); 892 892 break; 893 893 894 894 case 'alphabetical': 895 895 $this->members = BP_Core_User::get_alphabetical_users( $this->pag_num, $this->pag_page ); 896 896 break; 897 897 898 898 case 'active': default: 899 899 $this->members = BP_Core_User::get_active_users( $this->pag_num, $this->pag_page ); 900 break; 900 break; 901 901 } 902 902 } 903 903 904 904 if ( !$max || $max >= (int)$this->members['total'] ) 905 905 $this->total_member_count = (int)$this->members['total']; … … 917 917 $this->member_count = count($this->members); 918 918 } 919 920 if ( (int) $this->total_member_count && (int) $this->pag_num ) { 919 920 if ( (int) $this->total_member_count && (int) $this->pag_num ) { 921 921 $this->pag_links = paginate_links( array( 922 922 'base' => add_query_arg( 'upage', '%#%' ), … … 927 927 'next_text' => '»', 928 928 'mid_size' => 1 929 )); 929 )); 930 930 } 931 931 } 932 932 933 933 function has_members() { 934 934 if ( $this->member_count ) 935 935 return true; 936 936 937 937 return false; 938 938 } 939 939 940 940 function next_member() { 941 941 $this->current_member++; 942 942 $this->member = $this->members[$this->current_member]; 943 943 944 944 return $this->member; 945 945 } 946 946 947 947 function rewind_members() { 948 948 $this->current_member = -1; … … 951 951 } 952 952 } 953 954 function site_members() { 953 954 function site_members() { 955 955 if ( $this->current_member + 1 < $this->member_count ) { 956 956 return true; … … 964 964 return false; 965 965 } 966 966 967 967 function the_member() { 968 968 global $member, $bp; … … 977 977 wp_cache_set( 'bp_user_' . $user_id, $this->member, 'bp' ); 978 978 } 979 979 980 980 if ( $user_registered ) 981 981 $this->member->user_registered = $user_registered; 982 982 983 983 if ( 0 == $this->current_member ) // loop has just started 984 984 do_action('loop_start'); … … 988 988 function bp_rewind_site_members() { 989 989 global $site_members_template; 990 990 991 991 return $site_members_template->rewind_members(); 992 992 } … … 1005 1005 1006 1006 // type: active ( default ) | random | newest | popular | online | alphabetical 1007 1007 1008 1008 if ( $max ) { 1009 1009 if ( $per_page > $max ) … … 1012 1012 1013 1013 $site_members_template = new BP_Core_Members_Template( $type, $per_page, $max ); 1014 1014 1015 1015 return $site_members_template->has_members(); 1016 1016 } … … 1028 1028 function bp_site_members_pagination_count() { 1029 1029 global $bp, $site_members_template; 1030 1030 1031 1031 $from_num = intval( ( $site_members_template->pag_page - 1 ) * $site_members_template->pag_num ) + 1; 1032 1032 $to_num = ( $from_num + ( $site_members_template->pag_num - 1 ) > $site_members_template->total_member_count ) ? $site_members_template->total_member_count : $from_num + ( $site_members_template->pag_num - 1) ; … … 1041 1041 function bp_get_site_members_pagination_links() { 1042 1042 global $site_members_template; 1043 1043 1044 1044 return apply_filters( 'bp_get_site_members_pagination_links', $site_members_template->pag_links ); 1045 1045 } 1046 1046 1047 function bp_the_site_member_user_id() { 1048 echo bp_get_the_site_member_user_id(); 1049 } 1050 function bp_get_the_site_member_user_id() { 1051 global $site_members_template; 1052 1053 return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id ); 1047 function bp_the_site_member_user_id() { 1048 echo bp_get_the_site_member_user_id(); 1049 } 1050 function bp_get_the_site_member_user_id() { 1051 global $site_members_template; 1052 1053 return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id ); 1054 1054 } 1055 1055 … … 1057 1057 echo apply_filters( 'bp_the_site_member_avatar', bp_get_the_site_member_avatar() ); 1058 1058 } 1059 function bp_get_the_site_member_avatar() { 1060 global $site_members_template; 1059 function bp_get_the_site_member_avatar() { 1060 global $site_members_template; 1061 1061 1062 1062 return apply_filters( 'bp_get_the_site_member_avatar', $site_members_template->member->avatar_thumb ); … … 1100 1100 return apply_filters( 'bp_the_site_member_last_active', strtotime( $site_members_template->member->user_registered ) ); 1101 1101 } 1102 1102 1103 1103 function bp_the_site_member_add_friend_button() { 1104 1104 global $site_members_template; 1105 1105 1106 1106 if ( function_exists( 'bp_add_friend_button' ) ) { 1107 1107 echo bp_add_friend_button( $site_members_template->member->id ); … … 1111 1111 function bp_the_site_member_total_friend_count() { 1112 1112 global $site_members_template; 1113 1113 1114 1114 if ( !(int) $site_members_template->member->total_friends ) 1115 1115 return false; 1116 1116 1117 1117 echo bp_get_the_site_member_total_friend_count(); 1118 1118 } … … 1126 1126 return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $site_members_template->member->total_friends ) ); 1127 1127 else 1128 return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $site_members_template->member->total_friends ) ); 1129 } 1130 1128 return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $site_members_template->member->total_friends ) ); 1129 } 1130 1131 1131 function bp_the_site_member_random_profile_data() { 1132 1132 global $site_members_template; … … 1165 1165 function bp_home_blog_url() { 1166 1166 global $bp, $current_blog; 1167 1167 1168 1168 if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) { 1169 1169 $blog_id = $current_blog->blog_id; … … 1216 1216 function bp_get_loggedin_user_fullname() { 1217 1217 global $bp; 1218 return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname ); 1218 return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname ); 1219 1219 } 1220 1220 1221 1221 function bp_current_component() { 1222 1222 global $bp; 1223 return apply_filters( 'bp_current_component', $bp->current_component ); 1223 return apply_filters( 'bp_current_component', $bp->current_component ); 1224 1224 } 1225 1225 1226 1226 function bp_current_action() { 1227 1227 global $bp; 1228 return apply_filters( 'bp_current_action', $bp->current_action ); 1228 return apply_filters( 'bp_current_action', $bp->current_action ); 1229 1229 } 1230 1230 1231 1231 function bp_current_item() { 1232 1232 global $bp; 1233 return apply_filters( 'bp_current_item', $bp->current_item ); 1233 return apply_filters( 'bp_current_item', $bp->current_item ); 1234 1234 } 1235 1235 1236 1236 function bp_action_variables() { 1237 1237 global $bp; 1238 return apply_filters( 'bp_action_variables', $bp->action_variables ); 1238 return apply_filters( 'bp_action_variables', $bp->action_variables ); 1239 1239 } 1240 1240 … … 1244 1244 function bp_get_root_domain() { 1245 1245 global $bp; 1246 1246 1247 1247 return $bp->root_domain; 1248 1248 } … … 1252 1252 function bp_is_profile_component() { 1253 1253 global $bp; 1254 1254 1255 1255 if ( BP_XPROFILE_SLUG == $bp->current_component ) 1256 1256 return true; 1257 1257 1258 1258 return false; 1259 1259 } … … 1261 1261 function bp_is_activity_component() { 1262 1262 global $bp; 1263 1263 1264 1264 if ( BP_ACTIVITY_SLUG == $bp->current_component ) 1265 1265 return true; 1266 1267 return false; 1266 1267 return false; 1268 1268 } 1269 1269 1270 1270 function bp_is_blogs_component() { 1271 1271 global $bp; 1272 1272 1273 1273 if ( BP_BLOGS_SLUG == $bp->current_component ) 1274 1274 return true; 1275 1276 return false; 1275 1276 return false; 1277 1277 } 1278 1278 1279 1279 function bp_is_wire_component() { 1280 1280 global $bp; 1281 1281 1282 1282 if ( BP_WIRE_SLUG == $bp->current_action || in_array( BP_WIRE_SLUG, (array)$bp->action_variables ) ) 1283 1283 return true; 1284 1285 return false; 1284 1285 return false; 1286 1286 } 1287 1287 1288 1288 function bp_is_messages_component() { 1289 1289 global $bp; 1290 1290 1291 1291 if ( BP_MESSAGES_SLUG == $bp->current_component ) 1292 1292 return true; 1293 1294 return false; 1293 1294 return false; 1295 1295 } 1296 1296 1297 1297 function bp_is_friends_component() { 1298 1298 global $bp; 1299 1299 1300 1300 if ( BP_FRIENDS_SLUG == $bp->current_component ) 1301 1301 return true; 1302 1303 return false; 1302 1303 return false; 1304 1304 } 1305 1305 1306 1306 function bp_is_groups_component() { 1307 1307 global $bp; 1308 1308 1309 1309 if ( BP_GROUPS_SLUG == $bp->current_component ) 1310 1310 return true; 1311 1312 return false; 1311 1312 return false; 1313 1313 } 1314 1314 1315 1315 function bp_is_settings_component() { 1316 1316 global $bp; 1317 1317 1318 1318 if ( BP_SETTINGS_SLUG == $bp->current_component ) 1319 1319 return true; 1320 1321 return false; 1320 1321 return false; 1322 1322 } 1323 1323 1324 1324 function bp_is_user_activity() { 1325 1325 global $bp; 1326 1326 1327 1327 if ( BP_ACTIVITY_SLUG == $bp->current_component && ( !$bp->current_action || 'my-activity' == $bp->current_action ) ) 1328 1328 return true; 1329 1330 return false; 1331 } 1329 1330 return false; 1331 } 1332 1332 1333 1333 function bp_is_user_friends_activity() { 1334 1334 global $bp; 1335 1335 1336 1336 if ( BP_ACTIVITY_SLUG == $bp->current_component && 'my-friends' == $bp->current_action ) 1337 1337 return true; 1338 1339 return false; 1338 1339 return false; 1340 1340 } 1341 1341 1342 1342 function bp_is_user_profile() { 1343 1343 global $bp; 1344 1344 1345 1345 if ( BP_XPROFILE_SLUG == $bp->current_component ) 1346 1346 return true; 1347 1348 return false; 1347 1348 return false; 1349 1349 } 1350 1350 1351 1351 function bp_is_profile_edit() { 1352 1352 global $bp; 1353 1353 1354 1354 if ( BP_XPROFILE_SLUG == $bp->current_component && 'edit' == $bp->current_action ) 1355 1355 return true; 1356 1356 1357 1357 return false; 1358 1358 } … … 1360 1360 function bp_is_change_avatar() { 1361 1361 global $bp; 1362 1362 1363 1363 if ( BP_XPROFILE_SLUG == $bp->current_component && 'change-avatar' == $bp->current_action ) 1364 1364 return true; 1365 1366 return false; 1365 1366 return false; 1367 1367 } 1368 1368 1369 1369 function bp_is_profile_wire() { 1370 1370 global $bp; 1371 1371 1372 1372 if ( BP_XPROFILE_SLUG == $bp->current_component && 'wire' == $bp->current_action ) 1373 1373 return true; 1374 1375 return false; 1374 1375 return false; 1376 1376 } 1377 1377 1378 1378 function bp_is_user_groups() { 1379 1379 global $bp; 1380 1380 1381 1381 if ( BP_GROUPS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-groups' == $bp->current_action ) ) 1382 1382 return true; 1383 1384 return false; 1383 1384 return false; 1385 1385 } 1386 1386 1387 1387 function bp_is_group_home() { 1388 1388 global $bp; 1389 1389 1390 1390 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) ) 1391 1391 return true; 1392 1393 return false; 1392 1393 return false; 1394 1394 } 1395 1395 1396 1396 function bp_is_group_create() { 1397 1397 global $bp; 1398 1398 1399 1399 if ( BP_GROUPS_SLUG == $bp->current_component && 'create' == $bp->current_action ) 1400 1400 return true; 1401 1401 1402 1402 return false; 1403 1403 } … … 1406 1406 function bp_is_group_admin_page() { 1407 1407 global $bp; 1408 1408 1409 1409 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'admin' == $bp->current_action ) 1410 1410 return true; 1411 1412 return false; 1411 1412 return false; 1413 1413 } 1414 1414 1415 1415 function bp_is_group_wire() { 1416 1416 global $bp; 1417 1417 1418 1418 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'wire' == $bp->current_action ) 1419 1419 return true; 1420 1421 return false; 1420 1421 return false; 1422 1422 } 1423 1423 1424 1424 function bp_is_group_forum() { 1425 1425 global $bp; 1426 1426 1427 1427 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action ) 1428 1428 return true; 1429 1430 return false; 1429 1430 return false; 1431 1431 } 1432 1432 1433 1433 function bp_is_group_forum_topic() { 1434 1434 global $bp; 1435 1435 1436 1436 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] ) 1437 1437 return true; 1438 1439 return false; 1438 1439 return false; 1440 1440 } 1441 1441 1442 1442 function bp_is_group_members() { 1443 1443 global $bp; 1444 1444 1445 1445 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'members' == $bp->current_action ) 1446 1446 return true; 1447 1448 return false; 1447 1448 return false; 1449 1449 } 1450 1450 1451 1451 function bp_is_group_invites() { 1452 1452 global $bp; 1453 1453 1454 1454 if ( BP_GROUPS_SLUG == $bp->current_component && 'invites' == $bp->current_action ) 1455 1455 return true; 1456 1457 return false; 1456 1457 return false; 1458 1458 } 1459 1459 1460 1460 function bp_is_group_leave() { 1461 1461 global $bp; 1462 1462 1463 1463 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'leave-group' == $bp->current_action ) 1464 1464 return true; 1465 1466 return false; 1467 } 1468 1469 function bp_is_group_single() { 1470 global $bp; 1471 1472 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item ) 1473 return true; 1474 1475 return false; 1465 1466 return false; 1467 } 1468 1469 function bp_is_group_single() { 1470 global $bp; 1471 1472 if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item ) 1473 return true; 1474 1475 return false; 1476 1476 } 1477 1477 1478 1478 function bp_is_user_blogs() { 1479 1479 global $bp; 1480 1480 1481 1481 if ( BP_BLOGS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-blogs' == $bp->current_action ) ) 1482 1482 return true; 1483 1484 return false; 1483 1484 return false; 1485 1485 } 1486 1486 1487 1487 function bp_is_user_recent_posts() { 1488 1488 global $bp; 1489 1489 1490 1490 if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-posts' == $bp->current_action ) 1491 1491 return true; 1492 1493 return false; 1492 1493 return false; 1494 1494 } 1495 1495 1496 1496 function bp_is_user_recent_commments() { 1497 1497 global $bp; 1498 1498 1499 1499 if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-comments' == $bp->current_action ) 1500 1500 return true; 1501 1502 return false; 1501 1502 return false; 1503 1503 } 1504 1504 1505 1505 function bp_is_create_blog() { 1506 1506 global $bp; 1507 1507 1508 1508 if ( BP_BLOGS_SLUG == $bp->current_component && 'create-a-blog' == $bp->current_action ) 1509 1509 return true; 1510 1511 return false; 1510 1511 return false; 1512 1512 } 1513 1513 1514 1514 function bp_is_user_friends() { 1515 1515 global $bp; 1516 1516 1517 1517 if ( BP_FRIENDS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-friends' == $bp->current_action ) ) 1518 1518 return true; 1519 1520 return false; 1519 1520 return false; 1521 1521 } 1522 1522 1523 1523 function bp_is_friend_requests() { 1524 1524 global $bp; 1525 1525 1526 1526 if ( BP_FRIENDS_SLUG == $bp->current_component && 'requests' == $bp->current_action ) 1527 1527 return true; 1528 1529 return false; 1528 1529 return false; 1530 1530 } 1531 1531 1532 1532 function bp_is_messages_inbox() { 1533 1533 global $bp; 1534 1534 1535 1535 if ( BP_MESSAGES_SLUG == $bp->current_component && ( !$bp->current_action || 'inbox' == $bp->current_action ) ) 1536 1536 return true; 1537 1538 return false; 1537 1538 return false; 1539 1539 } 1540 1540 1541 1541 function bp_is_messages_sentbox() { 1542 1542 global $bp; 1543 1543 1544 1544 if ( BP_MESSAGES_SLUG == $bp->current_component && 'sentbox' == $bp->current_action ) 1545 1545 return true; 1546 1547 return false; 1546 1547 return false; 1548 1548 } 1549 1549 … … 1551 1551 function bp_is_notices() { 1552 1552 global $bp; 1553 1553 1554 1554 if ( BP_MESSAGES_SLUG == $bp->current_component && 'notices' == $bp->current_action ) 1555 1555 return true; 1556 1557 return false; 1556 1557 return false; 1558 1558 } 1559 1559 … … 1561 1561 function bp_is_messages_compose_screen() { 1562 1562 global $bp; 1563 1563 1564 1564 if ( BP_MESSAGES_SLUG == $bp->current_component && 'compose' == $bp->current_action ) 1565 1565 return true; 1566 1567 return false; 1566 1567 return false; 1568 1568 } 1569 1569 1570 1570 function bp_is_single_item() { 1571 1571 global $bp; 1572 1572 1573 1573 if ( $bp->is_single_item ) 1574 1574 return true; 1575 1575 1576 1576 return false; 1577 1577 } … … 1579 1579 function bp_is_activation_page() { 1580 1580 global $bp; 1581 1581 1582 1582 if ( BP_ACTIVATION_SLUG == $bp->current_component ) 1583 1583 return true; 1584 1585 return false; 1584 1585 return false; 1586 1586 } 1587 1587 1588 1588 function bp_is_register_page() { 1589 1589 global $bp; 1590 1590 1591 1591 if ( BP_REGISTER_SLUG == $bp->current_component ) 1592 1592 return true; 1593 1594 return false; 1593 1594 return false; 1595 1595 } 1596 1596 … … 1603 1603 global $bp; 1604 1604 1605 if ( bp_is_blog_page() && is_front_page() && $bp->current_component != BP_HOME_BLOG_SLUG ) 1606 $bp_classes[] = 'home-page'; 1607 1605 if ( bp_is_blog_page() && is_front_page() && $bp->current_component != BP_HOME_BLOG_SLUG ) 1606 $bp_classes[] = 'home-page'; 1607 1608 1608 if ( bp_is_blog_page() || bp_is_register_page() || bp_is_activation_page() ) 1609 1609 $bp_classes[] = 'blog-page'; 1610 1610 1611 1611 if ( !bp_is_blog_page() && !bp_is_register_page() && !bp_is_activation_page() ) 1612 1612 $bp_classes[] = 'internal-page'; 1613 1613 1614 1614 if ( bp_is_directory() ) 1615 1615 $bp_classes[] = 'directory'; 1616 1616 1617 1617 if ( bp_is_user_profile() && !bp_is_blog_page() ) 1618 1618 $bp_classes[] = 'profile'; 1619 1619 1620 1620 if ( bp_is_activity_component() && !bp_is_blog_page() ) 1621 $bp_classes[] = 'activity'; 1621 $bp_classes[] = 'activity'; 1622 1622 1623 1623 if ( bp_is_blogs_component() && !bp_is_blog_page() ) … … 1628 1628 1629 1629 if ( bp_is_messages_component() && !bp_is_blog_page() ) 1630 $bp_classes[] = 'messages'; 1631 1630 $bp_classes[] = 'messages'; 1631 1632 1632 if ( bp_is_friends_component() && !bp_is_blog_page() ) 1633 1633 $bp_classes[] = 'friends'; 1634 1634 1635 1635 if ( bp_is_groups_component() && !bp_is_blog_page() ) 1636 1636 $bp_classes[] = 'groups'; … … 1638 1638 if ( bp_is_settings_component() && !bp_is_blog_page() ) 1639 1639 $bp_classes[] = 'settings'; 1640 1640 1641 1641 if ( bp_is_single_item() ) 1642 1642 $bp_classes[] = 'single-item'; 1643 1643 1644 1644 if ( bp_is_messages_inbox() ) 1645 1645 $bp_classes[] = 'inbox'; … … 1653 1653 if ( bp_is_notices() ) 1654 1654 $bp_classes[] = 'notices'; 1655 1655 1656 1656 if ( bp_is_friend_requests() ) 1657 1657 $bp_classes[] = 'friend-requests'; … … 1659 1659 if ( bp_is_user_friends() ) 1660 1660 $bp_classes[] = 'my-friends'; 1661 1661 1662 1662 if ( bp_is_create_blog() ) 1663 1663 $bp_classes[] = 'create-blog'; 1664 1664 1665 1665 if ( bp_is_user_recent_commments() ) 1666 1666 $bp_classes[] = 'recent-comments'; 1667 1667 1668 1668 if ( bp_is_user_recent_posts() ) 1669 1669 $bp_classes[] = 'recent-posts'; 1670 1670 1671 1671 if ( bp_is_user_blogs() && !bp_is_directory() ) 1672 1672 $bp_classes[] = 'my-blogs'; 1673 1673 1674 1674 if ( bp_is_user_groups() && !bp_is_directory() ) 1675 1675 $bp_classes[] = 'my-groups'; 1676 1676 1677 1677 if ( bp_is_group_leave() ) 1678 1678 $bp_classes[] = 'leave-group'; 1679 1679 1680 1680 if ( bp_is_group_invites() ) 1681 1681 $bp_classes[] = 'group-invites'; 1682 1682 1683 1683 if ( bp_is_group_members() ) 1684 1684 $bp_classes[] = 'group-members'; 1685 1685 1686 1686 if ( bp_is_group_forum_topic() ) 1687 1687 $bp_classes[] = 'group-forum-topic'; 1688 1688 1689 1689 if ( bp_is_group_forum() ) 1690 1690 $bp_classes[] = 'group-forum'; 1691 1691 1692 1692 if ( bp_is_group_wire() ) 1693 1693 $bp_classes[] = 'group-wire'; 1694 1694 1695 1695 if ( bp_is_group_admin_page() ) 1696 1696 $bp_classes[] = 'group-admin'; 1697 1697 1698 1698 if ( bp_is_group_create() ) 1699 1699 $bp_classes[] = 'group-create'; 1700 1700 1701 1701 if ( bp_is_group_home() ) 1702 1702 $bp_classes[] = 'group-home'; 1703 1703 1704 1704 if ( bp_is_profile_wire() ) 1705 1705 $bp_classes[] = 'profile-wire'; 1706 1706 1707 1707 if ( bp_is_change_avatar() ) 1708 1708 $bp_classes[] = 'change-avatar'; 1709 1709 1710 1710 if ( bp_is_profile_edit() ) 1711 1711 $bp_classes[] = 'profile-edit'; 1712 1712 1713 1713 if ( bp_is_user_friends_activity() ) 1714 1714 $bp_classes[] = 'friends-activity'; 1715 1715 1716 1716 if ( bp_is_user_activity() ) 1717 1717 $bp_classes[] = 'my-activity'; 1718 1718 1719 1719 if ( bp_is_register_page() ) 1720 1720 $bp_classes[] = 'registration'; 1721 1721 1722 1722 if ( bp_is_activation_page() ) 1723 1723 $bp_classes[] = 'activation'; 1724 1724 1725 1725 if ( is_user_logged_in() ) 1726 1726 $bp_classes[] = 'logged-in'; … … 1730 1730 if ( !empty( $bp->current_component ) ) 1731 1731 $bp_classes[] = $bp->current_component; 1732 1732 1733 1733 if ( !empty( $bp->current_action ) ) 1734 1734 $bp_classes[] = $bp->current_action; 1735 1735 } 1736 1736 1737 1737 /* We don't want WordPress blog classes to appear on non-blog pages. */ 1738 1738 if ( !bp_is_blog_page() || is_home() ) { … … 1743 1743 $wp_classes = array(); 1744 1744 } 1745 1745 1746 1746 /* Merge WP classes with BP classes */ 1747 1747 $classes = array_merge( (array) $bp_classes, (array) $wp_classes ); 1748 1748 1749 1749 /* Remove any duplicates */ 1750 1750 $classes = array_unique( $classes ); 1751 1751 1752 1752 return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes ); 1753 1753 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)