Changeset 3952
- Timestamp:
- 01/27/2011 03:57:16 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-buddybar.php
r3951 r3952 1 1 <?php 2 3 2 4 3 /** … … 294 293 295 294 function bp_core_admin_bar() { 296 global $bp , $wpdb, $current_blog;295 global $bp; 297 296 298 297 if ( defined( 'BP_DISABLE_ADMIN_BAR' ) ) … … 324 323 global $bp; 325 324 326 echo '<a href="' . $bp->root_domain . '" id="admin-bar-logo">' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '</a>';325 echo '<a href="' . $bp->root_domain . '" id="admin-bar-logo">' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '</a>'; 327 326 } 328 327 … … 350 349 351 350 echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">'; 352 353 351 echo __( 'My Account', 'buddypress' ) . '</a>'; 354 352 echo '<ul>'; … … 398 396 } 399 397 400 // *** "My Blogs" Menu ********401 function bp_adminbar_blogs_menu() {402 global $bp;403 404 if ( !is_user_logged_in() || !bp_is_active( 'blogs' ) )405 return false;406 407 if ( !is_multisite() )408 return false;409 410 if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', 'bp' ) ) {411 $blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id, true );412 wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', $blogs, 'bp' );413 }414 415 $counter = 0;416 if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {417 418 echo '<li id="bp-adminbar-blogs-menu"><a href="' . trailingslashit( $bp->loggedin_user->domain . $bp->blogs->slug ) . '">';419 420 _e( 'My Blogs', 'buddypress' );421 422 echo '</a>';423 echo '<ul>';424 425 foreach ( (array)$blogs['blogs'] as $blog ) {426 $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';427 $site_url = esc_attr( $blog->siteurl );428 429 echo '<li' . $alt . '>';430 echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>';431 echo '<ul>';432 echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';433 echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';434 echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';435 echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';436 echo '</ul>';437 438 do_action( 'bp_adminbar_blog_items', $blog );439 440 echo '</li>';441 $counter++;442 }443 444 $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';445 446 if ( bp_blog_signup_enabled() ) {447 echo '<li' . $alt . '>';448 echo '<a href="' . $bp->root_domain . '/' . $bp->blogs->root_slug . '/create/">' . __( 'Create a Blog!', 'buddypress' ) . '</a>';449 echo '</li>';450 }451 452 echo '</ul>';453 echo '</li>';454 }455 }456 457 398 function bp_adminbar_thisblog_menu() { 458 399 if ( current_user_can( 'edit_posts' ) ) { 459 400 echo '<li id="bp-adminbar-thisblog-menu"><a href="' . admin_url() . '">'; 460 461 401 _e( 'Dashboard', 'buddypress' ); 462 463 402 echo '</a>'; 464 403 echo '<ul>'; … … 475 414 } 476 415 477 // **** "Notifications" Menu *********478 function bp_adminbar_notifications_menu() {479 global $bp;480 481 if ( !is_user_logged_in() )482 return false;483 484 echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';485 _e( 'Notifications', 'buddypress' );486 487 if ( $notifications = bp_members_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>488 <span><?php echo count( $notifications ) ?></span>489 <?php490 }491 492 echo '</a>';493 echo '<ul>';494 495 if ( $notifications ) {496 $counter = 0;497 for ( $i = 0; $i < count($notifications); $i++ ) {498 $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>499 500 <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>501 502 <?php $counter++;503 }504 } else { ?>505 506 <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>507 508 <?php509 }510 511 echo '</ul>';512 echo '</li>';513 }514 515 // **** "Blog Authors" Menu (visible when not logged in) ********516 function bp_adminbar_authors_menu() {517 global $bp, $current_blog, $wpdb;518 519 // Only for multisite520 if ( !is_multisite() )521 return false;522 523 // Hide on root blog524 if ( $current_blog->blog_id == BP_ROOT_BLOG || !bp_is_active( 'blogs' ) )525 return false;526 527 $blog_prefix = $wpdb->get_blog_prefix( $current_blog->blog_id );528 $authors = $wpdb->get_results( "SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY um.user_id" );529 530 if ( !empty( $authors ) ) {531 // This is a blog, render a menu with links to all authors532 echo '<li id="bp-adminbar-authors-menu"><a href="/">';533 _e('Blog Authors', 'buddypress');534 echo '</a>';535 536 echo '<ul class="author-list">';537 foreach( (array)$authors as $author ) {538 $caps = maybe_unserialize( $author->caps );539 if ( isset( $caps['subscriber'] ) || isset( $caps['contributor'] ) ) continue;540 541 echo '<li>';542 echo '<a href="' . bp_core_get_user_domain( $author->user_id, $author->user_nicename, $author->user_login ) . '">';543 echo bp_core_fetch_avatar( array( 'item_id' => $author->user_id, 'email' => $author->user_email, 'width' => 15, 'height' => 15 ) ) ;544 echo ' ' . $author->display_name . '</a>';545 echo '<div class="admin-bar-clear"></div>';546 echo '</li>';547 }548 echo '</ul>';549 echo '</li>';550 }551 }552 416 553 417 // **** "Random" Menu (visible when not logged in) ******** … … 558 422 <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a> 559 423 <ul class="random-list"> 560 <li><a href="<?php echo $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>424 <li><a href="<?php echo trailingslashit( $bp->root_domain . '/' . $bp->members->root_slug ) . '?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li> 561 425 562 426 <?php if ( bp_is_active( 'groups' ) ) : ?> 563 427 564 <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>428 <li class="alt"><a href="<?php echo trailingslashit( $bp->root_domain . '/' . $bp->groups->root_slug ) . '?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li> 565 429 566 430 <?php endif; ?> 567 431 568 <?php if ( bp_is_active( 'blogs' ) && is_multisite() ) : ?>569 570 <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>432 <?php if ( is_multisite() && bp_is_active( 'blogs' ) ) : ?> 433 434 <li><a href="<?php echo trailingslashit( $bp->root_domain . '/' . $bp->blogs->root_slug ) . '?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li> 571 435 572 436 <?php endif; ?> … … 594 458 add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 ); 595 459 add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 ); 596 add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );597 460 add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6 ); 598 add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );599 add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );600 461 add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 ); 601 462 -
trunk/bp-core/bp-core-hooks.php
r3923 r3952 32 32 33 33 // Setup admin bar 34 add_action( 'bp_loaded', 'bp_core_load_admin_bar' );34 add_action( 'bp_loaded', 'bp_core_load_admin_bar' ); 35 35 36 36 /** The hooks *****************************************************************/ -
trunk/bp-members/bp-members-loader.php
r3943 r3952 37 37 'screens', 38 38 'template', 39 'buddybar', 39 40 'functions', 40 41 'notifications',
Note: See TracChangeset
for help on using the changeset viewer.