* Prevent notice if legacy coupon menu is disabled

* Disable legacy menu for new install

* Add changelog entry

* Add PR number to changelog
This commit is contained in:
Mik 2021-12-06 15:21:08 +00:00 committed by GitHub
parent 6c2fbce0c0
commit 3fb028931e
2 changed files with 17 additions and 5 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: Fix
Prevent coupon move notice for new installs. #7995

View File

@ -33,6 +33,7 @@ class CouponPageMoved {
add_action( 'admin_init', [ $this, 'possibly_add_note' ] );
add_action( 'admin_init', [ $this, 'redirect_to_coupons' ] );
add_action( 'woocommerce_admin_newly_installed', [ $this, 'disable_legacy_menu_for_new_install' ] );
}
/**
@ -45,6 +46,11 @@ class CouponPageMoved {
return false;
}
// Don't add the notice if the legacy coupon menu is already disabled.
if ( ! self::should_display_legacy_menu() ) {
return false;
}
// Don't add the notice if it's been hidden by the user before.
if ( self::has_dismissed_note() ) {
return false;
@ -55,11 +61,6 @@ class CouponPageMoved {
return false;
}
// If new navigation feature is enabled.
if ( Features::is_enabled( 'navigation' ) ) {
return false;
}
return isset( $_GET[ self::$query_key ] ) && (bool) $_GET[ self::$query_key ]; // phpcs:ignore WordPress.Security.NonceVerification
}
@ -148,4 +149,11 @@ class CouponPageMoved {
wp_safe_redirect( self::get_management_url( 'coupons' ) );
exit;
}
/**
* Disable legacy coupon menu when installing for the first time.
*/
public function disable_legacy_menu_for_new_install() {
$this->display_legacy_menu( false );
}
}