← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Promotions.php
+28
-5
3.10.3
→
3.10.5
View file →
| @@ -158,9 +158,8 @@ | ||
| 158 | 158 | * Load available promotions. |
| 159 | 159 | */ |
| 160 | 160 | public function load_available() { |
| 161 | 161 | $this->promotions = $this->filter_by_screen_and_merge(); |
| 162 | - | |
| 163 | 162 | if ( empty( $this->promotions ) ) { |
| 164 | 163 | return; |
| 165 | 164 | } |
| 166 | 165 | |
| @@ -268,8 +267,24 @@ | ||
| 268 | 267 | return false; |
| 269 | 268 | } |
| 270 | 269 | |
| 271 | 270 | /** |
| 271 | + * Third-party compatibility. | |
| 272 | + * | |
| 273 | + * @return boolean | |
| 274 | + */ | |
| 275 | + private function has_conflicts() { | |
| 276 | + global $pagenow; | |
| 277 | + | |
| 278 | + // Editor notices aren't compatible with Enfold theme. | |
| 279 | + if ( defined( 'AV_FRAMEWORK_VERSION' ) && in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) { | |
| 280 | + return true; | |
| 281 | + } | |
| 282 | + | |
| 283 | + return false; | |
| 284 | + } | |
| 285 | + | |
| 286 | + /** | |
| 272 | 287 | * Get promotions. |
| 273 | 288 | * |
| 274 | 289 | * @return array |
| 275 | 290 | */ |
| @@ -284,8 +299,10 @@ | ||
| 284 | 299 | $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' ); |
| 285 | 300 | $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' ); |
| 286 | 301 | $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' ); |
| 287 | 302 | $is_min_fse_v = version_compare( get_bloginfo( 'version' ), '6.2', '>=' ); |
| 303 | + $current_theme = wp_get_theme(); | |
| 304 | + $has_neve_fse = $current_theme->template === 'neve-fse' || $current_theme->parent() === 'neve-fse'; | |
| 288 | 305 | $has_enough_attachments = $this->has_min_media_attachments(); |
| 289 | 306 | $has_enough_old_posts = $this->has_old_posts(); |
| 290 | 307 | |
| 291 | 308 | $all = [ |
| @@ -350,9 +367,9 @@ | ||
| 350 | 367 | ], |
| 351 | 368 | ], |
| 352 | 369 | 'neve-fse' => [ |
| 353 | 370 | 'neve-fse-themes-popular' => [ |
| 354 | - 'env' => $is_min_fse_v, | |
| 371 | + 'env' => ! $has_neve_fse && $is_min_fse_v, | |
| 355 | 372 | 'screen' => 'themes-install-popular', |
| 356 | 373 | ], |
| 357 | 374 | ], |
| 358 | 375 | ]; |
| @@ -358,9 +375,9 @@ | ||
| 358 | 375 | ]; |
| 359 | 376 | |
| 360 | 377 | foreach ( $all as $slug => $data ) { |
| 361 | 378 | foreach ( $data as $key => $conditions ) { |
| 362 | - if ( ! $conditions['env'] ) { | |
| 379 | + if ( ! $conditions['env'] || $this->has_conflicts() ) { | |
| 363 | 380 | unset( $all[ $slug ][ $key ] ); |
| 364 | 381 | |
| 365 | 382 | continue; |
| 366 | 383 | } |
| @@ -529,8 +546,14 @@ | ||
| 529 | 546 | case 'sparks-product-reviews': |
| 530 | 547 | $this->load_woo_promos(); |
| 531 | 548 | break; |
| 532 | 549 | case 'neve-fse-themes-popular': |
| 550 | + // Remove any other notifications if Neve FSE promotion is showing | |
| 551 | + remove_action( 'admin_notices', array( 'ThemeisleSDK\Modules\Notification', 'show_notification' ) ); | |
| 552 | + remove_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( 'ThemeisleSDK\Modules\Notification', 'dismiss' ) ); | |
| 553 | + remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'dismiss_get' ) ); | |
| 554 | + remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'setup_notifications' ) ); | |
| 555 | + // Add required actions to display this notification | |
| 533 | 556 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); |
| 534 | 557 | add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] ); |
| 535 | 558 | break; |
| 536 | 559 | } |
| @@ -783,9 +806,9 @@ | ||
| 783 | 806 | 'priority' => 1000, |
| 784 | 807 | ); |
| 785 | 808 | |
| 786 | 809 | return $tabs; |
| 787 | - } | |
| 810 | + } | |
| 788 | 811 | ); |
| 789 | 812 | |
| 790 | 813 | add_action( 'woocommerce_product_data_panels', array( $this, 'woocommerce_tab_content' ) ); |
| 791 | 814 | } |
| @@ -799,9 +822,9 @@ | ||
| 799 | 822 | $this->woo_promos, |
| 800 | 823 | function( $key ) { |
| 801 | 824 | return in_array( $key, $this->promotions, true ); |
| 802 | 825 | }, |
| 803 | - ARRAY_FILTER_USE_KEY | |
| 826 | + ARRAY_FILTER_USE_KEY | |
| 804 | 827 | ); |
| 805 | 828 | |
| 806 | 829 | // Display CSS |
| 807 | 830 | self::render_woo_tabs_css(); |