Add Theme Previews for block themes#50030
Conversation
|
Size Change: +694 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Mamaduka
left a comment
There was a problem hiding this comment.
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
|
@Mamaduka it will only be applied on the requests when |
c08950a to
f220ff3
Compare
2202a6e to
28472cd
Compare
draganescu
left a comment
There was a problem hiding this comment.
🎉 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_previewparameter. 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
apiFetchandcore-datapackages 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.phpand a new middleware functioncreateThemePreviewMiddleware.Why?
Theme previews are a missing feature for block themes.
How?
stylesheetandtemplateoptions when thetheme_previewURL parameter is set, to modify the blog option for to a different theme.🤖 Generated by Copilot at 3f68df7
theme-previews.phpfile in theload.phpfile (link)createThemePreviewMiddlewarefunction in theapi-fetchpackage (link,link,link)__experimentalGetTemplateForLinkresolver function in thecore-datapackage (link)theme_previewparameter to the fetch request, based on the value of thetheme_previewGET parameter in the window location (link)Testing Instructions
themePathis 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