PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.10.7
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.10.7
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 +120 -960 4.0.83.10.7 View file →
@@ -13,9 +13,8 @@
13 13
14 14 namespace ThemeisleSDK\Modules;
15 15
16 16 use ThemeisleSDK\Common\Abstract_Module;
17 -use ThemeisleSDK\Loader;
18 17 use ThemeisleSDK\Product;
19 18
20 19 // Exit if accessed directly.
21 20 if ( ! defined( 'ABSPATH' ) ) {
@@ -31,19 +30,11 @@
31 30 * Holds the promotions.
32 31 *
33 32 * @var array
34 33 */
35 - public $promotions = array();
34 + private $promotions = array();
36 35
37 36 /**
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 - /**
46 37 * Option key for promos.
47 38 *
48 39 * @var string
49 40 */
@@ -70,50 +61,15 @@
70 61 */
71 62 private $option_rop = 'themeisle_sdk_promotions_rop_installed';
72 63
73 64 /**
74 - * Option key for Neve promo.
65 + * Option key for Neve FSE promos.
75 66 *
76 67 * @var string
77 68 */
78 - private $option_neve = 'themeisle_sdk_promotions_neve_installed';
69 + private $option_neve_fse = 'themeisle_sdk_promotions_neve_fse_installed';
79 70
80 71 /**
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 - /**
116 72 * Loaded promotion.
117 73 *
118 74 * @var string
119 75 */
@@ -119,15 +75,8 @@
119 75 */
120 76 private $loaded_promo;
121 77
122 78 /**
123 - * Whether promotions were processed for the current screen.
124 - *
125 - * @var bool
126 - */
127 - private $available_promotions_loaded = false;
128 -
129 - /**
130 79 * Woo promotions.
131 80 *
132 81 * @var array
133 82 */
@@ -154,35 +103,23 @@
154 103 if ( $this->is_from_partner( $product ) ) {
155 104 return false;
156 105 }
157 106
158 - $this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug );
159 - $promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() );
160 -
107 + $this->debug = apply_filters( 'themeisle_sdk_promo_debug', $this->debug );
108 + $promotions_to_load = apply_filters( $product->get_key() . '_load_promotions', array() );
161 109 $promotions_to_load[] = 'optimole';
162 110 $promotions_to_load[] = 'rop';
163 111 $promotions_to_load[] = 'woo_plugins';
164 - $promotions_to_load[] = 'neve';
165 - $promotions_to_load[] = 'redirection-cf7';
166 - $promotions_to_load[] = 'hyve';
167 - $promotions_to_load[] = 'wp_full_pay';
168 - $promotions_to_load[] = 'feedzy_import';
169 - $promotions_to_load[] = 'learning-management-system';
112 + $promotions_to_load[] = 'neve-fse';
170 113
171 - if ( defined( 'NEVE_VERSION' ) || defined( 'WPMM_PATH' ) || defined( 'OTTER_BLOCKS_VERSION' ) || defined( 'OBFX_URL' ) ) {
172 - $promotions_to_load[] = 'feedzy_embed';
173 - }
174 - $promotions_to_load = array_unique( $promotions_to_load );
175 -
176 114 $this->promotions = $this->get_promotions();
177 115
178 - $this->dissallowed_promotions = apply_filters( $product->get_key() . '_dissallowed_promotions', array() );
179 -
180 116 foreach ( $this->promotions as $slug => $data ) {
181 117 if ( ! in_array( $slug, $promotions_to_load, true ) ) {
182 118 unset( $this->promotions[ $slug ] );
183 119 }
184 120 }
121 +
185 122 add_action( 'init', array( $this, 'register_settings' ), 99 );
186 123 add_action( 'admin_init', array( $this, 'register_reference' ), 99 );
187 124
188 125 return ! empty( $this->promotions );
@@ -197,236 +134,32 @@
197 134 if ( ! $this->is_writeable() || ! current_user_can( 'install_plugins' ) ) {
198 135 return;
199 136 }
200 137
201 - $last_dismiss_time = $this->get_last_dismiss_time();
138 + $this->product = $product;
202 139
203 - if ( ! $this->debug && is_int( $last_dismiss_time ) && ( time() - $last_dismiss_time ) < ( 3 * WEEK_IN_SECONDS ) ) {
140 + $last_dismiss = $this->get_last_dismiss_time();
141 +
142 + if ( ! $this->debug && $last_dismiss && ( time() - $last_dismiss ) < 7 * DAY_IN_SECONDS ) {
204 143 return;
205 144 }
206 145
207 - $this->product = $product;
208 -
209 146 add_filter( 'attachment_fields_to_edit', array( $this, 'add_attachment_field' ), 10, 2 );
210 147 add_action( 'current_screen', [ $this, 'load_available' ] );
211 148 add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'enqueue' ) );
212 - add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_visualizer_block_editor_shim' ), 100 );
213 149 add_action( 'wp_ajax_tisdk_update_option', array( $this, 'dismiss_promotion' ) );
214 - add_filter( 'plugins_api_result', array( $this, 'inject_visualizer_block_directory_suggestion' ), 10, 3 );
215 - add_filter( 'option_visualizer-activated', array( $this, 'suppress_visualizer_onboarding_in_editor' ) );
216 150 add_filter( 'themeisle_sdk_ran_promos', '__return_true' );
217 151
218 - if ( get_option( $this->option_neve, false ) !== true ) {
219 - add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', 'ThemeisleSDK\Modules\Notification::dismiss' );
152 + if ( get_option( $this->option_neve_fse, false ) !== true ) {
153 + add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', 'ThemeisleSDK\Modules\Notification::regular_dismiss' );
220 154 }
221 155 }
222 156
223 -
224 157 /**
225 - * Inject Visualizer as the first block-directory suggestion for chart queries.
226 - *
227 - * @param object|WP_Error $res Response object or WP_Error.
228 - * @param string $action The API action.
229 - * @param object $args The API arguments.
230 - * @return object|WP_Error
231 - */
232 - public function inject_visualizer_block_directory_suggestion( $res, $action, $args ) {
233 - if ( 'query_plugins' !== $action || ! is_object( $args ) || empty( $args->block ) ) {
234 - return $res;
235 - }
236 -
237 - if ( ! $this->should_suggest_visualizer( $args->block ) ) {
238 - return $res;
239 - }
240 -
241 - if ( $this->is_plugin_installed( 'visualizer' ) ) {
242 - return $res;
243 - }
244 -
245 - $plugin = $this->get_visualizer_block_directory_data();
246 - if ( empty( $plugin ) ) {
247 - return $res;
248 - }
249 -
250 - if ( is_wp_error( $res ) ) {
251 - $res = (object) array( 'plugins' => array() );
252 - }
253 -
254 - if ( ! isset( $res->plugins ) || ! is_array( $res->plugins ) ) {
255 - $res->plugins = array();
256 - }
257 -
258 - $res->plugins = array_values(
259 - array_filter(
260 - $res->plugins,
261 - function ( $existing ) use ( $plugin ) {
262 - return ! isset( $existing['slug'] ) || $existing['slug'] !== $plugin['slug'];
263 - }
264 - )
265 - );
266 -
267 - array_unshift( $res->plugins, $plugin );
268 -
269 - return $res;
270 - }
271 -
272 - /**
273 - * Check if the query should trigger the Visualizer suggestion.
274 - *
275 - * @param string $term Search term.
276 - * @return bool
277 - */
278 - private function should_suggest_visualizer( $term ) {
279 - $term = strtolower( (string) $term );
280 - return false !== strpos( $term, 'chart' ) || false !== strpos( $term, 'visualizer' ) || false !== strpos( $term, 'visualization' ) || false !== strpos( $term, 'graph' );
281 - }
282 -
283 - /**
284 - * Build the plugin data for Visualizer block directory results.
285 - *
286 - * @return array
287 - */
288 - private function get_visualizer_block_directory_data() {
289 - $slug = 'visualizer';
290 - $plugin_info = $this->call_plugin_api( $slug );
291 -
292 - if ( is_wp_error( $plugin_info ) || empty( $plugin_info ) ) {
293 - return array();
294 - }
295 -
296 - $icons = array();
297 - if ( ! empty( $plugin_info->icons ) ) {
298 - if ( ! empty( $plugin_info->icons['1x'] ) ) {
299 - $icons['1x'] = $plugin_info->icons['1x'];
300 - }
301 - if ( ! empty( $plugin_info->icons['2x'] ) ) {
302 - $icons['2x'] = $plugin_info->icons['2x'];
303 - }
304 - }
305 -
306 - $name = isset( $plugin_info->name ) ? $plugin_info->name : 'Visualizer';
307 -
308 - return array(
309 - 'slug' => $slug,
310 - 'name' => $name,
311 - 'short_description' => isset( $plugin_info->short_description ) ? $plugin_info->short_description : '',
312 - 'author' => isset( $plugin_info->author ) ? wp_strip_all_tags( $plugin_info->author ) : '',
313 - 'rating' => isset( $plugin_info->rating ) ? (int) $plugin_info->rating : 0,
314 - 'num_ratings' => isset( $plugin_info->num_ratings ) ? (int) $plugin_info->num_ratings : 0,
315 - 'active_installs' => isset( $plugin_info->active_installs ) ? (int) $plugin_info->active_installs : 0,
316 - 'author_block_rating' => isset( $plugin_info->author_block_rating ) ? (int) $plugin_info->author_block_rating : 0,
317 - 'author_block_count' => isset( $plugin_info->author_block_count ) ? (int) $plugin_info->author_block_count : 0,
318 - 'icons' => $icons,
319 - 'last_updated' => isset( $plugin_info->last_updated ) ? $plugin_info->last_updated : gmdate( 'Y-m-d H:i:s' ),
320 - 'blocks' => array(
321 - array(
322 - 'name' => 'visualizer/chart',
323 - 'title' => $name,
324 - ),
325 - ),
326 - );
327 - }
328 -
329 -
330 - /**
331 - * Prevent Visualizer onboarding redirects while in the block editor.
332 - *
333 - * @param mixed $value Option value.
334 - * @return mixed
335 - */
336 - public function suppress_visualizer_onboarding_in_editor( $value ) {
337 - if ( ! $this->is_block_editor_screen() ) {
338 - return $value;
339 - }
340 -
341 - return false;
342 - }
343 -
344 - /**
345 - * Add a small compatibility shim for Visualizer's block editor bundle.
346 - *
347 - * Visualizer's "Display an existing chart" flow reads
348 - * `google.visualization.Version` before the Google Charts loader has fully
349 - * populated `google.visualization`, which can throw after dynamic install.
350 - *
351 - * @return void
352 - */
353 - public function enqueue_visualizer_block_editor_shim() {
354 - global $themeisle_sdk_max_version;
355 -
356 - if ( ! $this->is_block_editor_screen() ) {
357 - return;
358 - }
359 -
360 - if ( ! wp_script_is( 'visualizer-gutenberg-block', 'enqueued' ) ) {
361 - return;
362 - }
363 -
364 - wp_register_script(
365 - 'ti-sdk-visualizer-editor-shim',
366 - '',
367 - array(),
368 - $themeisle_sdk_max_version,
369 - true
370 - );
371 - wp_enqueue_script( 'ti-sdk-visualizer-editor-shim' );
372 - wp_add_inline_script(
373 - 'ti-sdk-visualizer-editor-shim',
374 - 'window.google = window.google || {}; window.google.visualization = window.google.visualization || {}; window.google.visualization.Version = window.google.visualization.Version || "current";'
375 - );
376 - }
377 -
378 - /**
379 - * Check if the current admin screen is the block editor.
380 - *
381 - * @return bool
382 - */
383 - private function is_block_editor_screen() {
384 - if ( ! function_exists( 'get_current_screen' ) ) {
385 - return $this->is_block_editor_request();
386 - }
387 -
388 - $screen = get_current_screen();
389 - if ( is_object( $screen ) && method_exists( $screen, 'is_block_editor' ) && $screen->is_block_editor() ) {
390 - return true;
391 - }
392 -
393 - return $this->is_block_editor_request();
394 - }
395 -
396 - /**
397 - * Detect block editor requests before the current screen is available.
398 - *
399 - * @return bool
400 - */
401 - private function is_block_editor_request() {
402 - global $pagenow;
403 -
404 - if ( 'post-new.php' === $pagenow ) {
405 - $post_type = isset( $_GET['post_type'] ) ? sanitize_key( $_GET['post_type'] ) : 'post';
406 -
407 - return function_exists( 'use_block_editor_for_post_type' ) ? use_block_editor_for_post_type( $post_type ) : true;
408 - }
409 -
410 - if ( 'post.php' === $pagenow && isset( $_GET['post'] ) ) {
411 - $post_id = absint( $_GET['post'] );
412 -
413 - return function_exists( 'use_block_editor_for_post' ) ? use_block_editor_for_post( $post_id ) : true;
414 - }
415 -
416 - return false;
417 - }
418 -
419 - /**
420 158 * Load available promotions.
421 159 */
422 160 public function load_available() {
423 - if ( $this->available_promotions_loaded ) {
424 - return;
425 - }
426 -
427 - $this->available_promotions_loaded = true;
428 - $this->promotions = $this->filter_by_screen_and_merge();
161 + $this->promotions = $this->filter_by_screen_and_merge();
429 162 if ( empty( $this->promotions ) ) {
430 163 return;
431 164 }
432 165
@@ -464,24 +197,11 @@
464 197 if ( isset( $_GET['rop_reference_key'] ) ) {
465 198 update_option( 'rop_reference_key', sanitize_key( $_GET['rop_reference_key'] ) );
466 199 }
467 200
468 - if ( isset( $_GET['neve_reference_key'] ) ) {
469 - update_option( 'neve_reference_key', sanitize_key( $_GET['neve_reference_key'] ) );
201 + if ( isset( $_GET['neve_fse_reference_key'] ) ) {
202 + update_option( 'neve_fse_reference_key', sanitize_key( $_GET['neve_fse_reference_key'] ) );
470 203 }
471 -
472 - if ( isset( $_GET['hyve_reference_key'] ) ) {
473 - update_option( 'hyve_reference_key', sanitize_key( $_GET['hyve_reference_key'] ) );
474 - }
475 -
476 - if ( isset( $_GET['wp_full_pay_reference_key'] ) ) {
477 - update_option( 'wp_full_pay_reference_key', sanitize_key( $_GET['wp_full_pay_reference_key'] ) );
478 - }
479 -
480 - if ( isset( $_GET['feedzy_reference_key'] ) || ( isset( $_GET['from'], $_GET['plugin'] ) && $_GET['from'] === 'import' && str_starts_with( sanitize_key( $_GET['plugin'] ), 'feedzy' ) ) ) {
481 - update_option( 'feedzy_reference_key', sanitize_key( $_GET['feedzy_reference_key'] ?? 'i-' . $this->product->get_key() ) );
482 - update_option( $this->option_feedzy, 1 );
483 - }
484 204 }
485 205
486 206 /**
487 207 * Register Settings
@@ -531,9 +251,9 @@
531 251 )
532 252 );
533 253 register_setting(
534 254 'themeisle_sdk_settings',
535 - $this->option_neve,
255 + $this->option_neve_fse,
536 256 array(
537 257 'type' => 'boolean',
538 258 'sanitize_callback' => 'rest_sanitize_boolean',
539 259 'show_in_rest' => true,
@@ -539,48 +259,8 @@
539 259 'show_in_rest' => true,
540 260 'default' => false,
541 261 )
542 262 );
543 - register_setting(
544 - 'themeisle_sdk_settings',
545 - $this->option_redirection_cf7,
546 - array(
547 - 'type' => 'boolean',
548 - 'sanitize_callback' => 'rest_sanitize_boolean',
549 - 'show_in_rest' => true,
550 - 'default' => false,
551 - )
552 - );
553 - register_setting(
554 - 'themeisle_sdk_settings',
555 - $this->option_hyve,
556 - array(
557 - 'type' => 'boolean',
558 - 'sanitize_callback' => 'rest_sanitize_boolean',
559 - 'show_in_rest' => true,
560 - 'default' => false,
561 - )
562 - );
563 - register_setting(
564 - 'themeisle_sdk_settings',
565 - $this->option_wp_full_pay,
566 - array(
567 - 'type' => 'boolean',
568 - 'sanitize_callback' => 'rest_sanitize_boolean',
569 - 'show_in_rest' => true,
570 - 'default' => false,
571 - )
572 - );
573 - register_setting(
574 - 'themeisle_sdk_settings',
575 - $this->option_masteriyo,
576 - array(
577 - 'type' => 'boolean',
578 - 'sanitize_callback' => 'rest_sanitize_boolean',
579 - 'show_in_rest' => true,
580 - 'default' => false,
581 - )
582 - );
583 263 }
584 264
585 265 /**
586 266 * Check if the path is writable.
@@ -621,50 +301,33 @@
621 301 *
622 302 * @return array
623 303 */
624 304 private function get_promotions() {
625 - $has_otter = defined( 'OTTER_BLOCKS_VERSION' ) || $this->is_plugin_installed( 'otter-blocks' );
626 - $had_otter_from_promo = get_option( $this->option_otter, false );
627 - $has_optimole = defined( 'OPTIMOLE_VERSION' ) || $this->is_plugin_installed( 'optimole-wp' );
628 - $had_optimole_from_promo = get_option( $this->option_optimole, false );
629 - $has_rop = defined( 'ROP_LITE_VERSION' ) || $this->is_plugin_installed( 'tweet-old-post' );
630 - $had_rop_from_promo = get_option( $this->option_rop, false );
631 - $has_woocommerce = class_exists( 'WooCommerce' );
632 - $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' );
633 - $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' );
634 - $has_redirection_cf7 = defined( 'WPCF7_PRO_REDIRECT_PLUGIN_VERSION' ) || $this->is_plugin_installed( 'wpcf7-redirect' );
635 - $had_redirection_cf7_promo = get_option( $this->option_redirection_cf7, false );
636 - $is_min_php_7_4 = version_compare( PHP_VERSION, '7.4', '>=' );
637 - $is_min_php_7_2 = version_compare( PHP_VERSION, '7.2', '>=' );
638 - $can_check_plugin_install = $this->can_check_plugin_install_promo();
639 - $has_hyve = defined( 'HYVE_LITE_VERSION' ) || $this->is_plugin_installed( 'hyve' ) || $this->is_plugin_installed( 'hyve-lite' );
640 - $had_hyve_from_promo = get_option( $this->option_hyve, false );
641 - $has_hyve_conditions = $is_min_php_7_4 && ! $has_hyve && ! $had_hyve_from_promo && version_compare( get_bloginfo( 'version' ), '6.2', '>=' ) && $can_check_plugin_install && $this->has_support_page();
642 - $has_wfp_full_pay = defined( 'WP_FULL_STRIPE_BASENAME' ) || $this->is_plugin_installed( 'wp-full-stripe-free' );
643 - $had_wfp_from_promo = get_option( $this->option_wp_full_pay, false );
644 - $has_wfp_conditions = ! $has_wfp_full_pay && ! $had_wfp_from_promo && $can_check_plugin_install && $this->has_donate_page();
645 - $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' );
646 - $current_theme = wp_get_theme();
647 - $has_neve = $current_theme->template === 'neve' || $current_theme->parent() === 'neve';
648 - $has_neve_from_promo = get_option( $this->option_neve, false );
649 - $has_enough_attachments = $this->has_min_media_attachments();
650 - $has_enough_old_posts = $this->has_old_posts();
651 - $has_feedzy = defined( 'FEEDZY_BASEFILE' ) || $this->is_plugin_installed( 'feedzy-rss-feedss' );
652 - $had_feedzy_from_promo = get_option( $this->option_feedzy, false );
653 - $had_masteriyo_from_promo = get_option( $this->option_masteriyo, false );
654 - $has_masteriyo_conditions = $is_min_php_7_2 && ! $had_masteriyo_from_promo && ! $this->has_active_lms_plugin() && $can_check_plugin_install && $this->has_lms_tagline();
305 + $has_otter = defined( 'OTTER_BLOCKS_VERSION' ) || $this->is_plugin_installed( 'otter-blocks' );
306 + $had_otter_from_promo = get_option( $this->option_otter, false );
307 + $has_optimole = defined( 'OPTIMOLE_VERSION' ) || $this->is_plugin_installed( 'optimole-wp' );
308 + $had_optimole_from_promo = get_option( $this->option_optimole, false );
309 + $has_rop = defined( 'ROP_LITE_VERSION' ) || $this->is_plugin_installed( 'tweet-old-post' );
310 + $had_rop_from_promo = get_option( $this->option_rop, false );
311 + $has_woocommerce = class_exists( 'WooCommerce' );
312 + $has_sparks = defined( 'SPARKS_WC_VERSION' ) || $this->is_plugin_installed( 'sparks-for-woocommerce' );
313 + $has_ppom = defined( 'PPOM_VERSION' ) || $this->is_plugin_installed( 'woocommerce-product-addon' );
314 + $is_min_req_v = version_compare( get_bloginfo( 'version' ), '5.8', '>=' );
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';
318 + $has_enough_attachments = $this->has_min_media_attachments();
319 + $has_enough_old_posts = $this->has_old_posts();
655 320
656 321 $all = [
657 - 'optimole' => [
322 + 'optimole' => [
658 323 'om-editor' => [
659 - 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo,
660 - 'screen' => 'editor',
661 - 'delayed' => true,
324 + 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo,
325 + 'screen' => 'editor',
662 326 ],
663 327 'om-image-block' => [
664 - 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo,
665 - 'screen' => 'editor',
666 - 'delayed' => true,
328 + 'env' => ! $has_optimole && $is_min_req_v && ! $had_optimole_from_promo,
329 + 'screen' => 'editor',
667 330 ],
668 331 'om-attachment' => [
669 332 'env' => ! $has_optimole && ! $had_optimole_from_promo,
670 333 'screen' => 'media-editor',
@@ -673,51 +336,33 @@
673 336 'env' => ! $has_optimole && ! $had_optimole_from_promo && $has_enough_attachments,
674 337 'screen' => 'media',
675 338 ],
676 339 'om-elementor' => [
677 - 'env' => ! $has_optimole && ! $had_optimole_from_promo && defined( 'ELEMENTOR_VERSION' ),
678 - 'screen' => 'elementor',
679 - 'delayed' => true,
340 + 'env' => ! $has_optimole && ! $had_optimole_from_promo && defined( 'ELEMENTOR_VERSION' ),
341 + 'screen' => 'elementor',
680 342 ],
681 343 ],
682 - 'feedzy_import' => [
683 - 'feedzy-import' => [
684 - 'env' => true,
685 - 'screen' => 'import',
686 - 'always' => true,
687 - ],
688 - ],
689 - 'feedzy_embed' => [
690 - 'feedzy-editor' => [
691 - 'env' => ! $has_feedzy && is_main_site() && ! $had_feedzy_from_promo,
344 + 'otter' => [
345 + 'blocks-css' => [
346 + 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
692 347 'screen' => 'editor',
693 348 ],
694 - ],
695 - 'otter' => [
696 - 'blocks-css' => [
697 - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
698 - 'screen' => 'editor',
699 - 'delayed' => true,
700 - ],
701 349 'blocks-animation' => [
702 - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
703 - 'screen' => 'editor',
704 - 'delayed' => true,
350 + 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
351 + 'screen' => 'editor',
705 352 ],
706 353 'blocks-conditions' => [
707 - 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
708 - 'screen' => 'editor',
709 - 'delayed' => true,
354 + 'env' => ! $has_otter && $is_min_req_v && ! $had_otter_from_promo,
355 + 'screen' => 'editor',
710 356 ],
711 357 ],
712 - 'rop' => [
358 + 'rop' => [
713 359 'rop-posts' => [
714 - 'env' => ! $has_rop && ! $had_rop_from_promo && $has_enough_old_posts,
715 - 'screen' => 'edit-post',
716 - 'delayed' => true,
360 + 'env' => ! $has_rop && ! $had_rop_from_promo && $has_enough_old_posts,
361 + 'screen' => 'edit-post',
717 362 ],
718 363 ],
719 - 'woo_plugins' => [
364 + 'woo_plugins' => [
720 365 'ppom' => [
721 366 'env' => ! $has_ppom && $has_woocommerce,
722 367 'screen' => 'edit-product',
723 368 ],
@@ -733,39 +378,14 @@
733 378 'env' => ! $has_sparks && $has_woocommerce,
734 379 'screen' => 'edit-product',
735 380 ],
736 381 ],
737 - 'neve' => [
738 - 'neve-themes-popular' => [
739 - 'env' => ! $has_neve && ! $has_neve_from_promo,
382 + 'neve-fse' => [
383 + 'neve-fse-themes-popular' => [
384 + 'env' => ! $has_neve_fse && $is_min_fse_v,
740 385 'screen' => 'themes-install-popular',
741 386 ],
742 387 ],
743 - 'redirection-cf7' => [
744 - 'wpcf7' => [
745 - 'env' => ! $has_redirection_cf7 && ! $had_redirection_cf7_promo,
746 - 'screen' => 'wpcf7',
747 - 'delayed' => true,
748 - ],
749 - ],
750 - 'hyve' => [
751 - 'hyve-plugins-install' => [
752 - 'env' => $has_hyve_conditions,
753 - 'screen' => 'plugin-install',
754 - ],
755 - ],
756 - 'wp_full_pay' => [
757 - 'wp-full-pay-plugins-install' => [
758 - 'env' => $has_wfp_conditions,
759 - 'screen' => 'plugin-install',
760 - ],
761 - ],
762 - 'learning-management-system' => [
763 - 'masteriyo-plugins-install' => [
764 - 'env' => $has_masteriyo_conditions,
765 - 'screen' => 'plugin-install',
766 - ],
767 - ],
768 388 ];
769 389
770 390 foreach ( $all as $slug => $data ) {
771 391 foreach ( $data as $key => $conditions ) {
@@ -783,8 +403,9 @@
783 403 if ( empty( $all[ $slug ] ) ) {
784 404 unset( $all[ $slug ] );
785 405 }
786 406 }
407 +
787 408 return $all;
788 409 }
789 410
790 411 /**
@@ -809,14 +430,20 @@
809 430
810 431 /**
811 432 * Get the last dismiss time of a promotion.
812 433 *
813 - * @return int | false The timestamp of last dismiss or false.
434 + * @return int The timestamp of last dismiss, or install time - 4 days.
814 435 */
815 436 private function get_last_dismiss_time() {
816 437 $dismissed = $this->get_upsells_dismiss_time();
817 438
818 - return empty( $dismissed ) ? false : max( array_values( $dismissed ) );
439 + if ( empty( $dismissed ) ) {
440 + // we return the product install time - 4 days because we want to show the upsell after 3 days,
441 + // and we move the product install time 4 days in the past.
442 + return $this->product->get_install_time() - 4 * DAY_IN_SECONDS;
443 + }
444 +
445 + return max( array_values( $dismissed ) );
819 446 }
820 447
821 448 /**
822 449 * Filter by screen & merge into single array of keys.
@@ -825,54 +452,19 @@
825 452 */
826 453 private function filter_by_screen_and_merge() {
827 454 $current_screen = get_current_screen();
828 455
829 - $is_elementor = isset( $_GET['action'] ) && $_GET['action'] === 'elementor';
830 - $is_media = isset( $current_screen->id ) && $current_screen->id === 'upload';
831 - $is_posts = isset( $current_screen->id ) && $current_screen->id === 'edit-post';
832 - $is_editor = method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor();
833 - $is_theme_install = isset( $current_screen->id ) && ( $current_screen->id === 'theme-install' );
834 - $is_plugin_install = isset( $current_screen->id ) && ( $current_screen->id === 'plugin-install' );
835 - $is_product = isset( $current_screen->id ) && $current_screen->id === 'product';
836 - $is_import = isset( $current_screen->id ) && $current_screen->id === 'import';
837 - $is_cf7_install = isset( $current_screen->id ) && function_exists( 'str_contains' ) ? str_contains( $current_screen->id, 'page_wpcf7' ) : false;
456 + $is_elementor = isset( $_GET['action'] ) && $_GET['action'] === 'elementor';
457 + $is_media = isset( $current_screen->id ) && $current_screen->id === 'upload';
458 + $is_posts = isset( $current_screen->id ) && $current_screen->id === 'edit-post';
459 + $is_editor = method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor();
460 + $is_theme_install = isset( $current_screen->id ) && ( $current_screen->id === 'theme-install' || $current_screen->id === 'themes' );
461 + $is_product = isset( $current_screen->id ) && $current_screen->id === 'product';
838 462
839 - $return = [];
840 - $product_install_time = (int) $this->product->get_install_time();
841 - $is_older = time() > ( $product_install_time + ( 3 * DAY_IN_SECONDS ) );
842 - $is_newer = time() < ( $product_install_time + ( 6 * HOUR_IN_SECONDS ) );
463 + $return = [];
464 +
843 465 foreach ( $this->promotions as $slug => $promos ) {
844 - if ( ! is_array( $promos ) ) {
845 - continue;
846 - }
847 -
848 466 foreach ( $promos as $key => $data ) {
849 - if ( ! is_array( $data ) || ! array_key_exists( 'screen', $data ) ) {
850 - unset( $this->promotions[ $slug ][ $key ] );
851 -
852 - continue;
853 - }
854 -
855 - $data = wp_parse_args(
856 - $data,
857 - [
858 - 'delayed' => false,
859 - 'always' => false,
860 - ]
861 - );
862 -
863 - if (
864 - ! $this->debug &&
865 - (
866 - ( $data['delayed'] === true && ! $is_older ) || // Skip promotions that are delayed for 3 days.
867 - $is_newer // Skip promotions for the first 6 hours after install.
868 - )
869 - && ! $data['always']
870 - ) {
871 - unset( $this->promotions[ $slug ][ $key ] );
872 -
873 - continue;
874 - }
875 467 switch ( $data['screen'] ) {
876 468 case 'media-editor':
877 469 if ( ! $is_media && ! $is_editor ) {
878 470 unset( $this->promotions[ $slug ][ $key ] );
@@ -887,13 +479,8 @@
887 479 if ( ! $is_editor || $is_elementor ) {
888 480 unset( $this->promotions[ $slug ][ $key ] );
889 481 }
890 482 break;
891 - case 'import':
892 - if ( ! $is_import ) {
893 - unset( $this->promotions[ $slug ][ $key ] );
894 - }
895 - break;
896 483 case 'elementor':
897 484 if ( ! $is_elementor ) {
898 485 unset( $this->promotions[ $slug ][ $key ] );
899 486 }
@@ -912,18 +499,8 @@
912 499 if ( ! $is_theme_install ) {
913 500 unset( $this->promotions[ $slug ][ $key ] );
914 501 }
915 502 break;
916 - case 'wpcf7':
917 - if ( ! $is_cf7_install ) {
918 - unset( $this->promotions[ $slug ][ $key ] );
919 - }
920 - break;
921 - case 'plugin-install':
922 - if ( ! $is_plugin_install ) {
923 - unset( $this->promotions[ $slug ][ $key ] );
924 - }
925 - break;
926 503 }
927 504 }
928 505
929 506 $return = array_merge( $return, $this->promotions[ $slug ] );
@@ -928,16 +505,8 @@
928 505
929 506 $return = array_merge( $return, $this->promotions[ $slug ] );
930 507 }
931 508
932 - $return = array_filter(
933 - $return,
934 - function ( $value, $key ) {
935 - return ! in_array( $key, $this->dissallowed_promotions, true );
936 - },
937 - ARRAY_FILTER_USE_BOTH
938 - );
939 -
940 509 return array_keys( $return );
941 510 }
942 511
943 512 /**
@@ -956,31 +525,16 @@
956 525 }
957 526 if ( $this->get_upsells_dismiss_time( 'rop-posts' ) === false ) {
958 527 add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] );
959 528 }
960 - if ( $this->get_upsells_dismiss_time( 'neve-themes-popular' ) === false ) {
961 - add_action( 'admin_notices', [ $this, 'render_neve_themes_notice' ] );
529 + if ( $this->get_upsells_dismiss_time( 'neve-fse-themes-popular' ) === false ) {
530 + add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] );
962 531 }
963 - if ( $this->get_upsells_dismiss_time( 'redirection-cf7' ) === false ) {
964 - add_action( 'admin_notices', [ $this, 'render_redirection_cf7_notice' ] );
965 - }
966 - if ( $this->get_upsells_dismiss_time( 'hyve-plugins-install' ) === false ) {
967 - add_action( 'admin_notices', [ $this, 'render_hyve_notice' ] );
968 - }
969 532
970 - if ( $this->get_upsells_dismiss_time( 'wp-full-pay-plugins-install' ) === false ) {
971 - add_action( 'admin_notices', [ $this, 'render_wp_full_pay_notice' ] );
972 - }
973 -
974 - if ( $this->get_upsells_dismiss_time( 'masteriyo-plugins-install' ) === false ) {
975 - add_action( 'admin_notices', [ $this, 'render_masteriyo_notice' ] );
976 - }
977 -
978 - add_action( 'load-import.php', [ $this, 'add_import' ] );
979 533 $this->load_woo_promos();
980 -
981 534 return;
982 535 }
536 +
983 537 switch ( $slug ) {
984 538 case 'om-editor':
985 539 case 'om-image-block':
986 540 case 'blocks-css':
@@ -998,15 +552,8 @@
998 552 case 'rop-posts':
999 553 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
1000 554 add_action( 'admin_notices', [ $this, 'render_rop_dash_notice' ] );
1001 555 break;
1002 - case 'feedzy-import':
1003 - add_action( 'load-import.php', [ $this, 'add_import' ] );
1004 -
1005 - break;
1006 - case 'feedzy-editor':
1007 - add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue' ] );
1008 - break;
1009 556 case 'ppom':
1010 557 case 'sparks-wishlist':
1011 558 case 'sparks-announcement':
1012 559 case 'sparks-product-reviews':
@@ -1011,63 +558,22 @@
1011 558 case 'sparks-announcement':
1012 559 case 'sparks-product-reviews':
1013 560 $this->load_woo_promos();
1014 561 break;
1015 - case 'neve-themes-popular':
1016 - // Remove any other notifications if Neve promotion is showing
562 + case 'neve-fse-themes-popular':
563 + // Remove any other notifications if Neve FSE promotion is showing
1017 564 remove_action( 'admin_notices', array( 'ThemeisleSDK\Modules\Notification', 'show_notification' ) );
1018 - remove_action(
1019 - 'wp_ajax_themeisle_sdk_dismiss_notice',
1020 - array(
1021 - 'ThemeisleSDK\Modules\Notification',
1022 - 'dismiss',
1023 - )
1024 - );
565 + remove_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( 'ThemeisleSDK\Modules\Notification', 'dismiss' ) );
1025 566 remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'dismiss_get' ) );
1026 567 remove_action( 'admin_head', array( 'ThemeisleSDK\Modules\Notification', 'setup_notifications' ) );
1027 568 // Add required actions to display this notification
1028 569 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
1029 - add_action( 'admin_notices', [ $this, 'render_neve_themes_notice' ] );
570 + add_action( 'admin_notices', [ $this, 'render_neve_fse_themes_notice' ] );
1030 571 break;
1031 - case 'wpcf7':
1032 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
1033 - add_action( 'admin_notices', [ $this, 'render_redirection_cf7_notice' ] );
1034 - break;
1035 - case 'hyve-plugins-install':
1036 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
1037 - add_action( 'admin_notices', [ $this, 'render_hyve_notice' ] );
1038 - break;
1039 - case 'wp-full-pay-plugins-install':
1040 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
1041 - add_action( 'admin_notices', [ $this, 'render_wp_full_pay_notice' ] );
1042 - break;
1043 - case 'masteriyo-plugins-install':
1044 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ] );
1045 - add_action( 'admin_notices', [ $this, 'render_masteriyo_notice' ] );
1046 - break;
1047 572 }
1048 573 }
1049 574
1050 575 /**
1051 - * Add import row.
1052 - *
1053 - * @return void
1054 - */
1055 - public function add_import() {
1056 - global $wp_importers;
1057 - if ( isset( $wp_importers['feedzy-rss-feeds'] ) ) {
1058 - return;
1059 - }
1060 - $wp_importers['feedzy-rss-feeds'] = array( // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
1061 - 'Feedzy',
1062 - sprintf( Loader::$labels['promotions']['feedzy']['import_desc'], '<span style="float: left; font-style: italic;margin-top:0.4em;">', $this->product->get_friendly_name(), '</span>' ),
1063 - 'install' => 'feedzy-rss-feeds',
1064 - );
1065 - if ( defined( 'FEEDZY_BASEFILE' ) ) {
1066 - unset( $wp_importers['feedzy-rss-feeds']['install'] );
1067 - }
1068 - }
1069 - /**
1070 576 * Render dashboard notice.
1071 577 */
1072 578 public function render_optimole_dash_notice() {
1073 579 $screen = get_current_screen();
@@ -1090,68 +596,30 @@
1090 596 $user = wp_get_current_user();
1091 597 $asset_file = require $themeisle_sdk_max_path . '/assets/js/build/promos/index.asset.php';
1092 598 $deps = array_merge( $asset_file['dependencies'], [ 'updates' ] );
1093 599
1094 - $themes = wp_get_themes();
1095 - $neve_action = isset( $themes['neve'] ) ? 'activate' : 'install';
1096 - $labels = Loader::$labels['promotions'];
1097 - $labels['feedzy']['editor_recommends'] = sprintf(
1098 - $labels['feedzy']['editor_recommends'],
1099 - $this->product->get_friendly_name(),
1100 - '<a target="_blank" href="' . add_query_arg(
1101 - array(
1102 - 'tab' => 'plugin-information',
1103 - 'plugin' => 'feedzy-rss-feeds',
1104 - '_wpnonce' => wp_create_nonce( 'activate-plugin_feedzy-rss-feeds' ),
1105 - 'feedzy_reference_key' => 'e-' . $this->product->get_key(),
1106 - ),
1107 - network_admin_url( 'plugin-install.php' )
1108 - ) . '">',
1109 - '</a>'
1110 - );
1111 600 wp_register_script( $handle, $themeisle_sdk_src . 'assets/js/build/promos/index.js', $deps, $asset_file['version'], true );
1112 601 wp_localize_script(
1113 602 $handle,
1114 603 'themeisleSDKPromotions',
1115 604 [
1116 - 'debug' => $this->debug,
1117 - 'labels' => $labels,
1118 - 'email' => $user->user_email,
1119 - 'showPromotion' => $this->loaded_promo,
1120 - 'optionKey' => $this->option_main,
1121 - 'product' => $this->product->get_name(),
1122 - 'option' => empty( $saved ) ? new \stdClass() : $saved,
1123 - 'nonce' => wp_create_nonce( 'wp_rest' ),
1124 - 'assets' => $themeisle_sdk_src . 'assets/images/',
1125 - 'optimoleApi' => esc_url( rest_url( 'optml/v1/register_service' ) ),
1126 - 'optimoleActivationUrl' => $this->get_plugin_activation_link( 'optimole-wp' ),
1127 - 'otterActivationUrl' => $this->get_plugin_activation_link( 'otter-blocks' ),
1128 - 'ropActivationUrl' => $this->get_plugin_activation_link( 'tweet-old-post' ),
1129 - 'optimoleDash' => esc_url( add_query_arg( [ 'page' => 'optimole' ], admin_url( 'upload.php' ) ) ),
1130 - 'ropDash' => esc_url( add_query_arg( [ 'page' => 'TweetOldPost' ], admin_url( 'admin.php' ) ) ),
605 + 'debug' => $this->debug,
606 + 'email' => $user->user_email,
607 + 'showPromotion' => $this->loaded_promo,
608 + 'optionKey' => $this->option_main,
609 + 'product' => $this->product->get_name(),
610 + 'option' => empty( $saved ) ? new \stdClass() : $saved,
611 + 'nonce' => wp_create_nonce( 'wp_rest' ),
612 + 'assets' => $themeisle_sdk_src . 'assets/images/',
613 + 'optimoleApi' => esc_url( rest_url( 'optml/v1/register_service' ) ),
614 + 'optimoleActivationUrl' => $this->get_plugin_activation_link( 'optimole-wp' ),
615 + 'otterActivationUrl' => $this->get_plugin_activation_link( 'otter-blocks' ),
616 + 'ropActivationUrl' => $this->get_plugin_activation_link( 'tweet-old-post' ),
617 + 'optimoleDash' => esc_url( add_query_arg( [ 'page' => 'optimole' ], admin_url( 'upload.php' ) ) ),
618 + 'ropDash' => esc_url( add_query_arg( [ 'page' => 'TweetOldPost' ], admin_url( 'admin.php' ) ) ),
619 + 'neveFSEMoreUrl' => tsdk_utmify( 'https://themeisle.com/themes/neve-fse/', 'neve-fse-themes-popular', 'theme-install' ),
1131 620 // translators: %s is the product name.
1132 - 'title' => esc_html( sprintf( Loader::$labels['promotions']['recommended'], $this->product->get_name() ) ),
1133 - 'redirectionCF7MoreUrl' => tsdk_utmify( 'https://docs.themeisle.com/collection/2014-redirection-for-contact-form-7', 'redirection-for-contact-form-7', 'plugin-install' ),
1134 - 'rfCF7ActivationUrl' => $this->get_plugin_activation_link( 'wpcf7-redirect' ),
1135 - 'cf7Dash' => esc_url( add_query_arg( [ 'page' => 'wpcf7-new' ], admin_url( 'admin.php' ) ) ),
1136 - 'hyveActivationUrl' => $this->get_plugin_activation_link( 'hyve-lite' ),
1137 - 'hyveDash' => esc_url( add_query_arg( [ 'page' => 'wpfs-settings-stripe' ], admin_url( 'admin.php' ) ) ),
1138 - 'wpFullPayActivationUrl' => $this->get_plugin_activation_link( 'wp-full-stripe-free' ),
1139 - 'wpFullPayDash' => esc_url( add_query_arg( [ 'page' => 'wpfs-settings-stripe' ], admin_url( 'admin.php' ) ) ),
1140 - 'masteriyoActivationUrl' => $this->get_plugin_activation_link( 'masteriyo' ),
1141 - 'masteriyoDash' => esc_url( add_query_arg( [ 'page' => 'masteriyo-onboard' ], admin_url( 'index.php' ) ) ),
1142 - 'nevePreviewURL' => esc_url( add_query_arg( [ 'theme' => 'neve' ], admin_url( 'theme-install.php' ) ) ),
1143 - 'neveAction' => $neve_action,
1144 - 'activateNeveURL' => esc_url(
1145 - add_query_arg(
1146 - [
1147 - 'action' => 'activate',
1148 - 'stylesheet' => 'neve',
1149 - '_wpnonce' => wp_create_nonce( 'switch-theme_neve' ),
1150 - ],
1151 - admin_url( 'themes.php' )
1152 - )
1153 - ),
621 + 'title' => esc_html( sprintf( __( 'Recommended by %s', 'textdomain' ), $this->product->get_name() ) ),
1154 622 ]
1155 623 );
1156 624 wp_enqueue_script( $handle );
1157 625 wp_enqueue_style( $handle, $themeisle_sdk_src . 'assets/js/build/promos/style-index.css', [ 'wp-components' ], $asset_file['version'] );
@@ -1170,43 +638,15 @@
1170 638 echo '<div id="ti-rop-notice" class="notice notice-info ti-sdk-rop-notice"></div>';
1171 639 }
1172 640
1173 641 /**
1174 - * Render Neve Themes notice.
642 + * Render Neve FSE Themes notice.
1175 643 */
1176 - public function render_neve_themes_notice() {
1177 - echo '<div id="ti-neve-notice" class="notice notice-info ti-sdk-om-notice"></div>';
644 + public function render_neve_fse_themes_notice() {
645 + echo '<div id="ti-neve-fse-notice" class="notice notice-info ti-sdk-neve-fse-notice"></div>';
1178 646 }
1179 647
1180 648 /**
1181 - * Render Hyve notice.
1182 - */
1183 - public function render_hyve_notice() {
1184 - echo '<div id="ti-hyve-notice" class="notice notice-info ti-sdk-om-notice"></div>';
1185 - }
1186 -
1187 - /**
1188 - * Render WP Full Pay notice.
1189 - */
1190 - public function render_wp_full_pay_notice() {
1191 - echo '<div id="ti-wp-full-pay-notice" class="notice notice-info ti-sdk-om-notice"></div>';
1192 - }
1193 -
1194 - /**
1195 - * Render Redirection for CF7 notice.
1196 - */
1197 - public function render_redirection_cf7_notice() {
1198 - echo '<div id="ti-redirection-cf7-notice" class="notice notice-info ti-sdk-om-notice"></div>';
1199 - }
1200 -
1201 - /**
1202 - * Render Masteriyo notice.
1203 - */
1204 - public function render_masteriyo_notice() {
1205 - echo '<div id="ti-masteriyo-notice" class="notice notice-info ti-sdk-om-notice"></div>';
1206 - }
1207 -
1208 - /**
1209 649 * Add promo to attachment modal.
1210 650 *
1211 651 * @param array $fields Fields array.
1212 652 * @param \WP_Post $post Post object.
@@ -1223,9 +663,9 @@
1223 663 }
1224 664
1225 665 $meta = wp_get_attachment_metadata( $post->ID );
1226 666
1227 - if ( isset( $meta['filesize'] ) && $meta['filesize'] < 100000 ) {
667 + if ( isset( $meta['filesize'] ) && $meta['filesize'] < 200000 ) {
1228 668 return $fields;
1229 669 }
1230 670
1231 671 $fields['optimole'] = array(
@@ -1265,9 +705,8 @@
1265 705
1266 706
1267 707 set_transient( 'tsk_attachment_count', $attachment_count, DAY_IN_SECONDS );
1268 708 }
1269 -
1270 709 return $attachment_count > 50;
1271 710 }
1272 711
1273 712 /**
@@ -1327,10 +766,10 @@
1327 766 */
1328 767 private function load_woo_promos() {
1329 768 $this->woo_promos = array(
1330 769 'ppom' => array(
1331 - 'title' => Loader::$labels['promotions']['woo']['ppom_title'],
1332 - 'description' => Loader::$labels['promotions']['woo']['ppom_desc'],
770 + 'title' => 'Product Add-Ons',
771 + 'description' => 'Add extra custom fields & add-ons on your product pages, like sizes, colors & more.',
1333 772 '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>',
1334 773 'has_install' => true,
1335 774 'link' => wp_nonce_url(
1336 775 add_query_arg(
@@ -1343,22 +782,22 @@
1343 782 'install-plugin_woocommerce-product-addon'
1344 783 ),
1345 784 ),
1346 785 'sparks-wishlist' => array(
1347 - 'title' => Loader::$labels['promotions']['woo']['spark_title1'],
1348 - 'description' => Loader::$labels['promotions']['woo']['spark_desc1'],
786 + 'title' => 'Wishlist',
787 + 'description' => 'Loyalize your customers by allowing them to save their favorite products.',
1349 788 '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>',
1350 789 'link' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce/', 'promo', 'products-tabs' ),
1351 790 ),
1352 791 'sparks-announcement' => array(
1353 - 'title' => Loader::$labels['promotions']['woo']['spark_title2'],
1354 - 'description' => Loader::$labels['promotions']['woo']['spark_desc2'],
792 + 'title' => 'Multi-Announcement Bars',
793 + 'description' => 'Add a top notification bar on your website to highlight the latest products, offers, or upcoming events.',
1355 794 '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>',
1356 795 'link' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce/', 'promo', 'products-tabs' ),
1357 796 ),
1358 797 'sparks-product-review' => array(
1359 - 'title' => Loader::$labels['promotions']['woo']['spark_title3'],
1360 - 'description' => Loader::$labels['promotions']['woo']['spark_desc3'],
798 + 'title' => 'Advanced Product Review',
799 + 'description' => 'Enable an advanced review section, enlarging the basic review options with lots of capabilities.',
1361 800 '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>',
1362 801 'link' => tsdk_utmify( 'https://themeisle.com/plugins/sparks-for-woocommerce/', 'promo', 'products-tabs' ),
1363 802 ),
1364 803 );
@@ -1371,11 +810,11 @@
1371 810 }
1372 811
1373 812 add_action(
1374 813 'woocommerce_product_data_tabs',
1375 - function ( $tabs ) {
814 + function( $tabs ) {
1376 815 $tabs['tisdk-suggestions'] = array(
1377 - 'label' => Loader::$labels['promotions']['woo']['title'],
816 + 'label' => 'More extensions from Themeisle',
1378 817 'target' => 'tisdk_suggestions',
1379 818 'class' => array(),
1380 819 'priority' => 1000,
1381 820 );
@@ -1393,9 +832,9 @@
1393 832 public function woocommerce_tab_content() {
1394 833 // Filter content based on if the key exists in $this->promotions array.
1395 834 $content = array_filter(
1396 835 $this->woo_promos,
1397 - function ( $key ) {
836 + function( $key ) {
1398 837 return in_array( $key, $this->promotions, true );
1399 838 },
1400 839 ARRAY_FILTER_USE_KEY
1401 840 );
@@ -1407,9 +846,9 @@
1407 846 ?>
1408 847
1409 848 <div id="tisdk_suggestions" class="panel woocommerce_options_panel hidden">
1410 849 <div class="tisdk-suggestions-header">
1411 - <h4><?php echo esc_html( Loader::$labels['promotions']['woo']['title2'] ); ?></h4>
850 + <h4>Recommended extensions</h4>
1412 851 </div>
1413 852 <div class="tisdk-suggestions-content">
1414 853 <?php foreach ( $content as $key => $item ) : ?>
1415 854 <div class="tisdk-suggestion" id="<?php echo esc_attr( $key ); ?>">
@@ -1423,13 +862,11 @@
1423 862 <p><?php echo esc_html( $item['description'] ); ?></p>
1424 863 </div>
1425 864 <div class="tisdk-suggestion-cta">
1426 865 <a href="<?php echo esc_url( $item['link'] ); ?>" target="blank" class="button">
1427 - <?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'] ) ); ?>
866 + <?php echo ( ( isset( $item['has_install'] ) && $item['has_install'] ) ? 'Install' : 'Learn More' ); ?>
1428 867 </a>
1429 - <a class="suggestion-dismiss"
1430 - title="<?php echo esc_attr( Loader::$labels['promotions']['woo']['dismiss'] ); ?>"
1431 - href="#"></a>
868 + <a class="suggestion-dismiss" title="Dismiss this suggestion" href="#"></a>
1432 869 </div>
1433 870 </div>
1434 871 <?php endforeach; ?>
1435 872 </div>
@@ -1448,29 +885,25 @@
1448 885 .tisdk-suggestions_options a {
1449 886 display: flex !important;
1450 887 align-items: center;
1451 888 }
1452 -
1453 889 .tisdk-suggestions_options a::before {
1454 890 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;
1455 891 min-width: 13px;
1456 892 max-width: 13px;
893 + margin: auto;
1457 894 }
1458 -
1459 895 .tisdk-suggestions_options.active a::before {
1460 896 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;
1461 897 }
1462 -
1463 898 .tisdk-suggestions-header {
1464 899 padding: 1em 1.5em;
1465 900 border-bottom: 1px solid #eee;
1466 901 }
1467 -
1468 902 .tisdk-suggestions-header h4 {
1469 903 font-size: 1.1em;
1470 904 margin: 0;
1471 905 }
1472 -
1473 906 .tisdk-suggestion {
1474 907 display: flex;
1475 908 align-items: center;
1476 909 flex-direction: row;
@@ -1475,9 +908,8 @@
1475 908 align-items: center;
1476 909 flex-direction: row;
1477 910 padding: 1em 1.5em;
1478 911 }
1479 -
1480 912 .tisdk-suggestion-icon {
1481 913 height: 40px;
1482 914 margin: 0;
1483 915 margin-right: 0px;
@@ -1489,21 +921,17 @@
1489 921 border-radius: 100%;
1490 922 align-items: center;
1491 923 padding: 5px;
1492 924 }
1493 -
1494 925 .tisdk-suggestion-icon svg {
1495 926 fill: #fff;
1496 927 }
1497 -
1498 928 .tisdk-suggestion-content {
1499 929 flex: 1 1 60%;
1500 930 }
1501 -
1502 931 .tisdk-suggestion-content h4 {
1503 932 margin: 0;
1504 933 }
1505 -
1506 934 .tisdk-suggestion-content p {
1507 935 margin: 0;
1508 936 margin-top: 4px;
1509 937 padding: 0;
@@ -1508,15 +936,13 @@
1508 936 margin-top: 4px;
1509 937 padding: 0;
1510 938 line-height: 1.5;
1511 939 }
1512 -
1513 940 .tisdk-suggestion-cta {
1514 941 flex: 1 1 30%;
1515 942 min-width: 160px;
1516 943 text-align: right;
1517 944 }
1518 -
1519 945 .tisdk-suggestion-cta .button {
1520 946 display: inline-block;
1521 947 min-width: 120px;
1522 948 text-align: center;
@@ -1521,9 +947,8 @@
1521 947 min-width: 120px;
1522 948 text-align: center;
1523 949 margin: 0;
1524 950 }
1525 -
1526 951 .tisdk-suggestion-cta .suggestion-dismiss {
1527 952 position: relative;
1528 953 top: 5px;
1529 954 right: auto;
@@ -1539,13 +964,13 @@
1539 964 */
1540 965 public static function render_notice_dismiss_ajax() {
1541 966 ?>
1542 967 <script>
1543 - jQuery(document).ready(function ($) {
968 + jQuery(document).ready(function($) {
1544 969 // AJAX request to update the option value
1545 - $('.tisdk-suggestion .suggestion-dismiss').click(function (e) {
970 + $( '.tisdk-suggestion .suggestion-dismiss' ).click(function(e) {
1546 971 e.preventDefault();
1547 - var suggestion = $(this).closest('.tisdk-suggestion');
972 + var suggestion = $(this).closest( '.tisdk-suggestion' );
1548 973 var value = suggestion.attr('id');
1549 974
1550 975 var nonce = '<?php echo esc_attr( wp_create_nonce( 'tisdk_update_option' ) ); ?>';
1551 976
@@ -1560,13 +985,13 @@
1560 985 complete() {
1561 986 suggestion.remove();
1562 987
1563 988 // If element with .tisdk-suggestions-content has no children, hide the whole panel. Skip if the selector doesn't exist.
1564 - if ($('.tisdk-suggestions-content').length && !$('.tisdk-suggestions-content').children().length) {
1565 - $('.tisdk-suggestions_options').remove();
1566 - $('#tisdk_suggestions').remove();
1567 - $('.general_options').addClass('active');
1568 - $('#general_product_data').css('display', 'block');
989 + if ( $( '.tisdk-suggestions-content' ).length && ! $( '.tisdk-suggestions-content' ).children().length ) {
990 + $( '.tisdk-suggestions_options' ).remove();
991 + $( '#tisdk_suggestions' ).remove();
992 + $( '.general_options' ).addClass( 'active' );
993 + $( '#general_product_data' ).css( 'display', 'block' );
1569 994 }
1570 995 }
1571 996 });
1572 997 });
@@ -1612,271 +1037,6 @@
1612 1037 );
1613 1038
1614 1039 wp_send_json( $response );
1615 1040 wp_die();
1616 - }
1617 -
1618 - /**
1619 - * Check if the user has a support page.
1620 - */
1621 - public function has_support_page() {
1622 - $page_title_matches = $this->get_page_title_keyword_matches();
1623 -
1624 - return 'yes' === $page_title_matches['support'];
1625 - }
1626 -
1627 - /**
1628 - * Check if the user has a donate page.
1629 - */
1630 - public function has_donate_page() {
1631 - $page_title_matches = $this->get_page_title_keyword_matches();
1632 -
1633 - return 'yes' === $page_title_matches['donate'];
1634 - }
1635 -
1636 - /**
1637 - * Check if the tagline or a published page title contains LMS related keywords.
1638 - *
1639 - * @return bool True if LMS-related keywords are found, false otherwise.
1640 - */
1641 - public function has_lms_tagline() {
1642 - $tagline = strtolower( get_bloginfo( 'description' ) );
1643 -
1644 - foreach ( $this->get_lms_keywords() as $keyword ) {
1645 - if ( $this->has_lms_keyword_match( $tagline, $keyword ) ) {
1646 - return true;
1647 - }
1648 - }
1649 -
1650 - return $this->has_lms_page_title();
1651 - }
1652 -
1653 - /**
1654 - * Check if a supported LMS plugin is active.
1655 - *
1656 - * @return bool True if an LMS plugin is active, false otherwise.
1657 - */
1658 - private function has_active_lms_plugin() {
1659 - if ( defined( 'MASTERIYO_VERSION' ) ) {
1660 - return true;
1661 - }
1662 -
1663 - include_once ABSPATH . 'wp-admin/includes/plugin.php';
1664 -
1665 - $lms_plugins = array(
1666 - 'tutor/tutor.php',
1667 - 'sfwd-lms/sfwd_lms.php',
1668 - 'lifterlms/lifterlms.php',
1669 - 'sensei-lms/sensei-lms.php',
1670 - 'learnpress/learnpress.php',
1671 - 'masterstudy-lms-learning-management-system/masterstudy-lms-learning-management-system.php',
1672 - 'learning-management-system/lms.php',
1673 - );
1674 -
1675 - foreach ( $lms_plugins as $plugin ) {
1676 - if ( is_plugin_active( $plugin ) || ( is_multisite() && is_plugin_active_for_network( $plugin ) ) ) {
1677 - return true;
1678 - }
1679 - }
1680 -
1681 - return false;
1682 - }
1683 -
1684 - /**
1685 - * Check if the current request can display a plugin install promo.
1686 - *
1687 - * @return bool True if a plugin install promo can be displayed, false otherwise.
1688 - */
1689 - private function can_check_plugin_install_promo() {
1690 - if ( ! is_admin() || ! current_user_can( 'install_plugins' ) ) {
1691 - return false;
1692 - }
1693 -
1694 - $current_screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
1695 - if ( isset( $current_screen->id ) ) {
1696 - return $current_screen->id === 'plugin-install';
1697 - }
1698 -
1699 - global $pagenow;
1700 -
1701 - return isset( $pagenow ) && $pagenow === 'plugin-install.php';
1702 - }
1703 -
1704 - /**
1705 - * Check if a published page title contains LMS related keywords.
1706 - *
1707 - * @return bool True if an LMS-related page title is found, false otherwise.
1708 - */
1709 - private function has_lms_page_title() {
1710 - $lms_page_title_signal = get_transient( 'tisdk_lms_page_title_signal_v1' );
1711 -
1712 - if ( in_array( $lms_page_title_signal, array( 'yes', 'no' ), true ) ) {
1713 - return 'yes' === $lms_page_title_signal;
1714 - }
1715 -
1716 - $has_lms_page_title = $this->has_published_page_title_with_keywords( $this->get_lms_page_title_keywords() );
1717 -
1718 - set_transient( 'tisdk_lms_page_title_signal_v1', $has_lms_page_title ? 'yes' : 'no', 7 * DAY_IN_SECONDS );
1719 -
1720 - return $has_lms_page_title;
1721 - }
1722 -
1723 - /**
1724 - * Get cached keyword matches for published page titles.
1725 - *
1726 - * @return array Page title keyword matches.
1727 - */
1728 - private function get_page_title_keyword_matches() {
1729 - $default_matches = array(
1730 - 'support' => 'no',
1731 - 'donate' => 'no',
1732 - );
1733 -
1734 - $page_title_matches = get_transient( 'tisdk_page_title_signals_v1' );
1735 -
1736 - if ( is_array( $page_title_matches ) && empty( array_diff_key( $default_matches, $page_title_matches ) ) ) {
1737 - return array_merge( $default_matches, $page_title_matches );
1738 - }
1739 -
1740 - global $wpdb;
1741 -
1742 - $select_clauses = array();
1743 - $query_values = array();
1744 - $page_checks = $this->get_page_title_checks();
1745 -
1746 - foreach ( $page_checks as $match_key => $keywords ) {
1747 - $match_clauses = array();
1748 -
1749 - $query_values[] = 'page';
1750 - $query_values[] = 'publish';
1751 -
1752 - foreach ( $keywords as $keyword ) {
1753 - $match_clauses[] = 'post_title LIKE %s';
1754 - $query_values[] = '%' . $wpdb->esc_like( $keyword ) . '%';
1755 - }
1756 -
1757 - $select_clauses[] = 'EXISTS( SELECT 1 FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s AND ( ' . implode( ' OR ', $match_clauses ) . ' ) LIMIT 1 ) AS has_' . $match_key;
1758 - }
1759 -
1760 - // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1761 - $query = $wpdb->get_row( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1762 - $wpdb->prepare(
1763 - 'SELECT ' . implode( ', ', $select_clauses ),
1764 - $query_values
1765 - ),
1766 - ARRAY_A
1767 - );
1768 - // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1769 -
1770 - $page_title_matches = $default_matches;
1771 -
1772 - if ( is_array( $query ) ) {
1773 - foreach ( array_keys( $page_checks ) as $match_key ) {
1774 - $page_title_matches[ $match_key ] = ! empty( $query[ 'has_' . $match_key ] ) ? 'yes' : 'no';
1775 - }
1776 - }
1777 -
1778 - set_transient( 'tisdk_page_title_signals_v1', $page_title_matches, 7 * DAY_IN_SECONDS );
1779 -
1780 - return $page_title_matches;
1781 - }
1782 -
1783 - /**
1784 - * Check if a keyword matches content.
1785 - *
1786 - * @param string $content Content to check.
1787 - * @param string $keyword Keyword to look for.
1788 - *
1789 - * @return bool True if the keyword matches, false otherwise.
1790 - */
1791 - private function has_lms_keyword_match( $content, $keyword ) {
1792 - if ( in_array( $keyword, array( 'lms', 'course', 'class' ), true ) ) {
1793 - return preg_match( '/(^|[^a-z0-9])' . preg_quote( $keyword, '/' ) . '([^a-z0-9]|$)/', $content ) === 1;
1794 - }
1795 -
1796 - return strpos( $content, $keyword ) !== false;
1797 - }
1798 -
1799 - /**
1800 - * Get LMS related keywords.
1801 - *
1802 - * @return array LMS related keywords.
1803 - */
1804 - private function get_lms_keywords() {
1805 - return array(
1806 - 'lms',
1807 - 'learning',
1808 - 'course',
1809 - 'courses',
1810 - 'academy',
1811 - 'training',
1812 - 'lesson',
1813 - 'lessons',
1814 - 'class',
1815 - 'classes',
1816 - 'student',
1817 - 'students',
1818 - 'teach',
1819 - 'teaching',
1820 - 'tutor',
1821 - 'quiz',
1822 - 'education',
1823 - 'online course',
1824 - 'online courses',
1825 - );
1826 - }
1827 -
1828 - /**
1829 - * Get LMS related keywords for page title matching.
1830 - *
1831 - * @return array LMS related keywords.
1832 - */
1833 - private function get_lms_page_title_keywords() {
1834 - return array_values( array_diff( $this->get_lms_keywords(), array( 'lms', 'course', 'class' ) ) );
1835 - }
1836 -
1837 - /**
1838 - * Check if a published page title contains any of the provided keywords.
1839 - *
1840 - * @param array $keywords Keywords to look for.
1841 - *
1842 - * @return bool True if a matching page title is found, false otherwise.
1843 - */
1844 - private function has_published_page_title_with_keywords( $keywords ) {
1845 - if ( empty( $keywords ) ) {
1846 - return false;
1847 - }
1848 -
1849 - global $wpdb;
1850 -
1851 - $query_values = array( 'page', 'publish' );
1852 - $clauses = array();
1853 -
1854 - foreach ( $keywords as $keyword ) {
1855 - $clauses[] = 'post_title LIKE %s';
1856 - $query_values[] = '%' . $wpdb->esc_like( $keyword ) . '%';
1857 - }
1858 -
1859 - // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1860 - $page_title_match = $wpdb->get_var( //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
1861 - $wpdb->prepare(
1862 - 'SELECT 1 FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s AND ( ' . implode( ' OR ', $clauses ) . ' ) LIMIT 1',
1863 - $query_values
1864 - )
1865 - );
1866 - // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
1867 -
1868 - return ! empty( $page_title_match );
1869 - }
1870 -
1871 - /**
1872 - * Get page title keyword checks.
1873 - *
1874 - * @return array Page title keyword checks.
1875 - */
1876 - private function get_page_title_checks() {
1877 - return array(
1878 - 'support' => array( 'support' ),
1879 - 'donate' => array( 'donate' ),
1880 - );
1881 1041 }
1882 1042 }