From a9355bde2e8d42bd1a4fc85adf8888e149ddab8c Mon Sep 17 00:00:00 2001 From: Ashar Fuadi Date: Fri, 20 Dec 2024 14:42:49 +0700 Subject: [PATCH] Gutenberg 19.9: don't show launch banner when the site is previewed in Appearance -> Design (#40695) --- .../plugins/wpcomsh/changelog/fix-launch-banner-in-iframe | 4 ++++ projects/plugins/wpcomsh/private-site/logged-in-banner.php | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 projects/plugins/wpcomsh/changelog/fix-launch-banner-in-iframe diff --git a/projects/plugins/wpcomsh/changelog/fix-launch-banner-in-iframe b/projects/plugins/wpcomsh/changelog/fix-launch-banner-in-iframe new file mode 100644 index 0000000000000..3d25f5d5bcb47 --- /dev/null +++ b/projects/plugins/wpcomsh/changelog/fix-launch-banner-in-iframe @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Gutenberg 19.9: don't show launch banner when the site is previewed in Appearance -> Design diff --git a/projects/plugins/wpcomsh/private-site/logged-in-banner.php b/projects/plugins/wpcomsh/private-site/logged-in-banner.php index 28bd6cdeb0560..b478ff329c70c 100644 --- a/projects/plugins/wpcomsh/private-site/logged-in-banner.php +++ b/projects/plugins/wpcomsh/private-site/logged-in-banner.php @@ -199,6 +199,11 @@ function show_logged_in_banner() { el.style.display = 'none'; document.addEventListener( 'DOMContentLoaded', function() { + // Don't show the banner if the site is previewed via an iframe. + if ( window.top !== window.self ) { + return; + } + var el = document.querySelector( '#wpcom-launch-banner-wrapper' ); if ( el ) { el.style.display = null;