Skip to content

Commit

Permalink
fix: multiple notifications at the same time [#69]
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-ungureanu committed Sep 6, 2023
1 parent aa43843 commit 79d16aa
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions inc/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@
* Admin class.
*/
class Admin {

/**
* Property to suspend the survey.
* Change it to true to enable it.
*
* @var bool
*/
private $suspend_survey = false;

/**
* Admin constructor.
*/
public function __construct() {
$this->setup_otter_notice();
$this->add_install_time();
add_action( 'admin_init', array( $this, 'handle_notices' ) );
}

/**
Expand All @@ -37,14 +46,23 @@ private function add_install_time() {


/**
* Setup the Otter Blocks notice.
* Handle admin notices in Neve FSE.
*
* @return void
*/
public function setup_otter_notice() {
public function handle_notices() {
add_action( 'admin_notices', array( $this, 'render_welcome_notice' ), 0 );
add_action( 'admin_notices', array( $this, 'render_survey_notice' ) );
add_action( 'wp_ajax_neve_fse_dismiss_welcome_notice', array( $this, 'remove_welcome_notice' ) );

/**
* Do not show any other message on Themes page if Neve FSE promo is enabled.
*/
global $pagenow;
$current_promotion = apply_filters( 'themeisle_sdk_current_promotion', '' );
if ( 'neve-fse-themes-popular' === $current_promotion && 'themes.php' === $pagenow ) {
return;
}
add_action( 'admin_notices', array( $this, 'render_survey_notice' ) );
add_action( 'wp_ajax_neve_fse_dismiss_survey_notice', array( $this, 'remove_survey_notice' ) );
}

Expand All @@ -55,6 +73,10 @@ public function setup_otter_notice() {
*/
public function should_show_survey_notice() {

if ( $this->suspend_survey ) {
return false;
}

// Notice was dismissed.
if ( get_option( Constants::CACHE_KEYS['dismissed-survey-notice'], 'no' ) === 'yes' ) {
return false;
Expand Down

0 comments on commit 79d16aa

Please sign in to comment.