From b2e5d32db980aeddc36d92b002e34ebc171fe525 Mon Sep 17 00:00:00 2001 From: Joel Thiessen <444632+joelclimbsthings@users.noreply.github.com> Date: Tue, 13 Oct 2020 20:02:47 -0700 Subject: [PATCH] =?UTF-8?q?Preventing=20the=20legacy=20coupons=20page=20fr?= =?UTF-8?q?om=20being=20readded=20when=20the=20naviga=E2=80=A6=20(https://?= =?UTF-8?q?github.com/woocommerce/woocommerce-admin/pull/5307)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Preventing the legacy coupons page from being readded when the navigation plugin is active (woocommerce/navigation woocommerce/woocommerce-admin#122) I've also added a check to prevent the "coupons page has moved" note from being displayed, since it's no longer applicable in the new nav. * Addressing linting issues with PHP files * Updating conditions to work correctly with navigation as feature instead of external plugin * Updating comment text --- .../woocommerce-admin/src/Features/CouponsMovedTrait.php | 4 +++- plugins/woocommerce-admin/src/Notes/CouponPageMoved.php | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-admin/src/Features/CouponsMovedTrait.php b/plugins/woocommerce-admin/src/Features/CouponsMovedTrait.php index bfb730894a0..9a3bd405af9 100644 --- a/plugins/woocommerce-admin/src/Features/CouponsMovedTrait.php +++ b/plugins/woocommerce-admin/src/Features/CouponsMovedTrait.php @@ -5,6 +5,8 @@ namespace Automattic\WooCommerce\Admin\Features; +use Automattic\WooCommerce\Admin\Loader; + /** * CouponsMovedTrait trait. */ @@ -88,7 +90,7 @@ trait CouponsMovedTrait { * @return bool */ protected static function should_display_legacy_menu() { - return (bool) get_option( self::$option_key, 1 ); + return ( get_option( self::$option_key, 1 ) && ! Loader::is_feature_enabled( 'navigation' ) ); } /** diff --git a/plugins/woocommerce-admin/src/Notes/CouponPageMoved.php b/plugins/woocommerce-admin/src/Notes/CouponPageMoved.php index 1c729c479e6..561f80bd6eb 100644 --- a/plugins/woocommerce-admin/src/Notes/CouponPageMoved.php +++ b/plugins/woocommerce-admin/src/Notes/CouponPageMoved.php @@ -8,6 +8,7 @@ namespace Automattic\WooCommerce\Admin\Notes; use Automattic\WooCommerce\Admin\Features\CouponsMovedTrait; +use Automattic\WooCommerce\Admin\Loader; use stdClass; use WC_Data_Store; @@ -54,6 +55,11 @@ class Coupon_Page_Moved { return false; } + // If new navigation feature is enabled. + if ( Loader::is_feature_enabled( 'navigation' ) ) { + return false; + } + return isset( $_GET[ self::$query_key ] ) && (bool) $_GET[ self::$query_key ]; // phpcs:ignore WordPress.Security.NonceVerification }