diff --git src/bp-core/bp-core-buddybar.php src/bp-core/bp-core-buddybar.php
index f16557f..77fabd6 100644
|
|
function bp_core_remove_subnav_item( $parent_slug, $slug, $component = null ) { |
834 | 834 | // Backward compatibility for removing group nav items using the group slug as `$parent_slug`. |
835 | 835 | if ( ! $component && bp_is_active( 'groups' ) && isset( $bp->groups->nav ) ) { |
836 | 836 | if ( $bp->groups->nav->get_primary( array( 'slug' => $parent_slug ) ) ) { |
837 | | return bp_core_remove_subnav_item( $slug, $parent_slug, 'groups' ); |
| 837 | $component = 'groups'; |
838 | 838 | } |
839 | 839 | } |
840 | 840 | |
diff --git tests/phpunit/testcases/core/nav/bpCoreRemoveSubnavItem.php tests/phpunit/testcases/core/nav/bpCoreRemoveSubnavItem.php
index 1d87e1e..a91413a 100644
|
|
class BP_Tests_Core_Nav_BpCoreRemoveSubnavItem extends BP_UnitTestCase { |
70 | 70 | $bp->bp_nav = $_bp_nav; |
71 | 71 | $bp->bp_options_nav = $_bp_options_nav; |
72 | 72 | } |
| 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 | } |
73 | 102 | } |