Skip to content

Avoid changing non-theme-preview requests - #51221

Merged
draganescu merged 1 commit into
WordPress:trunkfrom
okmttdhr:update/block-theme-previews-fix
Jun 5, 2023
Merged

draganescu merged 1 commit into
WordPress:trunkfrom
okmttdhr:update/block-theme-previews-fix

Conversation

@okmttdhr

@okmttdhr okmttdhr commented Jun 5, 2023 •

Copy link
Copy Markdown
Contributor

What?

This PR prevents Block Theme Previews from changing non-theme-preview requests.

Why?

The current implementation would empty the original stylesheet when "there is a URL query (?theme_preview=) but no theme preview permission" (this behavior was introduced in #50338).
This unintentionally breaks functionality other than Block Theme Previews, so it has been modified not to change it except when Block Theme Previews should be applied.

How?

  • Return the original value when Block Theme Previews should not be applied.

Testing Instructions

  • Open the Site Editor and add the following to your URL: ?theme_preview=[themePath] where themePath is the relative path to the theme you want to preview (e.g. twentytwentythree).

@okmttdhr
okmttdhr marked this pull request as ready for review June 5, 2023 03:26
@okmttdhr
okmttdhr requested a review from spacedmonkey as a code owner June 5, 2023 03:26

@draganescu draganescu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch, there should be no effect in trying to preview without permission.

@draganescu
draganescu merged commit 27b78f2 into WordPress:trunk Jun 5, 2023
@github-actions github-actions Bot added this to the Gutenberg 16.0 milestone Jun 5, 2023
@okmttdhr
okmttdhr deleted the update/block-theme-previews-fix branch June 6, 2023 01:07
@ndiego ndiego added [Type] Bug An existing feature does not function as intended [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Jun 7, 2023
@ramonjd ramonjd added the Needs PHP backport Needs PHP backport to Core label Jun 8, 2023
@ramonjd

ramonjd commented Jun 8, 2023

Copy link
Copy Markdown
Member

Hello! Do you folks think theme previews will be part of WordPress 6.3? I'll add it to the backport issue to be sure. If not, we can remove it.

Thanks!

cc @scruffian

@draganescu

Copy link
Copy Markdown
Contributor

@ramonjd if there is no major blocker appearing in the mean time I think so yes!

@scruffian

Copy link
Copy Markdown
Contributor

Yes I agree, I hope it will be in 6.3.

@ramonjd

ramonjd commented Jun 8, 2023

Copy link
Copy Markdown
Member

Thanks for the feedback!

@ramonjd ramonjd removed the Needs PHP backport Needs PHP backport to Core label Jun 30, 2023
sethrubenstein pushed a commit to pewresearch/gutenberg that referenced this pull request Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants