PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.5
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.5
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/codeinwp/themeisle-sdk/src/Modules/Promotions.php +468 -79 3.10.03.11.5 View file →
@@ -13,8 +13,9 @@
13 13
14 14 namespace ThemeisleSDK\Modules;
15 15
16 16 use ThemeisleSDK\Common\Abstract_Module;
17 +use ThemeisleSDK\Loader;
17 18 use ThemeisleSDK\Product;
18 19
19 20 // Exit if accessed directly.
20 21 if ( ! defined( 'ABSPATH' ) ) {
@@ -33,8 +34,16 @@
33 34 */
34 35 private $promotions = array();
35 36
36 37 /**
38 + * Holds the values of the promotions that are not allowed to be shown.
39 + * Can be filtered by each product.
40 + *
41 + * @var array
42 + */
43 + private $dissallowed_promotions = array();
44 +
45 + /**
37 46 * Option key for promos.
38 47 *
39 48 * @var string
40 49 */
@@ -61,8 +70,15 @@
61 70 */
62 71 private $option_rop = 'themeisle_sdk_promotions_rop_installed';
63 72
64 73 /**
74 + * Option key for Neve FSE promos.
75 + *
76 + * @var string
77 + */
78 + private $option_neve_fse = 'themeisle_sdk_promotions_neve_fse_installed';
79 +
80 + /**
65 81 * Loaded promotion.
66 82 *
67 83 * @var string
68 84 */
@@ -68,8 +84,15 @@
68 84 */
69 85 private $loaded_promo;
70 86
71 87 /**
88 + * Woo promotions.
89 + *
90 + * @var array
91 + */
92 + private $woo_promos = array();
93 +
94 + /**
72 95 * Debug mode.
73 96 *
74 97 * @var bool
75 98 */
@@ -93,11 +116,15 @@
93 116 $this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug );
94 117 $promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() );
95 118 $promotions_to_load[] = 'optimole';
96 119 $promotions_to_load[] = 'rop';
120 + $promotions_to_load[] = 'woo_plugins';
121 + $promotions_to_load[] = 'neve-fse';
97 122
98 123 $this->promotions = $this->get_promotions();
99 124
125 + $this->dissallowed_promotions = apply_filters( $product->get_key() . '_dissallowed_promotions', array() );
126 +
100 127 foreach ( $this->promotions as $slug => $data ) {
101 128 if ( ! in_array( $slug, $promotions_to_load, true ) ) {
102 129 unset( $this->promotions[ $slug ] );
103 130 }
@@ -129,9 +156,14 @@
129 156
130 157 add_filter( 'attachment_fields_to_edit', array( $this, 'add_attachment_field' ), 10, 2 );
131 158 add_action( 'current_screen', [ $this, 'load_available' ] );
132 159 add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'enqueue' ) );
160 + add_action( 'wp_ajax_tisdk_update_option', array( $this, 'dismiss_promotion' ) );
133 161 add_filter( 'themeisle_sdk_ran_promos', '__return_true' );
162 +
163 + if ( get_option( $this->option_neve_fse, false ) !== true ) {
164 + add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', 'ThemeisleSDK\Modules\Notification::regular_dismiss' );
165 + }
134 166 }
135 167
136 168 /**
137 169 * Load available promotions.
@@ -137,9 +169,8 @@
137 169 * Load available promotions.
138 170 */
139 171 public function load_available() {
140 172 $this->promotions = $this->filter_by_screen_and_merge();
141 -
142 173 if ( empty( $this->promotions ) ) {
143 174 return;
144 175 }
145 176
@@ -152,8 +183,21 @@
152 183 *
153 184 * @return void
154 185 */
155 186 public function register_reference() {
187 + if ( ! current_user_can( 'activate_plugins' ) ) {
188 + return;
189 + }
190 +
191 + if ( ! isset( $_GET['plugin'] ) || ! isset( $_GET['_wpnonce'] ) ) {
192 + return;
193 + }
194 +
195 + $plugin = rawurldecode( $_GET['plugin'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
196 + if ( wp_verify_nonce( $_GET['_wpnonce'], 'activate-plugin_' . $plugin ) === false ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
197 + return;
198 + }
199 +
156 200 if ( isset( $_GET['reference_key'] ) ) {
157 201 update_option( 'otter_reference_key', sanitize_key( $_GET['reference_key'] ) );
158 202 }
159 203
@@ -163,8 +207,12 @@
163 207
164 208 if ( isset( $_GET['rop_reference_key'] ) ) {
165 209 update_option( 'rop_reference_key', sanitize_key( $_GET['rop_reference_key'] ) );
166 210 }
211 +
212 + if ( isset( $_GET['neve_fse_reference_key'] ) ) {
213 + update_option( 'neve_fse_reference_key', sanitize_key( $_GET['neve_fse_reference_key'] ) );
214 + }
167 215 }
168 216
169 217 /**
170 218 * Register Settings
@@ -212,31 +260,21 @@
212 260 'show_in_rest' => true,
213 261 'default' => false,
214 262 )
215 263 );
264 + register_setting(
265 + 'themeisle_sdk_settings',
266 + $this->option_neve_fse,
267 + array(
268 + 'type' => 'boolean',
269 + 'sanitize_callback' => 'rest_sanitize_boolean',
270 + 'show_in_rest' => true,
271 + 'default' => false,
272 + )
273 + );
216 274 }
217 275
218 276 /**
219 - * Get the SDK base url.
220 - *
221 - * @return string
222 - */
223 - private function get_sdk_uri() {
224 - global $themeisle_sdk_max_path;
225 -
226 - /**
227 - * $themeisle_sdk_max_path can point to the theme when the theme version is higher.
228 - * hence we also need to check that the path does not point to the theme else this will break the URL.
229 - * References: https://github.com/Codeinwp/neve-pro-addon/issues/2403
230 - */
231 - if ( $this->product->is_plugin() && false === strpos( $themeisle_sdk_max_path, get_template_directory() ) ) {
232 - return plugins_url( '/', $themeisle_sdk_max_path . '/themeisle-sdk/' );
233 - };
234 -
235 - return get_template_directory_uri() . '/vendor/codeinwp/themeisle-sdk/';
236 - }
237 -
238 - /**
239 277 * Check if the path is writable.
240 278 *
241 279 * @return boolean
242 280 * @access public
@@ -253,26 +291,17 @@
253 291 return false;
254 292 }
255 293
256 294 /**
257 - * Get the Otter Blocks plugin status.
295 + * Third-party compatibility.
258 296 *
259 - * @param string $plugin Plugin slug.
260 - *
261 - * @return bool
297 + * @return boolean
262 298 */
263 - private function is_plugin_installed( $plugin ) {
264 - static $allowed_keys = [
265 - 'otter-blocks' => 'otter-blocks/otter-blocks.php',
266 - 'optimole-wp' => 'optimole-wp/optimole-wp.php',
267 - 'tweet-old-post' => 'tweet-old-post/tweet-old-post.php',
268 - ];
299 + private function has_conflicts() {
300 + global $pagenow;
269 301
270 - if ( ! isset( $allowed_keys[ $plugin ] ) ) {
271 - return false;
272 - }
273 -
274 - if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $allowed_keys[ $plugin ] ) ) {
302 + // Editor notices aren't compatible with Enfold theme.
303 + if ( defined( 'AV_FRAMEWORK_VERSION' ) && in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) {
275 304 return true;
276 305 }
277 306
278 307 return false;
@@ -289,14 +318,20 @@
289 318 $has_optimole = defined( 'OPTIMOLE_VERSION' ) || $this->is_plugin_installed( 'optimole-wp' );
290 319 $had_optimole_from_promo = get_option( $this->option_optimole, false );
291 320 $has_rop = defined( 'ROP_LITE_VERSION' ) || $this->is_plugin_installed( 'tweet-old-post' );
292 321 $had_rop_from_promo = get_option( $this->option_rop, false );
322 + $has_woocommerce = class_exists( 'WooCommerce' );
323 + $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' );
324 + $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' );
293 325 $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' );
326 + $is_min_fse_v = version_compare( get_bloginfo( 'version' ), '6.2', '>=' );
327 + $current_theme = wp_get_theme();
328 + $has_neve_fse = $current_theme->template === 'neve-fse' || $current_theme->parent() === 'neve-fse';
294 329 $has_enough_attachments = $this->has_min_media_attachments();
295 330 $has_enough_old_posts = $this->has_old_posts();
296 331
297 332 $all = [
298 - 'optimole' => [
333 + 'optimole' => [
299 334 'om-editor' => [
300 335 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo,
301 336 'screen' => 'editor',
302 337 ],
@@ -316,9 +351,9 @@
316 351 'env' => ! $has_optimole && ! $had_optimole_from_promo && defined( 'ELEMENTOR_VERSION' ),
317 352 'screen' => 'elementor',
318 353 ],
319 354 ],
320 - 'otter' => [
355 + 'otter' => [
321 356 'blocks-css' => [
322 357 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
323 358 'screen' => 'editor',
324 359 ],
@@ -330,19 +365,43 @@
330 365 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
331 366 'screen' => 'editor',
332 367 ],
333 368 ],
334 - 'rop' => [
369 + 'rop' => [
335 370 'rop-posts' => [
336 371 'env' => ! $has_rop && ! $had_rop_from_promo && $has_enough_old_posts,
337 372 'screen' => 'edit-post',
338 373 ],
339 374 ],
375 + 'woo_plugins' => [
376 + 'ppom' => [
377 + 'env' => ! $has_ppom && $has_woocommerce,
378 + 'screen' => 'edit-product',
379 + ],
380 + 'sparks-wishlist' => [
381 + 'env' => ! $has_sparks && $has_woocommerce,
382 + 'screen' => 'edit-product',
383 + ],
384 + 'sparks-announcement' => [
385 + 'env' => ! $has_sparks && $has_woocommerce,
386 + 'screen' => 'edit-product',
387 + ],
388 + 'sparks-product-review' => [
389 + 'env' => ! $has_sparks && $has_woocommerce,
390 + 'screen' => 'edit-product',
391 + ],
392 + ],
393 + 'neve-fse' => [
394 + 'neve-fse-themes-popular' => [
395 + 'env' => ! $has_neve_fse && $is_min_fse_v,
396 + 'screen' => 'themes-install-popular',
397 + ],
398 + ],
340 399 ];
341 400
342 401 foreach ( $all as $slug => $data ) {
343 402 foreach ( $data as $key => $conditions ) {
344 - if ( ! $conditions['env'] ) {
403 + if ( ! $conditions['env'] || $this->has_conflicts() ) {
345 404 unset( $all[ $slug ][ $key ] );
346 405
347 406 continue;
348 407 }
@@ -364,9 +423,9 @@
364 423 * Get the upsell dismiss time.
365 424 *
366 425 * @param string $key The upsell key. If empty will return all dismiss times.
367 426 *
368 - * @return false | string
427 + * @return false | string | array
369 428 */
370 429 private function get_upsells_dismiss_time( $key = '' ) {
371 430 $old = get_option( 'themeisle_sdk_promotions_otter', '{}' );
372 431 $data = get_option( $this->option_main, $old );
@@ -382,20 +441,20 @@
382 441
383 442 /**
384 443 * Get the last dismiss time of a promotion.
385 444 *
386 - * @return false
445 + * @return int The timestamp of last dismiss, or install time - 4 days.
387 446 */
388 447 private function get_last_dismiss_time() {
389 448 $dismissed = $this->get_upsells_dismiss_time();
390 449
391 450 if ( empty( $dismissed ) ) {
392 - return false;
451 + // we return the product install time - 4 days because we want to show the upsell after 3 days,
452 + // and we move the product install time 4 days in the past.
453 + return $this->product->get_install_time() - 4 * DAY_IN_SECONDS;
393 454 }
394 455
395 - $last_dismiss = max( array_values( $dismissed ) );
396 -
397 - return $last_dismiss;
456 + return max( array_values( $dismissed ) );
398 457 }
399 458
400 459 /**
401 460 * Filter by screen & merge into single array of keys.
@@ -404,12 +463,14 @@
404 463 */
405 464 private function filter_by_screen_and_merge() {
406 465 $current_screen = get_current_screen();
407 466
408 - $is_elementor = isset( $_GET['action'] ) && $_GET['action'] === 'elementor';
409 - $is_media = isset( $current_screen->id ) && $current_screen->id === 'upload';
410 - $is_posts = isset( $current_screen->id ) && $current_screen->id === 'edit-post';
411 - $is_editor = method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor();
467 + $is_elementor = isset( $_GET['action'] ) && $_GET['action'] === 'elementor';
468 + $is_media = isset( $current_screen->id ) && $current_screen->id === 'upload';
469 + $is_posts = isset( $current_screen->id ) && $current_screen->id === 'edit-post';
470 + $is_editor = method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor();
471 + $is_theme_install = isset( $current_screen->id ) && ( $current_screen->id === 'theme-install' || $current_screen->id === 'themes' );
472 + $is_product = isset( $current_screen->id ) && $current_screen->id === 'product';
412 473
413 474 $return = [];
414 475
415 476 foreach ( $this->promotions as $slug => $promos ) {
@@ -439,8 +500,18 @@
439 500 if ( ! $is_posts ) {
440 501 unset( $this->promotions[ $slug ][ $key ] );
441 502 }
442 503 break;
504 + case 'edit-product':
505 + if ( ! $is_product ) {
506 + unset( $this->promotions[ $slug ][ $key ] );
507 + }
508 + break;
509 + case 'themes-install-popular':
510 + if ( ! $is_theme_install ) {
511 + unset( $this->promotions[ $slug ][ $key ] );
512 + }
513 + break;
443 514 }
444 515 }
445 516
446 517 $return = array_merge( $return, $this->promotions[ $slug ] );
@@ -445,8 +516,16 @@
445 516
446 517 $return = array_merge( $return, $this->promotions[ $slug ] );
447 518 }
448 519
520 + $return = array_filter(
521 + $return,
522 + function ( $value, $key ) {
523 + return ! in_array( $key, $this->dissallowed_promotions, true );
524 + },
525 + ARRAY_FILTER_USE_BOTH
526 + );
527 +
449 528 return array_keys( $return );
450 529 }
451 530
452 531 /**
@@ -465,9 +544,14 @@
465 544 }
466 545 if ( $this->get_upsells_dismiss_time( 'rop-posts' ) === false ) {
467 546 add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] );
468 547 }
548 + if ( $this->get_upsells_dismiss_time( 'neve-fse-themes-popular' ) === false ) {
549 + add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] );
550 + }
469 551
552 + $this->load_woo_promos();
553 +
470 554 return;
471 555 }
472 556
473 557 switch ( $slug ) {
@@ -488,8 +572,30 @@
488 572 case 'rop-posts':
489 573 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
490 574 add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] );
491 575 break;
576 + case 'ppom':
577 + case 'sparks-wishlist':
578 + case 'sparks-announcement':
579 + case 'sparks-product-reviews':
580 + $this->load_woo_promos();
581 + break;
582 + case 'neve-fse-themes-popular':
583 + // Remove any other notifications if Neve FSE promotion is showing
584 + remove_action( 'admin_notices', array( 'ThemeisleSDK\Modules\Notification', 'show_notification' ) );
585 + remove_action(
586 + 'wp_ajax_themeisle_sdk_dismiss_notice',
587 + array(
588 + 'ThemeisleSDK\Modules\Notification',
589 + 'dismiss',
590 + )
591 + );
592 + remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'dismiss_get' ) );
593 + remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'setup_notifications' ) );
594 + // Add required actions to display this notification
595 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
596 + add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] );
597 + break;
492 598 }
493 599 }
494 600
495 601 /**
@@ -513,17 +619,20 @@
513 619 $handle = 'ti-sdk-promo';
514 620 $saved = $this->get_upsells_dismiss_time();
515 621 $themeisle_sdk_src = $this->get_sdk_uri();
516 622 $user = wp_get_current_user();
517 - $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/index.asset.php';
623 + $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/promos/index.asset.php';
518 624 $deps = array_merge( $asset_file['dependencies'], [ 'updates' ] );
519 625
520 - wp_register_script( $handle, $themeisle_sdk_src . 'assets/js/build/index.js', $deps, $asset_file['version'], true );
626 + wp_register_script( $handle, $themeisle_sdk_src . 'assets/js/build/promos/index.js', $deps, $asset_file['version'], true );
521 627 wp_localize_script(
522 628 $handle,
523 629 'themeisleSDKPromotions',
524 630 [
525 631 'debug' => $this->debug,
632 + 'labels' => [
633 + 'optimole' => Loader::$labels['promotions']['optimole'],
634 + ],
526 635 'email' => $user->user_email,
527 636 'showPromotion' => $this->loaded_promo,
528 637 'optionKey' => $this->option_main,
529 638 'product' => $this->product->get_name(),
@@ -535,14 +644,15 @@
535 644 'otterActivationUrl' => $this->get_plugin_activation_link( 'otter-blocks' ),
536 645 'ropActivationUrl' => $this->get_plugin_activation_link( 'tweet-old-post' ),
537 646 'optimoleDash' => esc_url( add_query_arg( [ 'page' => 'optimole' ], admin_url( 'upload.php' ) ) ),
538 647 'ropDash' => esc_url( add_query_arg( [ 'page' => 'TweetOldPost' ], admin_url( 'admin.php' ) ) ),
648 + 'neveFSEMoreUrl' => tsdk_utmify( 'https://themeisle.com/themes/neve-fse/', 'neve-fse-themes-popular', 'theme-install' ),
539 649 // translators: %s is the product name.
540 - 'title' => esc_html( sprintf( __( 'Recommended by %s', 'textdomain' ), $this->product->get_name() ) ),
650 + 'title' => esc_html( sprintf( Loader::$labels['promotions']['recommended'], $this->product->get_name() ) ),
541 651 ]
542 652 );
543 653 wp_enqueue_script( $handle );
544 - wp_enqueue_style( $handle, $themeisle_sdk_src . 'assets/js/build/style-index.css', [ 'wp-components' ], $asset_file['version'] );
654 + wp_enqueue_style( $handle, $themeisle_sdk_src . 'assets/js/build/promos/style-index.css', [ 'wp-components' ], $asset_file['version'] );
545 655 }
546 656
547 657 /**
548 658 * Render rop notice.
@@ -557,8 +667,15 @@
557 667 echo '<div id="ti-rop-notice" class="notice notice-info ti-sdk-rop-notice"></div>';
558 668 }
559 669
560 670 /**
671 + * Render Neve FSE Themes notice.
672 + */
673 + public function render_neve_fse_themes_notice() {
674 + echo '<div id="ti-neve-fse-notice" class="notice notice-info ti-sdk-neve-fse-notice"></div>';
675 + }
676 +
677 + /**
561 678 * Add promo to attachment modal.
562 679 *
563 680 * @param array $fields Fields array.
564 681 * @param \WP_Post $post Post object.
@@ -593,33 +710,8 @@
593 710 return $fields;
594 711 }
595 712
596 713 /**
597 - * Get plugin activation link.
598 - *
599 - * @param string $slug The plugin slug.
600 - *
601 - * @return string
602 - */
603 - private function get_plugin_activation_link( $slug ) {
604 - $reference_key = $slug === 'otter-blocks' ? 'reference_key' : 'optimole_reference_key';
605 -
606 - return esc_url(
607 - add_query_arg(
608 - array(
609 - 'plugin_status' => 'all',
610 - 'paged' => '1',
611 - 'action' => 'activate',
612 - $reference_key => $this->product->get_key(),
613 - 'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ),
614 - '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $slug . '/' . $slug . '.php' ),
615 - ),
616 - admin_url( 'plugins.php' )
617 - )
618 - );
619 - }
620 -
621 - /**
622 714 * Check if has 50 image media items.
623 715 *
624 716 * @return bool
625 717 */
@@ -642,8 +734,9 @@
642 734
643 735
644 736 set_transient( 'tsk_attachment_count', $attachment_count, DAY_IN_SECONDS );
645 737 }
738 +
646 739 return $attachment_count > 50;
647 740 }
648 741
649 742 /**
@@ -693,6 +786,302 @@
693 786 }
694 787
695 788 // Check if there are more than 100 posts and more than 10 old posts
696 789 return $posts_count['total_posts'] > 100 && $posts_count['old_posts'] > 10;
790 + }
791 +
792 + /**
793 + * Check if should load Woo promos.
794 + *
795 + * @return bool
796 + */
797 + private function load_woo_promos() {
798 + $this->woo_promos = array(
799 + 'ppom' => array(
800 + 'title' => Loader::$labels['promotions']['woo']['ppom_title'],
801 + 'description' => Loader::$labels['promotions']['woo']['ppom_desc'],
802 + 'icon' => '<svg width="25" height="25" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800"><path d="M241.023,324.818c0.252,0,0.505,0.035,0.758,0.035h465.68c17.266,0,31.256-13.99,31.256-31.252 c0-17.262-13.99-31.247-31.256-31.247H351.021h-109.24c-17.258,0-31.252,13.985-31.252,31.247 C210.529,310.605,224.121,324.412,241.023,324.818z"/><path d="M210.529,450.306c0,17.257,13.994,31.252,31.252,31.252h769.451c17.262,0,31.256-13.995,31.256-31.252 c0-17.266-13.994-31.252-31.256-31.252H241.781C224.523,419.054,210.529,433.04,210.529,450.306z"/><path d="M1011.232,575.751H241.781c-8.149,0-15.549,3.147-21.116,8.261c-6.213,5.712-10.136,13.879-10.136,22.987 c0,17.262,13.994,31.26,31.252,31.26h769.451c17.262,0,31.256-13.999,31.256-31.26c0-9.108-3.923-17.275-10.141-22.987 C1026.781,578.898,1019.386,575.751,1011.232,575.751z"/><path d="M1011.232,732.461H241.781c-17.258,0-31.252,13.99-31.252,31.247c0,17.262,13.994,31.257,31.252,31.257 h769.451c17.262,0,31.256-13.995,31.256-31.257C1042.488,746.451,1028.494,732.461,1011.232,732.461z"/><path d="M1011.232,889.157H241.781c-8.149,0-15.549,3.147-21.116,8.261c-6.213,5.713-10.136,13.879-10.136,22.987 c0,17.257,13.994,31.261,31.252,31.261h769.451c17.262,0,31.256-14.004,31.256-31.261c0-9.108-3.923-17.274-10.141-22.987 C1026.781,892.305,1019.386,889.157,1011.232,889.157z"/><path d="M1011.232,1045.867H241.781c-17.258,0-31.252,13.99-31.252,31.243c0,17.271,13.994,31.265,31.252,31.265 h769.451c17.262,0,31.256-13.994,31.256-31.265C1042.488,1059.857,1028.494,1045.867,1011.232,1045.867z"/><path d="M1011.232,1202.576H241.781c-17.258,0-31.252,13.995-31.252,31.252c0,17.258,13.994,31.252,31.252,31.252 h769.451c17.262,0,31.256-13.994,31.256-31.252C1042.488,1216.571,1028.494,1202.576,1011.232,1202.576z"/><path d="M1011.232,1359.273H241.781c-8.149,0-15.549,3.151-21.116,8.265c-6.213,5.713-10.136,13.875-10.136,22.987 c0,17.258,13.994,31.261,31.252,31.261h769.451c17.262,0,31.256-14.003,31.256-31.261c0-9.112-3.923-17.274-10.141-22.987 C1026.781,1362.425,1019.386,1359.273,1011.232,1359.273z"/><path d="M1233.542,251.228l-49.851-45.109L1052.136,87.076l-59.185-53.554c-5.293-4.792-11.947-7.421-18.786-7.836 h-3.49H83.676c-45.688,0-82.858,37.375-82.858,83.316v1583.612c0,45.94,37.17,83.316,82.858,83.316h1078.562 c45.68,0,82.845-37.376,82.845-83.316V277.08v-3.182C1244.646,264.73,1240.261,256.589,1233.542,251.228z M1003.117,125.864 l131.119,118.657h-131.119V125.864z M1183.691,1692.613c0,12.094-9.622,21.926-21.454,21.926H83.676 c-11.836,0-21.467-9.832-21.467-21.926V109.001c0-12.089,9.631-21.925,21.467-21.925h857.857V275.38 c0,17.052,13.785,30.862,30.786,30.862h211.372V1692.613z"/><path d="M1798.578,180.737c-7.049-88.305-81.114-158.02-171.205-158.02c-0.004,0-0.004,0-0.004,0 c-45.889,0-89.033,17.874-121.479,50.32c-29.18,29.175-46.519,67.005-49.73,107.699h-0.586v13.609c0,0.06-0.005,0.115-0.005,0.175 c0,0.026,0.005,0.056,0.005,0.082l-0.005,1369.26h0.197c0.557,5.404,2.522,10.731,6.047,15.373l141.135,185.91 c5.803,7.648,14.851,12.136,24.447,12.136c9.601-0.004,18.646-4.496,24.447-12.14l141.093-185.897 c3.528-4.65,5.494-9.982,6.051-15.391h0.197V180.737H1798.578z M1549.299,116.448c20.854-20.855,48.578-32.339,78.07-32.339h0.004 c50.24,0,92.746,33.723,106.076,79.718h-212.19C1526.358,146.098,1535.896,129.852,1549.299,116.448z M1595.372,1502.468 l-78.413,0.005l0.005-1260.345h220.828v1260.336h-81.103l0.009-1016.486l-61.335,0.004L1595.372,1502.468z M1627.382,1695.821 l-100.171-131.963l200.338-0.004L1627.382,1695.821z"/></svg>',
803 + 'has_install' => true,
804 + 'link' => wp_nonce_url(
805 + add_query_arg(
806 + array(
807 + 'action' => 'install-plugin',
808 + 'plugin' => 'woocommerce-product-addon',
809 + ),
810 + admin_url( 'update.php' )
811 + ),
812 + 'install-plugin_woocommerce-product-addon'
813 + ),
814 + ),
815 + 'sparks-wishlist' => array(
816 + 'title' => Loader::$labels['promotions']['woo']['spark_title1'],
817 + 'description' => Loader::$labels['promotions']['woo']['spark_desc1'],
818 + 'icon' => '<svg width="25" height="25" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/SVG" aria-hidden="true"><path d="M60 21.25H57.5V40.125H60V21.25Z"></path><path d="M2.5 40H0V8.75C0 6.625 1.625 5 3.75 5H25V7.5H3.75C3 7.5 2.5 8 2.5 8.75V40Z"></path><path d="M56.25 51.25H3.75C1.625 51.25 0 49.625 0 47.5V42.5H25V45H2.5V47.5C2.5 48.25 3 48.75 3.75 48.75H56.25C57 48.75 57.5 48.25 57.5 47.5V43.75H60V47.5C60 49.625 58.375 51.25 56.25 51.25Z"></path><path d="M23.75 58.75H21.25V57.25L22.5 51.125V50H25V51.5L23.75 57.625V58.75Z"></path><path d="M38.75 58.75H36.25V57.625L35 51.25V50H37.5V51.125L38.75 57.5V58.75Z"></path><path d="M41.25 57.5H18.75V60H41.25V57.5Z"></path><path d="M56.25 32.5H43.75C41.625 32.5 40 30.875 40 28.75V3.75C40 1.625 41.625 0 43.75 0H56.25C58.375 0 60 1.625 60 3.75V28.75C60 30.875 58.375 32.5 56.25 32.5ZM43.75 2.5C43 2.5 42.5 3 42.5 3.75V28.75C42.5 29.5 43 30 43.75 30H56.25C57 30 57.5 29.5 57.5 28.75V3.75C57.5 3 57 2.5 56.25 2.5H43.75Z"></path><path d="M50 27.5C50.6904 27.5 51.25 26.9404 51.25 26.25C51.25 25.5596 50.6904 25 50 25C49.3096 25 48.75 25.5596 48.75 26.25C48.75 26.9404 49.3096 27.5 50 27.5Z"></path><path d="M51.25 45H31.25C29.125 45 27.5 43.375 27.5 41.25V8.75C27.5 6.625 29.125 5 31.25 5H37.5V7.5H31.25C30.5 7.5 30 8 30 8.75V41.25C30 42 30.5 42.5 31.25 42.5H51.25C52 42.5 52.5 42 52.5 41.25V35H55V41.25C55 43.375 53.375 45 51.25 45Z"></path><path d="M41.25 40C41.9404 40 42.5 39.4404 42.5 38.75C42.5 38.0596 41.9404 37.5 41.25 37.5C40.5596 37.5 40 38.0596 40 38.75C40 39.4404 40.5596 40 41.25 40Z"></path><path d="M21.75 40H18.25L13.25 35H11.75L6.75 40H0V37.5H5.75L10.75 32.5H14.25L19.25 37.5H20.75L52.875 5.375L54.625 7.125L21.75 40Z"></path><path d="M55 11.25H52.5V7.5H48.75V5H55V11.25Z"></path><defs><clip-path id="clip0"><rect width="60" height="60" fill="white"></rect></clip-path></defs></svg>',
819 + 'link' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce/', 'promo', 'products-tabs' ),
820 + ),
821 + 'sparks-announcement' => array(
822 + 'title' => Loader::$labels['promotions']['woo']['spark_title2'],
823 + 'description' => Loader::$labels['promotions']['woo']['spark_desc2'],
824 + 'icon' => '<svg width="25" height="25" viewBox="0 0 60 61" fill="none" xmlns="http://www.w3.org/2000/SVG" aria-hidden="true"><path d="M30 8.89282C29.6685 8.89282 29.3505 8.76113 29.1161 8.52671C28.8817 8.29228 28.75 7.97434 28.75 7.64282V1.39282C28.75 1.0613 28.8817 0.743359 29.1161 0.508939C29.3505 0.274518 29.6685 0.142822 30 0.142822C30.3315 0.142822 30.6495 0.274518 30.8839 0.508939C31.1183 0.743359 31.25 1.0613 31.25 1.39282V7.64282C31.25 7.97434 31.1183 8.29228 30.8839 8.52671C30.6495 8.76113 30.3315 8.89282 30 8.89282Z"></path><path d="M30 21.9105L26.25 18.1605V7.82598L26.9409 7.47992C27.8914 7.00723 28.9385 6.76123 30 6.76123C31.0615 6.76123 32.1086 7.00723 33.0591 7.47992L33.75 7.82598V18.1605L30 21.9105ZM28.75 17.1253L30 18.3753L31.25 17.1253V9.44219C30.4344 9.19928 29.5656 9.19928 28.75 9.44219V17.1253Z"></path><path d="M60 60.1428H0V22.6428H17.5C17.8315 22.6428 18.1495 22.7745 18.3839 23.0089C18.6183 23.2434 18.75 23.5613 18.75 23.8928C18.75 24.2243 18.6183 24.5423 18.3839 24.7767C18.1495 25.0111 17.8315 25.1428 17.5 25.1428H2.5V57.6428H57.5V25.1428H42.5C42.1685 25.1428 41.8505 25.0111 41.6161 24.7767C41.3817 24.5423 41.25 24.2243 41.25 23.8928C41.25 23.5613 41.3817 23.2434 41.6161 23.0089C41.8505 22.7745 42.1685 22.6428 42.5 22.6428H60V60.1428Z"></path><path d="M11.2493 53.8933C11.0421 53.8929 10.8383 53.841 10.6561 53.7424C10.474 53.6438 10.3191 53.5015 10.2055 53.3283C10.0919 53.1551 10.0231 52.9564 10.0052 52.75C9.98727 52.5436 10.0209 52.336 10.103 52.1458L26.353 14.6459C26.4182 14.4953 26.5125 14.359 26.6304 14.2448C26.7483 14.1306 26.8876 14.0408 27.0402 13.9804C27.1928 13.9201 27.3559 13.8903 27.52 13.893C27.6841 13.8956 27.8461 13.9306 27.9967 13.9958C28.1473 14.0611 28.2836 14.1553 28.3978 14.2732C28.5119 14.3912 28.6018 14.5304 28.6621 14.683C28.7225 14.8357 28.7522 14.9987 28.7496 15.1628C28.7469 15.3269 28.712 15.4889 28.6467 15.6395L12.3967 53.1395C12.2999 53.3634 12.1397 53.5541 11.9358 53.6881C11.7319 53.822 11.4932 53.8934 11.2493 53.8933Z"></path><path d="M48.7505 53.8935C48.5065 53.8935 48.2679 53.8222 48.064 53.6883C47.8601 53.5543 47.6999 53.3637 47.603 53.1398L31.353 15.6398C31.2212 15.3356 31.2157 14.9915 31.3376 14.6833C31.4595 14.375 31.6989 14.1278 32.003 13.9961C32.3072 13.8643 32.6513 13.8588 32.9595 13.9807C33.2678 14.1026 33.515 14.3419 33.6467 14.6461L49.8967 52.1461C49.9789 52.3363 50.0125 52.5439 49.9946 52.7503C49.9767 52.9566 49.9078 53.1553 49.7942 53.3285C49.6806 53.5018 49.5258 53.6441 49.3436 53.7427C49.1614 53.8413 48.9576 53.8932 48.7505 53.8936V53.8935Z"></path><path d="M30 33.8928C29.6685 33.8928 29.3505 33.7611 29.1161 33.5267C28.8817 33.2923 28.75 32.9743 28.75 32.6428V25.1428C28.75 24.8113 28.8817 24.4934 29.1161 24.2589C29.3505 24.0245 29.6685 23.8928 30 23.8928C30.3315 23.8928 30.6495 24.0245 30.8839 24.2589C31.1183 24.4934 31.25 24.8113 31.25 25.1428V32.6428C31.25 32.9743 31.1183 33.2923 30.8839 33.5267C30.6495 33.7611 30.3315 33.8928 30 33.8928Z"></path><path d="M45 30.1428H15C14.6685 30.1428 14.3505 30.0111 14.1161 29.7767C13.8817 29.5423 13.75 29.2243 13.75 28.8928C13.75 28.5613 13.8817 28.2434 14.1161 28.0089C14.3505 27.7745 14.6685 27.6428 15 27.6428H45C45.3315 27.6428 45.6495 27.7745 45.8839 28.0089C46.1183 28.2434 46.25 28.5613 46.25 28.8928C46.25 29.2243 46.1183 29.5423 45.8839 29.7767C45.6495 30.0111 45.3315 30.1428 45 30.1428Z"></path><defs><clip-path id="clip0"><rect width="60" height="60" fill="white" transform="translate(0 0.142822)"></rect></clip-path></defs></svg>',
825 + 'link' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce/', 'promo', 'products-tabs' ),
826 + ),
827 + 'sparks-product-review' => array(
828 + 'title' => Loader::$labels['promotions']['woo']['spark_title3'],
829 + 'description' => Loader::$labels['promotions']['woo']['spark_desc3'],
830 + 'icon' => '<svg width="25" height="25" viewBox="0 0 60 61" fill="none" xmlns="http://www.w3.org/2000/SVG" aria-hidden="true"><path d="M58.75 54.1797H1.25C1.08584 54.1797 0.923271 54.1474 0.771595 54.0846C0.619919 54.0218 0.482103 53.9297 0.366021 53.8137C0.24994 53.6976 0.157867 53.5598 0.0950637 53.4081C0.0322604 53.2564 -4.26571e-05 53.0939 4.22759e-08 52.9297V6.67969C-4.26571e-05 6.51552 0.0322604 6.35296 0.0950637 6.20128C0.157867 6.04961 0.24994 5.91179 0.366021 5.79571C0.482103 5.67963 0.619919 5.58755 0.771595 5.52475C0.923271 5.46195 1.08584 5.42964 1.25 5.42969H58.75C58.9142 5.42964 59.0767 5.46195 59.2284 5.52475C59.3801 5.58755 59.5179 5.67963 59.634 5.79571C59.7501 5.91179 59.8421 6.04961 59.9049 6.20128C59.9677 6.35296 60 6.51552 60 6.67969V52.9297C60 53.0939 59.9677 53.2564 59.9049 53.4081C59.8421 53.5598 59.7501 53.6976 59.634 53.8137C59.5179 53.9297 59.3801 54.0218 59.2284 54.0846C59.0767 54.1474 58.9142 54.1797 58.75 54.1797ZM2.5 51.6797H57.5V7.92969H2.5V51.6797Z"></path><path d="M6.25 15.4297C6.94036 15.4297 7.5 14.87 7.5 14.1797C7.5 13.4893 6.94036 12.9297 6.25 12.9297C5.55964 12.9297 5 13.4893 5 14.1797C5 14.87 5.55964 15.4297 6.25 15.4297Z"></path><path d="M10 15.4297C10.6904 15.4297 11.25 14.87 11.25 14.1797C11.25 13.4893 10.6904 12.9297 10 12.9297C9.30964 12.9297 8.75 13.4893 8.75 14.1797C8.75 14.87 9.30964 15.4297 10 15.4297Z"></path><path d="M13.75 15.4297C14.4404 15.4297 15 14.87 15 14.1797C15 13.4893 14.4404 12.9297 13.75 12.9297C13.0596 12.9297 12.5 13.4893 12.5 14.1797C12.5 14.87 13.0596 15.4297 13.75 15.4297Z"></path><path d="M58.75 15.4297H18.75C18.4185 15.4297 18.1005 15.298 17.8661 15.0636C17.6317 14.8292 17.5 14.5112 17.5 14.1797C17.5 13.8482 17.6317 13.5302 17.8661 13.2958C18.1005 13.0614 18.4185 12.9297 18.75 12.9297H58.75C59.0815 12.9297 59.3995 13.0614 59.6339 13.2958C59.8683 13.5302 60 13.8482 60 14.1797C60 14.5112 59.8683 14.8292 59.6339 15.0636C59.3995 15.298 59.0815 15.4297 58.75 15.4297Z"></path><path d="M28.7502 37.9297C28.4187 37.9295 28.1009 37.7978 27.8664 37.5634L24.4289 34.1259C24.198 33.8908 24.0693 33.574 24.0708 33.2445C24.0723 32.915 24.2039 32.5994 24.4369 32.3664C24.6699 32.1334 24.9855 32.0018 25.315 32.0003C25.6445 31.9988 25.9613 32.1275 26.1964 32.3584L28.6977 34.8597L38.8588 23.4522C38.968 23.3296 39.1002 23.2298 39.2479 23.1583C39.3957 23.0869 39.5561 23.0452 39.7199 23.0358C39.8838 23.0263 40.0479 23.0492 40.2029 23.1032C40.3579 23.1571 40.5008 23.2411 40.6233 23.3503C40.7459 23.4594 40.8457 23.5917 40.9172 23.7394C40.9886 23.8872 41.0303 24.0476 41.0397 24.2114C41.0492 24.3753 41.0263 24.5394 40.9723 24.6944C40.9184 24.8494 40.8344 24.9922 40.7253 25.1148L29.6834 37.511C29.5702 37.6382 29.4322 37.7409 29.2779 37.8129C29.1237 37.8849 28.9563 37.9247 28.7862 37.9298L28.7502 37.9297Z"></path><path d="M29.977 44.1812C28.3217 44.1775 26.6876 43.8085 25.1912 43.1007C23.6948 42.3928 22.3731 41.3635 21.3203 40.0861C20.2675 38.8087 19.5095 37.3148 19.1004 35.7108C18.6913 34.1068 18.6413 32.4322 18.9537 30.8067C19.2662 29.1811 19.9335 27.6445 20.9081 26.3065C21.8827 24.9684 23.1406 23.862 24.592 23.0659C26.0433 22.2699 27.6525 21.804 29.3046 21.7013C30.9568 21.5987 32.6113 21.8619 34.15 22.4722C34.4579 22.5949 34.7044 22.8349 34.8354 23.1393C34.9663 23.4438 34.9709 23.7878 34.8482 24.0957C34.7255 24.4036 34.4856 24.6501 34.1811 24.7811C33.8766 24.912 33.5326 24.9166 33.2247 24.7939C31.44 24.0862 29.472 23.985 27.6241 24.5059C25.7762 25.0269 24.1508 26.141 22.9985 27.6767C21.8462 29.2124 21.2308 31.0844 21.2473 33.0043C21.2637 34.9242 21.9111 36.7854 23.0895 38.3011C24.268 39.8168 25.9122 40.903 27.7688 41.3922C29.6254 41.8813 31.5913 41.7464 33.3637 41.0082C35.136 40.27 36.6164 38.9694 37.5768 37.3069C38.5372 35.6444 38.9242 33.7122 38.6782 31.8081C38.6568 31.6451 38.6678 31.4795 38.7104 31.3208C38.7531 31.1621 38.8267 31.0133 38.927 30.8831C39.0272 30.7528 39.1522 30.6436 39.2947 30.5617C39.4373 30.4798 39.5945 30.4268 39.7575 30.4058C39.9206 30.3848 40.0861 30.3961 40.2448 30.4391C40.4034 30.4822 40.552 30.5561 40.682 30.6566C40.8121 30.7572 40.921 30.8824 41.0026 31.0251C41.0842 31.1678 41.1368 31.3252 41.1574 31.4883C41.3469 32.9535 41.2459 34.4417 40.8602 35.8679C40.4745 37.294 39.8116 38.6303 38.9094 39.8002C38.0072 40.9702 36.8834 41.9509 35.6021 42.6865C34.3208 43.4221 32.9071 43.898 31.4419 44.0872C30.9561 44.1494 30.4668 44.1807 29.977 44.1812Z"></path><defs><clip-path id="clip0"><rect width="60" height="60" fill="white" transform="translate(0 0.429688)"></rect></clip-path></defs></svg>',
831 + 'link' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce/', 'promo', 'products-tabs' ),
832 + ),
833 + );
834 +
835 + // Check if $this-promotions isn't empty and has one of the items to load.
836 + $can_load = ! empty( $this->promotions ) && count( array_intersect( $this->promotions, array_keys( $this->woo_promos ) ) ) > 0;
837 +
838 + if ( ! $can_load && ! $this->debug ) {
839 + return;
840 + }
841 +
842 + add_action(
843 + 'woocommerce_product_data_tabs',
844 + function ( $tabs ) {
845 + $tabs['tisdk-suggestions'] = array(
846 + 'label' => Loader::$labels['promotions']['woo']['title'],
847 + 'target' => 'tisdk_suggestions',
848 + 'class' => array(),
849 + 'priority' => 1000,
850 + );
851 +
852 + return $tabs;
853 + }
854 + );
855 +
856 + add_action( 'woocommerce_product_data_panels', array( $this, 'woocommerce_tab_content' ) );
857 + }
858 +
859 + /**
860 + * WooCommerce Tab Content.
861 + */
862 + public function woocommerce_tab_content() {
863 + // Filter content based on if the key exists in $this->promotions array.
864 + $content = array_filter(
865 + $this->woo_promos,
866 + function ( $key ) {
867 + return in_array( $key, $this->promotions, true );
868 + },
869 + ARRAY_FILTER_USE_KEY
870 + );
871 +
872 + // Display CSS
873 + self::render_woo_tabs_css();
874 +
875 + self::render_notice_dismiss_ajax();
876 + ?>
877 +
878 + <div id="tisdk_suggestions" class="panel woocommerce_options_panel hidden">
879 + <div class="tisdk-suggestions-header">
880 + <h4><?php echo esc_html( Loader::$labels['promotions']['woo']['title2'] ); ?></h4>
881 + </div>
882 + <div class="tisdk-suggestions-content">
883 + <?php foreach ( $content as $key => $item ) : ?>
884 + <div class="tisdk-suggestion" id="<?php echo esc_attr( $key ); ?>">
885 + <?php if ( isset( $item['icon'] ) ) : ?>
886 + <div class="tisdk-suggestion-icon">
887 + <?php echo $item['icon']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
888 + </div>
889 + <?php endif; ?>
890 + <div class="tisdk-suggestion-content">
891 + <h4><?php echo esc_html( $item['title'] ); ?></h4>
892 + <p><?php echo esc_html( $item['description'] ); ?></p>
893 + </div>
894 + <div class="tisdk-suggestion-cta">
895 + <a href="<?php echo esc_url( $item['link'] ); ?>" target="blank" class="button">
896 + <?php echo( ( isset( $item['has_install'] ) && $item['has_install'] ) ? esc_html( Loader::$labels['promotions']['woo']['cta_install'] ) : esc_html( Loader::$labels['promotions']['woo']['learn_more'] ) ); ?>
897 + </a>
898 + <a class="suggestion-dismiss"
899 + title="<?php echo esc_attr( Loader::$labels['promotions']['woo']['dismiss'] ); ?>"
900 + href="#"></a>
901 + </div>
902 + </div>
903 + <?php endforeach; ?>
904 + </div>
905 + </div>
906 + <?php
907 + }
908 +
909 + /**
910 + * CSS for WooCommerce Tabs
911 + */
912 + public static function render_woo_tabs_css() {
913 + $icon = 'M208 88.286c0-10 6.286-21.714 17.715-21.714 11.142 0 17.714 11.714 17.714 21.714 0 10.285-6.572 21.714-17.714 21.714C214.286 110 208 98.571 208 88.286zm304 160c0 36.001-11.429 102.286-36.286 129.714-22.858 24.858-87.428 61.143-120.857 70.572l-1.143.286v32.571c0 16.286-12.572 30.571-29.143 30.571-10 0-19.429-5.714-24.572-14.286-5.427 8.572-14.856 14.286-24.856 14.286-10 0-19.429-5.714-24.858-14.286-5.142 8.572-14.571 14.286-24.57 14.286-10.286 0-19.429-5.714-24.858-14.286-5.143 8.572-14.571 14.286-24.571 14.286-18.857 0-29.429-15.714-29.429-32.857-16.286 12.285-35.715 19.428-56.571 19.428-22 0-43.429-8.285-60.286-22.857 10.285-.286 20.571-2.286 30.285-5.714-20.857-5.714-39.428-18.857-52-36.286 21.37 4.645 46.209 1.673 67.143-11.143-22-22-56.571-58.857-68.572-87.428C1.143 321.714 0 303.714 0 289.429c0-49.714 20.286-160 86.286-160 10.571 0 18.857 4.858 23.143 14.857a158.792 158.792 0 0 1 12-15.428c2-2.572 5.714-5.429 7.143-8.286 7.999-12.571 11.714-21.142 21.714-34C182.571 45.428 232 17.143 285.143 17.143c6 0 12 .285 17.714 1.143C313.714 6.571 328.857 0 344.572 0c14.571 0 29.714 6 40 16.286.857.858 1.428 2.286 1.428 3.428 0 3.714-10.285 13.429-12.857 16.286 4.286 1.429 15.714 6.858 15.714 12 0 2.857-2.857 5.143-4.571 7.143 31.429 27.714 49.429 67.143 56.286 108 4.286-5.143 10.285-8.572 17.143-8.572 10.571 0 20.857 7.144 28.571 14.001C507.143 187.143 512 221.714 512 248.286zM188 89.428c0 18.286 12.571 37.143 32.286 37.143 19.714 0 32.285-18.857 32.285-37.143 0-18-12.571-36.857-32.285-36.857-19.715 0-32.286 18.858-32.286 36.857zM237.714 194c0-19.714 3.714-39.143 8.571-58.286-52.039 79.534-13.531 184.571 68.858 184.571 21.428 0 42.571-7.714 60-20 2-7.429 3.714-14.857 3.714-22.572 0-14.286-6.286-21.428-20.572-21.428-4.571 0-9.143.857-13.429 1.714-63.343 12.668-107.142 3.669-107.142-63.999zm-41.142 254.858c0-11.143-8.858-20.857-20.286-20.857-11.429 0-20 9.715-20 20.857v32.571c0 11.143 8.571 21.142 20 21.142 11.428 0 20.286-9.715 20.286-21.142v-32.571zm49.143 0c0-11.143-8.572-20.857-20-20.857-11.429 0-20.286 9.715-20.286 20.857v32.571c0 11.143 8.857 21.142 20.286 21.142 11.428 0 20-10 20-21.142v-32.571zm49.713 0c0-11.143-8.857-20.857-20.285-20.857-11.429 0-20.286 9.715-20.286 20.857v32.571c0 11.143 8.857 21.142 20.286 21.142 11.428 0 20.285-9.715 20.285-21.142v-32.571zm49.715 0c0-11.143-8.857-20.857-20.286-20.857-11.428 0-20.286 9.715-20.286 20.857v32.571c0 11.143 8.858 21.142 20.286 21.142 11.429 0 20.286-10 20.286-21.142v-32.571zM421.714 286c-30.857 59.142-90.285 102.572-158.571 102.572-96.571 0-160.571-84.572-160.571-176.572 0-16.857 2-33.429 6-49.714-20 33.715-29.714 72.572-29.714 111.429 0 60.286 24.857 121.715 71.429 160.857 5.143-9.714 14.857-16.286 26-16.286 10 0 19.428 5.714 24.571 14.286 5.429-8.571 14.571-14.286 24.858-14.286 10 0 19.428 5.714 24.571 14.286 5.429-8.571 14.857-14.286 24.858-14.286 10 0 19.428 5.714 24.857 14.286 5.143-8.571 14.571-14.286 24.572-14.286 10.857 0 20.857 6.572 25.714 16 43.427-36.286 68.569-92 71.426-148.286zm10.572-99.714c0-53.714-34.571-105.714-92.572-105.714-30.285 0-58.571 15.143-78.857 36.857C240.862 183.812 233.41 254 302.286 254c28.805 0 97.357-28.538 84.286 36.857 28.857-26 45.714-65.714 45.714-104.571z';
914 +
915 + ?>
916 + <style>
917 + .tisdk-suggestions_options a {
918 + display: flex !important;
919 + align-items: center;
920 + }
921 +
922 + .tisdk-suggestions_options a::before {
923 + content: url("data:image/svg+xml,%3Csvg fill='%23135e96' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='<?php echo esc_attr( $icon ); ?>'/%3E%3C/svg%3E") !important;
924 + min-width: 13px;
925 + max-width: 13px;
926 + margin: auto;
927 + }
928 +
929 + .tisdk-suggestions_options.active a::before {
930 + content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='<?php echo esc_attr( $icon ); ?>'/%3E%3C/svg%3E") !important;
931 + }
932 +
933 + .tisdk-suggestions-header {
934 + padding: 1em 1.5em;
935 + border-bottom: 1px solid #eee;
936 + }
937 +
938 + .tisdk-suggestions-header h4 {
939 + font-size: 1.1em;
940 + margin: 0;
941 + }
942 +
943 + .tisdk-suggestion {
944 + display: flex;
945 + align-items: center;
946 + flex-direction: row;
947 + padding: 1em 1.5em;
948 + }
949 +
950 + .tisdk-suggestion-icon {
951 + height: 40px;
952 + margin: 0;
953 + margin-right: 0px;
954 + margin-right: 1.5em;
955 + flex: 0 0 40px;
956 + background: #966ccf;
957 + display: flex;
958 + justify-content: center;
959 + border-radius: 100%;
960 + align-items: center;
961 + padding: 5px;
962 + }
963 +
964 + .tisdk-suggestion-icon svg {
965 + fill: #fff;
966 + }
967 +
968 + .tisdk-suggestion-content {
969 + flex: 1 1 60%;
970 + }
971 +
972 + .tisdk-suggestion-content h4 {
973 + margin: 0;
974 + }
975 +
976 + .tisdk-suggestion-content p {
977 + margin: 0;
978 + margin-top: 4px;
979 + padding: 0;
980 + line-height: 1.5;
981 + }
982 +
983 + .tisdk-suggestion-cta {
984 + flex: 1 1 30%;
985 + min-width: 160px;
986 + text-align: right;
987 + }
988 +
989 + .tisdk-suggestion-cta .button {
990 + display: inline-block;
991 + min-width: 120px;
992 + text-align: center;
993 + margin: 0;
994 + }
995 +
996 + .tisdk-suggestion-cta .suggestion-dismiss {
997 + position: relative;
998 + top: 5px;
999 + right: auto;
1000 + margin-left: 1em;
1001 + text-decoration: none;
1002 + }
1003 + </style>
1004 + <?php
1005 + }
1006 +
1007 + /**
1008 + * JS for Dismissing Notice
1009 + */
1010 + public static function render_notice_dismiss_ajax() {
1011 + ?>
1012 + <script>
1013 + jQuery(document).ready(function ($) {
1014 + // AJAX request to update the option value
1015 + $('.tisdk-suggestion .suggestion-dismiss').click(function (e) {
1016 + e.preventDefault();
1017 + var suggestion = $(this).closest('.tisdk-suggestion');
1018 + var value = suggestion.attr('id');
1019 +
1020 + var nonce = '<?php echo esc_attr( wp_create_nonce( 'tisdk_update_option' ) ); ?>';
1021 +
1022 + $.ajax({
1023 + url: window.ajaxurl,
1024 + type: 'POST',
1025 + data: {
1026 + action: 'tisdk_update_option',
1027 + value,
1028 + nonce
1029 + },
1030 + complete() {
1031 + suggestion.remove();
1032 +
1033 + // If element with .tisdk-suggestions-content has no children, hide the whole panel. Skip if the selector doesn't exist.
1034 + if ($('.tisdk-suggestions-content').length && !$('.tisdk-suggestions-content').children().length) {
1035 + $('.tisdk-suggestions_options').remove();
1036 + $('#tisdk_suggestions').remove();
1037 + $('.general_options').addClass('active');
1038 + $('#general_product_data').css('display', 'block');
1039 + }
1040 + }
1041 + });
1042 + });
1043 + });
1044 + </script>
1045 + <?php
1046 + }
1047 +
1048 + /**
1049 + * Update the option value using AJAX
1050 + */
1051 + public function dismiss_promotion() {
1052 + if ( ! isset( $_POST['nonce'] ) || ! isset( $_POST['value'] ) ) {
1053 + $response = array(
1054 + 'success' => false,
1055 + 'message' => 'Missing nonce or value.',
1056 + );
1057 + wp_send_json( $response );
1058 + wp_die();
1059 + }
1060 +
1061 + $nonce = sanitize_text_field( $_POST['nonce'] );
1062 + $value = sanitize_text_field( $_POST['value'] );
1063 +
1064 + if ( ! wp_verify_nonce( $nonce, 'tisdk_update_option' ) ) {
1065 + $response = array(
1066 + 'success' => false,
1067 + 'message' => 'Invalid nonce.',
1068 + );
1069 + wp_send_json( $response );
1070 + wp_die();
1071 + }
1072 +
1073 + $options = get_option( $this->option_main );
1074 + $options = json_decode( $options, true );
1075 +
1076 + $options[ $value ] = time();
1077 +
1078 + update_option( $this->option_main, wp_json_encode( $options ) );
1079 +
1080 + $response = array(
1081 + 'success' => true,
1082 + );
1083 +
1084 + wp_send_json( $response );
1085 + wp_die();
697 1086 }
698 1087 }