Skip to:
Content

BuddyPress.org

Ticket #3419: 3419.03.patch

File 3419.03.patch, 42.5 KB (added by r-a-y, 10 years ago)
  • src/bp-activity/classes/class-bp-activity-component.php

     
    172172                        'position'            => 10,
    173173                        'screen_function'     => 'bp_activity_screen_my_activity',
    174174                        'default_subnav_slug' => 'just-me',
    175                         'item_css_id'         => $this->id
     175                        'item_css_id'         => $this->id,
    176176                );
    177177
    178178                // Add the subnav items to the activity nav item if we are using a theme that supports this.
     
    182182                        'parent_url'      => $activity_link,
    183183                        'parent_slug'     => $slug,
    184184                        'screen_function' => 'bp_activity_screen_my_activity',
    185                         'position'        => 10
     185                        'position'        => 10,
    186186                );
    187187
    188188                // Check @mentions.
     
    194194                                'parent_slug'     => $slug,
    195195                                'screen_function' => 'bp_activity_screen_mentions',
    196196                                'position'        => 20,
    197                                 'item_css_id'     => 'activity-mentions'
     197                                'item_css_id'     => 'activity-mentions',
    198198                        );
    199199                }
    200200
     
    207207                                'parent_slug'     => $slug,
    208208                                'screen_function' => 'bp_activity_screen_favorites',
    209209                                'position'        => 30,
    210                                 'item_css_id'     => 'activity-favs'
     210                                'item_css_id'     => 'activity-favs',
    211211                        );
    212212                }
    213213
     
    220220                                'parent_slug'     => $slug,
    221221                                'screen_function' => 'bp_activity_screen_friends',
    222222                                'position'        => 40,
    223                                 'item_css_id'     => 'activity-friends'
     223                                'item_css_id'     => 'activity-friends',
    224224                        ) ;
    225225                }
    226226
     
    233233                                'parent_slug'     => $slug,
    234234                                'screen_function' => 'bp_activity_screen_groups',
    235235                                'position'        => 50,
    236                                 'item_css_id'     => 'activity-groups'
     236                                'item_css_id'     => 'activity-groups',
    237237                        );
    238238                }
    239239
     
    244244         * Set up the component entries in the WordPress Admin Bar.
    245245         *
    246246         * @since 1.5.0
     247         * @since 2.7.0 Sync the WP Admin Nav with BP Nav items having the `show_in_admin_bar` property set to true.
    247248         *
    248249         * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
    249250         *      parameter array.
     
    252253         *                            description.
    253254         */
    254255        public function setup_admin_bar( $wp_admin_nav = array() ) {
     256                if ( ! is_user_logged_in() ) {
     257                        return;
     258                }
    255259
    256                 // Menus for logged in user.
    257                 if ( is_user_logged_in() ) {
    258 
    259                         // Setup the logged in user variables.
    260                         $activity_link = trailingslashit( bp_loggedin_user_domain() . bp_get_activity_slug() );
    261 
    262                         // Unread message count.
    263                         if ( bp_activity_do_mentions() ) {
    264                                 $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
    265                                 if ( !empty( $count ) ) {
    266                                         $title = sprintf(
    267                                                 /* translators: %s: Unread mention count for the current user */
    268                                                 _x( 'Mentions %s', 'Toolbar Mention logged in user', 'buddypress' ),
    269                                                 '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    270                                         );
    271                                 } else {
    272                                         $title = _x( 'Mentions', 'Toolbar Mention logged in user', 'buddypress' );
    273                                 }
    274                         }
    275 
    276                         // Add the "Activity" sub menu.
    277                         $wp_admin_nav[] = array(
    278                                 'parent' => buddypress()->my_account_menu_id,
    279                                 'id'     => 'my-account-' . $this->id,
    280                                 'title'  => _x( 'Activity', 'My Account Activity sub nav', 'buddypress' ),
    281                                 'href'   => $activity_link
    282                         );
    283 
    284                         // Personal.
    285                         $wp_admin_nav[] = array(
    286                                 'parent'   => 'my-account-' . $this->id,
    287                                 'id'       => 'my-account-' . $this->id . '-personal',
    288                                 'title'    => _x( 'Personal', 'My Account Activity sub nav', 'buddypress' ),
    289                                 'href'     => $activity_link,
    290                                 'position' => 10
    291                         );
    292 
    293                         // Mentions.
    294                         if ( bp_activity_do_mentions() ) {
    295                                 $wp_admin_nav[] = array(
    296                                         'parent'   => 'my-account-' . $this->id,
    297                                         'id'       => 'my-account-' . $this->id . '-mentions',
    298                                         'title'    => $title,
    299                                         'href'     => trailingslashit( $activity_link . 'mentions' ),
    300                                         'position' => 20
    301                                 );
    302                         }
    303 
    304                         // Favorite activity items.
    305                         if ( bp_activity_can_favorite() ) {
    306                                 $wp_admin_nav[] = array(
    307                                         'parent'   => 'my-account-' . $this->id,
    308                                         'id'       => 'my-account-' . $this->id . '-favorites',
    309                                         'title'    => _x( 'Favorites', 'My Account Activity sub nav', 'buddypress' ),
    310                                         'href'     => trailingslashit( $activity_link . 'favorites' ),
    311                                         'position' => 30
    312                                 );
    313                         }
    314 
    315                         // Friends?
    316                         if ( bp_is_active( 'friends' ) ) {
    317                                 $wp_admin_nav[] = array(
    318                                         'parent'   => 'my-account-' . $this->id,
    319                                         'id'       => 'my-account-' . $this->id . '-friends',
    320                                         'title'    => _x( 'Friends', 'My Account Activity sub nav', 'buddypress' ),
    321                                         'href'     => trailingslashit( $activity_link . bp_get_friends_slug() ),
    322                                         'position' => 40
    323                                 );
    324                         }
     260                // Get nav with 'show_in_admin_bar' support.
     261                $nav = buddypress()->members->nav->get_admin_nav( array(
     262                        'parent_slug' => bp_get_activity_slug(),
     263                ) );
    325264
    326                         // Groups?
    327                         if ( bp_is_active( 'groups' ) ) {
    328                                 $wp_admin_nav[] = array(
    329                                         'parent'   => 'my-account-' . $this->id,
    330                                         'id'       => 'my-account-' . $this->id . '-groups',
    331                                         'title'    => _x( 'Groups', 'My Account Activity sub nav', 'buddypress' ),
    332                                         'href'     => trailingslashit( $activity_link . bp_get_groups_slug() ),
    333                                         'position' => 50
    334                                 );
     265                // Override some nav items for the admin bar.
     266                if ( ! empty( $nav['children'] ) ) {
     267                        foreach ( $nav['children'] as $key => $sub_nav ) {
     268                                // Override title for "Mentions" nav to add count.
     269                                if ( 'mentions' === $sub_nav->slug && bp_activity_do_mentions() ) {
     270                                        $count = bp_get_total_mention_count_for_user( bp_loggedin_user_id() );
     271                                        if ( ! empty( $count ) ) {
     272                                                $nav['children'][$key]->name = sprintf(
     273                                                        /* translators: %s: Unread mention count for the current user */
     274                                                        _x( 'Mentions %s', 'Toolbar Mention logged in user', 'buddypress' ),
     275                                                        '<span class="count">' . bp_core_number_format( $count ) . '</span>'
     276                                                );
     277                                        }
     278                                }
    335279                        }
    336280                }
    337281
    338                 parent::setup_admin_bar( $wp_admin_nav );
     282                // Configure nav array for setup_admin_bar() method.
     283                $nav = $this->setup_admin_nav( $nav, array(
     284                        'default_subnav_id' => 'personal'
     285                ) );
     286
     287                // Setup the admin bar.
     288                parent::setup_admin_bar( $nav );
    339289        }
    340290
    341291        /**
  • src/bp-core/bp-core-buddybar.php

     
    3232 *     @type callable    $screen_function         The callback function that will run when the nav item is clicked.
    3333 *     @type bool|string $default_subnav_slug     Optional. The slug of the default subnav item to select when the nav
    3434 *                                                item is clicked.
     35 *     @type bool        $show_in_admin_bar       Optional. Whether to add this nav item to the WP Admin Bar.
     36 *                                                Default: true.
    3537 * }
    3638 * @param string       $component The component the navigation is attached to. Defaults to 'members'.
    3739 * @return bool|null Returns false on failure.
     
    4951                'site_admin_only'         => false, // Can only site admins see this nav item?
    5052                'position'                => 99,    // Index of where this nav item should be positioned.
    5153                'screen_function'         => false, // The name of the function to run when clicked.
    52                 'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked.
     54                'default_subnav_slug'     => false, // The slug of the default subnav item to select when clicked.
     55                'show_in_admin_bar'       => true,  // Whether to add this nav item to the WP Admin Bar.
    5356        );
    5457
    5558        $r = wp_parse_args( $args, $defaults );
     
    106109 *     @type callable    $screen_function         The callback function that will run when the nav item is clicked.
    107110 *     @type bool|string $default_subnav_slug     Optional. The slug of the default subnav item to select when the nav
    108111 *                                                item is clicked.
     112 *     @type bool        $show_in_admin_bar       Optional. Whether to add this nav item to the WP Admin Bar.
     113 *                                                Default: true.
    109114 * }
    110115 * @param string       $component Optional. Component that the nav belongs to.
    111116 * @return bool|BP_Nav_Item Returns false on failure, new nav item on success.
     
    121126                'site_admin_only'         => false, // Can only site admins see this nav item?
    122127                'position'                => 99,    // Index of where this nav item should be positioned.
    123128                'screen_function'         => false, // The name of the function to run when clicked.
    124                 'default_subnav_slug'     => false  // The slug of the default subnav item to select when clicked.
     129                'default_subnav_slug'     => false, // The slug of the default subnav item to select when clicked.
     130                'show_in_admin_bar'       => true,  // Whether to add this nav item to the WP Admin Bar.
    125131        );
    126132
    127133        $r = wp_parse_args( $args, $defaults );
     
    148154                'show_for_displayed_user' => $r['show_for_displayed_user'],
    149155                'position'                => $r['position'],
    150156                'screen_function'         => &$r['screen_function'],
    151                 'default_subnav_slug'     => $r['default_subnav_slug']
     157                'default_subnav_slug'     => $r['default_subnav_slug'],
     158                'show_in_admin_bar'       => $r['show_in_admin_bar'],
    152159        );
    153160
    154161        // Add the item to the nav.
     
    392399 *     @type string      $link              Optional. The URL that the subnav item should point to. Defaults to a value
    393400 *                                          generated from the `$parent_url` + `$slug`.
    394401 *     @type bool        $show_in_admin_bar Optional. Whether the nav item should be added into the group's "Edit"
    395  *                                          Admin Bar menu for group admins. Default: false.
     402 *                                          Admin Bar menu for group admins. Default: true.
    396403 * }
    397404 * @param string       $component The component the navigation is attached to. Defaults to 'members'.
    398405 * @return bool|null Returns false on failure.
     
    472479 *                                          to. Defaults to a value generated from the $parent_url + $slug.
    473480 *     @type bool        $show_in_admin_bar Optional. Whether the nav item should be added into
    474481 *                                          the group's "Edit" Admin Bar menu for group admins.
    475  *                                          Default: false.
     482 *                                          Default: true.
    476483 * }
    477484 * @param string       $component The component the navigation is attached to. Defaults to 'members'.
    478485 * @return bool|object Returns false on failure, new BP_Nav_Item instance on success.
     
    492499                'position'          => 90,    // Index of where this nav item should be positioned.
    493500                'screen_function'   => false, // The name of the function to run when clicked.
    494501                'link'              => '',    // The link for the subnav item; optional, not usually required.
    495                 'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu.
     502                'show_in_admin_bar' => true, // Show the Manage link in the current group's "Edit" Admin Bar menu.
    496503        ) );
    497504
    498505        // If we don't have the required info we need, don't create this subnav item.
     
    568575 *                                       Defaults to a value generated from the $parent_url + $slug.
    569576 *     @type bool     $show_in_admin_bar Optional. Whether the nav item should be added into
    570577 *                                       the group's "Edit" Admin Bar menu for group admins.
    571  *                                       Default: false.
     578 *                                       Default: true.
    572579 * }
    573580 * @param string       $component The component the navigation is attached to. Defaults to 'members'.
    574581 * @return bool|null Returns false on failure.
  • src/bp-core/classes/class-bp-component.php

     
    505505        }
    506506
    507507        /**
     508         * Helper method to configure nav array for setup_admin_bar() method.
     509         *
     510         * @since 2.7.0
     511         *
     512         * @param array $nav Nav from BP_Core_Nav::get_admin_nav().
     513         * @param array $args {
     514         *     Arguments for configuring the nav array.
     515         *     @type string $parent_title      Title for the parent nav.
     516         *     @type string $default_subnav_id Subnav ID for the default subnav.
     517         * }
     518         * @return array
     519         */
     520        public function setup_admin_nav( $nav = array(), $args = array() ) {
     521                if ( ! isset( buddypress()->members->nav ) ) {
     522                        return array();
     523                }
     524
     525                $wp_admin_nav = array();
     526
     527                if ( ! empty( $nav['parent'] ) ) {
     528                        // Add the parent menu.
     529                        $wp_admin_nav[] = array(
     530                                'parent' => buddypress()->my_account_menu_id,
     531                                'id'     => 'my-account-' . $this->id,
     532                                'title'  => isset( $args['parent_title'] ) ? $args['parent_title'] : $nav['parent']->name,
     533                                'href'   => $nav['parent']->link
     534                        );
     535                }
     536
     537                if ( ! empty( $nav['children'] ) ) {
     538                        foreach ( $nav['children'] as $key => $sub_nav ) {
     539                                if ( isset( $nav['parent']->default_subnav_slug ) && $sub_nav->slug !== $nav['parent']->default_subnav_slug ) {
     540                                        $sub_nav_id    = sprintf( 'my-account-%s-%s', $this->id, $sub_nav->slug );
     541                                } elseif ( isset( $nav['parent']->default_subnav_slug ) && $sub_nav->slug === $nav['parent']->default_subnav_slug ) {
     542                                        $sub_nav_id    = sprintf( 'my-account-%s-%s', $this->id, isset( $args['default_subnav_id'] ) ? $args['default_subnav_id'] : $sub_nav->slug );
     543                                }
     544
     545                                // Add the sub nav items.
     546                                $wp_admin_nav[] = array(
     547                                        'parent'   => 'my-account-' . $this->id,
     548                                        'id'       => $sub_nav_id,
     549                                        'title'    => $sub_nav->name,
     550                                        'href'     => $sub_nav->link,
     551                                        'position' => $sub_nav->position,
     552                                );
     553                        }
     554                }
     555
     556                return $wp_admin_nav;
     557        }
     558
     559        /**
    508560         * Set up the component entries in the WordPress Admin Bar.
    509561         *
    510562         * @since 1.5.0
  • src/bp-core/classes/class-bp-core-nav.php

     
    399399
    400400                return $primary_nav_items;
    401401        }
     402
     403        /**
     404         * Get the Nav Items to display in the WP Admin Bar
     405         *
     406         * @since  2.7.0
     407         *
     408         * @param  array  $args Filters to select the specific items. See wp_list_filter().
     409         * @return array        An associative array containing the parent nav and its children.
     410         */
     411        public function get_admin_nav( $args = array() ) {
     412                $admin_nav = array();
     413
     414                $params = wp_parse_args( $args, array( 'show_in_admin_bar' => true ) );
     415
     416                // We need the parent slug, and this is a WP Admin Nav!
     417                if ( empty( $params['parent_slug'] ) || empty( $params['show_in_admin_bar'] ) ) {
     418                        return $admin_nav;
     419                }
     420
     421                // Validate the primary nav item
     422                $primary_nav_item = $this->get( $params['parent_slug'] );
     423
     424                if ( ! $primary_nav_item || empty( $primary_nav_item->show_in_admin_bar ) ) {
     425                        return $admin_nav;
     426                }
     427
     428                $admin_nav['parent'] = $primary_nav_item;
     429                $secondary_nav_items = $this->get_secondary( $params );
     430
     431                if ( ! $secondary_nav_items ) {
     432                        return $admin_nav;
     433                }
     434
     435                return array_merge( $admin_nav, array( 'children' => $secondary_nav_items ) );
     436        }
    402437}
  • src/bp-friends/classes/class-bp-friends-component.php

     
    198198         *                            for description.
    199199         */
    200200        public function setup_admin_bar( $wp_admin_nav = array() ) {
     201                if ( ! is_user_logged_in() ) {
     202                        return;
     203                }
    201204
    202                 // Menus for logged in user.
    203                 if ( is_user_logged_in() ) {
    204 
    205                         // Setup the logged in user variables.
    206                         $friends_link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() );
    207 
    208                         // Pending friend requests.
    209                         $count = count( friends_get_friendship_request_user_ids( bp_loggedin_user_id() ) );
    210                         if ( !empty( $count ) ) {
    211                                 $title = sprintf(
    212                                         /* translators: %s: Pending friend request count for the current user */
    213                                         _x( 'Friends %s', 'My Account Friends menu', 'buddypress' ),
    214                                         '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    215                                 );
    216                                 $pending = sprintf(
    217                                         /* translators: %s: Pending friend request count for the current user */
    218                                         _x( 'Pending Requests %s', 'My Account Friends menu sub nav', 'buddypress' ),
    219                                         '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    220                                 );
    221                         } else {
    222                                 $title   = _x( 'Friends',            'My Account Friends menu',         'buddypress' );
    223                                 $pending = _x( 'No Pending Requests','My Account Friends menu sub nav', 'buddypress' );
    224                         }
     205                // Get nav with 'show_in_admin_bar' support.
     206                $nav = buddypress()->members->nav->get_admin_nav( array(
     207                        'parent_slug' => bp_get_friends_slug(),
     208                ) );
    225209
    226                         // Add the "My Account" sub menus.
    227                         $wp_admin_nav[] = array(
    228                                 'parent' => buddypress()->my_account_menu_id,
    229                                 'id'     => 'my-account-' . $this->id,
    230                                 'title'  => $title,
    231                                 'href'   => $friends_link
     210                // Pending friend requests.
     211                $count = count( friends_get_friendship_request_user_ids( bp_loggedin_user_id() ) );
     212                if ( !empty( $count ) ) {
     213                        $title = sprintf(
     214                                /* translators: %s: Pending friend request count for the current user */
     215                                _x( 'Friends %s', 'My Account Friends menu', 'buddypress' ),
     216                                '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    232217                        );
    233 
    234                         // My Friends.
    235                         $wp_admin_nav[] = array(
    236                                 'parent'   => 'my-account-' . $this->id,
    237                                 'id'       => 'my-account-' . $this->id . '-friendships',
    238                                 'title'    => _x( 'Friendships', 'My Account Friends menu sub nav', 'buddypress' ),
    239                                 'href'     => $friends_link,
    240                                 'position' => 10
     218                        $pending = sprintf(
     219                                /* translators: %s: Pending friend request count for the current user */
     220                                _x( 'Pending Requests %s', 'My Account Friends menu sub nav', 'buddypress' ),
     221                                '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    241222                        );
     223                } else {
     224                        $title   = _x( 'Friends',            'My Account Friends menu',         'buddypress' );
     225                        $pending = _x( 'No Pending Requests','My Account Friends menu sub nav', 'buddypress' );
     226                }
    242227
    243                         // Requests.
    244                         $wp_admin_nav[] = array(
    245                                 'parent'   => 'my-account-' . $this->id,
    246                                 'id'       => 'my-account-' . $this->id . '-requests',
    247                                 'title'    => $pending,
    248                                 'href'     => trailingslashit( $friends_link . 'requests' ),
    249                                 'position' => 20
    250                         );
     228                // Override some nav items for the admin bar.
     229                if ( ! empty( $nav['children'] ) ) {
     230                        foreach ( $nav['children'] as $key => $sub_nav ) {
     231                                // Override title for "Requests" nav to add count.
     232                                if ( 'requests' === $sub_nav->slug ) {
     233                                        $nav['children'][$key]->name = $pending;
     234                                }
     235                        }
    251236                }
    252237
    253                 parent::setup_admin_bar( $wp_admin_nav );
     238                // Configure nav array for setup_admin_bar() method.
     239                $nav = $this->setup_admin_nav( $nav, array(
     240                        'parent_title' => $title
     241                ) );
     242
     243                // Setup the admin bar.
     244                parent::setup_admin_bar( $nav );
    254245        }
    255246
    256247        /**
  • src/bp-groups/classes/class-bp-groups-component.php

     
    724724         * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a description.
    725725         */
    726726        public function setup_admin_bar( $wp_admin_nav = array() ) {
     727                if ( ! is_user_logged_in() ) {
     728                        return;
     729                }
    727730
    728                 // Menus for logged in user.
    729                 if ( is_user_logged_in() ) {
     731                // Get nav with 'show_in_admin_bar' support.
     732                $nav = buddypress()->members->nav->get_admin_nav( array(
     733                        'parent_slug' => bp_get_groups_slug(),
     734                ) );
    730735
    731                         // Setup the logged in user variables.
    732                         $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() );
     736                // Pending group invites.
     737                $count   = groups_get_invite_count_for_user();
     738                $title   = _x( 'Groups', 'My Account Groups', 'buddypress' );
     739                $pending = _x( 'No Pending Invites', 'My Account Groups sub nav', 'buddypress' );
    733740
    734                         // Pending group invites.
    735                         $count   = groups_get_invite_count_for_user();
    736                         $title   = _x( 'Groups', 'My Account Groups', 'buddypress' );
    737                         $pending = _x( 'No Pending Invites', 'My Account Groups sub nav', 'buddypress' );
     741                if ( ! empty( $count['total'] ) ) {
     742                        $title = sprintf(
     743                                /* translators: %s: Group invitation count for the current user */
     744                                _x( 'Groups %s', 'My Account Groups nav', 'buddypress' ),
     745                                '<span class="count">' . bp_core_number_format( $count ) . '</span>'
     746                        );
    738747
    739                         if ( ! empty( $count['total'] ) ) {
    740                                 $title = sprintf(
    741                                         /* translators: %s: Group invitation count for the current user */
    742                                         _x( 'Groups %s', 'My Account Groups nav', 'buddypress' ),
    743                                         '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    744                                 );
     748                        $pending = sprintf(
     749                                /* translators: %s: Group invitation count for the current user */
     750                                _x( 'Pending Invites %s', 'My Account Groups sub nav', 'buddypress' ),
     751                                '<span class="count">' . bp_core_number_format( $count ) . '</span>'
     752                        );
     753                }
    745754
    746                                 $pending = sprintf(
    747                                         /* translators: %s: Group invitation count for the current user */
    748                                         _x( 'Pending Invites %s', 'My Account Groups sub nav', 'buddypress' ),
    749                                         '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    750                                 );
     755                // Override some nav items for the admin bar.
     756                if ( ! empty( $nav['children'] ) ) {
     757                        foreach ( $nav['children'] as $key => $sub_nav ) {
     758                                // Override title for "Invites".
     759                                if ( 'invites' === $sub_nav->slug ) {
     760                                        $nav['children'][$key]->name = $pending;
     761                                }
    751762                        }
     763                }
    752764
    753                         // Add the "My Account" sub menus.
    754                         $wp_admin_nav[] = array(
    755                                 'parent' => buddypress()->my_account_menu_id,
    756                                 'id'     => 'my-account-' . $this->id,
    757                                 'title'  => $title,
    758                                 'href'   => $groups_link
    759                         );
    760 
    761                         // My Groups.
    762                         $wp_admin_nav[] = array(
    763                                 'parent'   => 'my-account-' . $this->id,
    764                                 'id'       => 'my-account-' . $this->id . '-memberships',
    765                                 'title'    => _x( 'Memberships', 'My Account Groups sub nav', 'buddypress' ),
    766                                 'href'     => $groups_link,
    767                                 'position' => 10
    768                         );
     765                // Configure nav array for setup_admin_bar() method.
     766                $nav = $this->setup_admin_nav( $nav, array(
     767                        'parent_title' => $title
     768                ) );
    769769
    770                         // Invitations.
    771                         $wp_admin_nav[] = array(
     770                // Create a Group.
     771                if ( bp_user_can_create_groups() ) {
     772                        $nav[] = array(
    772773                                'parent'   => 'my-account-' . $this->id,
    773                                 'id'       => 'my-account-' . $this->id . '-invites',
    774                                 'title'    => $pending,
    775                                 'href'     => trailingslashit( $groups_link . 'invites' ),
    776                                 'position' => 30
     774                                'id'       => 'my-account-' . $this->id . '-create',
     775                                'title'    => _x( 'Create a Group', 'My Account Groups sub nav', 'buddypress' ),
     776                                'href'     => trailingslashit( bp_get_groups_directory_permalink() . 'create' ),
     777                                'position' => 90
    777778                        );
    778 
    779                         // Create a Group.
    780                         if ( bp_user_can_create_groups() ) {
    781                                 $wp_admin_nav[] = array(
    782                                         'parent'   => 'my-account-' . $this->id,
    783                                         'id'       => 'my-account-' . $this->id . '-create',
    784                                         'title'    => _x( 'Create a Group', 'My Account Groups sub nav', 'buddypress' ),
    785                                         'href'     => trailingslashit( bp_get_groups_directory_permalink() . 'create' ),
    786                                         'position' => 90
    787                                 );
    788                         }
    789779                }
    790780
    791                 parent::setup_admin_bar( $wp_admin_nav );
     781                // Setup the admin bar.
     782                parent::setup_admin_bar( $nav );
    792783        }
    793784
    794785        /**
  • src/bp-messages/classes/class-bp-messages-component.php

     
    172172                        'show_for_displayed_user' => $access,
    173173                        'screen_function'         => 'messages_screen_inbox',
    174174                        'default_subnav_slug'     => 'inbox',
    175                         'item_css_id'             => $this->id
     175                        'item_css_id'             => $this->id,
    176176                );
    177177
    178178                // Add the subnav items to the profile.
     
    183183                        'parent_slug'     => $slug,
    184184                        'screen_function' => 'messages_screen_inbox',
    185185                        'position'        => 10,
    186                         'user_has_access' => $access
     186                        'user_has_access' => $access,
    187187                );
    188188
    189189                if ( bp_is_active( $this->id, 'star' ) ) {
     
    194194                                'parent_slug'     => $slug,
    195195                                'screen_function' => 'bp_messages_star_screen',
    196196                                'position'        => 11,
    197                                 'user_has_access' => $access
     197                                'user_has_access' => $access,
    198198                        );
    199199                }
    200200
     
    205205                        'parent_slug'     => $slug,
    206206                        'screen_function' => 'messages_screen_sentbox',
    207207                        'position'        => 20,
    208                         'user_has_access' => $access
     208                        'user_has_access' => $access,
    209209                );
    210210
    211211                $sub_nav[] = array(
     
    215215                        'parent_slug'     => $slug,
    216216                        'screen_function' => 'messages_screen_compose',
    217217                        'position'        => 30,
    218                         'user_has_access' => $access
     218                        'user_has_access' => $access,
    219219                );
    220220
    221221                if ( bp_current_user_can( 'bp_moderate' ) ) {
     
    226226                                'parent_slug'     => $slug,
    227227                                'screen_function' => 'messages_screen_notices',
    228228                                'position'        => 90,
    229                                 'user_has_access' => true
     229                                'user_has_access' => true,
    230230                        );
    231231                }
    232232
     
    239239         * @param array $wp_admin_nav See {BP_Component::setup_admin_bar()} for details.
    240240         */
    241241        public function setup_admin_bar( $wp_admin_nav = array() ) {
     242                if ( ! is_user_logged_in() ) {
     243                        return;
     244                }
    242245
    243                 // Menus for logged in user.
    244                 if ( is_user_logged_in() ) {
    245 
    246                         // Setup the logged in user variables.
    247                         $messages_link = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() );
    248 
    249                         // Unread message count.
    250                         $count = messages_get_unread_count();
    251                         if ( !empty( $count ) ) {
    252                                 $title = sprintf(
    253                                         /* translators: %s: Unread message count for the current user */
    254                                         __( 'Messages %s', 'buddypress' ),
    255                                         '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    256                                 );
    257                                 $inbox = sprintf(
    258                                         /* translators: %s: Unread message count for the current user */
    259                                         __( 'Inbox %s', 'buddypress' ),
    260                                         '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    261                                 );
    262                         } else {
    263                                 $title = __( 'Messages', 'buddypress' );
    264                                 $inbox = __( 'Inbox',    'buddypress' );
    265                         }
    266 
    267                         // Add main Messages menu.
    268                         $wp_admin_nav[] = array(
    269                                 'parent' => buddypress()->my_account_menu_id,
    270                                 'id'     => 'my-account-' . $this->id,
    271                                 'title'  => $title,
    272                                 'href'   => $messages_link
    273                         );
    274 
    275                         // Inbox.
    276                         $wp_admin_nav[] = array(
    277                                 'parent'   => 'my-account-' . $this->id,
    278                                 'id'       => 'my-account-' . $this->id . '-inbox',
    279                                 'title'    => $inbox,
    280                                 'href'     => $messages_link,
    281                                 'position' => 10
    282                         );
    283 
    284                         // Starred.
    285                         if ( bp_is_active( $this->id, 'star' ) ) {
    286                                 $wp_admin_nav[] = array(
    287                                         'parent'   => 'my-account-' . $this->id,
    288                                         'id'       => 'my-account-' . $this->id . '-starred',
    289                                         'title'    => __( 'Starred', 'buddypress' ),
    290                                         'href'     => trailingslashit( $messages_link . bp_get_messages_starred_slug() ),
    291                                         'position' => 11
    292                                 );
    293                         }
    294 
    295                         // Sent Messages.
    296                         $wp_admin_nav[] = array(
    297                                 'parent'   => 'my-account-' . $this->id,
    298                                 'id'       => 'my-account-' . $this->id . '-sentbox',
    299                                 'title'    => __( 'Sent', 'buddypress' ),
    300                                 'href'     => trailingslashit( $messages_link . 'sentbox' ),
    301                                 'position' => 20
    302                         );
     246                // Get nav with 'show_in_admin_bar' support.
     247                $nav = buddypress()->members->nav->get_admin_nav( array(
     248                        'parent_slug' => bp_get_messages_slug(),
     249                ) );
    303250
    304                         // Compose Message.
    305                         $wp_admin_nav[] = array(
    306                                 'parent'   => 'my-account-' . $this->id,
    307                                 'id'       => 'my-account-' . $this->id . '-compose',
    308                                 'title'    => __( 'Compose', 'buddypress' ),
    309                                 'href'     => trailingslashit( $messages_link . 'compose' ),
    310                                 'position' => 30
     251                // Set 'Inbox' subnav title.
     252                $count = messages_get_unread_count();
     253                if ( !empty( $count ) ) {
     254                        $inbox = sprintf(
     255                                /* translators: %s: Unread message count for the current user */
     256                                __( 'Inbox %s', 'buddypress' ),
     257                                '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    311258                        );
     259                } else {
     260                        $inbox = __( 'Inbox', 'buddypress' );
     261                }
    312262
    313                         // Site Wide Notices.
    314                         if ( bp_current_user_can( 'bp_moderate' ) ) {
    315                                 $wp_admin_nav[] = array(
    316                                         'parent'   => 'my-account-' . $this->id,
    317                                         'id'       => 'my-account-' . $this->id . '-notices',
    318                                         'title'    => __( 'All Member Notices', 'buddypress' ),
    319                                         'href'     => trailingslashit( $messages_link . 'notices' ),
    320                                         'position' => 90
    321                                 );
     263                // Override some nav items for the admin bar.
     264                if ( ! empty( $nav['children'] ) ) {
     265                        foreach ( $nav['children'] as $key => $sub_nav ) {
     266                                // Override title for "Inbox" nav to add count.
     267                                if ( 'inbox' === $sub_nav->slug ) {
     268                                        $nav['children'][$key]->name = $inbox;
     269                                }
    322270                        }
    323271                }
    324272
    325                 parent::setup_admin_bar( $wp_admin_nav );
     273                // Configure nav array for setup_admin_bar() method.
     274                $nav = $this->setup_admin_nav( $nav );
     275
     276                // Setup the admin bar.
     277                parent::setup_admin_bar( $nav );
    326278        }
    327279
    328280        /**
  • src/bp-notifications/classes/class-bp-notifications-component.php

     
    192192         *                            description.
    193193         */
    194194        public function setup_admin_bar( $wp_admin_nav = array() ) {
     195                if ( ! is_user_logged_in() ) {
     196                        return;
     197                }
    195198
    196                 // Menus for logged in user.
    197                 if ( is_user_logged_in() ) {
    198 
    199                         // Setup the logged in user variables.
    200                         $notifications_link = trailingslashit( bp_loggedin_user_domain() . bp_get_notifications_slug() );
    201 
    202                         // Pending notification requests.
    203                         $count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
    204                         if ( ! empty( $count ) ) {
    205                                 $title = sprintf(
    206                                         /* translators: %s: Unread notification count for the current user */
    207                                         _x( 'Notifications %s', 'My Account Notification pending', 'buddypress' ),
    208                                         '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    209                                 );
    210                                 $unread = sprintf(
    211                                         /* translators: %s: Unread notification count for the current user */
    212                                         _x( 'Unread %s', 'My Account Notification pending', 'buddypress' ),
    213                                         '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    214                                 );
    215                         } else {
    216                                 $title  = _x( 'Notifications', 'My Account Notification',         'buddypress' );
    217                                 $unread = _x( 'Unread',        'My Account Notification sub nav', 'buddypress' );
    218                         }
    219 
    220                         // Add the "My Account" sub menus.
    221                         $wp_admin_nav[] = array(
    222                                 'parent' => buddypress()->my_account_menu_id,
    223                                 'id'     => 'my-account-' . $this->id,
    224                                 'title'  => $title,
    225                                 'href'   => $notifications_link
    226                         );
     199                // Get nav with 'show_in_admin_bar' support.
     200                $nav = buddypress()->members->nav->get_admin_nav( array(
     201                        'parent_slug' => bp_get_notifications_slug(),
     202                ) );
    227203
    228                         // Unread.
    229                         $wp_admin_nav[] = array(
    230                                 'parent'   => 'my-account-' . $this->id,
    231                                 'id'       => 'my-account-' . $this->id . '-unread',
    232                                 'title'    => $unread,
    233                                 'href'     => $notifications_link,
    234                                 'position' => 10
     204                // Set 'Unread' subnav title.
     205                $count = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
     206                if ( ! empty( $count ) ) {
     207                        $unread = sprintf(
     208                                /* translators: %s: Unread notification count for the current user */
     209                                _x( 'Unread %s', 'My Account Notification pending', 'buddypress' ),
     210                                '<span class="count">' . bp_core_number_format( $count ) . '</span>'
    235211                        );
     212                } else {
     213                        $unread = _x( 'Unread', 'My Account Notification sub nav', 'buddypress' );
     214                }
    236215
    237                         // Read.
    238                         $wp_admin_nav[] = array(
    239                                 'parent'   => 'my-account-' . $this->id,
    240                                 'id'       => 'my-account-' . $this->id . '-read',
    241                                 'title'    => _x( 'Read', 'My Account Notification sub nav', 'buddypress' ),
    242                                 'href'     => trailingslashit( $notifications_link . 'read' ),
    243                                 'position' => 20
    244                         );
     216                // Override some nav items for the admin bar.
     217                if ( ! empty( $nav['children'] ) ) {
     218                        foreach ( $nav['children'] as $key => $sub_nav ) {
     219                                // Override title for "Unread" nav to add count.
     220                                if ( 'unread' === $sub_nav->slug ) {
     221                                        $nav['children'][$key]->name = $unread;
     222                                }
     223                        }
    245224                }
    246225
    247                 parent::setup_admin_bar( $wp_admin_nav );
     226                // Configure nav array for setup_admin_bar() method.
     227                $nav = $this->setup_admin_nav( $nav );
     228
     229                // Setup the admin bar.
     230                parent::setup_admin_bar( $nav );
    248231        }
    249232
    250233        /**
  • src/bp-settings/classes/class-bp-settings-component.php

     
    103103                        'position'                => 100,
    104104                        'show_for_displayed_user' => $access,
    105105                        'screen_function'         => 'bp_settings_screen_general',
    106                         'default_subnav_slug'     => 'general'
     106                        'default_subnav_slug'     => 'general',
    107107                );
    108108
    109109                // Add General Settings nav item.
     
    114114                        'parent_slug'     => $slug,
    115115                        'screen_function' => 'bp_settings_screen_general',
    116116                        'position'        => 10,
    117                         'user_has_access' => $access
     117                        'user_has_access' => $access,
    118118                );
    119119
    120120                // Add Email nav item. Formerly called 'Notifications', we
    121121                // retain the old slug and function names for backward compat.
    122122                $sub_nav[] = array(
    123                         'name'            => __( 'Email', 'buddypress' ),
    124                         'slug'            => 'notifications',
    125                         'parent_url'      => $settings_link,
    126                         'parent_slug'     => $slug,
    127                         'screen_function' => 'bp_settings_screen_notification',
    128                         'position'        => 20,
    129                         'user_has_access' => $access
     123                        'name'              => __( 'Email', 'buddypress' ),
     124                        'slug'              => 'notifications',
     125                        'parent_url'        => $settings_link,
     126                        'parent_slug'       => $slug,
     127                        'screen_function'   => 'bp_settings_screen_notification',
     128                        'position'          => 20,
     129                        'user_has_access'   => $access,
     130                        'show_in_admin_bar' => false,
    130131                );
    131132
    132133                // Add Spam Account nav item.
    133134                if ( bp_current_user_can( 'bp_moderate' ) ) {
    134135                        $sub_nav[] = array(
    135                                 'name'            => __( 'Capabilities', 'buddypress' ),
    136                                 'slug'            => 'capabilities',
    137                                 'parent_url'      => $settings_link,
    138                                 'parent_slug'     => $slug,
    139                                 'screen_function' => 'bp_settings_screen_capabilities',
    140                                 'position'        => 80,
    141                                 'user_has_access' => ! bp_is_my_profile()
     136                                'name'              => __( 'Capabilities', 'buddypress' ),
     137                                'slug'              => 'capabilities',
     138                                'parent_url'        => $settings_link,
     139                                'parent_slug'       => $slug,
     140                                'screen_function'   => 'bp_settings_screen_capabilities',
     141                                'position'          => 80,
     142                                'user_has_access'   => ! bp_is_my_profile(),
     143                                'show_in_admin_bar' => false,
    142144                        );
    143145                }
    144146
    145147                // Add Delete Account nav item.
    146148                if ( ( ! bp_disable_account_deletion() && bp_is_my_profile() ) || bp_current_user_can( 'delete_users' ) ) {
    147149                        $sub_nav[] = array(
    148                                 'name'            => __( 'Delete Account', 'buddypress' ),
    149                                 'slug'            => 'delete-account',
    150                                 'parent_url'      => $settings_link,
    151                                 'parent_slug'     => $slug,
    152                                 'screen_function' => 'bp_settings_screen_delete_account',
    153                                 'position'        => 90,
    154                                 'user_has_access' => ! is_super_admin( bp_displayed_user_id() )
     150                                'name'              => __( 'Delete Account', 'buddypress' ),
     151                                'slug'              => 'delete-account',
     152                                'parent_url'        => $settings_link,
     153                                'parent_slug'       => $slug,
     154                                'screen_function'   => 'bp_settings_screen_delete_account',
     155                                'position'          => 90,
     156                                'user_has_access'   => ! is_super_admin( bp_displayed_user_id() ),
     157                                'show_in_admin_bar' => false,
    155158                        );
    156159                }
    157160
     
    166169         * @param array $wp_admin_nav Array of Admin Bar items.
    167170         */
    168171        public function setup_admin_bar( $wp_admin_nav = array() ) {
     172                if ( ! is_user_logged_in() ) {
     173                        return;
     174                }
    169175
    170                 // Menus for logged in user.
    171                 if ( is_user_logged_in() ) {
     176                // Get nav with 'show_in_admin_bar' support.
     177                $nav = buddypress()->members->nav->get_admin_nav( array(
     178                        'parent_slug' => bp_get_settings_slug(),
     179                ) );
    172180
    173                         // Setup the logged in user variables.
    174                         $settings_link = trailingslashit( bp_loggedin_user_domain() . bp_get_settings_slug() );
     181                // Configure nav array for setup_admin_bar() method.
     182                $nav = $this->setup_admin_nav( $nav );
    175183
    176                         // Add main Settings menu.
    177                         $wp_admin_nav[] = array(
    178                                 'parent' => buddypress()->my_account_menu_id,
    179                                 'id'     => 'my-account-' . $this->id,
    180                                 'title'  => __( 'Settings', 'buddypress' ),
    181                                 'href'   => $settings_link
    182                         );
     184                // Notifications - only add the tab when there is something to display there.
     185                $settings_link = trailingslashit( bp_loggedin_user_domain() . bp_get_settings_slug() );
    183186
    184                         // General Account.
    185                         $wp_admin_nav[] = array(
     187                if ( has_action( 'bp_notification_settings' ) ) {
     188                        $nav[] = array(
    186189                                'parent'   => 'my-account-' . $this->id,
    187                                 'id'       => 'my-account-' . $this->id . '-general',
    188                                 'title'    => __( 'General', 'buddypress' ),
    189                                 'href'     => $settings_link,
    190                                 'position' => 10
     190                                'id'       => 'my-account-' . $this->id . '-notifications',
     191                                'title'    => __( 'Email', 'buddypress' ),
     192                                'href'     => trailingslashit( $settings_link . 'notifications' ),
     193                                'position' => 20
    191194                        );
     195                }
    192196
    193                         // Notifications - only add the tab when there is something to display there.
    194                         if ( has_action( 'bp_notification_settings' ) ) {
    195                                 $wp_admin_nav[] = array(
    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
    201                                 );
    202                         }
    203 
    204                         // Delete Account
    205                         if ( !bp_current_user_can( 'bp_moderate' ) && ! bp_core_get_root_option( 'bp-disable-account-deletion' ) ) {
    206                                 $wp_admin_nav[] = array(
    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
    212                                 );
    213                         }
     197                // Delete Account
     198                if ( !bp_current_user_can( 'bp_moderate' ) && ! bp_core_get_root_option( 'bp-disable-account-deletion' ) ) {
     199                        $nav[] = array(
     200                                'parent'   => 'my-account-' . $this->id,
     201                                'id'       => 'my-account-' . $this->id . '-delete-account',
     202                                'title'    => __( 'Delete Account', 'buddypress' ),
     203                                'href'     => trailingslashit( $settings_link . 'delete-account' ),
     204                                'position' => 90
     205                        );
    214206                }
    215207
    216                 parent::setup_admin_bar( $wp_admin_nav );
     208                // Setup the admin bar.
     209                parent::setup_admin_bar( $nav );
    217210        }
    218211}
  • src/bp-xprofile/classes/class-bp-xprofile-component.php

     
    212212                        'position'            => 20,
    213213                        'screen_function'     => 'xprofile_screen_display_profile',
    214214                        'default_subnav_slug' => 'public',
    215                         'item_css_id'         => $this->id
     215                        'item_css_id'         => $this->id,
    216216                );
    217217
    218218                // Add the subnav items to the profile.
     
    222222                        'parent_url'      => $profile_link,
    223223                        'parent_slug'     => $slug,
    224224                        'screen_function' => 'xprofile_screen_display_profile',
    225                         'position'        => 10
     225                        'position'        => 10,
    226226                );
    227227
    228228                // Edit Profile.
     
    233233                        'parent_slug'     => $slug,
    234234                        'screen_function' => 'xprofile_screen_edit_profile',
    235235                        'position'        => 20,
    236                         'user_has_access' => $access
     236                        'user_has_access' => $access,
    237237                );
    238238
    239239                // Change Avatar.
     
    245245                                'parent_slug'     => $slug,
    246246                                'screen_function' => 'xprofile_screen_change_avatar',
    247247                                'position'        => 30,
    248                                 'user_has_access' => $access
     248                                'user_has_access' => $access,
    249249                        );
    250250                }
    251251
     
    258258                                'parent_slug'     => $slug,
    259259                                'screen_function' => 'xprofile_screen_change_cover_image',
    260260                                'position'        => 40,
    261                                 'user_has_access' => $access
     261                                'user_has_access' => $access,
    262262                        );
    263263                }
    264264
     
    301301                        'parent_slug'     => $settings_slug,
    302302                        'screen_function' => 'bp_xprofile_screen_settings',
    303303                        'position'        => 30,
    304                         'user_has_access' => bp_core_can_edit_settings()
     304                        'user_has_access' => bp_core_can_edit_settings(),
    305305                ), 'members' );
    306306        }
    307307
     
    313313         * @param array $wp_admin_nav Admin Bar items.
    314314         */
    315315        public function setup_admin_bar( $wp_admin_nav = array() ) {
     316                if ( ! is_user_logged_in() ) {
     317                        return;
     318                }
    316319
    317                 // Menus for logged in user.
    318                 if ( is_user_logged_in() ) {
    319 
    320                         // Profile link.
    321                         $profile_link = trailingslashit( bp_loggedin_user_domain() . bp_get_profile_slug() );
    322 
    323                         // Add the "Profile" sub menu.
    324                         $wp_admin_nav[] = array(
    325                                 'parent' => buddypress()->my_account_menu_id,
    326                                 'id'     => 'my-account-' . $this->id,
    327                                 'title'  => _x( 'Profile', 'My Account Profile', 'buddypress' ),
    328                                 'href'   => $profile_link
    329                         );
    330 
    331                         // View Profile.
    332                         $wp_admin_nav[] = array(
    333                                 'parent'   => 'my-account-' . $this->id,
    334                                 'id'       => 'my-account-' . $this->id . '-public',
    335                                 'title'    => _x( 'View', 'My Account Profile sub nav', 'buddypress' ),
    336                                 'href'     => $profile_link,
    337                                 'position' => 10
    338                         );
    339 
    340                         // Edit Profile.
    341                         $wp_admin_nav[] = array(
    342                                 'parent'   => 'my-account-' . $this->id,
    343                                 'id'       => 'my-account-' . $this->id . '-edit',
    344                                 'title'    => _x( 'Edit', 'My Account Profile sub nav', 'buddypress' ),
    345                                 'href'     => trailingslashit( $profile_link . 'edit' ),
    346                                 'position' => 20
    347                         );
    348 
    349                         // Edit Avatar.
    350                         if ( buddypress()->avatar->show_avatars ) {
    351                                 $wp_admin_nav[] = array(
    352                                         'parent'   => 'my-account-' . $this->id,
    353                                         'id'       => 'my-account-' . $this->id . '-change-avatar',
    354                                         'title'    => _x( 'Change Profile Photo', 'My Account Profile sub nav', 'buddypress' ),
    355                                         'href'     => trailingslashit( $profile_link . 'change-avatar' ),
    356                                         'position' => 30
    357                                 );
    358                         }
     320                // Get nav with 'show_in_admin_bar' support.
     321                $nav = buddypress()->members->nav->get_admin_nav( array(
     322                        'parent_slug' => bp_get_profile_slug(),
     323                ) );
    359324
    360                         if ( bp_displayed_user_use_cover_image_header() ) {
    361                                 $wp_admin_nav[] = array(
    362                                         'parent'   => 'my-account-' . $this->id,
    363                                         'id'       => 'my-account-' . $this->id . '-change-cover-image',
    364                                         'title'    => _x( 'Change Cover Image', 'My Account Profile sub nav', 'buddypress' ),
    365                                         'href'     => trailingslashit( $profile_link . 'change-cover-image' ),
    366                                         'position' => 40
    367                                 );
    368                         }
    369                 }
     325                // Configure nav array for setup_admin_bar() method.
     326                $nav = $this->setup_admin_nav( $nav );
    370327
    371                 parent::setup_admin_bar( $wp_admin_nav );
     328                // Setup the admin bar.
     329                parent::setup_admin_bar( $nav );
    372330        }
    373331
    374332        /**