From 0ef7d95aff910b3f82b1a1e804ef2f8e4e0c8591 Mon Sep 17 00:00:00 2001 From: Chi-Hsuan Huang Date: Fri, 6 Sep 2024 10:39:55 +0800 Subject: [PATCH] Hide site visibility badge when "Launch Your Store" feature is disabled (#51159) * Fix: put site visibility badge behind the launch your store feature flag * Add changelog --- .../woocommerce/changelog/fix-site-visibility-badge | 4 ++++ .../Internal/ComingSoon/ComingSoonAdminBarBadge.php | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 plugins/woocommerce/changelog/fix-site-visibility-badge diff --git a/plugins/woocommerce/changelog/fix-site-visibility-badge b/plugins/woocommerce/changelog/fix-site-visibility-badge new file mode 100644 index 00000000000..ea310491096 --- /dev/null +++ b/plugins/woocommerce/changelog/fix-site-visibility-badge @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Put site visibility badge behind the launch your store feature flag diff --git a/plugins/woocommerce/src/Internal/ComingSoon/ComingSoonAdminBarBadge.php b/plugins/woocommerce/src/Internal/ComingSoon/ComingSoonAdminBarBadge.php index 0b65041e322..082944cd3b6 100644 --- a/plugins/woocommerce/src/Internal/ComingSoon/ComingSoonAdminBarBadge.php +++ b/plugins/woocommerce/src/Internal/ComingSoon/ComingSoonAdminBarBadge.php @@ -4,6 +4,8 @@ declare( strict_types = 1 ); namespace Automattic\WooCommerce\Internal\ComingSoon; +use Automattic\WooCommerce\Admin\Features\Features; + /** * Adds hooks to add a badge to the WordPress admin bar showing site visibility. */ @@ -27,6 +29,11 @@ class ComingSoonAdminBarBadge { * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance. */ public function site_visibility_badge( $wp_admin_bar ) { + // Early exit if LYS feature is disabled. + if ( ! Features::is_enabled( 'launch-your-store' ) ) { + return; + } + $labels = array( 'coming-soon' => __( 'Coming soon', 'woocommerce' ), 'store-coming-soon' => __( 'Store coming soon', 'woocommerce' ), @@ -60,6 +67,11 @@ class ComingSoonAdminBarBadge { * @internal */ public function output_css() { + // Early exit if LYS feature is disabled. + if ( ! Features::is_enabled( 'launch-your-store' ) ) { + return; + } + if ( is_admin_bar_showing() ) { echo '