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

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

t-hamano
Copy link
Contributor

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

⚒️ WIP ⚒️

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
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