PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.14
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.14
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 +483 -98 3.10.133.11.14 View file →
@@ -31,9 +31,9 @@
31 31 * Holds the promotions.
32 32 *
33 33 * @var array
34 34 */
35 - private $promotions = array();
35 + public $promotions = array();
36 36
37 37 /**
38 38 * Holds the values of the promotions that are not allowed to be shown.
39 39 * Can be filtered by each product.
@@ -70,15 +70,50 @@
70 70 */
71 71 private $option_rop = 'themeisle_sdk_promotions_rop_installed';
72 72
73 73 /**
74 - * Option key for Neve FSE promos.
74 + * Option key for Neve promo.
75 75 *
76 76 * @var string
77 77 */
78 - private $option_neve_fse = 'themeisle_sdk_promotions_neve_fse_installed';
78 + private $option_neve = 'themeisle_sdk_promotions_neve_installed';
79 79
80 80 /**
81 + * Option key for Redirection for CF7.
82 + *
83 + * @var string
84 + */
85 + private $option_redirection_cf7 = 'themeisle_sdk_promotions_redirection_cf7_installed';
86 +
87 + /**
88 + * Option key for Hyve.
89 + *
90 + * @var string
91 + */
92 + private $option_hyve = 'themeisle_sdk_promotions_hyve_installed';
93 +
94 + /**
95 + * Option key for WP Full Pay.
96 + *
97 + * @var string
98 + */
99 + private $option_wp_full_pay = 'themeisle_sdk_promotions_wp_full_pay_installed';
100 +
101 + /**
102 + * Option key for Feedzy.
103 + *
104 + * @var string
105 + */
106 + private $option_feedzy = 'themeisle_sdk_promotions_feedzy_installed';
107 +
108 + /**
109 + * Option key for Masteriyo promos.
110 + *
111 + * @var string
112 + */
113 + private $option_masteriyo = 'themeisle_sdk_promotions_masteriyo_installed';
114 +
115 + /**
81 116 * Loaded promotion.
82 117 *
83 118 * @var string
84 119 */
@@ -112,15 +147,26 @@
112 147 if ( $this->is_from_partner( $product ) ) {
113 148 return false;
114 149 }
115 150
116 - $this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug );
117 - $promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() );
151 + $this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug );
152 + $promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() );
153 +
118 154 $promotions_to_load[] = 'optimole';
119 155 $promotions_to_load[] = 'rop';
120 156 $promotions_to_load[] = 'woo_plugins';
121 - $promotions_to_load[] = 'neve-fse';
157 + $promotions_to_load[] = 'neve';
158 + $promotions_to_load[] = 'redirection-cf7';
159 + $promotions_to_load[] = 'hyve';
160 + $promotions_to_load[] = 'wp_full_pay';
161 + $promotions_to_load[] = 'feedzy_import';
162 + $promotions_to_load[] = 'learning-management-system';
122 163
164 + if ( defined( 'NEVE_VERSION' ) || defined( 'WPMM_PATH' ) || defined( 'OTTER_BLOCKS_VERSION' ) || defined( 'OBFX_URL' ) ) {
165 + $promotions_to_load[] = 'feedzy_embed';
166 + }
167 + $promotions_to_load = array_unique( $promotions_to_load );
168 +
123 169 $this->promotions = $this->get_promotions();
124 170
125 171 $this->dissallowed_promotions = apply_filters( $product->get_key() . '_dissallowed_promotions', array() );
126 172
@@ -128,9 +174,8 @@
128 174 if ( ! in_array( $slug, $promotions_to_load, true ) ) {
129 175 unset( $this->promotions[ $slug ] );
130 176 }
131 177 }
132 -
133 178 add_action( 'init', array( $this, 'register_settings' ), 99 );
134 179 add_action( 'admin_init', array( $this, 'register_reference' ), 99 );
135 180
136 181 return ! empty( $this->promotions );
@@ -145,16 +190,16 @@
145 190 if ( ! $this->is_writeable() || ! current_user_can( 'install_plugins' ) ) {
146 191 return;
147 192 }
148 193
149 - $this->product = $product;
194 + $last_dismiss_time = $this->get_last_dismiss_time();
150 195
151 - $last_dismiss = $this->get_last_dismiss_time();
152 -
153 - if ( ! $this->debug && $last_dismiss && ( time() - $last_dismiss ) < 7 * DAY_IN_SECONDS ) {
196 + if ( ! $this->debug && is_int( $last_dismiss_time ) && ( time() - $last_dismiss_time ) < ( 3 * WEEK_IN_SECONDS ) ) {
154 197 return;
155 198 }
156 199
200 + $this->product = $product;
201 +
157 202 add_filter( 'attachment_fields_to_edit', array( $this, 'add_attachment_field' ), 10, 2 );
158 203 add_action( 'current_screen', [ $this, 'load_available' ] );
159 204 add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'enqueue' ) );
160 205 add_action( 'wp_ajax_tisdk_update_option', array( $this, 'dismiss_promotion' ) );
@@ -159,9 +204,9 @@
159 204 add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'enqueue' ) );
160 205 add_action( 'wp_ajax_tisdk_update_option', array( $this, 'dismiss_promotion' ) );
161 206 add_filter( 'themeisle_sdk_ran_promos', '__return_true' );
162 207
163 - if ( get_option( $this->option_neve_fse, false ) !== true ) {
208 + if ( get_option( $this->option_neve, false ) !== true ) {
164 209 add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', 'ThemeisleSDK\Modules\Notification::regular_dismiss' );
165 210 }
166 211 }
167 212
@@ -208,11 +253,24 @@
208 253 if ( isset( $_GET['rop_reference_key'] ) ) {
209 254 update_option( 'rop_reference_key', sanitize_key( $_GET['rop_reference_key'] ) );
210 255 }
211 256
212 - if ( isset( $_GET['neve_fse_reference_key'] ) ) {
213 - update_option( 'neve_fse_reference_key', sanitize_key( $_GET['neve_fse_reference_key'] ) );
257 + if ( isset( $_GET['neve_reference_key'] ) ) {
258 + update_option( 'neve_reference_key', sanitize_key( $_GET['neve_reference_key'] ) );
214 259 }
260 +
261 + if ( isset( $_GET['hyve_reference_key'] ) ) {
262 + update_option( 'hyve_reference_key', sanitize_key( $_GET['hyve_reference_key'] ) );
263 + }
264 +
265 + if ( isset( $_GET['wp_full_pay_reference_key'] ) ) {
266 + update_option( 'wp_full_pay_reference_key', sanitize_key( $_GET['wp_full_pay_reference_key'] ) );
267 + }
268 +
269 + if ( isset( $_GET['feedzy_reference_key'] ) || ( isset( $_GET['from'], $_GET['plugin'] ) && $_GET['from'] === 'import' && str_starts_with( sanitize_key( $_GET['plugin'] ), 'feedzy' ) ) ) {
270 + update_option( 'feedzy_reference_key', sanitize_key( $_GET['feedzy_reference_key'] ?? 'i-' . $this->product->get_key() ) );
271 + update_option( $this->option_feedzy, 1 );
272 + }
215 273 }
216 274
217 275 /**
218 276 * Register Settings
@@ -262,9 +320,9 @@
262 320 )
263 321 );
264 322 register_setting(
265 323 'themeisle_sdk_settings',
266 - $this->option_neve_fse,
324 + $this->option_neve,
267 325 array(
268 326 'type' => 'boolean',
269 327 'sanitize_callback' => 'rest_sanitize_boolean',
270 328 'show_in_rest' => true,
@@ -270,8 +328,48 @@
270 328 'show_in_rest' => true,
271 329 'default' => false,
272 330 )
273 331 );
332 + register_setting(
333 + 'themeisle_sdk_settings',
334 + $this->option_redirection_cf7,
335 + array(
336 + 'type' => 'boolean',
337 + 'sanitize_callback' => 'rest_sanitize_boolean',
338 + 'show_in_rest' => true,
339 + 'default' => false,
340 + )
341 + );
342 + register_setting(
343 + 'themeisle_sdk_settings',
344 + $this->option_hyve,
345 + array(
346 + 'type' => 'boolean',
347 + 'sanitize_callback' => 'rest_sanitize_boolean',
348 + 'show_in_rest' => true,
349 + 'default' => false,
350 + )
351 + );
352 + register_setting(
353 + 'themeisle_sdk_settings',
354 + $this->option_wp_full_pay,
355 + array(
356 + 'type' => 'boolean',
357 + 'sanitize_callback' => 'rest_sanitize_boolean',
358 + 'show_in_rest' => true,
359 + 'default' => false,
360 + )
361 + );
362 + register_setting(
363 + 'themeisle_sdk_settings',
364 + $this->option_masteriyo,
365 + array(
366 + 'type' => 'boolean',
367 + 'sanitize_callback' => 'rest_sanitize_boolean',
368 + 'show_in_rest' => true,
369 + 'default' => false,
370 + )
371 + );
274 372 }
275 373
276 374 /**
277 375 * Check if the path is writable.
@@ -312,33 +410,50 @@
312 410 *
313 411 * @return array
314 412 */
315 413 private function get_promotions() {
316 - $has_otter = defined( 'OTTER_BLOCKS_VERSION' ) || $this->is_plugin_installed( 'otter-blocks' );
317 - $had_otter_from_promo = get_option( $this->option_otter, false );
318 - $has_optimole = defined( 'OPTIMOLE_VERSION' ) || $this->is_plugin_installed( 'optimole-wp' );
319 - $had_optimole_from_promo = get_option( $this->option_optimole, false );
320 - $has_rop = defined( 'ROP_LITE_VERSION' ) || $this->is_plugin_installed( 'tweet-old-post' );
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' );
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';
329 - $has_enough_attachments = $this->has_min_media_attachments();
330 - $has_enough_old_posts = $this->has_old_posts();
414 + $has_otter = defined( 'OTTER_BLOCKS_VERSION' ) || $this->is_plugin_installed( 'otter-blocks' );
415 + $had_otter_from_promo = get_option( $this->option_otter, false );
416 + $has_optimole = defined( 'OPTIMOLE_VERSION' ) || $this->is_plugin_installed( 'optimole-wp' );
417 + $had_optimole_from_promo = get_option( $this->option_optimole, false );
418 + $has_rop = defined( 'ROP_LITE_VERSION' ) || $this->is_plugin_installed( 'tweet-old-post' );
419 + $had_rop_from_promo = get_option( $this->option_rop, false );
420 + $has_woocommerce = class_exists( 'WooCommerce' );
421 + $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' );
422 + $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' );
423 + $has_redirection_cf7 = defined( 'WPCF7_PRO_REDIRECT_PLUGIN_VERSION' ) || $this->is_plugin_installed( 'wpcf7-redirect' );
424 + $had_redirection_cf7_promo = get_option( $this->option_redirection_cf7, false );
425 + $has_hyve = defined( 'HYVE_LITE_VERSION' ) || $this->is_plugin_installed( 'hyve' ) || $this->is_plugin_installed( 'hyve-lite' );
426 + $had_hyve_from_promo = get_option( $this->option_hyve, false );
427 + $has_hyve_conditions = version_compare( get_bloginfo( 'version' ), '6.2', '>=' ) && $this->has_support_page();
428 + $has_wfp_full_pay = defined( 'WP_FULL_STRIPE_BASENAME' ) || $this->is_plugin_installed( 'wp-full-stripe-free' );
429 + $had_wfp_from_promo = get_option( $this->option_wp_full_pay, false );
430 + $has_wfp_conditions = $this->has_donate_page();
431 + $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' );
432 + $current_theme = wp_get_theme();
433 + $has_neve = $current_theme->template === 'neve' || $current_theme->parent() === 'neve';
434 + $has_neve_from_promo = get_option( $this->option_neve, false );
435 + $has_enough_attachments = $this->has_min_media_attachments();
436 + $has_enough_old_posts = $this->has_old_posts();
437 + $is_min_php_7_4 = version_compare( PHP_VERSION, '7.4', '>=' );
438 + $has_feedzy = defined( 'FEEDZY_BASEFILE' ) || $this->is_plugin_installed( 'feedzy-rss-feedss' );
439 + $had_feedzy_from_promo = get_option( $this->option_feedzy, false );
440 + $has_masteriyo = defined( 'MASTERIYO_VERSION' ) || $this->is_plugin_installed( 'learning-management-system' );
441 + $had_masteriyo_from_promo = get_option( $this->option_masteriyo, false );
442 + $has_masteriyo_conditions = $this->has_lms_tagline();
443 + $is_min_php_7_2 = version_compare( PHP_VERSION, '7.2', '>=' );
331 444
332 445 $all = [
333 - 'optimole' => [
446 + 'optimole' => [
334 447 'om-editor' => [
335 - 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo,
336 - 'screen' => 'editor',
448 + 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo,
449 + 'screen' => 'editor',
450 + 'delayed' => true,
337 451 ],
338 452 'om-image-block' => [
339 - 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo,
340 - 'screen' => 'editor',
453 + 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo,
454 + 'screen' => 'editor',
455 + 'delayed' => true,
341 456 ],
342 457 'om-attachment' => [
343 458 'env' => ! $has_optimole && ! $had_optimole_from_promo,
344 459 'screen' => 'media-editor',
@@ -347,33 +462,51 @@
347 462 'env' => ! $has_optimole && ! $had_optimole_from_promo && $has_enough_attachments,
348 463 'screen' => 'media',
349 464 ],
350 465 'om-elementor' => [
351 - 'env' => ! $has_optimole && ! $had_optimole_from_promo && defined( 'ELEMENTOR_VERSION' ),
352 - 'screen' => 'elementor',
466 + 'env' => ! $has_optimole && ! $had_optimole_from_promo && defined( 'ELEMENTOR_VERSION' ),
467 + 'screen' => 'elementor',
468 + 'delayed' => true,
353 469 ],
354 470 ],
355 - 'otter' => [
471 + 'feedzy_import' => [
472 + 'feedzy-import' => [
473 + 'env' => true,
474 + 'screen' => 'import',
475 + 'always' => true,
476 + ],
477 + ],
478 + 'feedzy_embed' => [
479 + 'feedzy-editor' => [
480 + 'env' => ! $has_feedzy && is_main_site() && ! $had_feedzy_from_promo,
481 + 'screen' => 'editor',
482 + ],
483 + ],
484 + 'otter' => [
356 485 'blocks-css' => [
357 - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
358 - 'screen' => 'editor',
486 + 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
487 + 'screen' => 'editor',
488 + 'delayed' => true,
359 489 ],
360 490 'blocks-animation' => [
361 - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
362 - 'screen' => 'editor',
491 + 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
492 + 'screen' => 'editor',
493 + 'delayed' => true,
363 494 ],
364 495 'blocks-conditions' => [
365 - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
366 - 'screen' => 'editor',
496 + 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
497 + 'screen' => 'editor',
498 + 'delayed' => true,
367 499 ],
368 500 ],
369 - 'rop' => [
501 + 'rop' => [
370 502 'rop-posts' => [
371 - 'env' => ! $has_rop && ! $had_rop_from_promo && $has_enough_old_posts,
372 - 'screen' => 'edit-post',
503 + 'env' => ! $has_rop && ! $had_rop_from_promo && $has_enough_old_posts,
504 + 'screen' => 'edit-post',
505 + 'delayed' => true,
373 506 ],
374 507 ],
375 - 'woo_plugins' => [
508 + 'woo_plugins' => [
376 509 'ppom' => [
377 510 'env' => ! $has_ppom && $has_woocommerce,
378 511 'screen' => 'edit-product',
379 512 ],
@@ -389,14 +522,39 @@
389 522 'env' => ! $has_sparks && $has_woocommerce,
390 523 'screen' => 'edit-product',
391 524 ],
392 525 ],
393 - 'neve-fse' => [
394 - 'neve-fse-themes-popular' => [
395 - 'env' => ! $has_neve_fse && $is_min_fse_v,
526 + 'neve' => [
527 + 'neve-themes-popular' => [
528 + 'env' => ! $has_neve && ! $has_neve_from_promo,
396 529 'screen' => 'themes-install-popular',
397 530 ],
398 531 ],
532 + 'redirection-cf7' => [
533 + 'wpcf7' => [
534 + 'env' => ! $has_redirection_cf7 && ! $had_redirection_cf7_promo,
535 + 'screen' => 'wpcf7',
536 + 'delayed' => true,
537 + ],
538 + ],
539 + 'hyve' => [
540 + 'hyve-plugins-install' => [
541 + 'env' => $is_min_php_7_4 && ! $has_hyve && ! $had_hyve_from_promo && $has_hyve_conditions,
542 + 'screen' => 'plugin-install',
543 + ],
544 + ],
545 + 'wp_full_pay' => [
546 + 'wp-full-pay-plugins-install' => [
547 + 'env' => ! $has_wfp_full_pay && ! $had_wfp_from_promo && $has_wfp_conditions,
548 + 'screen' => 'plugin-install',
549 + ],
550 + ],
551 + 'learning-management-system' => [
552 + 'masteriyo-plugins-install' => [
553 + 'env' => $is_min_php_7_2 && ! $has_masteriyo && ! $had_masteriyo_from_promo && $has_masteriyo_conditions,
554 + 'screen' => 'plugin-install',
555 + ],
556 + ],
399 557 ];
400 558
401 559 foreach ( $all as $slug => $data ) {
402 560 foreach ( $data as $key => $conditions ) {
@@ -414,9 +572,8 @@
414 572 if ( empty( $all[ $slug ] ) ) {
415 573 unset( $all[ $slug ] );
416 574 }
417 575 }
418 -
419 576 return $all;
420 577 }
421 578
422 579 /**
@@ -441,20 +598,14 @@
441 598
442 599 /**
443 600 * Get the last dismiss time of a promotion.
444 601 *
445 - * @return int The timestamp of last dismiss, or install time - 4 days.
602 + * @return int | false The timestamp of last dismiss or false.
446 603 */
447 604 private function get_last_dismiss_time() {
448 605 $dismissed = $this->get_upsells_dismiss_time();
449 606
450 - if ( empty( $dismissed ) ) {
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;
454 - }
455 -
456 - return max( array_values( $dismissed ) );
607 + return empty( $dismissed ) ? false : max( array_values( $dismissed ) );
457 608 }
458 609
459 610 /**
460 611 * Filter by screen & merge into single array of keys.
@@ -463,19 +614,45 @@
463 614 */
464 615 private function filter_by_screen_and_merge() {
465 616 $current_screen = get_current_screen();
466 617
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';
618 + $is_elementor = isset( $_GET['action'] ) && $_GET['action'] === 'elementor';
619 + $is_media = isset( $current_screen->id ) && $current_screen->id === 'upload';
620 + $is_posts = isset( $current_screen->id ) && $current_screen->id === 'edit-post';
621 + $is_editor = method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor();
622 + $is_theme_install = isset( $current_screen->id ) && ( $current_screen->id === 'theme-install' );
623 + $is_plugin_install = isset( $current_screen->id ) && ( $current_screen->id === 'plugin-install' );
624 + $is_product = isset( $current_screen->id ) && $current_screen->id === 'product';
625 + $is_import = isset( $current_screen->id ) && $current_screen->id === 'import';
626 + $is_cf7_install = isset( $current_screen->id ) && function_exists( 'str_contains' ) ? str_contains( $current_screen->id, 'page_wpcf7' ) : false;
473 627
474 - $return = [];
475 -
628 + $return = [];
629 + $product_install_time = (int) $this->product->get_install_time();
630 + $is_older = time() > ( $product_install_time + ( 3 * DAY_IN_SECONDS ) );
631 + $is_newer = time() < ( $product_install_time + ( 6 * HOUR_IN_SECONDS ) );
476 632 foreach ( $this->promotions as $slug => $promos ) {
477 633 foreach ( $promos as $key => $data ) {
634 +
635 + $data = wp_parse_args(
636 + $data,
637 + [
638 + 'delayed' => false,
639 + 'always' => false,
640 + ]
641 + );
642 +
643 + if (
644 + ! $this->debug &&
645 + (
646 + ( $data['delayed'] === true && ! $is_older ) || // Skip promotions that are delayed for 3 days.
647 + $is_newer // Skip promotions for the first 6 hours after install.
648 + )
649 + && ! $data['always']
650 + ) {
651 + unset( $this->promotions[ $slug ][ $key ] );
652 +
653 + continue;
654 + }
478 655 switch ( $data['screen'] ) {
479 656 case 'media-editor':
480 657 if ( ! $is_media && ! $is_editor ) {
481 658 unset( $this->promotions[ $slug ][ $key ] );
@@ -490,8 +667,13 @@
490 667 if ( ! $is_editor || $is_elementor ) {
491 668 unset( $this->promotions[ $slug ][ $key ] );
492 669 }
493 670 break;
671 + case 'import':
672 + if ( ! $is_import ) {
673 + unset( $this->promotions[ $slug ][ $key ] );
674 + }
675 + break;
494 676 case 'elementor':
495 677 if ( ! $is_elementor ) {
496 678 unset( $this->promotions[ $slug ][ $key ] );
497 679 }
@@ -510,8 +692,18 @@
510 692 if ( ! $is_theme_install ) {
511 693 unset( $this->promotions[ $slug ][ $key ] );
512 694 }
513 695 break;
696 + case 'wpcf7':
697 + if ( ! $is_cf7_install ) {
698 + unset( $this->promotions[ $slug ][ $key ] );
699 + }
700 + break;
701 + case 'plugin-install':
702 + if ( ! $is_plugin_install ) {
703 + unset( $this->promotions[ $slug ][ $key ] );
704 + }
705 + break;
514 706 }
515 707 }
516 708
517 709 $return = array_merge( $return, $this->promotions[ $slug ] );
@@ -544,17 +736,31 @@
544 736 }
545 737 if ( $this->get_upsells_dismiss_time( 'rop-posts' ) === false ) {
546 738 add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] );
547 739 }
548 - if ( $this->get_upsells_dismiss_time( 'neve-fse-themes-popular' ) === false ) {
549 - add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] );
740 + if ( $this->get_upsells_dismiss_time( 'neve-themes-popular' ) === false ) {
741 + add_action( 'admin_notices', [ $this, 'render_neve_themes_notice' ] );
550 742 }
743 + if ( $this->get_upsells_dismiss_time( 'redirection-cf7' ) === false ) {
744 + add_action( 'admin_notices', [ $this, 'render_redirection_cf7_notice' ] );
745 + }
746 + if ( $this->get_upsells_dismiss_time( 'hyve-plugins-install' ) === false ) {
747 + add_action( 'admin_notices', [ $this, 'render_hyve_notice' ] );
748 + }
551 749
750 + if ( $this->get_upsells_dismiss_time( 'wp-full-pay-plugins-install' ) === false ) {
751 + add_action( 'admin_notices', [ $this, 'render_wp_full_pay_notice' ] );
752 + }
753 +
754 + if ( $this->get_upsells_dismiss_time( 'masteriyo-plugins-install' ) === false ) {
755 + add_action( 'admin_notices', [ $this, 'render_masteriyo_notice' ] );
756 + }
757 +
758 + add_action( 'load-import.php', [ $this, 'add_import' ] );
552 759 $this->load_woo_promos();
553 760
554 761 return;
555 762 }
556 -
557 763 switch ( $slug ) {
558 764 case 'om-editor':
559 765 case 'om-image-block':
560 766 case 'blocks-css':
@@ -572,8 +778,15 @@
572 778 case 'rop-posts':
573 779 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
574 780 add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] );
575 781 break;
782 + case 'feedzy-import':
783 + add_action( 'load-import.php', [ $this, 'add_import' ] );
784 +
785 + break;
786 + case 'feedzy-editor':
787 + add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue' ] );
788 + break;
576 789 case 'ppom':
577 790 case 'sparks-wishlist':
578 791 case 'sparks-announcement':
579 792 case 'sparks-product-reviews':
@@ -578,10 +791,10 @@
578 791 case 'sparks-announcement':
579 792 case 'sparks-product-reviews':
580 793 $this->load_woo_promos();
581 794 break;
582 - case 'neve-fse-themes-popular':
583 - // Remove any other notifications if Neve FSE promotion is showing
795 + case 'neve-themes-popular':
796 + // Remove any other notifications if Neve promotion is showing
584 797 remove_action( 'admin_notices', array( 'ThemeisleSDK\Modules\Notification', 'show_notification' ) );
585 798 remove_action(
586 799 'wp_ajax_themeisle_sdk_dismiss_notice',
587 800 array(
@@ -592,14 +805,49 @@
592 805 remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'dismiss_get' ) );
593 806 remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'setup_notifications' ) );
594 807 // Add required actions to display this notification
595 808 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
596 - add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] );
809 + add_action( 'admin_notices', [ $this, 'render_neve_themes_notice' ] );
597 810 break;
811 + case 'wpcf7':
812 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
813 + add_action( 'admin_notices', [ $this, 'render_redirection_cf7_notice' ] );
814 + break;
815 + case 'hyve-plugins-install':
816 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
817 + add_action( 'admin_notices', [ $this, 'render_hyve_notice' ] );
818 + break;
819 + case 'wp-full-pay-plugins-install':
820 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
821 + add_action( 'admin_notices', [ $this, 'render_wp_full_pay_notice' ] );
822 + break;
823 + case 'masteriyo-plugins-install':
824 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
825 + add_action( 'admin_notices', [ $this, 'render_masteriyo_notice' ] );
826 + break;
598 827 }
599 828 }
600 829
601 830 /**
831 + * Add import row.
832 + *
833 + * @return void
834 + */
835 + public function add_import() {
836 + global $wp_importers;
837 + if ( isset( $wp_importers['feedzy-rss-feeds'] ) ) {
838 + return;
839 + }
840 + $wp_importers['feedzy-rss-feeds'] = array( // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
841 + 'Feedzy',
842 + sprintf( Loader::$labels['promotions']['feedzy']['import_desc'], '<span style="float: left; font-style: italic;margin-top:0.4em;">', $this->product->get_friendly_name(), '</span>' ),
843 + 'install' => 'feedzy-rss-feeds',
844 + );
845 + if ( defined( 'FEEDZY_BASEFILE' ) ) {
846 + unset( $wp_importers['feedzy-rss-feeds']['install'] );
847 + }
848 + }
849 + /**
602 850 * Render dashboard notice.
603 851 */
604 852 public function render_optimole_dash_notice() {
605 853 $screen = get_current_screen();
@@ -622,33 +870,68 @@
622 870 $user = wp_get_current_user();
623 871 $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/promos/index.asset.php';
624 872 $deps = array_merge( $asset_file['dependencies'], [ 'updates' ] );
625 873
874 + $themes = wp_get_themes();
875 + $neve_action = isset( $themes['neve'] ) ? 'activate' : 'install';
876 + $labels = Loader::$labels['promotions'];
877 + $labels['feedzy']['editor_recommends'] = sprintf(
878 + $labels['feedzy']['editor_recommends'],
879 + $this->product->get_friendly_name(),
880 + '<a target="_blank" href="' . add_query_arg(
881 + array(
882 + 'tab' => 'plugin-information',
883 + 'plugin' => 'feedzy-rss-feeds',
884 + '_wpnonce' => wp_create_nonce( 'activate-plugin_feedzy-rss-feeds' ),
885 + 'feedzy_reference_key' => 'e-' . $this->product->get_key(),
886 + ),
887 + network_admin_url( 'plugin-install.php' )
888 + ) . '">',
889 + '</a>'
890 + );
626 891 wp_register_script( $handle, $themeisle_sdk_src . 'assets/js/build/promos/index.js', $deps, $asset_file['version'], true );
627 892 wp_localize_script(
628 893 $handle,
629 894 'themeisleSDKPromotions',
630 895 [
631 - 'debug' => $this->debug,
632 - 'labels' => [
633 - 'optimole' => Loader::$labels['promotions']['optimole'],
634 - ],
635 - 'email' => $user->user_email,
636 - 'showPromotion' => $this->loaded_promo,
637 - 'optionKey' => $this->option_main,
638 - 'product' => $this->product->get_name(),
639 - 'option' => empty( $saved ) ? new \stdClass() : $saved,
640 - 'nonce' => wp_create_nonce( 'wp_rest' ),
641 - 'assets' => $themeisle_sdk_src . 'assets/images/',
642 - 'optimoleApi' => esc_url( rest_url( 'optml/v1/register_service' ) ),
643 - 'optimoleActivationUrl' => $this->get_plugin_activation_link( 'optimole-wp' ),
644 - 'otterActivationUrl' => $this->get_plugin_activation_link( 'otter-blocks' ),
645 - 'ropActivationUrl' => $this->get_plugin_activation_link( 'tweet-old-post' ),
646 - 'optimoleDash' => esc_url( add_query_arg( [ 'page' => 'optimole' ], admin_url( 'upload.php' ) ) ),
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' ),
896 + 'debug' => $this->debug,
897 + 'labels' => $labels,
898 + 'email' => $user->user_email,
899 + 'showPromotion' => $this->loaded_promo,
900 + 'optionKey' => $this->option_main,
901 + 'product' => $this->product->get_name(),
902 + 'option' => empty( $saved ) ? new \stdClass() : $saved,
903 + 'nonce' => wp_create_nonce( 'wp_rest' ),
904 + 'assets' => $themeisle_sdk_src . 'assets/images/',
905 + 'optimoleApi' => esc_url( rest_url( 'optml/v1/register_service' ) ),
906 + 'optimoleActivationUrl' => $this->get_plugin_activation_link( 'optimole-wp' ),
907 + 'otterActivationUrl' => $this->get_plugin_activation_link( 'otter-blocks' ),
908 + 'ropActivationUrl' => $this->get_plugin_activation_link( 'tweet-old-post' ),
909 + 'optimoleDash' => esc_url( add_query_arg( [ 'page' => 'optimole' ], admin_url( 'upload.php' ) ) ),
910 + 'ropDash' => esc_url( add_query_arg( [ 'page' => 'TweetOldPost' ], admin_url( 'admin.php' ) ) ),
649 911 // translators: %s is the product name.
650 - 'title' => esc_html( sprintf( Loader::$labels['promotions']['recommended'], $this->product->get_name() ) ),
912 + 'title' => esc_html( sprintf( Loader::$labels['promotions']['recommended'], $this->product->get_name() ) ),
913 + 'redirectionCF7MoreUrl' => tsdk_utmify( 'https://docs.themeisle.com/collection/2014-redirection-for-contact-form-7', 'redirection-for-contact-form-7', 'plugin-install' ),
914 + 'rfCF7ActivationUrl' => $this->get_plugin_activation_link( 'wpcf7-redirect' ),
915 + 'cf7Dash' => esc_url( add_query_arg( [ 'page' => 'wpcf7-new' ], admin_url( 'admin.php' ) ) ),
916 + 'hyveActivationUrl' => $this->get_plugin_activation_link( 'hyve-lite' ),
917 + 'hyveDash' => esc_url( add_query_arg( [ 'page' => 'wpfs-settings-stripe' ], admin_url( 'admin.php' ) ) ),
918 + 'wpFullPayActivationUrl' => $this->get_plugin_activation_link( 'wp-full-stripe-free' ),
919 + 'wpFullPayDash' => esc_url( add_query_arg( [ 'page' => 'wpfs-settings-stripe' ], admin_url( 'admin.php' ) ) ),
920 + 'masteriyoActivationUrl' => $this->get_plugin_activation_link( 'masteriyo' ),
921 + 'masteriyoDash' => esc_url( add_query_arg( [ 'page' => 'masteriyo-onboard' ], admin_url( 'index.php' ) ) ),
922 + 'nevePreviewURL' => esc_url( add_query_arg( [ 'theme' => 'neve' ], admin_url( 'theme-install.php' ) ) ),
923 + 'neveAction' => $neve_action,
924 + 'activateNeveURL' => esc_url(
925 + add_query_arg(
926 + [
927 + 'action' => 'activate',
928 + 'stylesheet' => 'neve',
929 + '_wpnonce' => wp_create_nonce( 'switch-theme_neve' ),
930 + ],
931 + admin_url( 'themes.php' )
932 + )
933 + ),
651 934 ]
652 935 );
653 936 wp_enqueue_script( $handle );
654 937 wp_enqueue_style( $handle, $themeisle_sdk_src . 'assets/js/build/promos/style-index.css', [ 'wp-components' ], $asset_file['version'] );
@@ -667,15 +950,43 @@
667 950 echo '<div id="ti-rop-notice" class="notice notice-info ti-sdk-rop-notice"></div>';
668 951 }
669 952
670 953 /**
671 - * Render Neve FSE Themes notice.
954 + * Render Neve Themes notice.
672 955 */
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>';
956 + public function render_neve_themes_notice() {
957 + echo '<div id="ti-neve-notice" class="notice notice-info ti-sdk-om-notice"></div>';
675 958 }
676 959
677 960 /**
961 + * Render Hyve notice.
962 + */
963 + public function render_hyve_notice() {
964 + echo '<div id="ti-hyve-notice" class="notice notice-info ti-sdk-om-notice"></div>';
965 + }
966 +
967 + /**
968 + * Render WP Full Pay notice.
969 + */
970 + public function render_wp_full_pay_notice() {
971 + echo '<div id="ti-wp-full-pay-notice" class="notice notice-info ti-sdk-om-notice"></div>';
972 + }
973 +
974 + /**
975 + * Render Redirection for CF7 notice.
976 + */
977 + public function render_redirection_cf7_notice() {
978 + echo '<div id="ti-redirection-cf7-notice" class="notice notice-info ti-sdk-om-notice"></div>';
979 + }
980 +
981 + /**
982 + * Render Masteriyo notice.
983 + */
984 + public function render_masteriyo_notice() {
985 + echo '<div id="ti-masteriyo-notice" class="notice notice-info ti-sdk-om-notice"></div>';
986 + }
987 +
988 + /**
678 989 * Add promo to attachment modal.
679 990 *
680 991 * @param array $fields Fields array.
681 992 * @param \WP_Post $post Post object.
@@ -692,9 +1003,9 @@
692 1003 }
693 1004
694 1005 $meta = wp_get_attachment_metadata( $post->ID );
695 1006
696 - if ( isset( $meta['filesize'] ) && $meta['filesize'] < 200000 ) {
1007 + if ( isset( $meta['filesize'] ) && $meta['filesize'] < 100000 ) {
697 1008 return $fields;
698 1009 }
699 1010
700 1011 $fields['optimole'] = array(
@@ -922,9 +1233,8 @@
922 1233 .tisdk-suggestions_options a::before {
923 1234 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 1235 min-width: 13px;
925 1236 max-width: 13px;
926 - margin: auto;
927 1237 }
928 1238
929 1239 .tisdk-suggestions_options.active a::before {
930 1240 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;
@@ -1082,6 +1392,81 @@
1082 1392 );
1083 1393
1084 1394 wp_send_json( $response );
1085 1395 wp_die();
1396 + }
1397 +
1398 + /**
1399 + * Check if the user has a support page.
1400 + */
1401 + public function has_support_page() {
1402 + $transient_name = 'tisdk_has_support_page';
1403 + $has_support = get_transient( $transient_name );
1404 +
1405 + if ( false === $has_support ) {
1406 + global $wpdb;
1407 +
1408 + // We use %i escape identifier that was added in WP 6.2.0, hence need to ignore PHPCS warning.
1409 + // We only show this notice to users on higher version as that is the minimum for Hyve as well.
1410 + $query = $wpdb->get_var( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1411 + $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
1412 + 'SELECT ID FROM %i WHERE post_type = %s AND post_status = %s AND post_title LIKE %s LIMIT 1', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder
1413 + $wpdb->posts,
1414 + 'page',
1415 + 'publish',
1416 + '%support%'
1417 + )
1418 + );
1419 +
1420 + $has_support = $query ? 'yes' : 'no';
1421 +
1422 + set_transient( $transient_name, $has_support, 7 * DAY_IN_SECONDS );
1423 + }
1424 +
1425 + return 'yes' === $has_support;
1426 + }
1427 +
1428 + /**
1429 + * Check if the user has a donate page.
1430 + */
1431 + public function has_donate_page() {
1432 + $transient_name = 'tisdk_has_donate_page';
1433 + $has_donate = get_transient( $transient_name );
1434 +
1435 + if ( false === $has_donate ) {
1436 + global $wpdb;
1437 +
1438 + $query = $wpdb->get_var( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1439 + $wpdb->prepare(
1440 + 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s AND post_title LIKE %s LIMIT 1',
1441 + 'page',
1442 + 'publish',
1443 + '%donate%'
1444 + )
1445 + );
1446 +
1447 + $has_donate = $query ? 'yes' : 'no';
1448 +
1449 + set_transient( $transient_name, $has_donate, 7 * DAY_IN_SECONDS );
1450 + }
1451 +
1452 + return 'yes' === $has_donate;
1453 + }
1454 +
1455 + /**
1456 + * Check if the tagline contains LMS related keywords.
1457 + *
1458 + * @return bool True if the tagline contains LMS-related keywords, false otherwise.
1459 + */
1460 + public function has_lms_tagline() {
1461 + $tagline = strtolower( get_bloginfo( 'description' ) );
1462 + $lms_keywords = array( 'learning', 'courses' );
1463 +
1464 + foreach ( $lms_keywords as $keyword ) {
1465 + if ( strpos( $tagline, $keyword ) !== false ) {
1466 + return true;
1467 + }
1468 + }
1469 +
1470 + return false;
1086 1471 }
1087 1472 }