[wp-trac] [WordPress Trac] #38624: Allow starter content to apply after a site has already been set up and is no longer “fresh”

WordPress Trac noreply at wordpress.org
Thu Oct 12 03:09:03 UTC 2017


#38624: Allow starter content to apply after a site has already been set up and is
no longer “fresh”
-------------------------+-----------------------------
 Reporter:  westonruter  |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Future Release
Component:  Customize    |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+-----------------------------

Comment (by actionscripted):

 One workaround we're taking for a spin on a multi-site network is to check
 for {{{fresh_site}}} with a default value of {{{NULL}}} and then queuing
 an action to call
 {{{WP_Customize_Manager->import_theme_starter_content()}}} if the option
 value is {{{NULL}}} or {{{1}}}.


 For example:

 {{{#!php
 <?php // In functions.php...

 add_action('after_setup_theme', 'sometheme_setup');

 function sometheme_setup () {

   add_theme_support('starter-content', array(/* ... */));

   // Manually run starter content
   // Related: https://core.trac.wordpress.org/ticket/38624
   global $pagenow;
   $fresh_site = get_option('fresh_site', NULL);
   if ((is_null($fresh_site) || $fresh_site == 1) && $pagenow ===
 'customize.php') {
     global $wp_customize;
     add_action('after_setup_theme', array($wp_customize,
 'import_theme_starter_content'), 100);
   }

 } // End sometheme_setup()

 }}}


 From what I can tell the issue seems to be that {{{fresh_site}}} isn't set
 for sub-sites initially and so returns false when checked in
 {{{WP_Customize_Manager}}} (line 551).

 By setting the default value of {{{get_option()}}} to {{{NULL}}} and
 getting the {{{fresh_site}}} option we can distinguish between the false-y
 {{{0}}} value set in default-filters.php (line 197) or a non-existent
 value.

 This has allowed us to have starter content in sub-sites without issue.

 (Perhaps this information should go into another ticket as it doesn't
 quite belong here aside from the mention about multi-site support above by
 @webmandesign.)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38624#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list