-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add Theme Previews for block themes #50030
Conversation
Size Change: +694 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @scruffian
Can you provide more context why the new middleware is needed? It seems that new middleware will be applied to every request. Do you think that's necessary?
The PHP code could use notes on how it's meant to be migrated into the core. We should move the feature into the experimental
directory if it is still experimental. The former isn't a requirement, but I found it helpful when migrating the code to the WP core.
Flaky tests detected in c08950a0e159cb452a99d97c113bca0a96514f7e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4819963070
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the experiment be about Block Theme previews?
@Mamaduka it will only be applied on the requests when |
c08950a
to
f220ff3
Compare
2202a6e
to
28472cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 great experiment. the code looks well guarded and the testing went great.
make it work for child themes sanitize the theme_preview param use the url package move to middleware make a serverside middleware add comment remove comment change url add comments add the theme previews file rename param remove unsed params fix PHPCS Add live preview buttons to block themes partly update the editor to reflect that theme preview is on keep the preview flag on when navigating through pages activate theme from the preview add an experiment add default stylesheet hide behind and experiment Update lib/experiments-page.php Co-authored-by: Dave Smith <getdavemail@gmail.com> Update lib/experiments-page.php Co-authored-by: Dave Smith <getdavemail@gmail.com> Update lib/experiments-page.php Co-authored-by: Dave Smith <getdavemail@gmail.com> linting and docs add a snackbar notice Translate script strings Render theme name instead of path Update packages/edit-site/src/components/save-hub/index.js Use @wordpress/url utils show button on all block themes even after scrolling Update site editor save button to activate theme Fix activate buttons to remove url param Replace history instead of pushing only activate themes when saving dirty changes move functions to utils move activate to a hook add a return url use getQueryArgs Refactor save hub activate and save button add warning about theme activation Co-authored-by: Dave Smith <444434+getdave@users.noreply.github.com> rename function fix rebase fix PHPCS fix the experiment name wrap changes in an experiment
I have used the super power and merged this with one failing test: in |
I may be reading this wrong, but it seems like any visitor to the site can override the theme being used by passing |
Very cool. |
We have an issue for this: #50188 |
What?
This adds theme previews to the Site Editor by means of a
theme_preview
parameter. The aim is to enable theme previews from the theme directory as outlined in #37201 (comment).🤖 Generated by Copilot at 3f68df7
This pull request adds a new feature to the
apiFetch
andcore-data
packages that enables theme previews in the Site Editor for block themes. It also adds a compatibility layer for WordPress 6.3 that filters the blog options and sets the theme for the preview based on the REST API request. It creates and requires a new filetheme-previews.php
and a new middleware functioncreateThemePreviewMiddleware
.Why?
Theme previews are a missing feature for block themes.
How?
stylesheet
andtemplate
options when thetheme_preview
URL parameter is set, to modify the blog option for to a different theme.🤖 Generated by Copilot at 3f68df7
theme-previews.php
file in theload.php
file (link)createThemePreviewMiddleware
function in theapi-fetch
package (link,link,link)__experimentalGetTemplateForLink
resolver function in thecore-data
package (link)theme_preview
parameter to the fetch request, based on the value of thetheme_preview
GET parameter in the window location (link)Testing Instructions
themePath
is the relative path to the theme you want to preview (e.g.twentytwentythree
).Testing Instructions for Keyboard
Screenshots or screencast
Todo
Fixes #37201 and #47228
@WordPress/block-themers