mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
Menus: Add white space option to wp_nav_menu() and wp_list_pages().
Adds an `item_spacing` option to the arguments array for the functions `wp_nav_menu()`, `wp_list_pages()`, and `wp_page_menu()`. `item_spacing` is a boolean accepting either `preserve` or `discard`. Previously, certain CSS choices could result in a site's layout changing if `wp_nav_menu()` fell back to the default `wp_list_pages()` due to differences in the whitespace within the HTML. The new argument ensures a function outputs consistant HTML while maintaining backward compatibility. Fixes #35206. git-svn-id: https://develop.svn.wordpress.org/trunk@38523 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -299,6 +299,10 @@ NO;
|
||||
// After falling back, the 'after' argument should be set and output as '</ul>'.
|
||||
$this->assertRegExp( '/<\/ul><\/div>/', $menu );
|
||||
|
||||
// After falling back, the markup should include whitespace around <li>s
|
||||
$this->assertRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
|
||||
$this->assertNotRegExp( '/><li.*>|<\/li></U', $menu );
|
||||
|
||||
// No menus + wp_nav_menu() falls back to wp_page_menu(), this time without a container.
|
||||
$menu = wp_nav_menu( array(
|
||||
'echo' => false,
|
||||
@@ -307,5 +311,16 @@ NO;
|
||||
|
||||
// After falling back, the empty 'container' argument should still return a container element.
|
||||
$this->assertRegExp( '/<div class="menu">/', $menu );
|
||||
|
||||
// No menus + wp_nav_menu() falls back to wp_page_menu(), this time without white-space.
|
||||
$menu = wp_nav_menu( array(
|
||||
'echo' => false,
|
||||
'item_spacing' => 'discard',
|
||||
) );
|
||||
|
||||
// After falling back, the markup should not include whitespace around <li>s
|
||||
$this->assertNotRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
|
||||
$this->assertRegExp( '/><li.*>|<\/li></U', $menu );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user