Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/08/2016 05:56:22 AM (11 years ago)
Author:
r-a-y
Message:

BP Component: Allow plugins to set a custom position when registering an admin bar subnav menu.

This commit allows plugins to set a 'position' key when registering a WP
Admin Bar subnav menu item in the setup_admin_bar() method.

Previously, plugins had to do all sorts of array shuffling in order to
register their subnav at a preferred position. For backward compatibility,
we do some 'position' key backfilling, so if a plugin isn't using the new
'position' key, their subnav should still display at the same location.

Fixes #6859.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-settings/classes/class-bp-settings-component.php

    r10524 r10555  
    184184                        // General Account.
    185185                        $wp_admin_nav[] = array(
    186                                 'parent' => 'my-account-' . $this->id,
    187                                 'id'     => 'my-account-' . $this->id . '-general',
    188                                 'title'  => __( 'General', 'buddypress' ),
    189                                 'href'   => $settings_link
     186                                'parent'   => 'my-account-' . $this->id,
     187                                'id'       => 'my-account-' . $this->id . '-general',
     188                                'title'    => __( 'General', 'buddypress' ),
     189                                'href'     => $settings_link,
     190                                'position' => 10
    190191                        );
    191192
     
    193194                        if ( has_action( 'bp_notification_settings' ) ) {
    194195                                $wp_admin_nav[] = array(
    195                                         'parent' => 'my-account-' . $this->id,
    196                                         'id'     => 'my-account-' . $this->id . '-notifications',
    197                                         'title'  => __( 'Email', 'buddypress' ),
    198                                         'href'   => trailingslashit( $settings_link . 'notifications' )
     196                                        'parent'   => 'my-account-' . $this->id,
     197                                        'id'       => 'my-account-' . $this->id . '-notifications',
     198                                        'title'    => __( 'Email', 'buddypress' ),
     199                                        'href'     => trailingslashit( $settings_link . 'notifications' ),
     200                                        'position' => 20
    199201                                );
    200202                        }
    201203
    202                         // Delete Account.
     204                        // Delete Account
    203205                        if ( !bp_current_user_can( 'bp_moderate' ) && ! bp_core_get_root_option( 'bp-disable-account-deletion' ) ) {
    204206                                $wp_admin_nav[] = array(
    205                                         'parent' => 'my-account-' . $this->id,
    206                                         'id'     => 'my-account-' . $this->id . '-delete-account',
    207                                         'title'  => __( 'Delete Account', 'buddypress' ),
    208                                         'href'   => trailingslashit( $settings_link . 'delete-account' )
     207                                        'parent'   => 'my-account-' . $this->id,
     208                                        'id'       => 'my-account-' . $this->id . '-delete-account',
     209                                        'title'    => __( 'Delete Account', 'buddypress' ),
     210                                        'href'     => trailingslashit( $settings_link . 'delete-account' ),
     211                                        'position' => 90
    209212                                );
    210213                        }
Note: See TracChangeset for help on using the changeset viewer.