-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blueprint: Add an Import Theme Starter Content step. #1521
Blueprint: Add an Import Theme Starter Content step. #1521
Conversation
70b1e71
to
0372a52
Compare
This doesn't have any docs or integration tests included as I wasn't sure if it was going to be accepted, I can look into that if wanted. Additionally, the above has a lint failure due to the step not requiring any args, I'm not sure of the best way to handle that. I did go down the route of adding an option just to satisfy the linter, but I felt that the option was better off not added ultimately. So I force-pushed that commit off this PR. |
@dd32 it would be great if we could trigger this using an option instead of another blueprint step. The step feels really specific so the option seems like a good fit. |
I agree, but as it'd probably live as a step in code anyway, submitting it as-is seemed the easiest way to see if there was any buy-in. It'd probably be called the same as wordpress-playground/packages/playground/blueprints/src/lib/steps/install-theme.ts Lines 74 to 83 in 1ed4c01
|
…yground tests don't abide by this.
Implemented the option on 3b9a9b4 took way too long to track down.. |
This is a lovely feature. The PR looks great @dd32, thank you! |
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