Skip to:
Content

BuddyPress.org


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

    r10520 r10555  
    722722            // My Groups.
    723723            $wp_admin_nav[] = array(
    724                 'parent' => 'my-account-' . $this->id,
    725                 'id'     => 'my-account-' . $this->id . '-memberships',
    726                 'title'  => _x( 'Memberships', 'My Account Groups sub nav', 'buddypress' ),
    727                 'href'   => $groups_link
     724                'parent'   => 'my-account-' . $this->id,
     725                'id'       => 'my-account-' . $this->id . '-memberships',
     726                'title'    => _x( 'Memberships', 'My Account Groups sub nav', 'buddypress' ),
     727                'href'     => $groups_link,
     728                'position' => 10
    728729            );
    729730
    730731            // Invitations.
    731732            $wp_admin_nav[] = array(
    732                 'parent' => 'my-account-' . $this->id,
    733                 'id'     => 'my-account-' . $this->id . '-invites',
    734                 'title'  => $pending,
    735                 'href'   => trailingslashit( $groups_link . 'invites' )
     733                'parent'   => 'my-account-' . $this->id,
     734                'id'       => 'my-account-' . $this->id . '-invites',
     735                'title'    => $pending,
     736                'href'     => trailingslashit( $groups_link . 'invites' ),
     737                'position' => 30
    736738            );
    737739
     
    739741            if ( bp_user_can_create_groups() ) {
    740742                $wp_admin_nav[] = array(
    741                     'parent' => 'my-account-' . $this->id,
    742                     'id'     => 'my-account-' . $this->id . '-create',
    743                     'title'  => _x( 'Create a Group', 'My Account Groups sub nav', 'buddypress' ),
    744                     'href'   => trailingslashit( bp_get_groups_directory_permalink() . 'create' )
     743                    'parent'   => 'my-account-' . $this->id,
     744                    'id'       => 'my-account-' . $this->id . '-create',
     745                    'title'    => _x( 'Create a Group', 'My Account Groups sub nav', 'buddypress' ),
     746                    'href'     => trailingslashit( bp_get_groups_directory_permalink() . 'create' ),
     747                    'position' => 90
    745748                );
    746749            }
Note: See TracChangeset for help on using the changeset viewer.