Make WordPress Core


Ignore:
Timestamp:
10/08/2015 06:26:13 PM (9 years ago)
Author:
obenland
Message:

Template: Add fallback for empty containers.

Since [14031] the container can be omitted in wp_nav_menu(). It can not
however in wp_page_menu(), which creates a conflict if it is set as
the fallback, Let's make sure there is always a valid container tag.

Fixes #33974.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/template.php

    r34654 r34950  
    282282    /**
    283283     * @ticket 11095
     284     * @ticket 33974
    284285     */
    285286    public function test_wp_page_menu_wp_nav_menu_fallback() {
     
    294295        // After falling back, the 'after' argument should be set and output as '</ul>'.
    295296        $this->assertRegExp( '/<\/ul><\/div>/', $menu );
     297
     298        // No menus + wp_nav_menu() falls back to wp_page_menu(), this time without a container.
     299        $menu = wp_nav_menu( array(
     300            'echo'      => false,
     301            'container' => false,
     302        ) );
     303
     304        // After falling back, the empty 'container' argument should still return a container element.
     305        $this->assertRegExp( '/<div class="menu">/', $menu );
    296306    }
    297307}
Note: See TracChangeset for help on using the changeset viewer.