Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/10/2016 02:53:53 PM (10 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.