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-groups/bp-groups-loader.php

    r4088 r4151  
    338338
    339339    /**
     340     * Set up the admin bar
     341     *
     342     * @global obj $bp
     343     */
     344    function _setup_admin_bar() {
     345        global $bp;
     346
     347        // Menus for logged in user
     348        if ( is_user_logged_in() ) {
     349
     350            // Setup the logged in user variables
     351            $user_domain = $bp->loggedin_user->domain;
     352            $groups_link = trailingslashit( $user_domain . $this->slug );
     353
     354            // Pending group invites
     355            $count = groups_get_invites_for_user( $bp->loggedin_user->id );
     356
     357            if ( !empty( $count->total ) ) {
     358                $title   = sprintf( __( 'Groups <strong>(%s)</strong>',          'buddypress' ), $count->total );
     359                $pending = sprintf( __( 'Pending Invites <strong>(%s)</strong>', 'buddypress' ), $count->total );
     360            } else {
     361                $title   = __( 'Groups',             'buddypress' );
     362                $pending = __( 'No Pending Invites', 'buddypress' );
     363            }
     364
     365            // Add the "My Account" sub menus
     366            $wp_admin_nav[] = array(
     367                'parent' => $bp->my_account_menu_id,
     368                'id'     => 'my-account-' . $this->id,
     369                'title'  => $title,
     370                'href'   => trailingslashit( $groups_link )
     371            );
     372
     373            // My Groups
     374            $wp_admin_nav[] = array(
     375                'parent' => 'my-account-' . $this->id,
     376                'title'  => __( 'My Groups', 'buddypress' ),
     377                'href'   => trailingslashit( $groups_link )
     378            );
     379
     380            // Invitations
     381            $wp_admin_nav[] = array(
     382                'parent' => 'my-account-' . $this->id,
     383                'title'  => $pending,
     384                'href'   => trailingslashit( $groups_link . 'invites' )
     385            );
     386        }
     387
     388        parent::_setup_admin_bar( $wp_admin_nav );
     389    }
     390
     391    /**
    340392     * Sets up the title for pages and <title>
    341393     *
Note: See TracChangeset for help on using the changeset viewer.