Skip to:
Content

BuddyPress.org

Changeset 10876


Ignore:
Timestamp:
06/10/2016 02:53:53 PM (8 years ago)
Author:
boonebgorges
Message:

Fix syntax error in back compat block of bp_core_remove_subnav_item().

The arguments were reversed, causing a compatibility break with plugins
using bp_core_remove_subnav_item() to remove group nav items.

We simplify the logic by setting $component to 'groups' in thes cases, and
letting the rest of the function handle the nav removal.

To maintain the parallel construction, a similar syntax change has been
introduced to bp_core_remove_nav_item().

Props dcavins, imath.
Fixes #6534.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-buddybar.php

    r10825 r10876  
    784784    if ( ! $component && bp_is_active( 'groups' ) && isset( $bp->groups->nav ) ) {
    785785        if ( $bp->groups->nav->get_primary( array( 'slug' => $slug ) ) ) {
    786             return bp_core_remove_nav_item( $slug, 'groups' );
     786            $component = 'groups';
    787787        }
    788788    }
     
    835835    if ( ! $component && bp_is_active( 'groups' ) && isset( $bp->groups->nav ) ) {
    836836        if ( $bp->groups->nav->get_primary( array( 'slug' => $parent_slug ) ) ) {
    837             return bp_core_remove_subnav_item( $slug, $parent_slug, 'groups' );
     837            $component = 'groups';
    838838        }
    839839    }
  • trunk/tests/phpunit/testcases/core/nav/bpCoreRemoveSubnavItem.php

    r10745 r10876  
    7171        $bp->bp_options_nav = $_bp_options_nav;
    7272    }
     73
     74    public function test_backcompat_remove_group_nav_items() {
     75        $g1 = $this->factory->group->create();
     76
     77        // In group context
     78        $g_obj = groups_get_group( array( 'group_id' => $g1 ) );
     79        $this->go_to( bp_get_group_permalink( $g_obj ) );
     80
     81        bp_core_new_subnav_item( array(
     82            'name' => 'Clam',
     83            'slug' => 'clam',
     84            'parent_slug' => bp_get_current_group_slug(),
     85            'parent_url' => bp_get_group_permalink( $g_obj ),
     86            'screen_function' => 'clam_subnav',
     87        ) );
     88
     89        bp_core_remove_subnav_item( $g_obj->slug, 'clam' );
     90
     91        $nav = bp_get_nav_menu_items( 'groups' );
     92        $found = false;
     93        foreach ( $nav as $_nav ) {
     94            if ( 'clam' === $_nav->css_id ) {
     95                $found = true;
     96                break;
     97            }
     98        }
     99
     100        $this->assertFalse( $found );
     101    }
    73102}
Note: See TracChangeset for help on using the changeset viewer.