Skip to content
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

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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

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
*/
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 <[email protected]>
Co-authored-by: Mamaduka <[email protected]>

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

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
Status: 🔎 Needs Review
Development

Successfully merging this pull request may close these issues.

2 participants