<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[38523] trunk: Menus: Add white space option to `wp_nav_menu()` and `wp_list_pages()`.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/38523">38523</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/38523","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>peterwilsoncc</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-09-06 09:05:45 +0000 (Tue, 06 Sep 2016)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/ticket/35206">#35206</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswalkernavmenuphp">trunk/src/wp-includes/class-walker-nav-menu.php</a></li>
<li><a href="#trunksrcwpincludesclasswalkerpagephp">trunk/src/wp-includes/class-walker-page.php</a></li>
<li><a href="#trunksrcwpincludesnavmenutemplatephp">trunk/src/wp-includes/nav-menu-template.php</a></li>
<li><a href="#trunksrcwpincludesposttemplatephp">trunk/src/wp-includes/post-template.php</a></li>
<li><a href="#trunktestsphpunittestspostlistPagesphp">trunk/tests/phpunit/tests/post/listPages.php</a></li>
<li><a href="#trunktestsphpunittestspostnavmenuphp">trunk/tests/phpunit/tests/post/nav-menu.php</a></li>
<li><a href="#trunktestsphpunittestsposttemplatephp">trunk/tests/phpunit/tests/post/template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswalkernavmenuphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-walker-nav-menu.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-walker-nav-menu.php   2016-09-05 12:08:39 UTC (rev 38522)
+++ trunk/src/wp-includes/class-walker-nav-menu.php     2016-09-06 09:05:45 UTC (rev 38523)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,8 +50,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array  $args   An array of wp_nav_menu() arguments.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function start_lvl( &$output, $depth = 0, $args = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $indent = str_repeat("\t", $depth);
-               $output .= "\n$indent<ul class=\"sub-menu\">\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 'preserve' === $args->item_spacing ) {
+                       $t = "\t";
+                       $n = "\n";
+               } else {
+                       $t = '';
+                       $n = '';
+               }
+               $indent = str_repeat( $t, $depth );
+               $output .= "{$n}{$indent}<ul class=\"sub-menu\">{$n}";
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -66,8 +73,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array  $args   An array of wp_nav_menu() arguments.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function end_lvl( &$output, $depth = 0, $args = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $indent = str_repeat("\t", $depth);
-               $output .= "$indent</ul>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 'preserve' === $args->item_spacing ) {
+                       $t = "\t";
+                       $n = "\n";
+               } else {
+                       $t = '';
+                       $n = '';
+               }
+               $indent = str_repeat( $t, $depth );
+               $output .= "$indent</ul>{$n}";
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -85,7 +99,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param int    $id     Current item ID.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 'preserve' === $args->item_spacing ) {
+                       $t = "\t";
+                       $n = "\n";
+               } else {
+                       $t = '';
+                       $n = '';
+               }
+               $indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $classes = empty( $item->classes ) ? array() : (array) $item->classes;
</span><span class="cx" style="display: block; padding: 0 10px">                $classes[] = 'menu-item-' . $item->ID;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -216,7 +237,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array  $args   An array of wp_nav_menu() arguments.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function end_el( &$output, $item, $depth = 0, $args = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $output .= "</li>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 'preserve' === $args->item_spacing ) {
+                       $t = "\t";
+                       $n = "\n";
+               } else {
+                       $t = '';
+                       $n = '';
+               }
+               $output .= "</li>{$n}";
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> } // Walker_Nav_Menu
</span></span></pre></div>
<a id="trunksrcwpincludesclasswalkerpagephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-walker-page.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-walker-page.php       2016-09-05 12:08:39 UTC (rev 38522)
+++ trunk/src/wp-includes/class-walker-page.php 2016-09-06 09:05:45 UTC (rev 38523)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,8 +53,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *                       Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function start_lvl( &$output, $depth = 0, $args = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $indent = str_repeat("\t", $depth);
-               $output .= "\n$indent<ul class='children'>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 'preserve' === $args['item_spacing'] ) {
+                       $t = "\t";
+                       $n = "\n";
+               } else {
+                       $t = '';
+                       $n = '';
+               }
+               $indent = str_repeat( $t, $depth );
+               $output .= "{$n}{$indent}<ul class='children'>{$n}";
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -71,8 +78,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *                       Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function end_lvl( &$output, $depth = 0, $args = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $indent = str_repeat("\t", $depth);
-               $output .= "$indent</ul>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 'preserve' === $args['item_spacing'] ) {
+                       $t = "\t";
+                       $n = "\n";
+               } else {
+                       $t = '';
+                       $n = '';
+               }
+               $indent = str_repeat( $t, $depth );
+               $output .= "{$indent}</ul>{$n}";
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -89,8 +103,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param int     $current_page Optional. Page ID. Default 0.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                if ( 'preserve' === $args['item_spacing'] ) {
+                       $t = "\t";
+                       $n = "\n";
+               } else {
+                       $t = '';
+                       $n = '';
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( $depth ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $indent = str_repeat( "\t", $depth );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $indent = str_repeat( $t, $depth );
</ins><span class="cx" style="display: block; padding: 0 10px">                 } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        $indent = '';
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -175,7 +196,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param array   $args   Optional. Array of arguments. Default empty array.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function end_el( &$output, $page, $depth = 0, $args = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $output .= "</li>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 'preserve' === $args['item_spacing'] ) {
+                       $t = "\t";
+                       $n = "\n";
+               } else {
+                       $t = '';
+                       $n = '';
+               }
+               $output .= "</li>{$n}";
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesnavmenutemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/nav-menu-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/nav-menu-template.php       2016-09-05 12:08:39 UTC (rev 38522)
+++ trunk/src/wp-includes/nav-menu-template.php 2016-09-06 09:05:45 UTC (rev 38523)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,6 +40,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *                                               in order to be selectable by the user.
</span><span class="cx" style="display: block; padding: 0 10px">  *     @type string             $items_wrap      How the list items should be wrapped. Default is a ul with an id and class.
</span><span class="cx" style="display: block; padding: 0 10px">  *                                               Uses printf() format with numbered placeholders.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *     @type string             $item_spacing    Whether whitespace format the menu's HTML: 'discard' or 'preserve' (default).
</ins><span class="cx" style="display: block; padding: 0 10px">  * }
</span><span class="cx" style="display: block; padding: 0 10px">  * @return object|false|void Menu output if $echo is false, false if there are no items or no menu was found.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -47,10 +48,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">        static $menu_id_slugs = array();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'item_spacing' => 'preserve',
</ins><span class="cx" style="display: block; padding: 0 10px">         'depth' => 0, 'walker' => '', 'theme_location' => '' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $args = wp_parse_args( $args, $defaults );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
+               // invalid value, fall back to default.
+               $args['item_spacing'] = $defaults['item_spacing'];
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Filters the arguments used to display a navigation menu.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span></span></pre></div>
<a id="trunksrcwpincludesposttemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/post-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/post-template.php   2016-09-05 12:08:39 UTC (rev 38522)
+++ trunk/src/wp-includes/post-template.php     2016-09-06 09:05:45 UTC (rev 38523)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1138,6 +1138,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *                                'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
</span><span class="cx" style="display: block; padding: 0 10px">  *     @type string $title_li     List heading. Passing a null or empty value will result in no heading, and the list
</span><span class="cx" style="display: block; padding: 0 10px">  *                                will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *     @type string $item_spacing Whether whitespace format the menu's HTML: 'discard' or 'preserve' (default).
</ins><span class="cx" style="display: block; padding: 0 10px">  *     @type Walker $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
</span><span class="cx" style="display: block; padding: 0 10px">  * }
</span><span class="cx" style="display: block; padding: 0 10px">  * @return string|void HTML list of pages.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1149,11 +1150,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                'child_of' => 0, 'exclude' => '',
</span><span class="cx" style="display: block; padding: 0 10px">                'title_li' => __( 'Pages' ), 'echo' => 1,
</span><span class="cx" style="display: block; padding: 0 10px">                'authors' => '', 'sort_column' => 'menu_order, post_title',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                'link_before' => '', 'link_after' => '', 'walker' => '',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         'link_before' => '', 'link_after' => '', 'item_spacing' => 'preserve', 'walker' => '',
</ins><span class="cx" style="display: block; padding: 0 10px">         );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $r = wp_parse_args( $args, $defaults );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( ! in_array( $r['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
+               // invalid value, fall back to default.
+               $r['item_spacing'] = $defaults['item_spacing'];
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         $output = '';
</span><span class="cx" style="display: block; padding: 0 10px">        $current_page = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1230,38 +1236,53 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @param array|string $args {
</span><span class="cx" style="display: block; padding: 0 10px">  *     Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *     @type string          $sort_column How to short the list of pages. Accepts post column names.
- *                                        Default 'menu_order, post_title'.
- *     @type string          $menu_id     ID for the div containing the page list. Default is empty string.
- *     @type string          $menu_class  Class to use for the element containing the page list. Default 'menu'.
- *     @type string          $container   Element to use for the element containing the page list. Default 'div'.
- *     @type bool            $echo        Whether to echo the list or return it. Accepts true (echo) or false (return).
- *                                        Default true.
- *     @type int|bool|string $show_home   Whether to display the link to the home page. Can just enter the text
- *                                        you'd like shown for the home link. 1|true defaults to 'Home'.
- *     @type string          $link_before The HTML or text to prepend to $show_home text. Default empty.
- *     @type string          $link_after  The HTML or text to append to $show_home text. Default empty.
- *     @type string          $before      The HTML or text to prepend to the menu. Default is '<ul>'.
- *     @type string          $after       The HTML or text to append to the menu. Default is '</ul>'.
- *     @type Walker          $walker      Walker instance to use for listing pages. Default empty (Walker_Page).
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *     @type string          $sort_column  How to short the list of pages. Accepts post column names.
+ *                                         Default 'menu_order, post_title'.
+ *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
+ *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
+ *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
+ *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
+ *                                         Default true.
+ *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
+ *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
+ *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
+ *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
+ *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
+ *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
+ *     @type string          $item_spacing Whether whitespace format the menu's HTML: 'discard' or 'preserve' (default).
+ *     @type Walker          $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
</ins><span class="cx" style="display: block; padding: 0 10px">  * }
</span><span class="cx" style="display: block; padding: 0 10px">  * @return string|void HTML menu
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_page_menu( $args = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px">        $defaults = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                'sort_column' => 'menu_order, post_title',
-               'menu_id'     => '',
-               'menu_class'  => 'menu',
-               'container'   => 'div',
-               'echo'        => true,
-               'link_before' => '',
-               'link_after'  => '',
-               'before'      => '<ul>',
-               'after'       => '</ul>',
-               'walker'      => '',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         'sort_column'  => 'menu_order, post_title',
+               'menu_id'      => '',
+               'menu_class'   => 'menu',
+               'container'    => 'div',
+               'echo'         => true,
+               'link_before'  => '',
+               'link_after'   => '',
+               'before'       => '<ul>',
+               'after'        => '</ul>',
+               'item_spacing' => 'discard',
+               'walker'       => '',
</ins><span class="cx" style="display: block; padding: 0 10px">         );
</span><span class="cx" style="display: block; padding: 0 10px">        $args = wp_parse_args( $args, $defaults );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ) ) ) {
+               // invalid value, fall back to default.
+               $args['item_spacing'] = $defaults['item_spacing'];
+       }
+
+       if ( 'preserve' === $args['item_spacing'] ) {
+               $t = "\t";
+               $n = "\n";
+       } else {
+               $t = '';
+               $n = '';
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Filters the arguments used to generate a page-based menu.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1300,7 +1321,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $list_args['echo'] = false;
</span><span class="cx" style="display: block; padding: 0 10px">        $list_args['title_li'] = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $menu .= wp_list_pages( $list_args );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $container = sanitize_text_field( $args['container'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1315,7 +1336,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                if ( isset( $args['fallback_cb'] ) &&
</span><span class="cx" style="display: block; padding: 0 10px">                        'wp_page_menu' === $args['fallback_cb'] &&
</span><span class="cx" style="display: block; padding: 0 10px">                        'ul' !== $container ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $args['before'] = '<ul>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $args['before'] = "<ul>{$n}";
</ins><span class="cx" style="display: block; padding: 0 10px">                         $args['after'] = '</ul>';
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1331,7 +1352,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $attrs .= ' class="' . esc_attr( $args['menu_class'] ) . '"';
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Filters the HTML output of a page-based menu.
</span></span></pre></div>
<a id="trunktestsphpunittestspostlistPagesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/listPages.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/listPages.php      2016-09-05 12:08:39 UTC (rev 38522)
+++ trunk/tests/phpunit/tests/post/listPages.php        2016-09-06 09:05:45 UTC (rev 38523)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,6 +17,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                'link_before' => '',
</span><span class="cx" style="display: block; padding: 0 10px">                'link_after' => '',
</span><span class="cx" style="display: block; padding: 0 10px">                'walker' => '',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                'item_spacing' => 'preserve',
</ins><span class="cx" style="display: block; padding: 0 10px">                 'include'      => '',
</span><span class="cx" style="display: block; padding: 0 10px">                'post_type'    => 'page',
</span><span class="cx" style="display: block; padding: 0 10px">                'post_status'  => 'publish',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -342,4 +343,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $actual = wp_list_pages( $args );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->AssertEquals( $expected['exclude'], $actual );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       function test_wp_list_pages_discarded_whitespace() {
+               $args = array(
+                       'echo' => false,
+                       'item_spacing' => 'discard',
+               );
+               $expected['default'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a><ul class=\'children\'><li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li><li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a></li><li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a></li></ul></li><li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a><ul class=\'children\'><li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a></li><li class="page_item
  page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a></li><li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a></li></ul></li><li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a><ul class=\'children\'><li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a></li><li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a></li><li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a></li></ul></li></ul></li>';
+               $actual = wp_list_pages( $args );
+               $this->AssertEquals( $expected['default'], $actual );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestspostnavmenuphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/nav-menu.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/nav-menu.php       2016-09-05 12:08:39 UTC (rev 38522)
+++ trunk/tests/phpunit/tests/post/nav-menu.php 2016-09-06 09:05:45 UTC (rev 38523)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -277,6 +277,68 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @ticket 35206
+        */
+       function test_wp_nav_menu_whitespace_options() {
+               $post_id1 = self::factory()->post->create();
+               $post_id2 = self::factory()->post->create();
+               $post_id3 = self::factory()->post->create();
+               $post_id4 = self::factory()->post->create();
+
+               $post_insert = wp_update_nav_menu_item( $this->menu_id, 0, array(
+                       'menu-item-type' => 'post_type',
+                       'menu-item-object' => 'post',
+                       'menu-item-object-id' => $post_id1,
+                       'menu-item-status' => 'publish'
+               ) );
+
+               $post_inser2 = wp_update_nav_menu_item( $this->menu_id, 0, array(
+                       'menu-item-type' => 'post_type',
+                       'menu-item-object' => 'post',
+                       'menu-item-object-id' => $post_id2,
+                       'menu-item-status' => 'publish'
+               ) );
+
+               $post_insert3 = wp_update_nav_menu_item( $this->menu_id, 0, array(
+                       'menu-item-type' => 'post_type',
+                       'menu-item-object' => 'post',
+                       'menu-item-parent-id' => $post_insert,
+                       'menu-item-object-id' => $post_id3,
+                       'menu-item-status' => 'publish'
+               ) );
+
+               $post_insert4 = wp_update_nav_menu_item( $this->menu_id, 0, array(
+                       'menu-item-type' => 'post_type',
+                       'menu-item-object' => 'post',
+                       'menu-item-parent-id' => $post_insert,
+                       'menu-item-object-id' => $post_id4,
+                       'menu-item-status' => 'publish'
+               ) );
+
+               // No whitespace suppression.
+               $menu = wp_nav_menu( array(
+                       'echo' => false,
+                       'menu' => $this->menu_id,
+               ) );
+
+               // The markup should include whitespace between <li>s
+               $this->assertRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
+               $this->assertNotRegExp( '/<\/li><li.*>/U', $menu );
+
+
+               // Whitepsace suppressed.
+               $menu = wp_nav_menu( array(
+                       'echo'         => false,
+                       'item_spacing' => 'discard',
+                       'menu'         => $this->menu_id,
+               ) );
+
+               // The markup should not include whitespace around <li>s
+               $this->assertNotRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
+               $this->assertRegExp( '/><li.*>|<\/li></U', $menu );
+       }
+
+       /*
</ins><span class="cx" style="display: block; padding: 0 10px">          * Confirm `wp_nav_menu()` and `Walker_Nav_Menu` passes an $args object to filters.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * `wp_nav_menu()` is unique in that it uses an $args object rather than an array.
</span></span></pre></div>
<a id="trunktestsphpunittestsposttemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/template.php       2016-09-05 12:08:39 UTC (rev 38522)
+++ trunk/tests/phpunit/tests/post/template.php 2016-09-06 09:05:45 UTC (rev 38523)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -299,6 +299,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                // After falling back, the 'after' argument should be set and output as '</ul>'.
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertRegExp( '/<\/ul><\/div>/', $menu );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // 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 );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 // No menus + wp_nav_menu() falls back to wp_page_menu(), this time without a container.
</span><span class="cx" style="display: block; padding: 0 10px">                $menu = wp_nav_menu( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'echo'      => false,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -307,5 +311,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // After falling back, the empty 'container' argument should still return a container element.
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertRegExp( '/<div class="menu">/', $menu );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               // 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 );
+
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>