PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.10
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 +160 -48 3.10.13.11.10 View file →
@@ -52,8 +52,9 @@
52 52 public function __construct( Visualizer_Plugin $plugin ) {
53 53 parent::__construct( $plugin );
54 54 $this->_addAction( 'load-post.php', 'enqueueMediaScripts' );
55 55 $this->_addAction( 'load-post-new.php', 'enqueueMediaScripts' );
56 + $this->_addAction( 'enqueue_block_editor_assets', 'enqueueMediaScripts' );
56 57 $this->_addAction( 'admin_footer', 'renderTemplates' );
57 58 $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 0 );
58 59 $this->_addAction( 'admin_menu', 'registerAdminMenu' );
59 60 $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
@@ -75,14 +76,45 @@
75 76 $this->_addAction( 'admin_init', 'init' );
76 77
77 78 $this->_addAction( 'visualizer_chart_languages', 'addMultilingualSupport' );
78 79
80 + $this->_addFilter( 'admin_footer_text', 'render_review_notice' );
81 +
82 + if ( ! defined( 'TI_CYPRESS_TESTING' ) ) {
83 + $this->_addFilter( 'themeisle-sdk/survey/' . VISUALIZER_DIRNAME, 'get_survey_metadata', 10, 2 );
84 + }
85 +
79 86 if ( defined( 'TI_CYPRESS_TESTING' ) ) {
80 87 $this->load_cypress_hooks();
81 88 }
82 89
83 90 }
91 + /**
92 + * Display review notice.
93 + */
94 + public function render_review_notice( $footer_text ) {
95 + $current_screen = get_current_screen();
84 96
97 + $visualizer_page_ids = ['toplevel_page_visualizer', 'visualizer_page_viz-support', 'visualizer_page_ti-about-visualizer' ];
98 +
99 + if ( ! empty( $current_screen ) && isset( $current_screen->id ) ) {
100 + foreach ( $visualizer_page_ids as $page_to_check ) {
101 + if ( strpos( $current_screen->id, $page_to_check ) !== false ) {
102 + $footer_text = sprintf(
103 + __( 'Enjoying %1$s? %2$s %3$s rating. Thank you for being so supportive!', 'visualizer' ),
104 + '<b>Visualizer</b>',
105 + esc_html__( 'You can help us by leaving a', 'visualizer' ),
106 + '<a href="https://wordpress.org/support/plugin/visualizer/reviews/" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
107 + );
108 + break;
109 + }
110 + }
111 + }
112 +
113 + return $footer_text;
114 + }
115 +
116 +
85 117 /**
86 118 * Define the hooks that are needed for cypress.
87 119 *
88 120 * @since 3.4.0
@@ -113,23 +145,16 @@
113 145 if ( apply_filters( 'visualizer_is_business', false ) ) {
114 146 return;
115 147 }
116 148
117 - $license = __( 'PRO', 'visualizer' );
118 - if ( Visualizer_Module::is_pro() ) {
119 - switch ( $plan ) {
120 - case 1:
121 - $license = __( 'Developer', 'visualizer' );
122 - break;
123 - }
124 - }
149 + $is_new_personal = apply_filters( 'visualizer_is_new_personal', false );
125 150
126 151 $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' ),
152 + '0.16' => __( '10 minutes', 'visualizer' ),
153 + '1' => __( 'Each hour', 'visualizer' ),
154 + '12' => __( 'Each 12 hours', 'visualizer' ),
155 + '24' => __( 'Each day', 'visualizer' ),
156 + '72' => __( 'Each 3 days', 'visualizer' ),
132 157 );
133 158
134 159 switch ( $feature ) {
135 160 case 'json':
@@ -134,9 +159,9 @@
134 159 switch ( $feature ) {
135 160 case 'json':
136 161 case 'csv':
137 162 // no more schedules if pro is already active.
138 - if ( Visualizer_Module::is_pro() ) {
163 + if ( Visualizer_Module::is_pro() && ! $is_new_personal ) {
139 164 return;
140 165 }
141 166 break;
142 167 case 'wp':
@@ -146,9 +171,9 @@
146 171 default:
147 172 return;
148 173 }
149 174
150 - echo '<optgroup disabled label="' . sprintf( __( 'More in the %s version', 'visualizer' ), $license ) . '">';
175 + echo '<optgroup disabled label="' . __( 'Upgrade required', 'visualizer' ) . '">';
151 176 foreach ( $hours as $hour => $desc ) {
152 177 echo '<option disabled>' . $desc . '</option>';
153 178 }
154 179 echo '</optgroup>';
@@ -309,9 +334,11 @@
309 334 * @access public
310 335 */
311 336 public function enqueueMediaScripts() {
312 337 global $typenow;
313 - if ( post_type_supports( $typenow, 'editor' ) ) {
338 + global $current_screen;
339 +
340 + if ( post_type_supports( $typenow, 'editor' ) || $current_screen->id === 'widgets' || $current_screen->id === 'customize' ) {
314 341 wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION );
315 342
316 343 // Load all the assets for the different libraries we support.
317 344 $deps = array(
@@ -403,14 +430,14 @@
403 430 ),
404 431 'pie' => array(
405 432 'name' => esc_html__( 'Pie/Donut', 'visualizer' ),
406 433 'enabled' => true,
407 - 'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ),
434 + 'supports' => array( 'Google Charts', 'ChartJS' ),
408 435 ),
409 436 'line' => array(
410 437 'name' => esc_html__( 'Line', 'visualizer' ),
411 438 'enabled' => true,
412 - 'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ),
439 + 'supports' => array( 'Google Charts', 'ChartJS' ),
413 440 ),
414 441 'bar' => array(
415 442 'name' => esc_html__( 'Bar', 'visualizer' ),
416 443 'enabled' => true,
@@ -420,18 +447,21 @@
420 447 'name' => esc_html__( 'Area', 'visualizer' ),
421 448 'enabled' => $enabled,
422 449 // in ChartJS, the fill option is used to make Line chart an area: https://www.chartjs.org/docs/latest/charts/area.html
423 450 'supports' => array( 'Google Charts' ),
451 + 'demo_url' => 'https://demo.themeisle.com/visualizer/area-chart/',
424 452 ),
425 453 'geo' => array(
426 454 'name' => esc_html__( 'Geo', 'visualizer' ),
427 455 'enabled' => $enabled,
428 456 'supports' => array( 'Google Charts' ),
457 + 'demo_url' => 'https://demo.themeisle.com/visualizer/geo-chart/',
429 458 ),
430 459 'column' => array(
431 460 'name' => esc_html__( 'Column', 'visualizer' ),
432 461 'enabled' => $enabled,
433 462 'supports' => array( 'Google Charts', 'ChartJS' ),
463 + 'demo_url' => 'https://demo.themeisle.com/visualizer/column-chart/',
434 464 ),
435 465 'bubble' => array(
436 466 'name' => esc_html__( 'Bubble', 'visualizer' ),
437 467 'enabled' => $enabled,
@@ -436,23 +466,27 @@
436 466 'name' => esc_html__( 'Bubble', 'visualizer' ),
437 467 'enabled' => $enabled,
438 468 // 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 469 'supports' => array( 'Google Charts' ),
470 + 'demo_url' => 'https://demo.themeisle.com/visualizer/bubble-chart/',
440 471 ),
441 472 'scatter' => array(
442 473 'name' => esc_html__( 'Scatter', 'visualizer' ),
443 474 'enabled' => $enabled,
444 475 'supports' => array( 'Google Charts' ),
476 + 'demo_url' => 'https://demo.themeisle.com/visualizer/scatter-chart/',
445 477 ),
446 478 'gauge' => array(
447 479 'name' => esc_html__( 'Gauge', 'visualizer' ),
448 480 'enabled' => $enabled,
449 481 'supports' => array( 'Google Charts' ),
482 + 'demo_url' => 'https://demo.themeisle.com/visualizer/gauge-chart/',
450 483 ),
451 484 'candlestick' => array(
452 485 'name' => esc_html__( 'Candlestick', 'visualizer' ),
453 486 'enabled' => $enabled,
454 487 'supports' => array( 'Google Charts' ),
488 + 'demo_url' => 'https://demo.themeisle.com/visualizer/candlestick-chart/',
455 489 ),
456 490 // pro types
457 491 'timeline' => array(
458 492 'name' => esc_html__( 'Timeline', 'visualizer' ),
@@ -457,23 +491,27 @@
457 491 'timeline' => array(
458 492 'name' => esc_html__( 'Timeline', 'visualizer' ),
459 493 'enabled' => false,
460 494 'supports' => array( 'Google Charts', 'ChartJS' ),
495 + 'demo_url' => 'https://demo.themeisle.com/visualizer/timeline-chart/',
461 496 ),
462 497 'combo' => array(
463 498 'name' => esc_html__( 'Combo', 'visualizer' ),
464 499 'enabled' => false,
465 500 'supports' => array( 'Google Charts' ),
501 + 'demo_url' => 'https://demo.themeisle.com/visualizer/combo-chart/',
466 502 ),
467 503 'polarArea' => array(
468 504 'name' => esc_html__( 'Polar Area', 'visualizer' ),
469 505 'enabled' => false,
470 506 'supports' => array( 'ChartJS' ),
507 + 'demo_url' => 'https://demo.themeisle.com/visualizer/polar-area-chart/',
471 508 ),
472 509 'radar' => array(
473 510 'name' => esc_html__( 'Radar/Spider', 'visualizer' ),
474 511 'enabled' => false,
475 512 'supports' => array( 'ChartJS' ),
513 + 'demo_url' => 'https://demo.themeisle.com/visualizer/radar-spider-chart/',
476 514 ),
477 515 )
478 516 );
479 517 $types = apply_filters( 'visualizer_pro_chart_types', $types );
@@ -670,9 +708,9 @@
670 708 Visualizer_Plugin::NAME,
671 709 __( 'Chart Library', 'visualizer' ),
672 710 __( 'Chart Library', 'visualizer' ),
673 711 'edit_posts',
674 - admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME )
712 + 'admin.php?page=' . Visualizer_Plugin::NAME
675 713 );
676 714 add_submenu_page(
677 715 Visualizer_Plugin::NAME,
678 716 __( 'Add New Chart', 'visualizer' ),
@@ -677,9 +715,9 @@
677 715 Visualizer_Plugin::NAME,
678 716 __( 'Add New Chart', 'visualizer' ),
679 717 __( 'Add New Chart', 'visualizer' ),
680 718 'edit_posts',
681 - admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew' )
719 + 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew'
682 720 );
683 721 add_submenu_page(
684 722 Visualizer_Plugin::NAME,
685 723 __( 'Support', 'visualizer' ),
@@ -688,22 +726,12 @@
688 726 'viz-support',
689 727 array( $this, 'renderSupportPage' )
690 728 );
691 729
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 730 remove_submenu_page( Visualizer_Plugin::NAME, Visualizer_Plugin::NAME );
704 731
705 732 add_action( "load-{$this->_libraryPage}", array( $this, 'addScreenOptions' ) );
733 + add_action( 'admin_footer', array( $this, 'handleGetProSubMenu' ) );
706 734 }
707 735
708 736 /**
709 737 * Handle get pro plugin submenu.
@@ -708,35 +736,35 @@
708 736 /**
709 737 * Handle get pro plugin submenu.
710 738 */
711 739 public function handleGetProSubMenu() {
712 - ?>
740 + if ( ! Visualizer_Module::is_pro() ) {
741 + ?>
713 742 <style type="text/css">
714 - #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li {
743 + #toplevel_page_visualizer ul.wp-submenu li:last-child {
715 744 background: #FF7E65;
716 745 font-size: 14px;
717 746 font-weight: 600;
718 747 color: #fff;
719 748 }
720 - #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li > a {
749 + #toplevel_page_visualizer ul.wp-submenu li:last-child > a > span {
721 750 color: #fff !important;
722 751 }
723 - #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li > a:hover {
752 + #toplevel_page_visualizer ul.wp-submenu li:last-child > a:hover {
724 753 box-shadow: inherit;
725 754 }
726 - #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li + li {
727 - display: none;
755 + </style>
756 + <?php
757 + if ( get_option( 'visualizer_fresh_install', false ) ) {
758 + ?>
759 + <style type="text/css">
760 + #toplevel_page_visualizer ul.wp-submenu li.wp-first-item + li + li + li {
761 + display: none;
762 + }
763 + </style>
764 + <?php
728 765 }
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
766 + }
739 767 }
740 768
741 769 /**
742 770 * Adds the screen options for pagination.
@@ -909,8 +937,9 @@
909 937 * @access public
910 938 */
911 939 public function renderSupportPage() {
912 940 wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION );
941 + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' );
913 942 include_once VISUALIZER_ABSPATH . '/templates/support.php';
914 943 }
915 944
916 945 /**
@@ -1007,8 +1036,9 @@
1007 1036 );
1008 1037 }
1009 1038 // enqueue charts array
1010 1039 $ajaxurl = admin_url( 'admin-ajax.php' );
1040 +
1011 1041 wp_localize_script(
1012 1042 'visualizer-library',
1013 1043 'visualizer',
1014 1044 array(
@@ -1045,8 +1075,9 @@
1045 1075 'i10n' => array(
1046 1076 'copied' => __( 'The shortcode has been copied to your clipboard. Hit Ctrl-V/Cmd-V to paste it.', 'visualizer' ),
1047 1077 '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 1078 ),
1079 + 'is_pro_user' => Visualizer_Module::is_pro(),
1049 1080 )
1050 1081 );
1051 1082 // render library page
1052 1083 $render = new Visualizer_Render_Library();
@@ -1062,8 +1093,15 @@
1062 1093 'total' => $query->max_num_pages,
1063 1094 'type' => 'array',
1064 1095 )
1065 1096 );
1097 +
1098 + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );
1099 +
1100 + if ( ! apply_filters( 'visualizer_is_business', false ) ) {
1101 + do_action( 'themeisle_sdk_load_banner', 'visualizer' );
1102 + }
1103 +
1066 1104 $render->render();
1067 1105 }
1068 1106
1069 1107 /**
@@ -1114,9 +1152,9 @@
1114 1152 );
1115 1153 // flattr link
1116 1154 $plugin_meta[] = sprintf(
1117 1155 '<a style="color:red" href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'pluginrow' ) . '" target="_blank">%s</a>',
1118 - esc_html__( 'Pro Addon', 'visualizer' )
1156 + esc_html__( 'Get Visualizer Pro', 'visualizer' )
1119 1157 );
1120 1158 }
1121 1159
1122 1160 return $plugin_meta;
@@ -1190,6 +1228,80 @@
1190 1228 if ( isset( $types[ $type ] ) ) {
1191 1229 return ! empty( $types[ $type ]['enabled'] );
1192 1230 }
1193 1231 return false;
1232 + }
1233 +
1234 + /**
1235 + * Get the survey metadata.
1236 + *
1237 + * @param array $data The data for survey in Formbricks format.
1238 + * @param string $page_slug The slug of the loaded page.
1239 + *
1240 + * @return array The survey metadata.
1241 + */
1242 + public function get_survey_metadata( $data, $page_slug ) {
1243 + $install_date = get_option( 'visualizer_install', time() );
1244 + $install_days_number = intval( ( time() - $install_date ) / DAY_IN_SECONDS );
1245 +
1246 + $license_status = apply_filters( 'product_visualizer_license_status', 'invalid' );
1247 + $license_plan = apply_filters( 'product_visualizer_license_plan', false );
1248 + $license_key = apply_filters( 'product_visualizer_license_key', false );
1249 +
1250 + $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false );
1251 + $plugin_version = '';
1252 +
1253 + if ( ! empty( $plugin_data['Version'] ) ) {
1254 + $plugin_version = $plugin_data['Version'];
1255 + }
1256 +
1257 + $count_charts_cache_key = 'visualizer_count_charts';
1258 + $charts_number = get_transient( $count_charts_cache_key );
1259 +
1260 + if ( false === $charts_number ) {
1261 + $charts_number = $this->count_charts( 100 );
1262 + set_transient( $count_charts_cache_key, $charts_number, 100 === $charts_number ? WEEK_IN_SECONDS : 6 * HOUR_IN_SECONDS );
1263 + } else {
1264 + $charts_number = strval( $charts_number );
1265 + }
1266 +
1267 + $data = array(
1268 + 'environmentId' => 'cltef8cut1s7wyyfxy3rlxzs5',
1269 + 'attributes' => array(
1270 + 'free_version' => $plugin_version,
1271 + 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '',
1272 + 'license_status' => $license_status,
1273 + 'install_days_number' => $install_days_number,
1274 + 'charts_number' => $charts_number,
1275 + ),
1276 + );
1277 +
1278 + if ( ! empty( $license_plan ) ) {
1279 + $data['attributes']['plan'] = $license_plan;
1280 + }
1281 +
1282 + if ( ! empty( $license_key ) ) {
1283 + $data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_key );
1284 + }
1285 +
1286 + return $data;
1287 + }
1288 +
1289 + /**
1290 + * Count the charts.
1291 + *
1292 + * @param int $limit The count limit (optional).
1293 + *
1294 + * @return int The number of charts.
1295 + */
1296 + public function count_charts( $limit = -1 ) {
1297 + $args = array(
1298 + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
1299 + 'post_status' => 'publish',
1300 + 'posts_per_page' => $limit,
1301 + 'fields' => 'ids',
1302 + );
1303 +
1304 + $query = new WP_Query( $args);
1305 + return $query->post_count;
1194 1306 }
1195 1307 }