Skip to content

Site Editor: Set IFRAME_REQUEST constant for classic theme site preview #69535

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

Merged
merged 3 commits into from
Mar 18, 2025

Conversation

t-hamano
Copy link
Contributor

@t-hamano t-hamano commented Mar 12, 2025

What?

Follow-up #69514
Related core PR: WordPress/wordpress-develop#8475

Note

Don't add Backport to WP 6.8 Beta/RC label to this PR. This is because the auto cherry-pick has failed in #69514. I plan to submit another PR to the wp/6.8 branch that includes this PR and #69514.

Why?

In #69514, We added a get parameter to hide admin bar in the classic theme site preview. However, we found that some plugins load code into the preview.

How?

To solve this problem, it seems best to define IFRAME_REQUEST instead of filtering show_admin_bar hook.

Testing Instructions

  • Activate Twenty Twenty-One.
  • Install and activate https://ja.wordpress.org/plugins/query-monitor/ plugin.
  • Access Appearance > Design.
  • Confirm that the admin bar isn't displayed within the site preview.
  • Confirm that the Query Monitor plugin doesn't load anything.
  • Reload your browser a few times and check again.
Before After
image image

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Mar 12, 2025
@t-hamano t-hamano self-assigned this Mar 12, 2025
@github-project-automation github-project-automation bot moved this to 🔎 Needs Review in WordPress 6.8 Editor Tasks Mar 12, 2025
*/
function wp_initialize_site_preview_hooks() {
if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['wp_site_preview'] ) && 1 === (int) $_GET['wp_site_preview'] ) {
define( 'IFRAME_REQUEST', true );
Copy link
Member

Choose a reason for hiding this comment

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

Great catch, @t-hamano! Today, I also learned about IFRAME_REQUEST 😄

@t-hamano t-hamano force-pushed the classic-site-preview-iframe-request branch from 78242a5 to bf6b891 Compare March 12, 2025 10:14
Copy link

Flaky tests detected in 2859a73.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13829249888
📝 Reported issues:

@t-hamano t-hamano marked this pull request as ready for review March 15, 2025 09:13
@t-hamano t-hamano requested a review from spacedmonkey as a code owner March 15, 2025 09:13
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka
Copy link
Member

@t-hamano, do you have time to finish the backport PR for tomorrow morning/afternoon your timezone?

@t-hamano
Copy link
Contributor Author

@Mamaduka The backport PR for 6.8 has already been approved 👍

#69536

@Mamaduka
Copy link
Member

That's great!

@Mamaduka Mamaduka merged commit b47d966 into trunk Mar 18, 2025
64 checks passed
@Mamaduka Mamaduka deleted the classic-site-preview-iframe-request branch March 18, 2025 07:08
@github-project-automation github-project-automation bot moved this from 🔎 Needs Review to ✅ Done in WordPress 6.8 Editor Tasks Mar 18, 2025
@github-actions github-actions bot added this to the Gutenberg 20.6 milestone Mar 18, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…view (WordPress#69535)

* Site Editor: Set `IFRAME_REQUEST` constant for classic theme site preview
* Add backport changelog
* Add user capabilities check

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Bug An existing feature does not function as intended
Projects
Development

Successfully merging this pull request may close these issues.

2 participants