WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/28/2016 02:56:16 AM (4 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyseventeen/functions.php

    r38867 r38991  
    103103     */
    104104    add_editor_style( array( 'assets/css/editor-style.css', twentyseventeen_fonts_url() ) );
     105
     106    add_theme_support( 'starter-content', array(
     107        'widgets' => array(
     108            'sidebar-1' => array(
     109                'text_business_info',
     110                'search',
     111                'text_credits',
     112            ),
     113
     114            'sidebar-2' => array(
     115                'text_business_info',
     116            ),
     117
     118            'sidebar-3' => array(
     119                'text_credits',
     120            ),
     121        ),
     122
     123        'posts' => array(
     124            'home',
     125            'about-us',
     126            'contact-us',
     127            'blog',
     128            'homepage-section',
     129        ),
     130
     131        'options' => array(
     132            'show_on_front' => 'page',
     133            'page_on_front' => '{{home}}',
     134            'page_for_posts' => '{{blog}}',
     135        ),
     136
     137        'theme_mods' => array(
     138            'panel_1' => '{{homepage-section}}',
     139            'panel_2' => '{{about-us}}',
     140            'panel_3' => '{{blog}}',
     141            'panel_4' => '{{contact-us}}',
     142        ),
     143
     144        'nav_menus' => array(
     145            'top' => array(
     146                'name' => __( 'Top' ),
     147                'items' => array(
     148                    'page_home',
     149                    'page_about',
     150                    'page_blog',
     151                    'page_contact',
     152                ),
     153            ),
     154            'social' => array(
     155                'name' => __( 'Social' ),
     156                'items' => array(
     157                    'link_yelp',
     158                    'link_facebook',
     159                    'link_twitter',
     160                    'link_instagram',
     161                    'link_email',
     162                ),
     163            ),
     164        ),
     165    ) );
    105166}
    106167add_action( 'after_setup_theme', 'twentyseventeen_setup' );
Note: See TracChangeset for help on using the changeset viewer.