<!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>[38991] trunk/src: Customize: Introduce starter content and site freshness state.</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/38991">38991</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/38991","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-10-28 02:56:16 +0000 (Fri, 28 Oct 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: Introduce starter content and site freshness state.

A theme can opt-in for tailored starter content to apply to the customizer when previewing the theme on a fresh install, when `fresh_site` is at its initial `1` value. Starter content is staged in the customizer and does not go live unless the changes are published. Initial starter content is added to Twenty Seventeen.

* The `fresh_site` flag is cleared when a published post or page is saved, when widgets are modified, or when the customizer state is saved.
* Starter content is registered via `starter-content` theme support, where the argument is an array containing `widgets`, `posts`, `nav_menus`, `options`, and `theme_mods`. Posts/pages in starter content are created with the `auto-draft` status, re-using the page/post stubs feature added to nav menus and the static front page controls.
* A `get_theme_starter_content` filter allows for plugins to extend a theme's starter content.
* Starter content in themes can/should re-use existing starter content items in core by using named placeholders.
* Import theme starter content into customized state when fresh site.
* Prevent original_title differences from causing refreshes if title is present.
* Ensure nav menu item url is set according to object when previewing.
* Make sure initial saved state is false if there are dirty settings without an existing changeset.
* Ensure dirty settings are cleaned upon changeset publishing.

