Skip to content

Commit

Permalink
Merge pull request #193 from Codeinwp/fix/neve-fse-multiple-notices
Browse files Browse the repository at this point in the history
Notifications for Neve FSE
  • Loading branch information
HardeepAsrani authored Oct 5, 2023
2 parents 50115d4 + 451ab59 commit 6c743a1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Modules/Promotions.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public function load( $product ) {
*/
public function load_available() {
$this->promotions = $this->filter_by_screen_and_merge();

if ( empty( $this->promotions ) ) {
return;
}
Expand Down Expand Up @@ -301,6 +300,8 @@ private function get_promotions() {
$has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' );
$is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' );
$is_min_fse_v = version_compare( get_bloginfo( 'version' ), '6.2', '>=' );
$current_theme = wp_get_theme();
$has_neve_fse = $current_theme->template === 'neve-fse' || $current_theme->parent() === 'neve-fse';
$has_enough_attachments = $this->has_min_media_attachments();
$has_enough_old_posts = $this->has_old_posts();

Expand Down Expand Up @@ -367,7 +368,7 @@ private function get_promotions() {
],
'neve-fse' => [
'neve-fse-themes-popular' => [
'env' => $is_min_fse_v,
'env' => ! $has_neve_fse && $is_min_fse_v,
'screen' => 'themes-install-popular',
],
],
Expand Down Expand Up @@ -546,6 +547,12 @@ private function load_promotion( $slug ) {
$this->load_woo_promos();
break;
case 'neve-fse-themes-popular':
// Remove any other notifications if Neve FSE promotion is showing
remove_action( 'admin_notices', array( 'ThemeisleSDK\Modules\Notification', 'show_notification' ) );
remove_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( 'ThemeisleSDK\Modules\Notification', 'dismiss' ) );
remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'dismiss_get' ) );
remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'setup_notifications' ) );
// Add required actions to display this notification
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] );
break;
Expand Down Expand Up @@ -800,7 +807,7 @@ function( $tabs ) {
);

return $tabs;
}
}
);

add_action( 'woocommerce_product_data_panels', array( $this, 'woocommerce_tab_content' ) );
Expand All @@ -816,7 +823,7 @@ public function woocommerce_tab_content() {
function( $key ) {
return in_array( $key, $this->promotions, true );
},
ARRAY_FILTER_USE_KEY
ARRAY_FILTER_USE_KEY
);

// Display CSS
Expand Down

0 comments on commit 6c743a1

Please sign in to comment.