Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/24/2011 05:26:18 AM (10 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-core/bp-core-component.php

    r3991 r4151  
    5454
    5555    /**
     56     * @var array WordPress admin bar links
     57     */
     58    var $admin_menu;
     59
     60    /**
    5661     * Component loader
    5762     *
     
    189194
    190195        // Register post types
     196        add_action( 'bp_setup_admin_bar',          array ( $this, '_setup_admin_bar'         ), 10 );
     197
     198        // Register post types
    191199        add_action( 'bp_setup_title',              array ( $this, '_setup_title'             ), 10 );
    192200
     
    214222     */
    215223    function _setup_nav( $main_nav = '', $sub_nav = '' ) {
     224
    216225        // No sub nav items without a main nav item
    217226        if ( !empty( $main_nav ) ) {
     
    231240
    232241    /**
     242     * Setup the admin bar
     243     *
     244     * @global obj $wp_admin_bar
     245     * @param array $wp_admin_menus
     246     */
     247    function _setup_admin_bar( $wp_admin_nav = '' ) {
     248
     249        // Do not proceed if constant is not set
     250        if ( !defined( 'BP_USE_WP_ADMIN_BAR' ) )
     251            return;
     252
     253        // Do we have admin bar menus to add?
     254        if ( !empty( $wp_admin_nav ) ) {
     255
     256            // Set this objects menus
     257            $this->admin_menu = $wp_admin_nav;
     258
     259            // Define the WordPress global
     260            global $wp_admin_bar;
     261
     262            // Add each admin menu
     263            foreach( $this->admin_menu as $admin_menu )
     264                $wp_admin_bar->add_menu( $admin_menu );
     265        }
     266
     267        // Call action
     268        do_action( 'bp_' . $this->id . '_setup_admin_bar' );
     269    }
     270
     271    /**
    233272     * Setup the component title
    234273     *
Note: See TracChangeset for help on using the changeset viewer.