Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/08/2016 05:56:22 AM (8 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-xprofile/classes/class-bp-xprofile-component.php

    r10525 r10555  
    319319            // View Profile.
    320320            $wp_admin_nav[] = array(
    321                 'parent' => 'my-account-' . $this->id,
    322                 'id'     => 'my-account-' . $this->id . '-public',
    323                 'title'  => _x( 'View', 'My Account Profile sub nav', 'buddypress' ),
    324                 'href'   => $profile_link
     321                'parent'   => 'my-account-' . $this->id,
     322                'id'       => 'my-account-' . $this->id . '-public',
     323                'title'    => _x( 'View', 'My Account Profile sub nav', 'buddypress' ),
     324                'href'     => $profile_link,
     325                'position' => 10
    325326            );
    326327
    327328            // Edit Profile.
    328329            $wp_admin_nav[] = array(
    329                 'parent' => 'my-account-' . $this->id,
    330                 'id'     => 'my-account-' . $this->id . '-edit',
    331                 'title'  => _x( 'Edit', 'My Account Profile sub nav', 'buddypress' ),
    332                 'href'   => trailingslashit( $profile_link . 'edit' )
     330                'parent'   => 'my-account-' . $this->id,
     331                'id'       => 'my-account-' . $this->id . '-edit',
     332                'title'    => _x( 'Edit', 'My Account Profile sub nav', 'buddypress' ),
     333                'href'     => trailingslashit( $profile_link . 'edit' ),
     334                'position' => 20
    333335            );
    334336
     
    336338            if ( buddypress()->avatar->show_avatars ) {
    337339                $wp_admin_nav[] = array(
    338                     'parent' => 'my-account-' . $this->id,
    339                     'id'     => 'my-account-' . $this->id . '-change-avatar',
    340                     'title'  => _x( 'Change Profile Photo', 'My Account Profile sub nav', 'buddypress' ),
    341                     'href'   => trailingslashit( $profile_link . 'change-avatar' )
     340                    'parent'   => 'my-account-' . $this->id,
     341                    'id'       => 'my-account-' . $this->id . '-change-avatar',
     342                    'title'    => _x( 'Change Profile Photo', 'My Account Profile sub nav', 'buddypress' ),
     343                    'href'     => trailingslashit( $profile_link . 'change-avatar' ),
     344                    'position' => 30
    342345                );
    343346            }
     
    345348            if ( bp_displayed_user_use_cover_image_header() ) {
    346349                $wp_admin_nav[] = array(
    347                     'parent' => 'my-account-' . $this->id,
    348                     'id'     => 'my-account-' . $this->id . '-change-cover-image',
    349                     'title'  => _x( 'Change Cover Image', 'My Account Profile sub nav', 'buddypress' ),
    350                     'href'   => trailingslashit( $profile_link . 'change-cover-image' )
     350                    'parent'   => 'my-account-' . $this->id,
     351                    'id'       => 'my-account-' . $this->id . '-change-cover-image',
     352                    'title'    => _x( 'Change Cover Image', 'My Account Profile sub nav', 'buddypress' ),
     353                    'href'     => trailingslashit( $profile_link . 'change-cover-image' ),
     354                    'position' => 40
    351355                );
    352356            }
Note: See TracChangeset for help on using the changeset viewer.