Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/22/2013 07:31:29 PM (12 years ago)
Author:
r-a-y
Message:

Add a fourth parameter to the BP_Component::start() method.

This parameter is an array that allows extended classes to define some
properties that need to be set early one for BP_Component to be able
to work its magic.

Currently accepts 'adminbar_myaccount_order', which sets a custom
position for the component menu generated under the WP Toolbar's
"My Account" menu. If this value isn't set, we set the value to 90,
which will generate the menu before the Settings menu is added.

Fixes #3769.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-component.php

    r7445 r7454  
    115115     * @since BuddyPress (1.5.0)
    116116     *
    117      * @uses bp_Component::setup_actions() Set up the hooks and actions.
     117     * @uses BP_Component::setup_actions() Set up the hooks and actions.
    118118     *
    119119     * @param string $id Unique ID (for internal identification). Letters,
     
    123123     * @param string $path The file path for the component's files. Used by
    124124     *        {@link BP_Component::includes()}.
    125      */
    126     public function start( $id = '', $name = '', $path = '' ) {
     125     * @param array $params Additional parameters used by the component.
     126     *        The config array supports the following values:
     127     *        - 'adminbar_myaccount_order' Sets the position for our
     128     *          component menu under the WP Toolbar's "My Account" menu.
     129     */
     130    public function start( $id = '', $name = '', $path = '', $params = array() ) {
    127131
    128132        // Internal identifier of component
     
    134138        // Path for includes
    135139        $this->path = $path;
     140
     141        // Miscellaneous component parameters that need to be set early on
     142        if ( ! empty( $params ) ) {
     143            // Sets the position for our menu under the WP Toolbar's "My Account" menu
     144            if ( ! empty( $params['adminbar_myaccount_order'] ) ) {
     145                $this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order'];
     146            }
     147
     148        // Set defaults if not passed
     149        } else {
     150            // new component menus are added before the settings menu if not set
     151            $this->adminbar_myaccount_order = 90;
     152        }
    136153
    137154        // Move on to the next step
     
    305322
    306323        // Setup WP Toolbar menus
    307         add_action( 'bp_setup_admin_bar',        array( $this, 'setup_admin_bar'        ), 10 );
     324        add_action( 'bp_setup_admin_bar',        array( $this, 'setup_admin_bar'        ), $this->adminbar_myaccount_order );
    308325
    309326        // Setup component title
Note: See TracChangeset for help on using the changeset viewer.