<!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>[39395] branches/4.7: Customize: Fix handling of the nav menu item labels (titles) that match defaults (original titles) and fix the display of item type labels.</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/39395">39395</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/39395","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-11-30 23:41:50 +0000 (Wed, 30 Nov 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: Fix handling of the nav menu item labels (titles) that match defaults (original titles) and fix the display of item type labels.

* Show default labels for nav menu item as placeholders in a control's label field instead of showing blank.
* Store empty string as label instead of copying default labels.
* Prevent labels for post type archive items from being dropped in preview.
* Also ensure that the item type label is displayed on nav menu item controls for settings that are loaded from an existing changeset.

Amends <a href="https://core.trac.wordpress.org/changeset/38618">[38618]</a>.
See <a href="https://core.trac.wordpress.org/ticket/38015">#38015</a>.
Fixes <a href="https://core.trac.wordpress.org/ticket/38955">#38955</a> for 4.7 branch.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branches47srcwpcontentthemestwentyseventeentemplatepartsheaderheaderimagephp">branches/4.7/src/wp-content/themes/twentyseventeen/template-parts/header/header-image.php</a></li>
<li><a href="#branches47srcwpincludescustomizeclasswpcustomizenavmenuitemsettingphp">branches/4.7/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php</a></li>
<li><a href="#branches47testsphpunittestscustomizenavmenuitemsettingphp">branches/4.7/tests/phpunit/tests/customize/nav-menu-item-setting.php</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#branches47">branches/4.7/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/4.7
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/4.7 2016-11-30 23:38:54 UTC (rev 39394)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/4.7  2016-11-30 23:41:50 UTC (rev 39395)
</ins><a id="branches47"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/4.7</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/3.1:18031
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/3.3:20543
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/3.4:21757
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk:18512,39365,39369,39371,39373,39376,39378,39380,39382,39384,39386,39388,39390,39392
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:18512,39365,39369,39371,39373,39376,39378,39380,39382,39384,39386,39388,39390,39392-39393
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches47srcwpcontentthemestwentyseventeentemplatepartsheaderheaderimagephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/src/wp-content/themes/twentyseventeen/template-parts/header/header-image.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.7/src/wp-content/themes/twentyseventeen/template-parts/header/header-image.php 2016-11-30 23:38:54 UTC (rev 39394)
+++ branches/4.7/src/wp-content/themes/twentyseventeen/template-parts/header/header-image.php   2016-11-30 23:41:50 UTC (rev 39395)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -11,11 +11,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <div class="custom-header">
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        <?php if ( has_custom_header() ) : ?>
-               <div class="custom-header-image">
-                       <?php the_custom_header_markup(); ?>
-               </div>
-       <?php endif; ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <div class="custom-header-image">
+               <?php the_custom_header_markup(); ?>
+       </div>
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        <?php get_template_part( 'template-parts/header/site', 'branding' ); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="branches47srcwpincludescustomizeclasswpcustomizenavmenuitemsettingphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/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">--- branches/4.7/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php       2016-11-30 23:38:54 UTC (rev 39394)
+++ branches/4.7/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php 2016-11-30 23:41:50 UTC (rev 39395)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -233,6 +233,9 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        if ( ! empty( $value ) && empty( $value['original_title'] ) ) {
+                               $value['original_title'] = $this->get_original_title( (object) $value );
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px">                 } elseif ( isset( $this->value ) ) {
</span><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="lines" style="display: block; padding: 0 10px; color: #888">@@ -260,6 +263,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $value = $this->value;
</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">+                if ( ! empty( $value ) && empty( $value['type_label'] ) ) {
+                       $value['type_label'] = $this->get_type_label( (object) $value );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 return $value;
</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">@@ -273,11 +280,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string The original title.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        protected function get_original_title( $item ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( empty( $item->object_id ) ) {
-                       return '';
-               }
</del><span class="cx" style="display: block; padding: 0 10px">                 $original_title = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( 'post_type' === $item->type ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 'post_type' === $item->type && ! empty( $item->object_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $original_object = get_post( $item->object_id );
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( $original_object ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                /** This filter is documented in wp-includes/post-template.php */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -288,17 +292,54 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                        $original_title = sprintf( __( '#%d (no title)' ), $original_object->ID );
</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">-                } elseif ( 'taxonomy' === $item->type ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         } elseif ( 'taxonomy' === $item->type && ! empty( $item->object_id ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         $original_term_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( ! is_wp_error( $original_term_title ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                $original_title = $original_term_title;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                } elseif ( 'post_type_archive' === $item->type ) {
+                       $original_object = get_post_type_object( $item->object );
+                       if ( $original_object ) {
+                               $original_title = $original_object->labels->archives;
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">                $original_title = html_entity_decode( $original_title, ENT_QUOTES, get_bloginfo( 'charset' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                return $original_title;
</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 type label.
+        *
+        * @since 4.7.0
+        * @access protected
+        *
+        * @param object $item Nav menu item.
+        * @returns string The type label.
+        */
+       protected function get_type_label( $item ) {
+               if ( 'post_type' === $item->type ) {
+                       $object = get_post_type_object( $item->object );
+                       if ( $object ) {
+                               $type_label = $object->labels->singular_name;
+                       } else {
+                               $type_label = $item->object;
+                       }
+               } elseif ( 'taxonomy' === $item->type ) {
+                       $object = get_taxonomy( $item->object );
+                       if ( $object ) {
+                               $type_label = $object->labels->singular_name;
+                       } else {
+                               $type_label = $item->object;
+                       }
+               } elseif ( 'post_type_archive' === $item->type ) {
+                       $type_label = __( 'Post Type Archive' );
+               } else {
+                       $type_label = __( 'Custom Link' );
+               }
+               return $type_label;
+       }
+
+       /**
</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">@@ -584,23 +625,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( $post->type_label ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( 'post_type' === $post->type ) {
-                               $object = get_post_type_object( $post->object );
-                               if ( $object ) {
-                                       $post->type_label = $object->labels->singular_name;
-                               } else {
-                                       $post->type_label = $post->object;
-                               }
-                       } elseif ( 'taxonomy' === $post->type ) {
-                               $object = get_taxonomy( $post->object );
-                               if ( $object ) {
-                                       $post->type_label = $object->labels->singular_name;
-                               } else {
-                                       $post->type_label = $post->object;
-                               }
-                       } else {
-                               $post->type_label = __( 'Custom Link' );
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $post->type_label = $this->get_type_label( $post );
</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">                // Ensure nav menu item URL is set according to linked object.
</span></span></pre></div>
<a id="branches47testsphpunittestscustomizenavmenuitemsettingphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/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">--- branches/4.7/tests/phpunit/tests/customize/nav-menu-item-setting.php      2016-11-30 23:38:54 UTC (rev 39394)
+++ branches/4.7/tests/phpunit/tests/customize/nav-menu-item-setting.php        2016-11-30 23:41:50 UTC (rev 39395)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -811,8 +811,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $setting->preview();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $item_value = $setting->value();
+               $this->assertArrayHasKey( 'type_label', $item_value );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'Custom Link', $nav_menu_item->type_label );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $this->assertEquals( $item_value['type_label'], $nav_menu_item->type_label );
</ins><span class="cx" style="display: block; padding: 0 10px">                 add_filter( 'wp_setup_nav_menu_item', array( $this, 'filter_type_label' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'Custom Label', $nav_menu_item->type_label );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -895,6 +898,167 @@
</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 WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() for obtaining original title.
+        *
+        * @ticket 38945
+        * @covers WP_Customize_Nav_Menu_Item_Setting::get_original_title()
+        */
+       function test_get_original_title() {
+               $menu_id = wp_create_nav_menu( 'Menu' );
+               register_post_type( 'press_release', array(
+                       'has_archive' => true,
+                       'labels' => array(
+                               'name' => 'PRs',
+                               'singular_name' => 'PR',
+                               'archives' => 'All PRs',
+                       ),
+               ) );
+               $original_post_title = 'The PR Post';
+               $post_id = self::factory()->post->create( array( 'post_type' => 'press_release', 'post_title' => $original_post_title ) );
+               $original_term_title = 'The Category Term';
+               $term_id = self::factory()->term->create( array( 'taxonomy' => 'category', 'name' => $original_term_title ) );
+
+               // Post: existing nav menu item.
+               $nav_menu_item_id = wp_update_nav_menu_item( $menu_id, 0, array(
+                       'menu-item-object-id' => $post_id,
+                       'menu-item-type' => 'post_type',
+                       'menu-item-object' => 'press_release',
+                       'menu-item-title' => '',
+                       'menu-item-status' => 'publish',
+               ) );
+               $setting = new WP_Customize_Nav_Menu_Item_Setting(
+                       $this->wp_customize,
+                       'nav_menu_item[' . $nav_menu_item_id . ']'
+               );
+               $item_value = $setting->value();
+               $this->assertEquals( $original_post_title, $item_value['original_title'] );
+               $this->assertEquals( '', $item_value['title'] );
+               $item = $setting->value_as_wp_post_nav_menu_item();
+               $this->assertObjectHasAttribute( 'type_label', $item );
+               $this->assertEquals( $original_post_title, $item->original_title );
+               $this->assertEquals( $original_post_title, $item->title );
+               $this->assertArrayHasKey( 'type_label', $item_value );
+               $this->assertEquals( get_post_type_object( 'press_release' )->labels->singular_name, $item_value['type_label'] );
+               $this->assertEquals( $item->type_label, $item_value['type_label'] );
+
+               // Post: staged nav menu item.
+               $setting = new WP_Customize_Nav_Menu_Item_Setting(
+                       $this->wp_customize,
+                       'nav_menu_item[-1]'
+               );
+               $this->wp_customize->set_post_value( $setting->id, array(
+                       'object_id' => $post_id,
+                       'type' => 'post_type',
+                       'object' => 'press_release',
+                       'title' => '',
+                       'status' => 'publish',
+               ) );
+               $setting->preview();
+               $item_value = $setting->value();
+               $this->assertEquals( $original_post_title, $item_value['original_title'] );
+               $this->assertEquals( '', $item_value['title'] );
+               $item = $setting->value_as_wp_post_nav_menu_item();
+               $this->assertObjectHasAttribute( 'type_label', $item );
+               $this->assertEquals( $original_post_title, $item->original_title );
+               $this->assertEquals( $original_post_title, $item->title );
+               $this->assertArrayHasKey( 'type_label', $item_value );
+               $this->assertEquals( get_post_type_object( 'press_release' )->labels->singular_name, $item_value['type_label'] );
+               $this->assertEquals( $item->type_label, $item_value['type_label'] );
+
+               // Term: existing nav menu item.
+               $nav_menu_item_id = wp_update_nav_menu_item( $menu_id, 0, array(
+                       'menu-item-object-id' => $term_id,
+                       'menu-item-type' => 'taxonomy',
+                       'menu-item-object' => 'category',
+                       'menu-item-title' => '',
+                       'menu-item-status' => 'publish',
+               ) );
+               $setting = new WP_Customize_Nav_Menu_Item_Setting(
+                       $this->wp_customize,
+                       'nav_menu_item[' . $nav_menu_item_id . ']'
+               );
+               $item_value = $setting->value();
+               $this->assertEquals( $original_term_title, $item_value['original_title'] );
+               $this->assertEquals( '', $item_value['title'] );
+               $item = $setting->value_as_wp_post_nav_menu_item();
+               $this->assertObjectHasAttribute( 'type_label', $item );
+               $this->assertEquals( $original_term_title, $item->original_title );
+               $this->assertEquals( $original_term_title, $item->title );
+               $this->assertArrayHasKey( 'type_label', $item_value );
+               $this->assertEquals( get_taxonomy( 'category' )->labels->singular_name, $item_value['type_label'] );
+               $this->assertEquals( $item->type_label, $item_value['type_label'] );
+
+               // Term: staged nav menu item.
+               $setting = new WP_Customize_Nav_Menu_Item_Setting(
+                       $this->wp_customize,
+                       'nav_menu_item[-2]'
+               );
+               $this->wp_customize->set_post_value( $setting->id, array(
+                       'object_id' => $term_id,
+                       'type' => 'taxonomy',
+                       'object' => 'category',
+                       'title' => '',
+                       'status' => 'publish',
+               ) );
+               $setting->preview();
+               $item_value = $setting->value();
+               $this->assertEquals( $original_term_title, $item_value['original_title'] );
+               $this->assertEquals( '', $item_value['title'] );
+               $item = $setting->value_as_wp_post_nav_menu_item();
+               $this->assertObjectHasAttribute( 'type_label', $item );
+               $this->assertEquals( $original_term_title, $item->original_title );
+               $this->assertEquals( $original_term_title, $item->title );
+               $this->assertArrayHasKey( 'type_label', $item_value );
+               $this->assertEquals( get_taxonomy( 'category' )->labels->singular_name, $item_value['type_label'] );
+               $this->assertEquals( $item->type_label, $item_value['type_label'] );
+
+               // Post Type Archive: existing nav menu item.
+               $nav_menu_item_id = wp_update_nav_menu_item( $menu_id, 0, array(
+                       'menu-item-type' => 'post_type_archive',
+                       'menu-item-object' => 'press_release',
+                       'menu-item-title' => '',
+                       'menu-item-status' => 'publish',
+               ) );
+               $setting = new WP_Customize_Nav_Menu_Item_Setting(
+                       $this->wp_customize,
+                       'nav_menu_item[' . $nav_menu_item_id . ']'
+               );
+               $item_value = $setting->value();
+               $this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item_value['original_title'] );
+               $this->assertEquals( '', $item_value['title'] );
+               $item = $setting->value_as_wp_post_nav_menu_item();
+               $this->assertObjectHasAttribute( 'type_label', $item );
+               $this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item->original_title );
+               $this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item->title );
+               $this->assertArrayHasKey( 'type_label', $item_value );
+               $this->assertEquals( __( 'Post Type Archive' ), $item_value['type_label'] );
+               $this->assertEquals( $item->type_label, $item_value['type_label'] );
+
+               // Post Type Archive: staged nav menu item.
+               $setting = new WP_Customize_Nav_Menu_Item_Setting(
+                       $this->wp_customize,
+                       'nav_menu_item[-3]'
+               );
+               $this->wp_customize->set_post_value( $setting->id, array(
+                       'type' => 'post_type_archive',
+                       'object' => 'press_release',
+                       'title' => '',
+                       'status' => 'publish',
+               ) );
+               $setting->preview();
+               $item_value = $setting->value();
+               $this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item_value['original_title'] );
+               $this->assertEquals( '', $item_value['title'] );
+               $item = $setting->value_as_wp_post_nav_menu_item();
+               $this->assertObjectHasAttribute( 'type_label', $item );
+               $this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item->original_title );
+               $this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item->title );
+               $this->assertArrayHasKey( 'type_label', $item_value );
+               $this->assertEquals( __( 'Post Type Archive' ), $item_value['type_label'] );
+               $this->assertEquals( $item->type_label, $item_value['type_label'] );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Test WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() where title is empty.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 38015
</span></span></pre>
</div>
</div>

</body>
</html>