WordPress.org

Make WordPress Core

Opened 8 months ago

Closed 8 months ago

Last modified 7 weeks ago

#38533 closed enhancement (fixed)

Introduce a flag to indicate a "fresh site"

Reported by: helen Owned by: westonruter
Milestone: 4.7 Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: has-patch
Focuses: Cc:

Description

Closely tied to starter content in #38114, but also potentially generally useful.

Thinking a flag (option) that is set on install and then deleted upon the first run of one of a number of actions. Those actions should be: adding/updating a post or page, changing widgets, or saving customizer settings.

Attachments (3)

38533.diff (1.8 KB) - added by helen 8 months ago.
38533.1.diff (1.8 KB) - added by ocean90 8 months ago.
38533.2.diff (863 bytes) - added by westonruter 8 months ago.

Download all attachments as: .zip

Change History (15)

@helen
8 months ago

@ocean90
8 months ago

#1 @swissspidy
8 months ago

It might make more sense to have different options for each action to target the user better. They could open the customizer and hit save, but still be a newbie in regard to saving posts and widgets.

#2 @ocean90
8 months ago

  • Keywords has-patch added

38533.1.diff sets the option to 0 so the option is autoloaded to prevent further db queries.

Not sure about the get_option() in default-filters though, looks like it's first one that runs so early. Currently it's wp_plugin_directory_constants() with get_option('siteurl') so I guess it's fine.

#3 @westonruter
8 months ago

Please review and make additional revs via pushing to feature branch on GitHub. See PR: https://github.com/xwp/wordpress-develop/pull/188

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


8 months ago

#5 @westonruter
8 months ago

  • Owner set to westonruter
  • Resolution set to fixed
  • Status changed from new to closed

In 38991:

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.

This ticket was mentioned in Slack in #core-themes by helen. View the logs.


8 months ago

#7 @helen
8 months ago

  • Keywords needs-patch added; has-patch removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Looks like this is getting populated as 1 on existing sites, I guess we should populate as 0 in that case.

@westonruter
8 months ago

#8 @westonruter
8 months ago

  • Keywords has-patch added; needs-patch removed

OK, so populate_options() will populate the options defined when upgrading in addition to when installing. Maybe the fresh_site flag should be set in wp_install() instead. This would ensure it only gets added for new installs and only once.

See 38533.2.diff.

#9 @helen
8 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 39076:

Only set fresh_site during an actual fresh install.

props westonruter.
fixes #38533.

#10 @ocean90
8 months ago

#38552 was marked as a duplicate.

#11 @westonruter
7 months ago

In 39276:

Customize: Add unit tests for importing theme starter content.

Props welcher, westonruter.
See #38114, #38533, #38615.
Fixes #38540.

#12 @westonruter
7 weeks ago

In 40608:

Customize: Fix clearing of fresh_site option flag when editing sidebars on widgets admin screen.

Amends [38991].
See #38114, #38533.
Fixes #40722.

Note: See TracTickets for help on using tickets.