Blueprint: Add an Import Theme Starter Content step. #1521
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Motivation for the change, related issues
As part of working on Theme Previews for WordPress.org, I found myself needing to import Starter Content from themes into the playground site.
After working up the PHP as a
runPHP
step (See WordPress/wordpress.org#329), similar to theimportWXR
step I felt that this might be useful to others, so I've converted it into a fully fledged playground Step.This was also partially an exercise in understanding how Playground Steps work under the hood. If this is deemed to not be useful feature for Playground Core, that's OK, we can't add everything as a builtin option.
Implementation details
This is modeled on the existing ImportWXR and runPHP steps, using some somewhat awkward PHP to simulate a Customizer save request, before using the Customizer import starter content to changeset function, and publish changeset functions to make the changes to the site.
I imagine this could also bean option to toggle oninstallTheme
, such asinstallStarterContent: true
. Option implementedThis is the same as the user loading a playground instance with a theme, clicking customize, seeing the starter content, then clicking publish. (See the video at the end)
Testing Instructions (or ideally a Blueprint)
http://127.0.0.1:5400/website-server/#{%22steps%22:[{%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22},{%22step%22:%22installTheme%22,%22themeZipFile%22:{%22resource%22:%22wordpress.org/themes%22,%22slug%22:%22twentytwenty%22},%22options%22:{%22importStarterContent%22:true}}]}
Screen.Recording.2024-06-18.at.2.20.33.PM.mov