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 +251 -76 3.10.03.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.
@@ -670,9 +735,9 @@
670 735 Visualizer_Plugin::NAME,
671 736 __( 'Chart Library', 'visualizer' ),
672 737 __( 'Chart Library', 'visualizer' ),
673 738 'edit_posts',
674 - admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME )
739 + 'admin.php?page=' . Visualizer_Plugin::NAME
675 740 );
676 741 add_submenu_page(
677 742 Visualizer_Plugin::NAME,
678 743 __( 'Add New Chart', 'visualizer' ),
@@ -677,11 +742,12 @@
677 742 Visualizer_Plugin::NAME,
678 743 __( 'Add New Chart', 'visualizer' ),
679 744 __( 'Add New Chart', 'visualizer' ),
680 745 'edit_posts',
681 - admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew' )
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',
@@ -688,22 +754,12 @@
688 754 'viz-support',
689 755 array( $this, 'renderSupportPage' )
690 756 );
691 757
692 - if ( ! Visualizer_Module::is_pro() ) {
693 - add_submenu_page(
694 - Visualizer_Plugin::NAME,
695 - __( 'Get Visualizer Pro', 'visualizer' ),
696 - __( 'Get Visualizer Pro', 'visualizer' ),
697 - 'edit_posts',
698 - 'viz-get-pro',
699 - '__return_null'
700 - );
701 - add_action( 'admin_footer', array( $this, 'handleGetProSubMenu' ) );
702 - }
703 758 remove_submenu_page( Visualizer_Plugin::NAME, Visualizer_Plugin::NAME );
704 759
705 760 add_action( "load-{$this->_libraryPage}", array( $this, 'addScreenOptions' ) );
761 + add_action( 'admin_footer', array( $this, 'handleGetProSubMenu' ) );
706 762 }
707 763
708 764 /**
709 765 * Handle get pro plugin submenu.
@@ -708,35 +764,35 @@
708 764 /**
709 765 * Handle get pro plugin submenu.
710 766 */
711 767 public function handleGetProSubMenu() {
712 - ?>
768 + if ( ! Visualizer_Module::is_pro() ) {
769 + ?>
713 770 <style type="text/css">
714 - #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li {
771 + #toplevel_page_visualizer ul.wp-submenu li:last-child {
715 772 background: #FF7E65;
716 773 font-size: 14px;
717 774 font-weight: 600;
718 775 color: #fff;
719 776 }
720 - #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li > a {
777 + #toplevel_page_visualizer ul.wp-submenu li:last-child > a > span {
721 778 color: #fff !important;
722 779 }
723 - #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li > a:hover {
780 + #toplevel_page_visualizer ul.wp-submenu li:last-child > a:hover {
724 781 box-shadow: inherit;
725 782 }
726 - #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li + li {
727 - display: none;
783 + </style>
784 + <?php
785 + if ( get_option( 'visualizer_fresh_install', false ) ) {
786 + ?>
787 + <style type="text/css">
788 + #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li {
789 + display: none;
790 + }
791 + </style>
792 + <?php
728 793 }
729 - </style>
730 - <script type="text/javascript">
731 - jQuery( document ).ready( function() {
732 - jQuery( '#toplevel_page_visualizer' ).on( 'click', 'li:not(.wp-submenu-head, .wp-first-item):eq(2)', function( e ) {
733 - e.preventDefault();
734 - window.open( '<?php echo tsdk_utmify( 'https://themeisle.com/plugins/visualizer-charts-and-graphs/upgrade/', 'toplevel' ); ?>', '_blank' );
735 - } );
736 - } );
737 - </script>
738 - <?php
794 + }
739 795 }
740 796
741 797 /**
742 798 * Adds the screen options for pagination.
@@ -1007,8 +1063,9 @@
1007 1063 );
1008 1064 }
1009 1065 // enqueue charts array
1010 1066 $ajaxurl = admin_url( 'admin-ajax.php' );
1067 +
1011 1068 wp_localize_script(
1012 1069 'visualizer-library',
1013 1070 'visualizer',
1014 1071 array(
@@ -1045,8 +1102,9 @@
1045 1102 'i10n' => array(
1046 1103 'copied' => __( 'The shortcode has been copied to your clipboard. Hit Ctrl-V/Cmd-V to paste it.', 'visualizer' ),
1047 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' ),
1048 1105 ),
1106 + 'is_pro_user' => Visualizer_Module::is_pro(),
1049 1107 )
1050 1108 );
1051 1109 // render library page
1052 1110 $render = new Visualizer_Render_Library();
@@ -1062,8 +1120,9 @@
1062 1120 'total' => $query->max_num_pages,
1063 1121 'type' => 'array',
1064 1122 )
1065 1123 );
1124 +
1066 1125 $render->render();
1067 1126 }
1068 1127
1069 1128 /**
@@ -1114,9 +1173,9 @@
1114 1173 );
1115 1174 // flattr link
1116 1175 $plugin_meta[] = sprintf(
1117 1176 '<a style="color:red" href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'pluginrow' ) . '" target="_blank">%s</a>',
1118 - esc_html__( 'Pro Addon', 'visualizer' )
1177 + esc_html__( 'Get Visualizer Pro', 'visualizer' )
1119 1178 );
1120 1179 }
1121 1180
1122 1181 return $plugin_meta;
@@ -1190,6 +1249,122 @@
1190 1249 if ( isset( $types[ $type ] ) ) {
1191 1250 return ! empty( $types[ $type ]['enabled'] );
1192 1251 }
1193 1252 return false;
1253 + }
1254 +
1255 + /**
1256 + * Get the survey metadata.
1257 + *
1258 + * @param array $data The data for survey in Formbricks format.
1259 + * @param string $page_slug The slug of the loaded page.
1260 + *
1261 + * @return array The survey metadata.
1262 + */
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 );
1266 +
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 );
1270 +
1271 + $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false );
1272 + $plugin_version = '';
1273 +
1274 + if ( ! empty( $plugin_data['Version'] ) ) {
1275 + $plugin_version = $plugin_data['Version'];
1276 + }
1277 +
1278 + $count_charts_cache_key = 'visualizer_count_charts';
1279 + $charts_number = get_transient( $count_charts_cache_key );
1280 +
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 );
1286 + }
1287 +
1288 + $data = array(
1289 + 'environmentId' => 'cltef8cut1s7wyyfxy3rlxzs5',
1290 + 'attributes' => array(
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,
1296 + ),
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;
1308 + }
1309 +
1310 + /**
1311 + * Count the charts.
1312 + *
1313 + * @param int $limit The count limit (optional).
1314 + *
1315 + * @return int The number of charts.
1316 + */
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 + );
1324 +
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%';
1352 + }
1353 +
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 + );
1359 +
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 + );
1365 +
1366 + $configs[ VISUALIZER_DIRNAME ] = $config;
1367 +
1368 + return $configs;
1194 1369 }
1195 1370 }