Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/24/2011 05:26:18 AM (13 years ago)
Author:
johnjamesjacoby
Message:

This first pass at WP Admin Bar integration unhooks all WP core menus and replaces them with a full set of action based routines to handle the creation of admin bar menus at a BP component class level. This allows future external components to manipulate core menus or add their own with relative ease. Currently works off the BP_USE_WP_ADMIN_BAR constant, and should eventually phase out the BuddyBar in the long-term.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-friends/bp-friends-loader.php

    r3917 r4151  
    124124
    125125        parent::_setup_nav( $main_nav, $sub_nav );
     126    }
     127
     128    /**
     129     * Set up the admin bar
     130     *
     131     * @global obj $bp
     132     */
     133    function _setup_admin_bar() {
     134        global $bp;
     135
     136        // "My Account" menu
     137        if ( is_user_logged_in() ) {
     138
     139            // Setup the logged in user variables
     140            $user_domain  = $bp->loggedin_user->domain;
     141            $friends_link = trailingslashit( $user_domain . $this->slug );
     142
     143            // Pending friend requests
     144            if ( $count = count( friends_get_friendship_request_user_ids( $bp->loggedin_user->id ) ) ) {
     145                $title   = sprintf( __( 'Friends <strong>(%s)</strong>',          'buddypress' ), $count );
     146                $pending = sprintf( __( 'Pending Requests <strong>(%s)</strong>', 'buddypress' ), $count );
     147            } else {
     148                $title   = __( 'Friends',             'buddypress' );
     149                $pending = __( 'No Pending Requests', 'buddypress' );
     150            }
     151
     152            // Add the "My Account" sub menus
     153            $wp_admin_nav[] = array(
     154                'parent' => $bp->my_account_menu_id,
     155                'id'     => 'my-account-' . $this->id,
     156                'title'  => $title,
     157                'href'   => trailingslashit( $friends_link )
     158            );
     159
     160            // My Groups
     161            $wp_admin_nav[] = array(
     162                'parent' => 'my-account-' . $this->id,
     163                'title'  => __( 'My Friends', 'buddypress' ),
     164                'href'   => trailingslashit( $friends_link )
     165            );
     166
     167            // Requests
     168            $wp_admin_nav[] = array(
     169                'parent' => 'my-account-' . $this->id,
     170                'title'  => $pending,
     171                'href'   => trailingslashit( $friends_link . 'requests' )
     172            );
     173        }
     174
     175        parent::_setup_admin_bar( $wp_admin_nav );
    126176    }
    127177
Note: See TracChangeset for help on using the changeset viewer.