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-messages/classes/class-bp-messages-component.php

    r10522 r10555  
    254254                        // Inbox.
    255255                        $wp_admin_nav[] = array(
    256                                 'parent' => 'my-account-' . $this->id,
    257                                 'id'     => 'my-account-' . $this->id . '-inbox',
    258                                 'title'  => $inbox,
    259                                 'href'   => $messages_link
     256                                'parent'   => 'my-account-' . $this->id,
     257                                'id'       => 'my-account-' . $this->id . '-inbox',
     258                                'title'    => $inbox,
     259                                'href'     => $messages_link,
     260                                'position' => 10
    260261                        );
    261262
     
    263264                        if ( bp_is_active( $this->id, 'star' ) ) {
    264265                                $wp_admin_nav[] = array(
    265                                         'parent' => 'my-account-' . $this->id,
    266                                         'id'     => 'my-account-' . $this->id . '-starred',
    267                                         'title'  => __( 'Starred', 'buddypress' ),
    268                                         'href'   => trailingslashit( $messages_link . bp_get_messages_starred_slug() )
     266                                        'parent'   => 'my-account-' . $this->id,
     267                                        'id'       => 'my-account-' . $this->id . '-starred',
     268                                        'title'    => __( 'Starred', 'buddypress' ),
     269                                        'href'     => trailingslashit( $messages_link . bp_get_messages_starred_slug() ),
     270                                        'position' => 11
    269271                                );
    270272                        }
     
    272274                        // Sent Messages.
    273275                        $wp_admin_nav[] = array(
    274                                 'parent' => 'my-account-' . $this->id,
    275                                 'id'     => 'my-account-' . $this->id . '-sentbox',
    276                                 'title'  => __( 'Sent', 'buddypress' ),
    277                                 'href'   => trailingslashit( $messages_link . 'sentbox' )
     276                                'parent'   => 'my-account-' . $this->id,
     277                                'id'       => 'my-account-' . $this->id . '-sentbox',
     278                                'title'    => __( 'Sent', 'buddypress' ),
     279                                'href'     => trailingslashit( $messages_link . 'sentbox' ),
     280                                'position' => 20
    278281                        );
    279282
    280283                        // Compose Message.
    281284                        $wp_admin_nav[] = array(
    282                                 'parent' => 'my-account-' . $this->id,
    283                                 'id'     => 'my-account-' . $this->id . '-compose',
    284                                 'title'  => __( 'Compose', 'buddypress' ),
    285                                 'href'   => trailingslashit( $messages_link . 'compose' )
     285                                'parent'   => 'my-account-' . $this->id,
     286                                'id'       => 'my-account-' . $this->id . '-compose',
     287                                'title'    => __( 'Compose', 'buddypress' ),
     288                                'href'     => trailingslashit( $messages_link . 'compose' ),
     289                                'position' => 30
    286290                        );
    287291
     
    289293                        if ( bp_current_user_can( 'bp_moderate' ) ) {
    290294                                $wp_admin_nav[] = array(
    291                                         'parent' => 'my-account-' . $this->id,
    292                                         'id'     => 'my-account-' . $this->id . '-notices',
    293                                         'title'  => __( 'All Member Notices', 'buddypress' ),
    294                                         'href'   => trailingslashit( $messages_link . 'notices' )
     295                                        'parent'   => 'my-account-' . $this->id,
     296                                        'id'       => 'my-account-' . $this->id . '-notices',
     297                                        'title'    => __( 'All Member Notices', 'buddypress' ),
     298                                        'href'     => trailingslashit( $messages_link . 'notices' ),
     299                                        'position' => 90
    295300                                );
    296301                        }
Note: See TracChangeset for help on using the changeset viewer.