Make WordPress Core

Opened 7 years ago

Last modified 3 years ago

#38624 new enhancement

Allow starter content to apply after a site has already been set up and is no longer “fresh”

Reported by: westonruter's profile westonruter Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: Cc:

Description

Starter content for themes was introduced in #38114. In order to prevent the starter content from overriding a site's existing content, a fresh_site option flag was added to prevent the content from applying after the site has been first updated. This means the starter content has limited use when installing new themes to try out during the life of a site.

The primary problem for applying starter content on an existing site is how to handle the merge conflicts, how to decide when to use the starter content/configs and when to use existing site content/configs. One option would be a button to “reset” a site to use the starter content. For more granularity, once the starter content is applied there could be a list of the settings that were modified so that you could then go through and evaluate each change to see if you want to keep it. Each control that has a setting containing dirty starter content could be highlighted in some way with a button that allows you to revert the starter content or toggle the starter content so you can compare before/after.

This is closely related to #21666 (Customizer reset/undo/revert) and #31089 (Add revisions of settings to the Customizer).

Attachments (2)

load-starter-content-button.png (40.0 KB) - added by westonruter 7 years ago.
Starter.jpg (290.7 KB) - added by JoshuaWold 7 years ago.
Starter Content Sketches

Download all attachments as: .zip

Change History (30)

#1 @westonruter
7 years ago

  • Type changed from defect (bug) to enhancement

This ticket was mentioned in Slack in #themereview by rabmalin. View the logs.


7 years ago

#3 @westonruter
7 years ago

I want there to be a feature plugin soon that provides a UI, a button, for applying starter content to your already-established site. I also want there to be a UI for being able to select from among multiple sets of starter content.

#4 @webmandesign
7 years ago

Hi,

Just adding additional info about the current implementation issue here:

With current checking for `fresh_site` it is actually not possible to use a theme starter content with WordPress network (multisite) setup either. As fresh_site is actually set during the WordPress installation only and is nulled after publishing a post/page or saving a widget or customizer settings, which could already be triggered on one of sites in the network installation.

Please keep this in mind too. Would be great if the feature works with WordPress network.

Thanks and regards,

Oliver

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


7 years ago

#6 @westonruter
7 years ago

  • Milestone changed from Future Release to 4.8

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


7 years ago

This ticket was mentioned in Slack in #themereview by suganya. View the logs.


7 years ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


7 years ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


7 years ago

#11 @jbpaul17
7 years ago

  • Milestone changed from 4.8 to 4.8.1

Punting to 4.8.1 per today's bug scrub.

#12 @westonruter
7 years ago

@joshuawold I reworked the feature plugin I initially put together for prototyping starter content to now be a plugin for adding a UI for applying starter content to non-fresh sites: https://github.com/xwp/wp-trac-38624

Initial rudimentary UI can be seen in load-starter-content-button.png.

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


7 years ago

#14 @westonruter
7 years ago

  • Milestone changed from 4.8.1 to 4.9

#15 @suganya1993
7 years ago

Hi @westonruter,

Is there any future idea to add post category in starter content. now post possible arguments are

'post_type',
'post_title',
'post_excerpt',
'post_name',
'post_content',
'menu_order',
'comment_status',
'thumbnail',
'template',

#16 @westonruter
7 years ago

@suganya1993 that's a good suggestion, but without #38227 it would be required to actually insert live terms into the database even prior to publishing.

#17 @westonruter
7 years ago

#41122 was marked as a duplicate.

@JoshuaWold
7 years ago

Starter Content Sketches

#18 @JoshuaWold
7 years ago

@joshuawold I reworked the feature plugin

  1. Is this testable now?
  1. Is the above sketch still relevant to the discussion (pulling from our chat into this ticket)?

#19 @westonruter
7 years ago

@JoshuaWold the feature plugin merely adds the Load Starter Content button, which then just ignores whether or not it is a fresh_site when applying the starter content. Your sketch is definitely still relevant, as the feature plugin implements no UI other than that one button. The button needs to be augmented/replaced with fine-grained control over which starter content bits gets applied.

#20 @westonruter
7 years ago

  • Milestone changed from 4.9 to Future Release

#21 @actionscripted
6 years ago

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 // 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.)

This ticket was mentioned in Slack in #core by westonruter. View the logs.


6 years ago

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


6 years ago

This ticket was mentioned in Slack in #themereview by joyously. View the logs.


6 years ago

This ticket was mentioned in Slack in #design by joshuawold. View the logs.


6 years ago

This ticket was mentioned in Slack in #themereview by dannycooper. View the logs.


5 years ago

This ticket was mentioned in Slack in #core-customize by dlh. View the logs.


3 years ago

#28 @helen
3 years ago

#51821 was marked as a duplicate.

Note: See TracTickets for help on using tickets.