Changeset 1021 for trunk/bp-core/bp-core-templatetags.php
- Timestamp:
- 02/06/2009 03:07:48 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-templatetags.php (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-templatetags.php
r958 r1021 4 4 * TEMPLATE TAG 5 5 * 6 * Uses the $bp ['bp_nav']global to render out the navigation within a BuddyPress install.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 * … … 20 20 21 21 /* Sort the nav by key as the array has been put together in different locations */ 22 $bp ['bp_nav'] = bp_core_sort_nav_items( $bp['bp_nav']);22 $bp->bp_nav = bp_core_sort_nav_items( $bp->bp_nav ); 23 23 24 24 /* Loop through each navigation item */ 25 foreach( (array) $bp ['bp_nav']as $nav_item ) {25 foreach( (array) $bp->bp_nav as $nav_item ) { 26 26 /* If the current component matches the nav item id, then add a highlight CSS class. */ 27 if ( $bp ['current_component']== $nav_item['css_id'] ) {27 if ( $bp->current_component == $nav_item['css_id'] ) { 28 28 $selected = ' class="current"'; 29 29 } else { … … 31 31 } 32 32 33 /* If we are viewing another person (current_userid does not equal loggedin_user id)33 /* If we are viewing another person (current_userid does not equal loggedin_user->id) 34 34 then check to see if the two users are friends. if they are, add a highlight CSS class 35 35 to the friends nav item if it exists. */ 36 if ( !bp_is_home() && $bp ['current_userid']) {36 if ( !bp_is_home() && $bp->displayed_user->id ) { 37 37 if ( function_exists('friends_install') ) { 38 if ( friends_check_friendship( $bp ['loggedin_userid'], $bp['current_userid'] ) && $nav_item['css_id'] == $bp['friends']['slug']) {38 if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) && $nav_item['css_id'] == $bp->friends->slug ) { 39 39 $selected = ' class="current"'; 40 40 } else { … … 60 60 * TEMPLATE TAG 61 61 * 62 * Uses the $bp ['bp_options_nav']global to render out the sub navigation for the current component.62 * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component. 63 63 * Each component adds to its sub navigation array within its own [component_name]_setup_nav() function. 64 64 * … … 78 78 /* Only render this navigation when the logged in user is looking at one of their own pages. */ 79 79 if ( bp_is_home() || $is_single_group ) { 80 if ( count( $bp ['bp_options_nav'][$bp['current_component']] ) < 1 )80 if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 ) 81 81 return false; 82 82 83 83 /* Loop through each navigation item */ 84 foreach ( $bp ['bp_options_nav'][$bp['current_component']] as $slug => $values ) {84 foreach ( $bp->bp_options_nav[$bp->current_component] as $slug => $values ) { 85 85 $title = $values['name']; 86 86 $link = $values['link']; … … 88 88 89 89 /* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */ 90 if ( $slug == $bp ['current_action'] || in_array( $slug, $bp['action_variables']) ) {90 if ( $slug == $bp->current_action || in_array( $slug, $bp->action_variables ) ) { 91 91 $selected = ' class="current"'; 92 92 } else { … … 98 98 } 99 99 } else { 100 if ( !$bp ['bp_users_nav'])100 if ( !$bp->bp_users_nav ) 101 101 return false; 102 102 … … 109 109 * TEMPLATE TAG 110 110 * 111 * Uses the $bp ['bp_users_nav']global to render out the user navigation when viewing another user other than111 * Uses the $bp->bp_users_nav global to render out the user navigation when viewing another user other than 112 112 * yourself. 113 113 * … … 119 119 120 120 /* Sort the nav by key as the array has been put together in different locations */ 121 $bp ['bp_users_nav'] = bp_core_sort_nav_items( $bp['bp_users_nav']);122 123 foreach ( $bp ['bp_users_nav']as $user_nav_item ) {124 if ( $bp ['current_component']== $user_nav_item['css_id'] ) {121 $bp->bp_users_nav = bp_core_sort_nav_items( $bp->bp_users_nav ); 122 123 foreach ( $bp->bp_users_nav as $user_nav_item ) { 124 if ( $bp->current_component == $user_nav_item['css_id'] ) { 125 125 $selected = ' class="current"'; 126 126 } else { … … 145 145 global $bp; 146 146 147 if ( $bp['bp_options_avatar'] == '')147 if ( empty( $bp->bp_options_avatar ) ) 148 148 return false; 149 149 … … 164 164 global $bp; 165 165 166 echo apply_filters( 'bp_get_options_avatar', $bp ['bp_options_avatar']);166 echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_avatar ); 167 167 } 168 168 … … 170 170 global $bp; 171 171 172 if ( $bp['bp_options_title'] == '')173 $bp ['bp_options_title'] = __('Options', 'buddypress');174 175 echo apply_filters( 'bp_get_options_avatar', $bp ['bp_options_title']);172 if ( empty( $bp->bp_options_title ) ) 173 $bp->bp_options_title = __( 'Options', 'buddypress' ); 174 175 echo apply_filters( 'bp_get_options_avatar', $bp->bp_options_title ); 176 176 } 177 177 … … 200 200 201 201 if ( $width && $height ) 202 echo apply_filters( 'bp_loggedinuser_avatar', bp_core_get_avatar( $bp ['loggedin_userid'], 2, $width, $height ) );202 echo apply_filters( 'bp_loggedinuser_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 2, $width, $height ) ); 203 203 else 204 echo apply_filters( 'bp_loggedinuser_avatar', bp_core_get_avatar( $bp ['loggedin_userid'], 2 ) );204 echo apply_filters( 'bp_loggedinuser_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 2 ) ); 205 205 } 206 206 … … 209 209 210 210 if ( $width && $height ) 211 echo apply_filters( 'bp_get_options_avatar', bp_core_get_avatar( $bp ['loggedin_userid'], 1, $width, $height ) );211 echo apply_filters( 'bp_get_options_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 1, $width, $height ) ); 212 212 else 213 echo apply_filters( 'bp_get_options_avatar', bp_core_get_avatar( $bp ['loggedin_userid'], 1 ) );213 echo apply_filters( 'bp_get_options_avatar', bp_core_get_avatar( $bp->loggedin_user->id, 1 ) ); 214 214 } 215 215 … … 219 219 220 220 function bp_is_home() { 221 global $bp , $current_blog, $doing_admin_bar;222 223 if ( is_user_logged_in() && $bp ['loggedin_userid'] == $bp['current_userid'])221 global $bp; 222 223 if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id ) 224 224 return true; 225 225 … … 231 231 232 232 if ( !$user_id ) 233 $user_id = $bp ['current_userid'];233 $user_id = $bp->displayed_user->id; 234 234 235 235 if ( function_exists('xprofile_install') ) { 236 // First check the usermeta table for a easily fetchable value 237 //$data = get_usermeta( $user_id, 'bp_display_name' ); 238 239 //if ( $data == '' ) { 240 $data = bp_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id ); 241 242 if ( empty($data) ) { 243 $ud = get_userdata($user_id); 244 $data = $ud->display_name; 245 } else { 246 $data = ucfirst($data); 247 } 248 249 // store this in usermeta for less expensive fetching. 250 // update_usermeta( $user_id, 'bp_display_name', $data ); 251 //} 236 $data = bp_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user_id ); 237 238 if ( empty($data) ) { 239 $ud = get_userdata($user_id); 240 $data = $ud->display_name; 241 } else { 242 $data = ucfirst($data); 243 } 252 244 } else { 253 245 $ud = get_userdata($user_id); … … 265 257 266 258 if ( !$user_id ) 267 $user_id = $bp ['current_userid'];259 $user_id = $bp->displayed_user->id; 268 260 269 261 $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') ); … … 277 269 function bp_the_avatar() { 278 270 global $bp; 279 echo apply_filters( 'bp_the_avatar', bp_core_get_avatar( $bp ['current_userid'], 2 ) );271 echo apply_filters( 'bp_the_avatar', bp_core_get_avatar( $bp->displayed_user->id, 2 ) ); 280 272 } 281 273 282 274 function bp_the_avatar_thumbnail() { 283 275 global $bp; 284 echo apply_filters( 'bp_the_avatar_thumbnail', bp_core_get_avatar( $bp ['current_userid'], 1 ) );276 echo apply_filters( 'bp_the_avatar_thumbnail', bp_core_get_avatar( $bp->displayed_user->id, 1 ) ); 285 277 } 286 278 … … 288 280 global $bp; 289 281 290 echo apply_filters( 'bp_the_avatar_thumbnail', $bp ['current_domain']);282 echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain ); 291 283 } 292 284 … … 322 314 $youtext = ucfirst($youtext); 323 315 324 if ( $bp ['current_userid'] == $bp['loggedin_userid']) {316 if ( $bp->displayed_user->id == $bp->loggedin_user->id ) { 325 317 if ( $echo ) 326 318 echo apply_filters( 'bp_word_or_name', $youtext ); … … 328 320 return apply_filters( 'bp_word_or_name', $youtext ); 329 321 } else { 330 $nametext = sprintf( $nametext, $bp['current_fullname']);322 $nametext = sprintf( $nametext, $bp->displayed_user->fullname ); 331 323 if ( $echo ) 332 324 echo apply_filters( 'bp_word_or_name', $nametext ); … … 342 334 $yourtext = ucfirst($yourtext); 343 335 344 if ( $bp ['current_userid'] == $bp['loggedin_userid']) {336 if ( $bp->displayed_user->id == $bp->loggedin_user->id ) { 345 337 if ( $echo ) 346 338 echo apply_filters( 'bp_your_or_their', $yourtext ); … … 358 350 global $bp, $current_user; 359 351 360 if ( $link = bp_core_get_userlink( $bp ['loggedin_userid']) ) {352 if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) { 361 353 echo apply_filters( 'bp_loggedinuser_link', $link ); 362 354 } else { 363 $ud = get_userdata($ current_user->ID);355 $ud = get_userdata($displayed_user->id); 364 356 echo apply_filters( 'bp_loggedinuser_link', $ud->user_login ); 365 357 } … … 374 366 global $bp, $is_member_page; 375 367 376 if ( $bp ['current_component'] == NEWS_SLUG )377 return true; 378 379 if ( !$is_member_page && !in_array( $bp ['current_component'], $bp['root_components']) )380 return true; 381 368 if ( $bp->current_component == HOME_BLOG_SLUG ) 369 return true; 370 371 if ( !$is_member_page && !in_array( $bp->current_component, $bp->root_components ) ) 372 return true; 373 382 374 return false; 383 375 } … … 386 378 global $bp; 387 379 388 if ( $bp['current_fullname'] != '') {389 echo apply_filters( 'bp_page_title', strip_tags( $bp ['current_fullname'] . ' » ' . ucwords($bp['current_component']) . ' » ' . $bp['bp_options_nav'][$bp['current_component']][$bp['current_action']]['name'] ) );390 } else { 391 echo apply_filters( 'bp_page_title', strip_tags( ucwords( $bp['current_component']) . ' » ' . ucwords($bp['bp_options_title']) . ' » ' . ucwords($bp['current_action']) ) );380 if ( !empty( $bp->displayed_user->fullname ) ) { 381 echo apply_filters( 'bp_page_title', strip_tags( $bp->displayed_user->fullname . ' » ' . ucwords( $bp->current_component ) . ' » ' . $bp->bp_options_nav[$bp->current_component][$bp->current_action]['name'] ) ); 382 } else { 383 echo apply_filters( 'bp_page_title', strip_tags( ucwords( $bp->current_component ) . ' » ' . ucwords( $bp->bp_options_title ) . ' » ' . ucwords( $bp->current_action ) ) ); 392 384 } 393 385 } … … 401 393 global $bp; 402 394 403 if ( $bp ['current_userid'])395 if ( $bp->displayed_user->id ) 404 396 return false; 405 397 406 if ( $page == $bp ['current_component'] || $page == 'home' && $bp['current_component'] == $bp['default_component'])398 if ( $page == $bp->current_component || $page == 'home' && $bp->current_component == $bp->default_component ) 407 399 return true; 408 400 … … 422 414 if ( bp_has_custom_signup_page() ) { 423 415 if ( $echo ) 424 echo $bp ['root_domain']. '/' . REGISTER_SLUG;425 else 426 return $bp ['root_domain']. '/' . REGISTER_SLUG;427 } else { 428 if ( $echo ) 429 echo $bp ['root_domain']. '/wp-signup.php';430 else 431 return $bp ['root_domain']. '/wp-signup.php';416 echo $bp->root_domain . '/' . REGISTER_SLUG; 417 else 418 return $bp->root_domain . '/' . REGISTER_SLUG; 419 } else { 420 if ( $echo ) 421 echo $bp->root_domain . '/wp-signup.php'; 422 else 423 return $bp->root_domain . '/wp-signup.php'; 432 424 } 433 425 } … … 528 520 529 521 if ( function_exists('friends_install') ) { 530 if ( friends_check_friendship( $bp ['loggedin_userid'], $bp['current_userid']) )522 if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) ) 531 523 return true; 532 524 else … … 540 532 global $bp; 541 533 ?> 542 <li<?php if (bp_is_page('home')) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a></li>543 <li<?php if (bp_is_page(HOME_BLOG_SLUG)) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a></li>544 <li<?php if (bp_is_page(MEMBERS_SLUG)) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a></li>545 546 <?php if ( function_exists( 'groups_install') ) { ?>547 <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>534 <li<?php if ( bp_is_page( 'home' ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a></li> 535 <li<?php if ( bp_is_page( HOME_BLOG_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a></li> 536 <li<?php if ( bp_is_page( MEMBERS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a></li> 537 538 <?php if ( function_exists( 'groups_install' ) ) { ?> 539 <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> 548 540 <?php } ?> 549 541 550 <?php if ( function_exists( 'bp_blogs_install') ) { ?>551 <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>542 <?php if ( function_exists( 'bp_blogs_install' ) ) { ?> 543 <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> 552 544 <?php } ?> 553 545 <?php … … 568 560 function bp_current_user_id() { 569 561 global $bp; 570 return apply_filters( 'bp_current_user_id', $bp ['current_userid']);562 return apply_filters( 'bp_current_user_id', $bp->displayed_user->id ); 571 563 } 572 564 573 565 function bp_user_fullname() { 574 566 global $bp; 575 echo apply_filters( 'bp_user_fullname', $bp ['current_fullname']);567 echo apply_filters( 'bp_user_fullname', $bp->displayed_user->fullname ); 576 568 } 577 569
Note: See TracChangeset
for help on using the changeset viewer.