Skip to:
Content

BuddyPress.org

Changeset 13093


Ignore:
Timestamp:
08/25/2021 08:13:04 AM (3 years ago)
Author:
imath
Message:

Make sure bp_core_new_nav_default() updates the previous default nav

  • The previous default nav item needs to have its slug added to its link property.
  • The default subnav slug needs to be added to the URL used by the corresponding wp_admin_nav item.
  • The new default nav item needs to have its slug removed from its link property.

Fixes #8471

Location:
trunk/src
Files:
10 edited

Legend:

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

    r13001 r13093  
    368368                'id'       => 'my-account-' . $this->id . '-personal',
    369369                'title'    => _x( 'Personal', 'My Account Activity sub nav', 'buddypress' ),
    370                 'href'     => $activity_link,
     370                'href'     => trailingslashit( $activity_link . 'just-me' ),
    371371                'position' => 10
    372372            );
  • trunk/src/bp-blogs/classes/class-bp-blogs-component.php

    r13024 r13093  
    297297                'id'       => 'my-account-' . $this->id . '-my-sites',
    298298                'title'    => __( 'My Sites', 'buddypress' ),
    299                 'href'     => $blogs_link,
     299                'href'     => trailingslashit( $blogs_link . 'my-sites' ),
    300300                'position' => 10
    301301            );
  • trunk/src/bp-core/bp-core-buddybar.php

    r12893 r13093  
    326326    $parent_nav = reset( $parent_nav );
    327327
    328     if ( ! empty( $parent_nav->screen_function ) ) {
    329         // Remove our screen hook if screen function is callable.
    330         if ( is_callable( $parent_nav->screen_function ) ) {
    331             remove_action( 'bp_screens', $parent_nav->screen_function, 3 );
    332         }
    333     }
    334 
    335328    // Edit the screen function for the parent nav.
    336     $bp->members->nav->edit_nav( array(
    337         'screen_function'     => &$r['screen_function'],
    338         'default_subnav_slug' => $r['subnav_slug'],
    339     ), $parent_nav->slug );
     329    $bp->members->nav->edit_nav(
     330        array(
     331            'screen_function'     => &$r['screen_function'],
     332            'default_subnav_slug' => $r['subnav_slug'],
     333        ),
     334        $parent_nav->slug
     335    );
     336
     337    /**
     338     * Update secondary nav items:
     339     * - The previous default nav item needs to have its slug added to its link property.
     340     * - The new default nav item needs to have its slug removed from its link property.
     341     */
     342    $previous_default_subnav = $bp->members->nav->get( $parent_nav->slug . '/' . $parent_nav->default_subnav_slug );
     343
     344    // Edit the link of the previous default nav item.
     345    $bp->members->nav->edit_nav(
     346        array(
     347            'link' => trailingslashit( $previous_default_subnav->link . $previous_default_subnav->slug ),
     348        ),
     349        $previous_default_subnav->slug,
     350        $parent_nav->slug
     351    );
     352
     353    $new_default_subnav = $bp->members->nav->get( $parent_nav->slug . '/' . $r['subnav_slug'] );
     354
     355    // Edit the link of the new default nav item.
     356    $bp->members->nav->edit_nav(
     357        array(
     358            'link' => rtrim( untrailingslashit( $new_default_subnav->link ), $new_default_subnav->slug ),
     359        ),
     360        $new_default_subnav->slug,
     361        $parent_nav->slug
     362    );
    340363
    341364    if ( bp_is_current_component( $parent_nav->slug ) ) {
  • trunk/src/bp-friends/classes/class-bp-friends-component.php

    r13092 r13093  
    272272                'id'       => 'my-account-' . $this->id . '-friendships',
    273273                'title'    => _x( 'Friendships', 'My Account Friends menu sub nav', 'buddypress' ),
    274                 'href'     => $friends_link,
     274                'href'     => trailingslashit( $friends_link . 'my-friends' ),
    275275                'position' => 10,
    276276            );
  • trunk/src/bp-groups/classes/class-bp-groups-component.php

    r13087 r13093  
    844844                'id'       => 'my-account-' . $this->id . '-memberships',
    845845                'title'    => _x( 'Memberships', 'My Account Groups sub nav', 'buddypress' ),
    846                 'href'     => $groups_link,
     846                'href'     => trailingslashit( $groups_link . 'my-groups' ),
    847847                'position' => 10
    848848            );
  • trunk/src/bp-members/classes/class-bp-members-component.php

    r13087 r13093  
    640640                    'id'       => 'my-account-' . $this->id . '-public',
    641641                    'title'    => _x( 'View', 'My Account Profile sub nav', 'buddypress' ),
    642                     'href'     => $profile_link,
     642                    'href'     => trailingslashit( $profile_link . 'public' ),
    643643                    'position' => 10
    644644                );
  • trunk/src/bp-messages/classes/class-bp-messages-component.php

    r13005 r13093  
    347347                'id'       => 'my-account-' . $this->id . '-inbox',
    348348                'title'    => $inbox,
    349                 'href'     => $messages_link,
     349                'href'     => trailingslashit( $messages_link . 'inbox' ),
    350350                'position' => 10
    351351            );
  • trunk/src/bp-notifications/classes/class-bp-notifications-component.php

    r13091 r13093  
    258258                'id'       => 'my-account-' . $this->id . '-unread',
    259259                'title'    => $unread,
    260                 'href'     => $notifications_link,
     260                'href'     => trailingslashit( $notifications_link . 'unread' ),
    261261                'position' => 10,
    262262            );
  • trunk/src/bp-settings/classes/class-bp-settings-component.php

    r13091 r13093  
    260260                'id'       => 'my-account-' . $this->id . '-general',
    261261                'title'    => __( 'General', 'buddypress' ),
    262                 'href'     => $settings_link,
     262                'href'     => trailingslashit( $settings_link . 'general' ),
    263263                'position' => 10,
    264264            );
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-component.php

    r12994 r13093  
    345345                'id'       => 'my-account-' . $this->id . '-public',
    346346                'title'    => _x( 'View', 'My Account Profile sub nav', 'buddypress' ),
    347                 'href'     => $profile_link,
     347                'href'     => trailingslashit( $profile_link . 'public' ),
    348348                'position' => 10
    349349            );
Note: See TracChangeset for help on using the changeset viewer.