← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Promotions.php
+41
-5
3.10.2
→
3.10.7
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 | |
| @@ -173,8 +172,21 @@ | ||
| 173 | 172 | * |
| 174 | 173 | * @return void |
| 175 | 174 | */ |
| 176 | 175 | public function register_reference() { |
| 176 | + if ( ! current_user_can( 'activate_plugins' ) ) { | |
| 177 | + return; | |
| 178 | + } | |
| 179 | + | |
| 180 | + if ( ! isset( $_GET['plugin'] ) || ! isset( $_GET['_wpnonce'] ) ) { | |
| 181 | + return; | |
| 182 | + } | |
| 183 | + | |
| 184 | + $plugin = rawurldecode( $_GET['plugin'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 185 | + if ( wp_verify_nonce( $_GET['_wpnonce'], 'activate-plugin_' . $plugin ) === false ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 186 | + return; | |
| 187 | + } | |
| 188 | + | |
| 177 | 189 | if ( isset( $_GET['reference_key'] ) ) { |
| 178 | 190 | update_option( 'otter_reference_key', sanitize_key( $_GET['reference_key'] ) ); |
| 179 | 191 | } |
| 180 | 192 | |
| @@ -268,8 +280,24 @@ | ||
| 268 | 280 | return false; |
| 269 | 281 | } |
| 270 | 282 | |
| 271 | 283 | /** |
| 284 | + * Third-party compatibility. | |
| 285 | + * | |
| 286 | + * @return boolean | |
| 287 | + */ | |
| 288 | + private function has_conflicts() { | |
| 289 | + global $pagenow; | |
| 290 | + | |
| 291 | + // Editor notices aren't compatible with Enfold theme. | |
| 292 | + if ( defined( 'AV_FRAMEWORK_VERSION' ) && in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) { | |
| 293 | + return true; | |
| 294 | + } | |
| 295 | + | |
| 296 | + return false; | |
| 297 | + } | |
| 298 | + | |
| 299 | + /** | |
| 272 | 300 | * Get promotions. |
| 273 | 301 | * |
| 274 | 302 | * @return array |
| 275 | 303 | */ |
| @@ -284,8 +312,10 @@ | ||
| 284 | 312 | $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' ); |
| 285 | 313 | $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' ); |
| 286 | 314 | $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' ); |
| 287 | 315 | $is_min_fse_v = version_compare( get_bloginfo( 'version' ), '6.2', '>=' ); |
| 316 | + $current_theme = wp_get_theme(); | |
| 317 | + $has_neve_fse = $current_theme->template === 'neve-fse' || $current_theme->parent() === 'neve-fse'; | |
| 288 | 318 | $has_enough_attachments = $this->has_min_media_attachments(); |
| 289 | 319 | $has_enough_old_posts = $this->has_old_posts(); |
| 290 | 320 | |
| 291 | 321 | $all = [ |
| @@ -350,9 +380,9 @@ | ||
| 350 | 380 | ], |
| 351 | 381 | ], |
| 352 | 382 | 'neve-fse' => [ |
| 353 | 383 | 'neve-fse-themes-popular' => [ |
| 354 | - 'env' => $is_min_fse_v, | |
| 384 | + 'env' => ! $has_neve_fse && $is_min_fse_v, | |
| 355 | 385 | 'screen' => 'themes-install-popular', |
| 356 | 386 | ], |
| 357 | 387 | ], |
| 358 | 388 | ]; |
| @@ -358,9 +388,9 @@ | ||
| 358 | 388 | ]; |
| 359 | 389 | |
| 360 | 390 | foreach ( $all as $slug => $data ) { |
| 361 | 391 | foreach ( $data as $key => $conditions ) { |
| 362 | - if ( ! $conditions['env'] ) { | |
| 392 | + if ( ! $conditions['env'] || $this->has_conflicts() ) { | |
| 363 | 393 | unset( $all[ $slug ][ $key ] ); |
| 364 | 394 | |
| 365 | 395 | continue; |
| 366 | 396 | } |
| @@ -529,8 +559,14 @@ | ||
| 529 | 559 | case 'sparks-product-reviews': |
| 530 | 560 | $this->load_woo_promos(); |
| 531 | 561 | break; |
| 532 | 562 | case 'neve-fse-themes-popular': |
| 563 | + // Remove any other notifications if Neve FSE promotion is showing | |
| 564 | + remove_action( 'admin_notices', array( 'ThemeisleSDK\Modules\Notification', 'show_notification' ) ); | |
| 565 | + remove_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( 'ThemeisleSDK\Modules\Notification', 'dismiss' ) ); | |
| 566 | + remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'dismiss_get' ) ); | |
| 567 | + remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'setup_notifications' ) ); | |
| 568 | + // Add required actions to display this notification | |
| 533 | 569 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] ); |
| 534 | 570 | add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] ); |
| 535 | 571 | break; |
| 536 | 572 | } |
| @@ -783,9 +819,9 @@ | ||
| 783 | 819 | 'priority' => 1000, |
| 784 | 820 | ); |
| 785 | 821 | |
| 786 | 822 | return $tabs; |
| 787 | - } | |
| 823 | + } | |
| 788 | 824 | ); |
| 789 | 825 | |
| 790 | 826 | add_action( 'woocommerce_product_data_panels', array( $this, 'woocommerce_tab_content' ) ); |
| 791 | 827 | } |
| @@ -799,9 +835,9 @@ | ||
| 799 | 835 | $this->woo_promos, |
| 800 | 836 | function( $key ) { |
| 801 | 837 | return in_array( $key, $this->promotions, true ); |
| 802 | 838 | }, |
| 803 | - ARRAY_FILTER_USE_KEY | |
| 839 | + ARRAY_FILTER_USE_KEY | |
| 804 | 840 | ); |
| 805 | 841 | |
| 806 | 842 | // Display CSS |
| 807 | 843 | self::render_woo_tabs_css(); |