<!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>[38618] trunk: Customize: Ensure nav menu items lacking a label use the title from the original object.</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/38618">38618</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/38618","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>westonruter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-09-17 21:49:49 +0000 (Sat, 17 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'>Customize: Ensure nav menu items lacking a label use the title from the original object.

Use original title as placeholder for label and in control title. Prevent original title from overriding empty label in initial setting values.

Fixes <a href="https://core.trac.wordpress.org/ticket/38015">#38015</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminjscustomizenavmenusjs">trunk/src/wp-admin/js/customize-nav-menus.js</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizenavmenusphp">trunk/src/wp-includes/class-wp-customize-nav-menus.php</a></li>
<li><a href="#trunksrcwpincludescustomizeclasswpcustomizenavmenuitemcontrolphp">trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-control.php</a></li>
<li><a href="#trunksrcwpincludescustomizeclasswpcustomizenavmenuitemsettingphp">trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php</a></li>
<li><a href="#trunktestsphpunittestscustomizenavmenuitemsettingphp">trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminjscustomizenavmenusjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/customize-nav-menus.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/customize-nav-menus.js      2016-09-17 16:22:03 UTC (rev 38617)
+++ trunk/src/wp-admin/js/customize-nav-menus.js        2016-09-17 21:49:49 UTC (rev 38618)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1397,14 +1397,14 @@
</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">                                var titleEl = control.container.find( '.menu-item-title' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                    titleText = item.title || api.Menus.data.l10n.untitled;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                             titleText = item.title || item.original_title || api.Menus.data.l10n.untitled;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( item._invalid ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                        titleText = api.Menus.data.l10n.invalidTitleTpl.replace( '%s', titleText );
</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">                                // Don't update to an empty title.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                if ( item.title ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( item.title || item.original_title ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         titleEl
</span><span class="cx" style="display: block; padding: 0 10px">                                                .text( titleText )
</span><span class="cx" style="display: block; padding: 0 10px">                                                .removeClass( 'no-title' );
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizenavmenusphp"></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-wp-customize-nav-menus.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-nav-menus.php    2016-09-17 16:22:03 UTC (rev 38617)
+++ trunk/src/wp-includes/class-wp-customize-nav-menus.php      2016-09-17 21:49:49 UTC (rev 38618)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -587,6 +587,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                $menu_item_setting_id = 'nav_menu_item[' . $item->ID . ']';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                $value = (array) $item;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                if ( empty( $value['post_title'] ) ) {
+                                       $value['title'] = '';
+                               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $value['nav_menu_term_id'] = $menu_id;
</span><span class="cx" style="display: block; padding: 0 10px">                                $this->manager->add_setting( new WP_Customize_Nav_Menu_Item_Setting( $this->manager, $menu_item_setting_id, array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'value'     => $value,
</span></span></pre></div>
<a id="trunksrcwpincludescustomizeclasswpcustomizenavmenuitemcontrolphp"></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/customize/class-wp-customize-nav-menu-item-control.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-control.php      2016-09-17 16:22:03 UTC (rev 38617)
+++ trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-control.php        2016-09-17 21:49:49 UTC (rev 38618)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -69,7 +69,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                <span class="item-type" aria-hidden="true">{{ data.item_type_label }}</span>
</span><span class="cx" style="display: block; padding: 0 10px">                                <span class="item-title" aria-hidden="true">
</span><span class="cx" style="display: block; padding: 0 10px">                                        <span class="spinner"></span>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        <span class="menu-item-title<# if ( ! data.title ) { #> no-title<# } #>">{{ data.title || wp.customize.Menus.data.l10n.untitled }}</span>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 <span class="menu-item-title<# if ( ! data.title && ! data.original_title ) { #> no-title<# } #>">{{ data.title || data.original_title || wp.customize.Menus.data.l10n.untitled }}</span>
</ins><span class="cx" style="display: block; padding: 0 10px">                                 </span>
</span><span class="cx" style="display: block; padding: 0 10px">                                <span class="item-controls">
</span><span class="cx" style="display: block; padding: 0 10px">                                        <button type="button" class="button-link item-edit" aria-expanded="false"><span class="screen-reader-text"><?php
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,7 +96,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        <p class="description description-thin">
</span><span class="cx" style="display: block; padding: 0 10px">                                <label for="edit-menu-item-title-{{ data.menu_item_id }}">
</span><span class="cx" style="display: block; padding: 0 10px">                                        <?php _e( 'Navigation Label' ); ?><br />
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        <input type="text" id="edit-menu-item-title-{{ data.menu_item_id }}" class="widefat edit-menu-item-title" name="menu-item-title" />
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 <input type="text" id="edit-menu-item-title-{{ data.menu_item_id }}" placeholder="{{ data.original_title }}" class="widefat edit-menu-item-title" name="menu-item-title" />
</ins><span class="cx" style="display: block; padding: 0 10px">                                 </label>
</span><span class="cx" style="display: block; padding: 0 10px">                        </p>
</span><span class="cx" style="display: block; padding: 0 10px">                        <p class="field-link-target description description-thin">
</span></span></pre></div>
<a id="trunksrcwpincludescustomizeclasswpcustomizenavmenuitemsettingphp"></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/customize/class-wp-customize-nav-menu-item-setting.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php      2016-09-17 16:22:03 UTC (rev 38617)
+++ trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php        2016-09-17 21:49:49 UTC (rev 38618)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -233,7 +233,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        } else {
</span><span class="cx" style="display: block; padding: 0 10px">                                $value = $post_value;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                } else if ( isset( $this->value ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         } elseif ( isset( $this->value ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $value = $this->value;
</span><span class="cx" style="display: block; padding: 0 10px">                } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        $value = false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,7 +242,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( $this->post_id > 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $post = get_post( $this->post_id );
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( $post && self::POST_TYPE === $post->post_type ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        $is_title_empty = empty( $post->post_title );
</ins><span class="cx" style="display: block; padding: 0 10px">                                         $value = (array) wp_setup_nav_menu_item( $post );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        if ( $is_title_empty ) {
+                                               $value['title'] = '';
+                                       }
</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">@@ -260,6 +264,40 @@
</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">+         * Get original title.
+        *
+        * @since 4.7.0
+        *
+        * @param object $item Nav menu item.
+        * @return string The original title.
+        */
+       protected function get_original_title( $item ) {
+               if ( empty( $item->object_id ) ) {
+                       return '';
+               }
+               $original_title = '';
+               if ( 'post_type' === $item->type ) {
+                       $original_object = get_post( $item->object_id );
+                       if ( $original_object ) {
+                               /** This filter is documented in wp-includes/post-template.php */
+                               $original_title = apply_filters( 'the_title', $original_object->post_title, $original_object->ID );
+
+                               if ( '' === $original_title ) {
+                                       /* translators: %d: ID of a post */
+                                       $original_title = sprintf( __( '#%d (no title)' ), $original_object->ID );
+                               }
+                       }
+               } elseif ( 'taxonomy' === $item->type ) {
+                       $original_term_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
+                       if ( ! is_wp_error( $original_term_title ) ) {
+                               $original_title = $original_term_title;
+                       }
+               }
+               $original_title = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) );
+               return $original_title;
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Ensure that the value is fully populated with the necessary properties.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * Translates some properties added by wp_setup_nav_menu_item() and removes others.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -284,16 +322,7 @@
</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">                if ( ! isset( $this->value['original_title'] ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $original_title = '';
-                       if ( 'post_type' === $this->value['type'] ) {
-                               $original_title = get_the_title( $this->value['object_id'] );
-                       } elseif ( 'taxonomy' === $this->value['type'] ) {
-                               $original_title = get_term_field( 'name', $this->value['object_id'], $this->value['object'], 'raw' );
-                               if ( is_wp_error( $original_title ) ) {
-                                       $original_title = '';
-                               }
-                       }
-                       $this->value['original_title'] = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $this->value['original_title'] = $this->get_original_title( (object) $this->value );
</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">                if ( ! isset( $this->value['nav_menu_term_id'] ) && $this->post_id > 0 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -534,6 +563,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $item->menu_order = $item->position;
</span><span class="cx" style="display: block; padding: 0 10px">                unset( $item->position );
</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 ( empty( $item->original_title ) ) {
+                       $item->original_title = $this->get_original_title( $item );
+               }
+               if ( empty( $item->title ) && ! empty( $item->original_title ) ) {
+                       $item->title = $item->original_title;
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( $item->title ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $item->post_title = $item->title;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -554,7 +589,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                } else {
</span><span class="cx" style="display: block; padding: 0 10px">                                        $post->type_label = $post->object;
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        } elseif ( 'taxonomy' == $post->type ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 } elseif ( 'taxonomy' === $post->type ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 $object = get_taxonomy( $post->object );
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( $object ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                        $post->type_label = $object->labels->singular_name;
</span></span></pre></div>
<a id="trunktestsphpunittestscustomizenavmenuitemsettingphp"></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/customize/nav-menu-item-setting.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php     2016-09-17 16:22:03 UTC (rev 38617)
+++ trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php       2016-09-17 21:49:49 UTC (rev 38618)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -185,6 +185,34 @@
</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">+         * Test value method with post without nav menu item title (label).
+        *
+        * @see WP_Customize_Nav_Menu_Item_Setting::value()
+        */
+       function test_value_type_post_type_without_label() {
+               do_action( 'customize_register', $this->wp_customize );
+
+               $original_title = 'Hello World';
+               $post_id = self::factory()->post->create( array( 'post_title' => $original_title ) );
+
+               $menu_id = wp_create_nav_menu( 'Menu' );
+               $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
+                       'menu-item-type' => 'post_type',
+                       'menu-item-object' => 'post',
+                       'menu-item-object-id' => $post_id,
+                       'menu-item-title' => '',
+                       'menu-item-status' => 'publish',
+               ) );
+
+               $setting_id = "nav_menu_item[$item_id]";
+               $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
+
+               $value = $setting->value();
+               $this->assertEquals( '', $value['title'] );
+               $this->assertEquals( $original_title, $value['original_title'] );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Test value method with taxonomy.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @see WP_Customize_Nav_Menu_Item_Setting::value()
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -804,4 +832,37 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( $expected, $nav_menu_item->attr_title );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'Attempted \o/ o&#8217;o markup', $nav_menu_item->description );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Test WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() where title is empty.
+        *
+        * @ticket 38015
+        * @see WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item()
+        */
+       function test_value_as_wp_post_nav_menu_item_with_empty_title() {
+               $original_title = 'The Original Title';
+               $post_id = self::factory()->post->create( array( 'post_title' => $original_title ) );
+
+               $setting = new WP_Customize_Nav_Menu_Item_Setting(
+                       $this->wp_customize,
+                       'nav_menu_item[123]'
+               );
+
+               $post_value = array_merge(
+                       $setting->default,
+                       array(
+                               'object_id'        => $post_id,
+                               'object'           => 'post',
+                               'type'             => 'post_type',
+                               'status'           => 'publish',
+                               'nav_menu_term_id' => 0,
+                       )
+               );
+               $this->wp_customize->set_post_value( $setting->id, $post_value );
+
+               $setting->preview();
+
+               $nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
+               $this->assertEquals( $original_title, $nav_menu_item->title );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>