Props helen, westonruter, ocean90.
Fixes <a href="https://core.trac.wordpress.org/ticket/38114">#38114</a>, <a href="https://core.trac.wordpress.org/ticket/38533">#38533</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesschemaphp">trunk/src/wp-admin/includes/schema.php</a></li>
<li><a href="#trunksrcwpadminjscustomizecontrolsjs">trunk/src/wp-admin/js/customize-controls.js</a></li>
<li><a href="#trunksrcwpcontentthemestwentyseventeenfunctionsphp">trunk/src/wp-content/themes/twentyseventeen/functions.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizemanagerphp">trunk/src/wp-includes/class-wp-customize-manager.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="#trunksrcwpincludesdefaultfiltersphp">trunk/src/wp-includes/default-filters.php</a></li>
<li><a href="#trunksrcwpincludesfunctionsphp">trunk/src/wp-includes/functions.php</a></li>
<li><a href="#trunksrcwpincludesjscustomizepreviewnavmenusjs">trunk/src/wp-includes/js/customize-preview-nav-menus.js</a></li>
<li><a href="#trunksrcwpincludesthemephp">trunk/src/wp-includes/theme.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesschemaphp"></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/includes/schema.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/schema.php    2016-10-28 02:06:17 UTC (rev 38990)
+++ trunk/src/wp-admin/includes/schema.php      2016-10-28 02:56:16 UTC (rev 38991)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -516,6 +516,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">        // 4.4.0
</span><span class="cx" style="display: block; padding: 0 10px">        'medium_large_size_w' => 768,
</span><span class="cx" style="display: block; padding: 0 10px">        'medium_large_size_h' => 0,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       // 4.7.0
+       'fresh_site' => 1,
</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">        // 3.3
</span></span></pre></div>
<a id="trunksrcwpadminjscustomizecontrolsjs"></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-controls.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/customize-controls.js       2016-10-28 02:06:17 UTC (rev 38990)
+++ trunk/src/wp-admin/js/customize-controls.js 2016-10-28 02:56:16 UTC (rev 38991)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -146,7 +146,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        settingRevision = api._latestSettingRevisions[ setting.id ];
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        // Skip including settings that have already been included in the changeset, if only requesting unsaved.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( ( options && options.unsaved ) && ( _.isUndefined( settingRevision ) || settingRevision <= api._lastSavedRevision ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 if ( api.state( 'changesetStatus' ).get() && ( options && options.unsaved ) && ( _.isUndefined( settingRevision ) || settingRevision <= api._lastSavedRevision ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                                 return;
</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">@@ -4880,7 +4880,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                api.bind( 'change', captureSettingModifiedDuringSave );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                submit = function () {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        var request, query, settingInvalidities = {};
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 var request, query, settingInvalidities = {}, latestRevision = api._latestRevision;
</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">                                         * Block saving if there are any settings that are marked as
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4984,6 +4984,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                                api.state( 'changesetStatus' ).set( response.changeset_status );
</span><span class="cx" style="display: block; padding: 0 10px">                                                if ( 'publish' === response.changeset_status ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                                                       // Mark all published as clean if they haven't been modified during the request.
+                                                       api.each( function( setting ) {
+                                                               /*
+                                                                * Note that the setting revision will be undefined in the case of setting
+                                                                * values that are marked as dirty when the customizer is loaded, such as
+                                                                * when applying starter content. All other dirty settings will have an
+                                                                * associated revision due to their modification triggering a change event.
+                                                                */
+                                                               if ( setting._dirty && ( _.isUndefined( api._latestSettingRevisions[ setting.id ] ) || api._latestSettingRevisions[ setting.id ] <= latestRevision ) ) {
+                                                                       setting._dirty = false;
+                                                               }
+                                                       } );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                                         api.state( 'changesetStatus' ).set( '' );
</span><span class="cx" style="display: block; padding: 0 10px">                                                        api.settings.changeset.uuid = response.next_changeset_uuid;
</span><span class="cx" style="display: block; padding: 0 10px">                                                        parent.send( 'changeset-uuid', api.settings.changeset.uuid );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5152,7 +5166,15 @@
</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">                        // Set default states.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        changesetStatus( api.settings.changeset.status );
</ins><span class="cx" style="display: block; padding: 0 10px">                         saved( true );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        if ( '' === changesetStatus() ) { // Handle case for loading starter content.
+                               api.each( function( setting ) {
+                                       if ( setting._dirty ) {
+                                               saved( false );
+                                       }
+                               } );
+                       }
</ins><span class="cx" style="display: block; padding: 0 10px">                         saving( false );
</span><span class="cx" style="display: block; padding: 0 10px">                        activated( api.settings.theme.active );
</span><span class="cx" style="display: block; padding: 0 10px">                        processing( 0 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5161,7 +5183,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        expandedSection( false );
</span><span class="cx" style="display: block; padding: 0 10px">                        previewerAlive( true );
</span><span class="cx" style="display: block; padding: 0 10px">                        editShortcutVisibility( 'initial' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        changesetStatus( api.settings.changeset.status );
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        api.bind( 'change', function() {
</span><span class="cx" style="display: block; padding: 0 10px">                                state('saved').set( false );
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentyseventeenfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentyseventeen/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentyseventeen/functions.php 2016-10-28 02:06:17 UTC (rev 38990)
+++ trunk/src/wp-content/themes/twentyseventeen/functions.php   2016-10-28 02:56:16 UTC (rev 38991)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,6 +102,67 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * specifically font, colors, and column width.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        add_editor_style( array( 'assets/css/editor-style.css', twentyseventeen_fonts_url() ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       add_theme_support( 'starter-content', array(
+               'widgets' => array(
+                       'sidebar-1' => array(
+                               'text_business_info',
+                               'search',
+                               'text_credits',
+                       ),
+
+                       'sidebar-2' => array(
+                               'text_business_info',
+                       ),
+
+                       'sidebar-3' => array(
+                               'text_credits',
+                       ),
+               ),
+
+               'posts' => array(
+                       'home',
+                       'about-us',
+                       'contact-us',
+                       'blog',
+                       'homepage-section',
+               ),
+
+               'options' => array(
+                       'show_on_front' => 'page',
+                       'page_on_front' => '{{home}}',
+                       'page_for_posts' => '{{blog}}',
+               ),
+
+               'theme_mods' => array(
+                       'panel_1' => '{{homepage-section}}',
+                       'panel_2' => '{{about-us}}',
+                       'panel_3' => '{{blog}}',
+                       'panel_4' => '{{contact-us}}',
+               ),
+
+               'nav_menus' => array(
+                       'top' => array(
+                               'name' => __( 'Top' ),
+                               'items' => array(
+                                       'page_home',
+                                       'page_about',
+                                       'page_blog',
+                                       'page_contact',
+                               ),
+                       ),
+                       'social' => array(
+                               'name' => __( 'Social' ),
+                               'items' => array(
+                                       'link_yelp',
+                                       'link_facebook',
+                                       'link_twitter',
+                                       'link_instagram',
+                                       'link_email',
+                               ),
+                       ),
+               ),
+       ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'after_setup_theme', 'twentyseventeen_setup' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizemanagerphp"></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-manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-manager.php      2016-10-28 02:06:17 UTC (rev 38990)
+++ trunk/src/wp-includes/class-wp-customize-manager.php        2016-10-28 02:56:16 UTC (rev 38991)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -531,6 +531,11 @@
</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">+                // Import theme starter content for fresh installs when landing in the customizer and no existing changeset loaded.
+               if ( get_option( 'fresh_site' ) && 'customize.php' === $pagenow && ! $this->changeset_post_id() ) {
+                       add_action( 'after_setup_theme', array( $this, 'import_theme_starter_content' ), 100 );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->start_previewing_theme();
</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">@@ -888,6 +893,135 @@
</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">+         * Import theme starter content into post values.
+        *
+        * @since 4.7.0
+        * @access public
+        *
+        * @param array $starter_content Starter content. Defaults to `get_theme_starter_content()`.
+        */
+       function import_theme_starter_content( $starter_content = array() ) {
+               if ( empty( $starter_content ) ) {
+                       $starter_content = get_theme_starter_content();
+               }
+
+               $sidebars_widgets = isset( $starter_content['widgets'] ) && ! empty( $this->widgets ) ? $starter_content['widgets'] : array();
+               $posts = isset( $starter_content['posts'] ) && ! empty( $this->nav_menus ) ? $starter_content['posts'] : array();
+               $options = isset( $starter_content['options'] ) ? $starter_content['options'] : array();
+               $nav_menus = isset( $starter_content['nav_menus'] ) && ! empty( $this->nav_menus ) ? $starter_content['nav_menus'] : array();
+               $theme_mods = isset( $starter_content['theme_mods'] ) ? $starter_content['theme_mods'] : array();
+
+               // Widgets.
+               $max_widget_numbers = array();
+               foreach ( $sidebars_widgets as $sidebar_id => $widgets ) {
+                       $sidebar_widget_ids = array();
+                       foreach ( $widgets as $widget ) {
+                               list( $id_base, $instance ) = $widget;
+
+                               if ( ! isset( $max_widget_numbers[ $id_base ] ) ) {
+
+                                       // When $settings is an array-like object, get an intrinsic array for use with array_keys().
+                                       $settings = get_option( "widget_{$id_base}", array() );
+                                       if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) {
+                                               $settings = $settings->getArrayCopy();
+                                       }
+
+                                       // Find the max widget number for this type.
+                                       $widget_numbers = array_keys( $settings );
+                                       $widget_numbers[] = 1;
+                                       $max_widget_numbers[ $id_base ] = call_user_func_array( 'max', $widget_numbers );
+                               }
+                               $max_widget_numbers[ $id_base ] += 1;
+
+                               $widget_id = sprintf( '%s-%d', $id_base, $max_widget_numbers[ $id_base ] );
+                               $setting_id = sprintf( 'widget_%s[%d]', $id_base, $max_widget_numbers[ $id_base ] );
+
+                               $class = 'WP_Customize_Setting';
+
+                               /** This filter is documented in wp-includes/class-wp-customize-manager.php */
+                               $args = apply_filters( 'customize_dynamic_setting_args', false, $setting_id );
+
+                               if ( false !== $args ) {
+
+                                       /** This filter is documented in wp-includes/class-wp-customize-manager.php */
+                                       $class = apply_filters( 'customize_dynamic_setting_class', $class, $setting_id, $args );
+
+                                       $setting = new $class( $this, $setting_id, $args );
+                                       $setting_value = call_user_func( $setting->sanitize_js_callback, $instance, $setting );
+                                       $this->set_post_value( $setting_id, $setting_value );
+                                       $sidebar_widget_ids[] = $widget_id;
+                               }
+                       }
+
+                       $this->set_post_value( sprintf( 'sidebars_widgets[%s]', $sidebar_id ), $sidebar_widget_ids );
+               }
+
+               // Posts & pages.
+               if ( ! empty( $posts ) ) {
+                       foreach ( array_keys( $posts ) as $post_symbol ) {
+                               $posts[ $post_symbol ]['ID'] = wp_insert_post( wp_slash( array_merge(
+                                       $posts[ $post_symbol ],
+                                       array( 'post_status' => 'auto-draft' )
+                               ) ) );
+                       }
+                       $this->set_post_value( 'nav_menus_created_posts', wp_list_pluck( $posts, 'ID' ) ); // This is why nav_menus component is dependency for adding posts.
+               }
+
+               // Nav menus.
+               $placeholder_id = -1;
+               foreach ( $nav_menus as $nav_menu_location => $nav_menu ) {
+                       $nav_menu_term_id = $placeholder_id--;
+                       $nav_menu_setting_id = sprintf( 'nav_menu[%d]', $nav_menu_term_id );
+                       $this->set_post_value( $nav_menu_setting_id, array(
+                               'name' => isset( $nav_menu['name'] ) ? $nav_menu['name'] : $nav_menu_location,
+                       ) );
+
+                       // @todo Add support for menu_item_parent.
+                       $position = 0;
+                       foreach ( $nav_menu['items'] as $nav_menu_item ) {
+                               $nav_menu_item_setting_id = sprintf( 'nav_menu_item[%d]', $placeholder_id-- );
+                               if ( ! isset( $nav_menu_item['position'] ) ) {
+                                       $nav_menu_item['position'] = $position++;
+                               }
+                               $nav_menu_item['nav_menu_term_id'] = $nav_menu_term_id;
+
+                               if ( isset( $nav_menu_item['object_id'] ) ) {
+                                       if ( 'post_type' === $nav_menu_item['type'] && preg_match( '/^{{(?P<symbol>.+)}}$/', $nav_menu_item['object_id'], $matches ) && isset( $posts[ $matches['symbol'] ] ) ) {
+                                               $nav_menu_item['object_id'] = $posts[ $matches['symbol'] ]['ID'];
+                                               if ( empty( $nav_menu_item['title'] ) ) {
+                                                       $original_object = get_post( $nav_menu_item['object_id'] );
+                                                       $nav_menu_item['title'] = $original_object->post_title;
+                                               }
+                                       } else {
+                                               continue;
+                                       }
+                               } else {
+                                       $nav_menu_item['object_id'] = 0;
+                               }
+                               $this->set_post_value( $nav_menu_item_setting_id, $nav_menu_item );
+                       }
+
+                       $this->set_post_value( sprintf( 'nav_menu_locations[%s]', $nav_menu_location ), $nav_menu_term_id );
+               }
+
+               // Options.
+               foreach ( $options as $name => $value ) {
+                       if ( preg_match( '/^{{(?P<symbol>.+)}}$/', $value, $matches ) && isset( $posts[ $matches['symbol'] ] ) ) {
+                               $value = $posts[ $matches['symbol'] ]['ID'];
+                       }
+                       $this->set_post_value( $name, $value );
+               }
+
+               // Theme mods.
+               foreach ( $theme_mods as $name => $value ) {
+                       if ( preg_match( '/^{{(?P<symbol>.+)}}$/', $value, $matches ) && isset( $posts[ $matches['symbol'] ] ) ) {
+                               $value = $posts[ $matches['symbol'] ]['ID'];
+                       }
+                       $this->set_post_value( $name, $value );
+               }
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Get dirty pre-sanitized setting values in the current customized state.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * The returned array consists of a merge of three sources:
</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-10-28 02:06:17 UTC (rev 38990)
+++ trunk/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php        2016-10-28 02:56:16 UTC (rev 38991)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -602,6 +602,17 @@
</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">+                // Ensure nav menu item URL is set according to linked object.
+               if ( ! empty( $post->object_id ) ) {
+                       if ( 'post_type' === $post->type ) {
+                               $post->url = get_permalink( $post->object_id );
+                       } elseif ( 'post_type_archive' === $post->type && ! empty( $post->object ) ) {
+                               $post->url = get_post_type_archive_link( $post->object );
+                       } elseif ( 'taxonomy' == $post->type && ! empty( $post->object ) ) {
+                               $post->url = get_term_link( (int) $post->object, $post->object );
+                       }
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 /** This filter is documented in wp-includes/nav-menu.php */
</span><span class="cx" style="display: block; padding: 0 10px">                $post->attr_title = apply_filters( 'nav_menu_attr_title', $post->attr_title );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpincludesdefaultfiltersphp"></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/default-filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/default-filters.php 2016-10-28 02:06:17 UTC (rev 38990)
+++ trunk/src/wp-includes/default-filters.php   2016-10-28 02:56:16 UTC (rev 38991)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -188,6 +188,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Email filters
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Mark site as no longer fresh
+if ( get_option( 'fresh_site' ) ) {
+       foreach ( array( 'publish_post', 'publish_page', 'wp_ajax_save-widget', 'wp_ajax_widgets-order', 'customize_save_after' ) as $action ) {
+               add_action( $action, '_delete_option_fresh_site' );
+       }
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Misc filters
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'option_ping_sites',        'privacy_ping_filter'                 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'option_blog_charset',      '_wp_specialchars'                    ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop
</span></span></pre></div>
<a id="trunksrcwpincludesfunctionsphp"></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/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/functions.php       2016-10-28 02:06:17 UTC (rev 38990)
+++ trunk/src/wp-includes/functions.php 2016-10-28 02:56:16 UTC (rev 38991)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3241,6 +3241,16 @@
</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">+ * Delete the fresh site option.
+ *
+ * @since 4.7.0
+ * @access private
+ */
+function _delete_option_fresh_site() {
+       update_option( 'fresh_site', 0 );
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Set the localized direction for MCE plugin.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * Will only set the direction to 'rtl', if the WordPress locale has
</span></span></pre></div>
<a id="trunksrcwpincludesjscustomizepreviewnavmenusjs"></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/js/customize-preview-nav-menus.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/customize-preview-nav-menus.js   2016-10-28 02:06:17 UTC (rev 38990)
+++ trunk/src/wp-includes/js/customize-preview-nav-menus.js     2016-10-28 02:56:16 UTC (rev 38991)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,6 +139,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                _oldValue.url = urlParser.href;
</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">+                                        // Prevent original_title differences from causing refreshes if title is present.
+                                       if ( newValue.title ) {
+                                               delete _oldValue.original_title;
+                                               delete _newValue.original_title;
+                                       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                         if ( _.isEqual( _oldValue, _newValue ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                                return false;
</span><span class="cx" style="display: block; padding: 0 10px">                                        }
</span></span></pre></div>
<a id="trunksrcwpincludesthemephp"></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/theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/theme.php   2016-10-28 02:06:17 UTC (rev 38990)
+++ trunk/src/wp-includes/theme.php     2016-10-28 02:56:16 UTC (rev 38991)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1756,6 +1756,175 @@
</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">+ * Expand a theme's starter content configuration using core-provided data.
+ *
+ * @since 4.7.0
+ *
+ * @return array Array of starter content.
+ */
+function get_theme_starter_content() {
+       $theme_support = get_theme_support( 'starter-content' );
+       if ( ! empty( $theme_support ) ) {
+               $config = $theme_support[0];
+       } else {
+               $config = array();
+       }
+
+       $core_content = array (
+               'widgets' => array(
+                       'text_business_info' => array ( 'text', array (
+                               'title' => __( 'Find Us' ),
+                               'text' => join( '', array (
+                                       '<p><strong>' . __( 'Address' ) . '</strong><br />',
+                                       __( '123 Main Street' ) . '<br />' . __( 'New York, NY 10001' ) . '</p>',
+                                       '<p><strong>' . __( 'Hours' ) . '</strong><br />',
+                                       __( 'Monday&mdash;Friday: 9:00AM&ndash;5:00PM' ) . '<br />' . __( 'Saturday &amp; Sunday: 11:00AM&ndash;3:00PM' ) . '</p>'
+                               ) ),
+                       ) ),
+                       'search' => array ( 'search', array (
+                               'title' => __( 'Site Search' ),
+                       ) ),
+                       'text_credits' => array ( 'text', array (
+                               'title' => __( 'Site Credits' ),
+                               'text' => sprintf( __( 'This site was created on %s' ), get_date_from_gmt( current_time( 'mysql', 1 ), 'c' ) ),
+                       ) ),
+               ),
+               'nav_menus' => array (
+                       'page_home' => array(
+                               'type' => 'post_type',
+                               'object' => 'page',
+                               'object_id' => '{{home}}',
+                       ),
+                       'page_about' => array(
+                               'type' => 'post_type',
+                               'object' => 'page',
+                               'object_id' => '{{about-us}}',
+                       ),
+                       'page_blog' => array(
+                               'type' => 'post_type',
+                               'object' => 'page',
+                               'object_id' => '{{blog}}',
+                       ),
+                       'page_contact' => array(
+                               'type' => 'post_type',
+                               'object' => 'page',
+                               'object_id' => '{{contact-us}}',
+                       ),
+
+                       'link_yelp' => array(
+                               'title' => __( 'Yelp' ),
+                               'url' => 'https://www.yelp.com',
+                       ),
+                       'link_facebook' => array(
+                               'title' => __( 'Facebook' ),
+                               'url' => 'https://www.facebook.com/wordpress',
+                       ),
+                       'link_twitter' => array(
+                               'title' => __( 'Twitter' ),
+                               'url' => 'https://twitter.com/wordpress',
+                       ),
+                       'link_instagram' => array(
+                               'title' => __( 'Instagram' ),
+                               'url' => 'https://www.instagram.com/explore/tags/wordcamp/',
+                       ),
+                       'link_email' => array(
+                               'title' => __( 'Email' ),
+                               'url' => 'mailto:wordpress@example.com',
+                       ),
+               ),
+               'posts' => array(
+                       'home' => array(
+                               'post_type' => 'page',
+                               'post_title' => __( 'Homepage' ),
+                               'post_content' => __( 'Welcome home.' ),
+                       ),
+                       'about-us' => array(
+                               'post_type' => 'page',
+                               'post_title' => __( 'About Us' ),
+                               'post_content' => __( 'More than you ever wanted to know.' ),
+                       ),
+                       'contact-us' => array(
+                               'post_type' => 'page',
+                               'post_title' => __( 'Contact Us' ),
+                               'post_content' => __( 'Call us at 999-999-9999.' ),
+                       ),
+                       'blog' => array(
+                               'post_type' => 'page',
+                               'post_title' => __( 'Blog' ),
+                       ),
+
+                       'homepage-section' => array(
+                               'post_type' => 'page',
+                               'post_title' => __( 'A homepage section' ),
+                               'post_content' => __( 'This is an example of a homepage section, which are managed in theme options.' ),
+                       ),
+               ),
+       );
+
+       $content = array();
+
+       foreach ( $config as $type => $args ) {
+               switch( $type ) {
+                       // Use options and theme_mods as-is
+                       case 'options' :
+                       case 'theme_mods' :
+                               $content[ $type ] = $config[ $type ];
+                               break;
+
+                       // Widgets are an extra level down due to groupings
+                       case 'widgets' :
+                               foreach ( $config[ $type ] as $group => $items ) {
+                                       foreach ( $items as $id ) {
+                                               if ( ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $id ] ) ) {
+                                                       $content[ $type ][ $group ][ $id ] = $core_content[ $type ][ $id ];
+                                               }
+                                       }
+                               }
+                               break;
+
+                       // And nav menus are yet another level down
+                       case 'nav_menus' :
+                               foreach ( $config[ $type ] as $group => $args2 ) {
+                                       // Menu groups need a name
+                                       if ( empty( $args['name'] ) ) {
+                                               $args2['name'] = $group;
+                                       }
+
+                                       $content[ $type ][ $group ]['name'] = $args2['name'];
+
+                                       // Do we need to check if this is empty?
+                                       foreach ( $args2['items'] as $id ) {
+                                               if ( ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $id ] ) ) {
+                                                       $content[ $type ][ $group ]['items'][ $id ] = $core_content[ $type ][ $id ];
+                                               }
+                                       }
+                               }
+                               break;
+
+
+                       // Everything else should map at the next level
+                       default :
+                               foreach( $config[ $type ] as $id ) {
+                                       if ( ! empty( $core_content[ $type ] ) && ! empty( $core_content[ $type ][ $id ] ) ) {
+                                               $content[ $type ][ $id ] = $core_content[ $type ][ $id ];
+                                       }
+                               }
+                               break;
+               }
+       }
+
+       /**
+        * Filters the expanded array of starter content.
+        *
+        * @since 4.7.0
+        *
+        * @param array $content Array of starter content.
+        * @param array $config  Array of theme-specific starter content configuration.
+        */
+       return apply_filters( 'get_theme_starter_content', $content, $config );
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Registers theme support for a given feature.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * Must be called in the theme's functions.php file to work.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1767,12 +1936,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 3.9.0 The `html5` feature now also accepts 'gallery' and 'caption'
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 4.1.0 The `title-tag` feature was added
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 4.5.0 The `customize-selective-refresh-widgets` feature was added
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 4.7.0 The `starter-content` feature was added
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @global array $_wp_theme_features
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @param string $feature  The feature being added. Likely core values include 'post-formats',
</span><span class="cx" style="display: block; padding: 0 10px">  *                         'post-thumbnails', 'html5', 'custom-logo', 'custom-header-uploads',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *                         'custom-header', 'custom-background', 'title-tag', etc.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *                         'custom-header', 'custom-background', 'title-tag', 'starter-content', etc.
</ins><span class="cx" style="display: block; padding: 0 10px">  * @param mixed  $args,... Optional extra arguments to pass along with certain features.
</span><span class="cx" style="display: block; padding: 0 10px">  * @return void|bool False on failure, void otherwise.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2204,7 +2374,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * The dynamic portion of the hook name, `$feature`, refers to the specific theme
</span><span class="cx" style="display: block; padding: 0 10px">         * feature. Possible values include 'post-formats', 'post-thumbnails', 'custom-background',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * 'custom-header', 'menus', 'automatic-feed-links', 'html5', and `customize-selective-refresh-widgets`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * 'custom-header', 'menus', 'automatic-feed-links', 'html5',
+        * 'starter-content', and 'customize-selective-refresh-widgets'.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 3.4.0
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span></span></pre>
</div>
</div>

</body>
</html>