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 | classes/Visualizer/Module/Admin.php +201 -91 3.10.133.11.14 View file →
@@ -40,8 +40,16 @@
40 40 */
41 41 private $_libraryPage;
42 42
43 43 /**
44 + * Support page suffix.
45 + *
46 + * @access private
47 + * @var string
48 + */
49 + private $_supportPage;
50 +
51 + /**
44 52 * Constructor.
45 53 *
46 54 * @since 1.0.0
47 55 *
@@ -52,10 +60,12 @@
52 60 public function __construct( Visualizer_Plugin $plugin ) {
53 61 parent::__construct( $plugin );
54 62 $this->_addAction( 'load-post.php', 'enqueueMediaScripts' );
55 63 $this->_addAction( 'load-post-new.php', 'enqueueMediaScripts' );
64 + $this->_addAction( 'enqueue_block_editor_assets', 'enqueueMediaScripts' );
56 65 $this->_addAction( 'admin_footer', 'renderTemplates' );
57 66 $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 0 );
67 + $this->_addAction( 'admin_enqueue_scripts', 'enqueue_support_page' );
58 68 $this->_addAction( 'admin_menu', 'registerAdminMenu' );
59 69 $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
60 70 $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
61 71 $this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 );
@@ -60,8 +70,9 @@
60 70 $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
61 71 $this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 );
62 72 $this->_addFilter( 'visualizer_logger_data', 'getLoggerData' );
63 73 $this->_addFilter( 'visualizer_feedback_review_trigger', 'feedbackReviewTrigger' );
74 + $this->_addFilter( 'themeisle_sdk_blackfriday_data', 'add_black_friday_data' );
64 75
65 76 // screen pagination
66 77 $this->_addFilter( 'set-screen-option', 'setScreenOptions', 10, 3 );
67 78
@@ -75,14 +86,46 @@
75 86 $this->_addAction( 'admin_init', 'init' );
76 87
77 88 $this->_addAction( 'visualizer_chart_languages', 'addMultilingualSupport' );
78 89
90 + $this->_addFilter( 'admin_footer_text', 'render_review_notice' );
91 +
92 + if ( ! defined( 'TI_CYPRESS_TESTING' ) ) {
93 + $this->_addFilter( 'themeisle-sdk/survey/' . VISUALIZER_DIRNAME, 'get_survey_metadata', 10, 2 );
94 + }
95 +
79 96 if ( defined( 'TI_CYPRESS_TESTING' ) ) {
80 97 $this->load_cypress_hooks();
81 98 }
82 99
83 100 }
101 + /**
102 + * Display review notice.
103 + */
104 + public function render_review_notice( $footer_text ) {
105 + $current_screen = get_current_screen();
84 106
107 + $visualizer_page_ids = ['toplevel_page_visualizer', 'visualizer_page_viz-support', 'visualizer_page_ti-about-visualizer' ];
108 +
109 + if ( ! empty( $current_screen ) && isset( $current_screen->id ) ) {
110 + foreach ( $visualizer_page_ids as $page_to_check ) {
111 + if ( strpos( $current_screen->id, $page_to_check ) !== false ) {
112 + $footer_text = sprintf(
113 + // translators: %1$s - the name of the plugin (Visualizer), %2$s - message (You can help us by leaving a), %3$s - HTML entity code.
114 + __( 'Enjoying %1$s? %2$s %3$s rating. Thank you for being so supportive!', 'visualizer' ),
115 + '<b>Visualizer</b>',
116 + esc_html__( 'You can help us by leaving a', 'visualizer' ),
117 + '<a href="https://wordpress.org/support/plugin/visualizer/reviews/" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
118 + );
119 + break;
120 + }
121 + }
122 + }
123 +
124 + return $footer_text;
125 + }
126 +
127 +
85 128 /**
86 129 * Define the hooks that are needed for cypress.
87 130 *
88 131 * @since 3.4.0
@@ -113,23 +156,16 @@
113 156 if ( apply_filters( 'visualizer_is_business', false ) ) {
114 157 return;
115 158 }
116 159
117 - $license = __( 'PRO', 'visualizer' );
118 - if ( Visualizer_Module::is_pro() ) {
119 - switch ( $plan ) {
120 - case 1:
121 - $license = __( 'Developer', 'visualizer' );
122 - break;
123 - }
124 - }
160 + $is_new_personal = apply_filters( 'visualizer_is_new_personal', false );
125 161
126 162 $hours = array(
127 - '0' => __( 'Live', 'visualizer' ),
128 - '1' => __( 'Each hour', 'visualizer' ),
129 - '12' => __( 'Each 12 hours', 'visualizer' ),
130 - '24' => __( 'Each day', 'visualizer' ),
131 - '72' => __( 'Each 3 days', 'visualizer' ),
163 + '0.16' => __( '10 minutes', 'visualizer' ),
164 + '1' => __( 'Each hour', 'visualizer' ),
165 + '12' => __( 'Each 12 hours', 'visualizer' ),
166 + '24' => __( 'Each day', 'visualizer' ),
167 + '72' => __( 'Each 3 days', 'visualizer' ),
132 168 );
133 169
134 170 switch ( $feature ) {
135 171 case 'json':
@@ -134,9 +170,9 @@
134 170 switch ( $feature ) {
135 171 case 'json':
136 172 case 'csv':
137 173 // no more schedules if pro is already active.
138 - if ( Visualizer_Module::is_pro() ) {
174 + if ( Visualizer_Module::is_pro() && ! $is_new_personal ) {
139 175 return;
140 176 }
141 177 break;
142 178 case 'wp':
@@ -146,9 +182,9 @@
146 182 default:
147 183 return;
148 184 }
149 185
150 - echo '<optgroup disabled label="' . sprintf( __( 'More in the %s version', 'visualizer' ), $license ) . '">';
186 + echo '<optgroup disabled label="' . __( 'Upgrade required', 'visualizer' ) . '">';
151 187 foreach ( $hours as $hour => $desc ) {
152 188 echo '<option disabled>' . $desc . '</option>';
153 189 }
154 190 echo '</optgroup>';
@@ -309,9 +345,11 @@
309 345 * @access public
310 346 */
311 347 public function enqueueMediaScripts() {
312 348 global $typenow;
313 - if ( post_type_supports( $typenow, 'editor' ) ) {
349 + global $current_screen;
350 +
351 + if ( post_type_supports( $typenow, 'editor' ) || $current_screen->id === 'widgets' || $current_screen->id === 'customize' ) {
314 352 wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION );
315 353
316 354 // Load all the assets for the different libraries we support.
317 355 $deps = array(
@@ -403,14 +441,14 @@
403 441 ),
404 442 'pie' => array(
405 443 'name' => esc_html__( 'Pie/Donut', 'visualizer' ),
406 444 'enabled' => true,
407 - 'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ),
445 + 'supports' => array( 'Google Charts', 'ChartJS' ),
408 446 ),
409 447 'line' => array(
410 448 'name' => esc_html__( 'Line', 'visualizer' ),
411 449 'enabled' => true,
412 - 'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ),
450 + 'supports' => array( 'Google Charts', 'ChartJS' ),
413 451 ),
414 452 'bar' => array(
415 453 'name' => esc_html__( 'Bar', 'visualizer' ),
416 454 'enabled' => true,
@@ -420,18 +458,21 @@
420 458 'name' => esc_html__( 'Area', 'visualizer' ),
421 459 'enabled' => $enabled,
422 460 // in ChartJS, the fill option is used to make Line chart an area: https://www.chartjs.org/docs/latest/charts/area.html
423 461 'supports' => array( 'Google Charts' ),
462 + 'demo_url' => 'https://demo.themeisle.com/visualizer/area-chart/',
424 463 ),
425 464 'geo' => array(
426 465 'name' => esc_html__( 'Geo', 'visualizer' ),
427 466 'enabled' => $enabled,
428 467 'supports' => array( 'Google Charts' ),
468 + 'demo_url' => 'https://demo.themeisle.com/visualizer/geo-chart/',
429 469 ),
430 470 'column' => array(
431 471 'name' => esc_html__( 'Column', 'visualizer' ),
432 472 'enabled' => $enabled,
433 473 'supports' => array( 'Google Charts', 'ChartJS' ),
474 + 'demo_url' => 'https://demo.themeisle.com/visualizer/column-chart/',
434 475 ),
435 476 'bubble' => array(
436 477 'name' => esc_html__( 'Bubble', 'visualizer' ),
437 478 'enabled' => $enabled,
@@ -436,23 +477,27 @@
436 477 'name' => esc_html__( 'Bubble', 'visualizer' ),
437 478 'enabled' => $enabled,
438 479 // chartjs' bubble is ugly looking (and it won't work off the default bubble.csv) so it is being excluded for the time being.
439 480 'supports' => array( 'Google Charts' ),
481 + 'demo_url' => 'https://demo.themeisle.com/visualizer/bubble-chart/',
440 482 ),
441 483 'scatter' => array(
442 484 'name' => esc_html__( 'Scatter', 'visualizer' ),
443 485 'enabled' => $enabled,
444 486 'supports' => array( 'Google Charts' ),
487 + 'demo_url' => 'https://demo.themeisle.com/visualizer/scatter-chart/',
445 488 ),
446 489 'gauge' => array(
447 490 'name' => esc_html__( 'Gauge', 'visualizer' ),
448 491 'enabled' => $enabled,
449 492 'supports' => array( 'Google Charts' ),
493 + 'demo_url' => 'https://demo.themeisle.com/visualizer/gauge-chart/',
450 494 ),
451 495 'candlestick' => array(
452 496 'name' => esc_html__( 'Candlestick', 'visualizer' ),
453 497 'enabled' => $enabled,
454 498 'supports' => array( 'Google Charts' ),
499 + 'demo_url' => 'https://demo.themeisle.com/visualizer/candlestick-chart/',
455 500 ),
456 501 // pro types
457 502 'timeline' => array(
458 503 'name' => esc_html__( 'Timeline', 'visualizer' ),
@@ -457,23 +502,27 @@
457 502 'timeline' => array(
458 503 'name' => esc_html__( 'Timeline', 'visualizer' ),
459 504 'enabled' => false,
460 505 'supports' => array( 'Google Charts', 'ChartJS' ),
506 + 'demo_url' => 'https://demo.themeisle.com/visualizer/timeline-chart/',
461 507 ),
462 508 'combo' => array(
463 509 'name' => esc_html__( 'Combo', 'visualizer' ),
464 510 'enabled' => false,
465 511 'supports' => array( 'Google Charts' ),
512 + 'demo_url' => 'https://demo.themeisle.com/visualizer/combo-chart/',
466 513 ),
467 514 'polarArea' => array(
468 515 'name' => esc_html__( 'Polar Area', 'visualizer' ),
469 516 'enabled' => false,
470 517 'supports' => array( 'ChartJS' ),
518 + 'demo_url' => 'https://demo.themeisle.com/visualizer/polar-area-chart/',
471 519 ),
472 520 'radar' => array(
473 521 'name' => esc_html__( 'Radar/Spider', 'visualizer' ),
474 522 'enabled' => false,
475 523 'supports' => array( 'ChartJS' ),
524 + 'demo_url' => 'https://demo.themeisle.com/visualizer/radar-spider-chart/',
476 525 ),
477 526 )
478 527 );
479 528 $types = apply_filters( 'visualizer_pro_chart_types', $types );
@@ -600,42 +649,58 @@
600 649 *
601 650 * @param string $suffix The current page suffix.
602 651 */
603 652 public function enqueueLibraryScripts( $suffix ) {
604 - if ( $suffix === $this->_libraryPage ) {
605 - wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
606 - $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
607 - wp_enqueue_media();
653 + if ( $suffix !== $this->_libraryPage ) {
654 + return;
655 + }
656 +
657 + wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
658 + $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
659 + wp_enqueue_media();
660 + wp_enqueue_script(
661 + 'visualizer-library',
662 + VISUALIZER_ABSURL . 'js/library.js',
663 + array(
664 + 'jquery',
665 + 'media-views',
666 + 'clipboard',
667 + ),
668 + Visualizer_Plugin::VERSION,
669 + true
670 + );
671 +
672 + wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
673 +
674 + $query = $this->getQuery();
675 + while ( $query->have_posts() ) {
676 + $chart = $query->next_post();
677 + $library = $this->load_chart_type( $chart->ID );
678 + if ( is_null( $library ) ) {
679 + continue;
680 + }
608 681 wp_enqueue_script(
609 - 'visualizer-library',
610 - VISUALIZER_ABSURL . 'js/library.js',
611 - array(
612 - 'jquery',
613 - 'media-views',
614 - 'clipboard',
615 - ),
682 + "visualizer-render-$library",
683 + VISUALIZER_ABSURL . 'js/render-facade.js',
684 + apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
616 685 Visualizer_Plugin::VERSION,
617 686 true
618 687 );
688 + }
619 689
620 - wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
690 + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );
691 + }
621 692
622 - $query = $this->getQuery();
623 - while ( $query->have_posts() ) {
624 - $chart = $query->next_post();
625 - $library = $this->load_chart_type( $chart->ID );
626 - if ( is_null( $library ) ) {
627 - continue;
628 - }
629 - wp_enqueue_script(
630 - "visualizer-render-$library",
631 - VISUALIZER_ABSURL . 'js/render-facade.js',
632 - apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
633 - Visualizer_Plugin::VERSION,
634 - true
635 - );
636 - }
693 + /**
694 + * Enqueue script for support page.
695 + *
696 + * @param string $hook_suffix Current hook.
697 + */
698 + public function enqueue_support_page( $hook_suffix ) {
699 + if ( $this->_supportPage !== $hook_suffix ) {
700 + return;
637 701 }
702 + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' );
638 703 }
639 704
640 705 /**
641 706 * Adds visualizer tab for media upload tabs array.
@@ -679,9 +744,10 @@
679 744 __( 'Add New Chart', 'visualizer' ),
680 745 'edit_posts',
681 746 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew'
682 747 );
683 - add_submenu_page(
748 +
749 + $this->_supportPage = add_submenu_page(
684 750 Visualizer_Plugin::NAME,
685 751 __( 'Support', 'visualizer' ),
686 752 __( 'Support', 'visualizer' ) . '<span class="dashicons dashicons-editor-help more-features-icon" style="width: 17px; height: 17px; margin-left: 4px; color: #ffca54; font-size: 17px; vertical-align: -3px;"></span>',
687 753 'edit_posts',
@@ -707,9 +773,9 @@
707 773 font-size: 14px;
708 774 font-weight: 600;
709 775 color: #fff;
710 776 }
711 - #toplevel_page_visualizer ul.wp-submenu li:last-child > a {
777 + #toplevel_page_visualizer ul.wp-submenu li:last-child > a > span {
712 778 color: #fff !important;
713 779 }
714 780 #toplevel_page_visualizer ul.wp-submenu li:last-child > a:hover {
715 781 box-shadow: inherit;
@@ -899,9 +965,8 @@
899 965 * @access public
900 966 */
901 967 public function renderSupportPage() {
902 968 wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION );
903 - $this->load_survey();
904 969 include_once VISUALIZER_ABSPATH . '/templates/support.php';
905 970 }
906 971
907 972 /**
@@ -998,8 +1063,9 @@
998 1063 );
999 1064 }
1000 1065 // enqueue charts array
1001 1066 $ajaxurl = admin_url( 'admin-ajax.php' );
1067 +
1002 1068 wp_localize_script(
1003 1069 'visualizer-library',
1004 1070 'visualizer',
1005 1071 array(
@@ -1036,8 +1102,9 @@
1036 1102 'i10n' => array(
1037 1103 'copied' => __( 'The shortcode has been copied to your clipboard. Hit Ctrl-V/Cmd-V to paste it.', 'visualizer' ),
1038 1104 'conflict' => __( 'We have detected a potential conflict with another component that prevents Visualizer from functioning properly. Please disable any of the following components if they are activated on your instance: Modern Events Calendar plugin, Acronix plugin. In case the aforementioned components are not activated or you continue to see this error message, please disable all other plugins and enable them one by one to find out the component that is causing the conflict.', 'visualizer' ),
1039 1105 ),
1106 + 'is_pro_user' => Visualizer_Module::is_pro(),
1040 1107 )
1041 1108 );
1042 1109 // render library page
1043 1110 $render = new Visualizer_Render_Library();
@@ -1054,10 +1121,8 @@
1054 1121 'type' => 'array',
1055 1122 )
1056 1123 );
1057 1124
1058 - $this->load_survey();
1059 -
1060 1125 $render->render();
1061 1126 }
1062 1127
1063 1128 /**
@@ -1108,9 +1173,9 @@
1108 1173 );
1109 1174 // flattr link
1110 1175 $plugin_meta[] = sprintf(
1111 1176 '<a style="color:red" href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'pluginrow' ) . '" target="_blank">%s</a>',
1112 - esc_html__( 'Pro Addon', 'visualizer' )
1177 + esc_html__( 'Get Visualizer Pro', 'visualizer' )
1113 1178 );
1114 1179 }
1115 1180
1116 1181 return $plugin_meta;
@@ -1189,72 +1254,117 @@
1189 1254
1190 1255 /**
1191 1256 * Get the survey metadata.
1192 1257 *
1258 + * @param array $data The data for survey in Formbricks format.
1259 + * @param string $page_slug The slug of the loaded page.
1260 + *
1193 1261 * @return array The survey metadata.
1194 1262 */
1195 - private function get_survey_metadata() {
1196 - $install_date = get_option( 'visualizer_install', false );
1197 - $install_category = 0;
1263 + public function get_survey_metadata( $data, $page_slug ) {
1264 + $install_date = get_option( 'visualizer_install', time() );
1265 + $install_days_number = intval( ( time() - $install_date ) / DAY_IN_SECONDS );
1198 1266
1199 - if ( false !== $install_date ) {
1200 - $days_since_install = round( ( time() - $install_date ) / DAY_IN_SECONDS );
1267 + $license_status = apply_filters( 'product_visualizer_license_status', 'invalid' );
1268 + $license_plan = apply_filters( 'product_visualizer_license_plan', false );
1269 + $license_key = apply_filters( 'product_visualizer_license_key', false );
1201 1270
1202 - if ( 0 === $days_since_install || 1 === $days_since_install ) {
1203 - $install_category = 0;
1204 - } elseif ( 1 < $days_since_install && 8 > $days_since_install ) {
1205 - $install_category = 7;
1206 - } elseif ( 8 <= $days_since_install && 31 > $days_since_install ) {
1207 - $install_category = 30;
1208 - } elseif ( 30 < $days_since_install && 90 > $days_since_install ) {
1209 - $install_category = 90;
1210 - } elseif ( 90 <= $days_since_install ) {
1211 - $install_category = 91;
1212 - }
1213 - }
1214 -
1215 1271 $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false );
1216 1272 $plugin_version = '';
1273 +
1217 1274 if ( ! empty( $plugin_data['Version'] ) ) {
1218 1275 $plugin_version = $plugin_data['Version'];
1219 1276 }
1220 1277
1221 - $user_id = 'visualizer_' . preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID.
1278 + $count_charts_cache_key = 'visualizer_count_charts';
1279 + $charts_number = get_transient( $count_charts_cache_key );
1222 1280
1223 - $license_data = get_option( 'visualizer_pro_license_data', false );
1224 - if ( false !== $license_data ) {
1225 - $user_id = 'visualizer_' . $license_data->key;
1281 + if ( false === $charts_number ) {
1282 + $charts_number = $this->count_charts( 100 );
1283 + set_transient( $count_charts_cache_key, $charts_number, 100 === $charts_number ? WEEK_IN_SECONDS : 6 * HOUR_IN_SECONDS );
1284 + } else {
1285 + $charts_number = strval( $charts_number );
1226 1286 }
1227 1287
1228 - return array(
1229 - 'userId' => $user_id,
1288 + $data = array(
1289 + 'environmentId' => 'cltef8cut1s7wyyfxy3rlxzs5',
1230 1290 'attributes' => array(
1231 - 'days_since_install' => $install_category,
1232 - 'free_version' => $plugin_version,
1233 - 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '',
1234 - 'license_status' => apply_filters( 'product_visualizer_license_status', 'invalid' ),
1291 + 'free_version' => $plugin_version,
1292 + 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '',
1293 + 'license_status' => $license_status,
1294 + 'install_days_number' => $install_days_number,
1295 + 'charts_number' => $charts_number,
1235 1296 ),
1236 1297 );
1298 +
1299 + if ( ! empty( $license_plan ) ) {
1300 + $data['attributes']['plan'] = $license_plan;
1301 + }
1302 +
1303 + if ( ! empty( $license_key ) ) {
1304 + $data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_key );
1305 + }
1306 +
1307 + return $data;
1237 1308 }
1238 1309
1239 1310 /**
1240 - * Load the survey.
1311 + * Count the charts.
1312 + *
1313 + * @param int $limit The count limit (optional).
1314 + *
1315 + * @return int The number of charts.
1241 1316 */
1242 - private function load_survey() {
1317 + public function count_charts( $limit = -1 ) {
1318 + $args = array(
1319 + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
1320 + 'post_status' => 'publish',
1321 + 'posts_per_page' => $limit,
1322 + 'fields' => 'ids',
1323 + );
1243 1324
1244 - if ( defined( 'TI_CYPRESS_TESTING' ) ) {
1245 - return;
1325 + $query = new WP_Query( $args);
1326 + return $query->post_count;
1327 + }
1328 +
1329 + /**
1330 + * Set the black friday data.
1331 + *
1332 + * @param array $configs The configuration array for the loaded products.
1333 + * @return array
1334 + */
1335 + public function add_black_friday_data( $configs ) {
1336 + $config = $configs['default'];
1337 +
1338 + // translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
1339 + $message_template = __( 'Our biggest sale of the year: %1$sup to %2$s OFF%3$s on %4$s. Don\'t miss this limited-time offer.', 'visualizer' );
1340 + $product_label = 'Visualizer';
1341 + $discount = '70%';
1342 +
1343 + $plan = apply_filters( 'product_visualizer_license_plan', 0 );
1344 + $license = apply_filters( 'product_visualizer_license_key', false );
1345 + $is_pro = 0 < $plan;
1346 +
1347 + if ( $is_pro ) {
1348 + // translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
1349 + $message_template = __( 'Get %1$sup to %2$s off%3$s when you upgrade your %4$s plan or renew early.', 'visualizer' );
1350 + $product_label = 'Visualizer Pro';
1351 + $discount = '30%';
1246 1352 }
1247 1353
1248 - $survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' );
1354 + $product_label = sprintf( '<strong>%s</strong>', $product_label );
1355 + $url_params = array(
1356 + 'utm_term' => $is_pro ? 'plan-' . $plan : 'free',
1357 + 'lkey' => ! empty( $license ) ? $license : false,
1358 + );
1249 1359
1250 - if ( empty( $survey_handler ) ) {
1251 - return;
1252 - }
1360 + $config['message'] = sprintf( $message_template, '<strong>', $discount, '</strong>', $product_label );
1361 + $config['sale_url'] = add_query_arg(
1362 + $url_params,
1363 + tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/vizualizer-bf', 'bfcm', 'visualizer' ) )
1364 + );
1253 1365
1254 - $metadata = $this->get_survey_metadata();
1366 + $configs[ VISUALIZER_DIRNAME ] = $config;
1255 1367
1256 - do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' );
1257 - wp_enqueue_script( 'visualizer_chart_survey', VISUALIZER_ABSURL . 'js/survey.js', array( $survey_handler ), $metadata['attributes']['free_version'], true );
1258 - wp_localize_script( 'visualizer_chart_survey', 'visualizerSurveyData', $metadata );
1368 + return $configs;
1259 1369 }
1260 1370 }