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 #38114, #38533.


git-svn-id: https://develop.svn.wordpress.org/trunk@38991 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter
2016-10-28 02:56:16 +00:00
parent 76012a9a59
commit 630fd305fc
9 changed files with 429 additions and 5 deletions
@@ -102,6 +102,67 @@ function twentyseventeen_setup() {
* specifically font, colors, and column width.
*/
add_editor_style( array( 'assets/css/editor-style.css', twentyseventeen_fonts_url() ) );
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',
),
),
),
) );
}
add_action( 'after_setup_theme', 'twentyseventeen_setup' );