Changeset 8568 for trunk/src/bp-core/bp-core-buddybar.php
- Timestamp:
- 07/09/2014 04:43:00 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-buddybar.php
r8556 r8568 557 557 } 558 558 559 /** BuddyBar Template functions ***********************************************/560 561 /**562 * Wrapper function for rendering the BuddyBar.563 *564 * @return bool|null Returns false if the BuddyBar is disabled.565 */566 function bp_core_admin_bar() {567 global $bp;568 569 if ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR )570 return false;571 572 if ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )573 return false;574 575 $bp->doing_admin_bar = true;576 577 echo '<div id="wp-admin-bar"><div class="padder">';578 579 // **** Do bp-adminbar-logo Actions ********580 do_action( 'bp_adminbar_logo' );581 582 echo '<ul class="main-nav">';583 584 // **** Do bp-adminbar-menus Actions ********585 do_action( 'bp_adminbar_menus' );586 587 echo '</ul>';588 echo "</div></div><!-- #wp-admin-bar -->\n\n";589 590 $bp->doing_admin_bar = false;591 }592 593 /**594 * Output the BuddyBar logo.595 */596 function bp_adminbar_logo() {597 echo '<a href="' . bp_get_root_domain() . '" id="admin-bar-logo">' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . '</a>';598 }599 600 /**601 * Output the "Log In" and "Sign Up" names to the BuddyBar.602 *603 * Visible only to visitors who are not logged in.604 *605 * @return bool|null Returns false if the current user is logged in.606 */607 function bp_adminbar_login_menu() {608 609 if ( is_user_logged_in() )610 return false;611 612 echo '<li class="bp-login no-arrow"><a href="' . wp_login_url() . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';613 614 // Show "Sign Up" link if user registrations are allowed615 if ( bp_get_signup_allowed() )616 echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page() . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';617 }618 619 /**620 * Output the My Account BuddyBar menu.621 *622 * @return bool|null Returns false on failure.623 */624 function bp_adminbar_account_menu() {625 global $bp;626 627 if ( !$bp->bp_nav || !is_user_logged_in() )628 return false;629 630 echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';631 echo __( 'My Account', 'buddypress' ) . '</a>';632 echo '<ul>';633 634 // Loop through each navigation item635 $counter = 0;636 foreach( (array) $bp->bp_nav as $nav_item ) {637 $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';638 639 if ( -1 == $nav_item['position'] )640 continue;641 642 echo '<li' . $alt . '>';643 echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';644 645 if ( isset( $bp->bp_options_nav[$nav_item['slug']] ) && is_array( $bp->bp_options_nav[$nav_item['slug']] ) ) {646 echo '<ul>';647 $sub_counter = 0;648 649 foreach( (array) $bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {650 $link = $subnav_item['link'];651 $name = $subnav_item['name'];652 653 if ( bp_displayed_user_domain() )654 $link = str_replace( bp_displayed_user_domain(), bp_loggedin_user_domain(), $subnav_item['link'] );655 656 if ( isset( $bp->displayed_user->userdata->user_login ) )657 $name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );658 659 $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';660 echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $link . '">' . $name . '</a></li>';661 $sub_counter++;662 }663 echo '</ul>';664 }665 666 echo '</li>';667 668 $counter++;669 }670 671 $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';672 673 echo '<li' . $alt . '><a id="bp-admin-logout" class="logout" href="' . wp_logout_url( home_url() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';674 echo '</ul>';675 echo '</li>';676 }677 678 function bp_adminbar_thisblog_menu() {679 if ( current_user_can( 'edit_posts' ) ) {680 echo '<li id="bp-adminbar-thisblog-menu"><a href="' . admin_url() . '">';681 _e( 'Dashboard', 'buddypress' );682 echo '</a>';683 echo '<ul>';684 685 echo '<li class="alt"><a href="' . admin_url() . 'post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';686 echo '<li><a href="' . admin_url() . 'edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';687 echo '<li class="alt"><a href="' . admin_url() . 'edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';688 689 do_action( 'bp_adminbar_thisblog_items' );690 691 echo '</ul>';692 echo '</li>';693 }694 }695 696 /**697 * Output the Random BuddyBar menu.698 *699 * Not visible for logged-in users.700 */701 function bp_adminbar_random_menu() {702 ?>703 704 <li class="align-right" id="bp-adminbar-visitrandom-menu">705 <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>706 <ul class="random-list">707 <li><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) . '?random-member' ?>" rel="nofollow"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>708 709 <?php if ( bp_is_active( 'groups' ) ) : ?>710 711 <li class="alt"><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() ) . '?random-group' ?>" rel="nofollow"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>712 713 <?php endif; ?>714 715 <?php if ( is_multisite() && bp_is_active( 'blogs' ) ) : ?>716 717 <li><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_blogs_root_slug() ) . '?random-blog' ?>" rel="nofollow"><?php _e( 'Random Site', 'buddypress' ) ?></a></li>718 719 <?php endif; ?>720 721 <?php do_action( 'bp_adminbar_random_menu' ) ?>722 723 </ul>724 </li>725 726 <?php727 }728 559 729 560 /** … … 748 579 return 'true' === $pref; 749 580 } 750 751 /**752 * Enqueue the BuddyBar CSS.753 */754 function bp_core_load_buddybar_css() {755 global $wp_styles;756 757 if ( bp_use_wp_admin_bar() || ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) || ( defined( 'BP_DISABLE_ADMIN_BAR' ) && BP_DISABLE_ADMIN_BAR ) )758 return;759 760 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';761 762 if ( file_exists( get_stylesheet_directory() . '/_inc/css/adminbar.css' ) ) { // Backwards compatibility763 $stylesheet = get_stylesheet_directory_uri() . '/_inc/css/adminbar.css';764 } else {765 $stylesheet = buddypress()->plugin_url . "bp-core/css/buddybar{$min}.css";766 }767 768 wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_buddybar_rtl_css', $stylesheet ), array(), bp_get_version() );769 $wp_styles->add_data( 'bp-admin-bar', 'rtl', true );770 if ( $min )771 $wp_styles->add_data( 'bp-admin-bar', 'suffix', $min );772 }773 add_action( 'bp_init', 'bp_core_load_buddybar_css' );
Note: See TracChangeset
for help on using the changeset viewer.