Skip to content

Commit

Permalink
release: v3.3.6
Browse files Browse the repository at this point in the history
- Fix duplicate notification in Neve FSE
- Fix SDK breaking Enfold theme builder
  • Loading branch information
HardeepAsrani authored Oct 5, 2023
2 parents 978771f + 6c743a1 commit e72f1c6
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 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 @@ -268,6 +267,22 @@ public function is_writeable() {
return false;
}

/**
* Third-party compatibility.
*
* @return boolean
*/
private function has_conflicts() {
global $pagenow;

// Editor notices aren't compatible with Enfold theme.
if ( defined( 'AV_FRAMEWORK_VERSION' ) && in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) {
return true;
}

return false;
}

/**
* Get promotions.
*
Expand All @@ -285,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 @@ -351,15 +368,15 @@ 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',
],
],
];

foreach ( $all as $slug => $data ) {
foreach ( $data as $key => $conditions ) {
if ( ! $conditions['env'] ) {
if ( ! $conditions['env'] || $this->has_conflicts() ) {
unset( $all[ $slug ][ $key ] );

continue;
Expand Down Expand Up @@ -530,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 @@ -784,7 +807,7 @@ function( $tabs ) {
);

return $tabs;
}
}
);

add_action( 'woocommerce_product_data_panels', array( $this, 'woocommerce_tab_content' ) );
Expand All @@ -800,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 e72f1c6

Please sign in to comment.