Changeset 12194
- Timestamp:
- 07/24/2018 02:52:05 AM (7 years ago)
- Location:
- branches/3.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/src/bp-core/bp-core-buddybar.php
r11815 r12194 609 609 610 610 $parent_nav = $bp->{$component}->nav->get_primary( array( 'slug' => $r['parent_slug'] ), false ); 611 if ( ! $parent_nav ) { 612 return ; 613 } 614 615 $parent_nav = reset( $parent_nav ); 611 if ( is_array( $parent_nav ) ) { 612 $parent_nav = reset( $parent_nav ); 613 } 616 614 617 615 // If we *do* meet condition (2), then the added subnav item is currently being requested. -
branches/3.0/tests/phpunit/testcases/core/nav/bpCoreNewSubnavItem.php
r11737 r12194 336 336 $this->assertSame( 'bar', buddypress()->bp_options_nav['parent']['foo']['css_id'] ); 337 337 } 338 339 /** 340 * @ticket BP7931 341 */ 342 public function test_subnav_should_not_404_on_early_bp_setup_nav_priority() { 343 $u = self::factory()->user->create(); 344 $old_current_user = get_current_user_id(); 345 $this->set_current_user( $u ); 346 347 $user_domain = bp_core_get_user_domain( $u ); 348 349 // Register a subnav on 'bp_setup_nav' hook early (at priority zero). 350 add_action( 'bp_setup_nav', function() use ( $user_domain ) { 351 /* 352 * Emulate a subnav screen. 353 * 354 * The bp_core_load_template() call is imperative for our 404 check to work! 355 */ 356 $screen = function() { 357 bp_core_load_template ('members/single/plugins'); 358 }; 359 360 // Register the subnav. 361 bp_core_new_subnav_item( array ( 362 'name' => 'Testing', 363 'slug' => 'testing', 364 'parent_url' => $user_domain . bp_get_profile_slug (). '/', 365 'parent_slug' => bp_get_profile_slug (), 366 'screen_function' => $screen, 367 'position' => 20 368 ) ); 369 }, 0 ); 370 371 // Emulate visit to our new subnav page. 372 $this->go_to( $user_domain . bp_get_profile_slug () . '/testing/' ); 373 374 // Assert that subnav page does not 404. 375 $this->assertFalse( is_404() ); 376 377 $this->set_current_user( $old_current_user ); 378 } 338 379 }
Note: See TracChangeset
for help on using the changeset viewer.