Ticket #35272: 35272.4.diff
File 35272.4.diff, 2.3 KB (added by , 9 years ago) |
---|
-
src/wp-includes/nav-menu-template.php
334 334 $possible_object_parents = array_filter( $possible_object_parents ); 335 335 336 336 $front_page_url = home_url(); 337 $front_page_id = (int) get_option( 'page_on_front' ); 337 338 338 339 foreach ( (array) $menu_items as $key => $menu_item ) { 339 340 … … 344 345 $classes[] = 'menu-item-type-' . $menu_item->type; 345 346 $classes[] = 'menu-item-object-' . $menu_item->object; 346 347 348 // This menu item is set as the 'Front Page'. 349 if ( $front_page_id === (int) $menu_item->object_id ) { 350 $classes[] = 'menu-item-home'; 351 } 352 347 353 // if the menu item corresponds to a taxonomy term for the currently-queried non-hierarchical post object 348 354 if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) { 349 355 $active_parent_object_ids[] = (int) $menu_item->object_id; … … 377 383 $classes[] = 'current_page_item'; 378 384 } 379 385 380 if ( 'page_on_front' ) {381 $classes[] = 'menu-item-home';382 }383 384 386 $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; 385 387 $active_parent_object_ids[] = (int) $menu_item->post_parent; 386 388 $active_object = $menu_item->object; -
tests/phpunit/tests/post/nav-menu.php
444 444 $this->assertTrue( is_object( $args ) ); 445 445 return $ignored_1; 446 446 } 447 448 449 /** 450 * @ticket 35272 451 */ 452 function test_class_applied_to_front_page_item() { 453 454 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Home Page' ) ); 455 update_option( 'page_on_front', $page_id ); 456 457 wp_update_nav_menu_item( $this->menu_id, 0, array( 458 'menu-item-type' => 'post_type', 459 'menu-item-object' => 'page', 460 'menu-item-object-id' => $page_id, 461 'menu-item-status' => 'publish', 462 )); 463 464 $menu_items = wp_get_nav_menu_items( $this->menu_id ); 465 _wp_menu_item_classes_by_context( $menu_items ); 466 467 $classes = $menu_items[0]->classes; 468 469 $this->assertContains( 'menu-item-home', $classes ); 470 } 447 471 }