Skip to content

Instantly share code, notes, and snippets.

@christophherr
Created October 26, 2016 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save christophherr/91e961aefe4b3961a745016f7f0a26b8 to your computer and use it in GitHub Desktop.
Save christophherr/91e961aefe4b3961a745016f7f0a26b8 to your computer and use it in GitHub Desktop.
Forth unit test 35272
function test_class_not_applied_to_page_item() {
$page_id1 = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Home Page' ) );
update_option( 'page_on_front', $page_id1 );
$page_id2 = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Test Page' ) );
wp_update_nav_menu_item( $this->menu_id, 0, array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'page',
'menu-item-object-id' => $page_id1,
'menu-item-status' => 'publish',
));
wp_update_nav_menu_item( $this->menu_id, 0, array(
'menu-item-type' => 'post_type',
'menu-item-object' => 'page',
'menu-item-object-id' => $page_id2,
'menu-item-status' => 'publish',
));
$permalink = get_permalink( $page_id2 );
$this->go_to( $permalink );
$menu_items = wp_get_nav_menu_items( $this->menu_id );
_wp_menu_item_classes_by_context( $menu_items );
$classes = $menu_items[1]->classes;
delete_option( 'page_on_front' );
$this->assertNotContains( 'menu-item-home', $classes );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment