Skip to:
Content

BuddyPress.org

Changeset 7454


Ignore:
Timestamp:
10/22/2013 07:31:29 PM (13 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.

Location:
trunk
Files:
10 edited

Legend:

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

    r7400 r7454  
    2929                        'activity',
    3030                        __( 'Activity Streams', 'buddypress' ),
    31                         BP_PLUGIN_DIR
     31                        BP_PLUGIN_DIR,
     32                        array(
     33                                'adminbar_myaccount_order' => 10
     34                        )
    3235                );
    3336        }
  • trunk/bp-blogs/bp-blogs-loader.php

    r7352 r7454  
    2424                        'blogs',
    2525                        __( 'Site Tracking', 'buddypress' ),
    26                         BP_PLUGIN_DIR
     26                        BP_PLUGIN_DIR,
     27                        array(
     28                                'adminbar_myaccount_order' => 30
     29                        )
    2730                );
    2831        }
  • 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
  • trunk/bp-forums/bp-forums-loader.php

    r7347 r7454  
    2424                        'forums',
    2525                        __( 'Discussion Forums', 'buddypress' ),
    26                         BP_PLUGIN_DIR
     26                        BP_PLUGIN_DIR,
     27                        array(
     28                                'adminbar_myaccount_order' => 80
     29                        )
    2730                );
    2831        }
  • trunk/bp-friends/bp-friends-loader.php

    r7392 r7454  
    2323                        'friends',
    2424                        __( 'Friend Connections', 'buddypress' ),
    25                         BP_PLUGIN_DIR
     25                        BP_PLUGIN_DIR,
     26                        array(
     27                                'adminbar_myaccount_order' => 60
     28                        )
    2629                );
    2730        }
  • trunk/bp-groups/bp-groups-loader.php

    r7442 r7454  
    8282                        'groups',
    8383                        __( 'User Groups', 'buddypress' ),
    84                         BP_PLUGIN_DIR
     84                        BP_PLUGIN_DIR,
     85                        array(
     86                                'adminbar_myaccount_order' => 70
     87                        )
    8588                );
    8689        }
  • trunk/bp-members/bp-members-loader.php

    r7347 r7454  
    2323                        'members',
    2424                        __( 'Members', 'buddypress' ),
    25                         BP_PLUGIN_DIR
     25                        BP_PLUGIN_DIR,
     26                        array(
     27                                'adminbar_myaccount_order' => 20
     28                        )
    2629                );
    2730        }
  • trunk/bp-messages/bp-messages-loader.php

    r7430 r7454  
    3232                        'messages',
    3333                        __( 'Private Messages', 'buddypress' ),
    34                         BP_PLUGIN_DIR
     34                        BP_PLUGIN_DIR,
     35                        array(
     36                                'adminbar_myaccount_order' => 50
     37                        )
    3538                );
    3639        }
  • trunk/bp-settings/bp-settings-loader.php

    r7347 r7454  
    2222                        'settings',
    2323                        __( 'Settings', 'buddypress' ),
    24                         BP_PLUGIN_DIR
     24                        BP_PLUGIN_DIR,
     25                        array(
     26                                'adminbar_myaccount_order' => 100
     27                        )
    2528                );
    2629        }
  • trunk/bp-xprofile/bp-xprofile-loader.php

    r7347 r7454  
    4040                        'xprofile',
    4141                        __( 'Extended Profiles', 'buddypress' ),
    42                         BP_PLUGIN_DIR
     42                        BP_PLUGIN_DIR,
     43                        array(
     44                                'adminbar_myaccount_order' => 20
     45                        )
    4346                );
    4447        }
Note: See TracChangeset for help on using the changeset viewer.