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 +113 -66 3.10.123.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 );
@@ -707,9 +745,9 @@
707 745 font-size: 14px;
708 746 font-weight: 600;
709 747 color: #fff;
710 748 }
711 - #toplevel_page_visualizer ul.wp-submenu li:last-child > a {
749 + #toplevel_page_visualizer ul.wp-submenu li:last-child > a > span {
712 750 color: #fff !important;
713 751 }
714 752 #toplevel_page_visualizer ul.wp-submenu li:last-child > a:hover {
715 753 box-shadow: inherit;
@@ -899,9 +937,9 @@
899 937 * @access public
900 938 */
901 939 public function renderSupportPage() {
902 940 wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION );
903 - $this->load_survey();
941 + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' );
904 942 include_once VISUALIZER_ABSPATH . '/templates/support.php';
905 943 }
906 944
907 945 /**
@@ -998,8 +1036,9 @@
998 1036 );
999 1037 }
1000 1038 // enqueue charts array
1001 1039 $ajaxurl = admin_url( 'admin-ajax.php' );
1040 +
1002 1041 wp_localize_script(
1003 1042 'visualizer-library',
1004 1043 'visualizer',
1005 1044 array(
@@ -1036,8 +1075,9 @@
1036 1075 'i10n' => array(
1037 1076 'copied' => __( 'The shortcode has been copied to your clipboard. Hit Ctrl-V/Cmd-V to paste it.', 'visualizer' ),
1038 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' ),
1039 1078 ),
1079 + 'is_pro_user' => Visualizer_Module::is_pro(),
1040 1080 )
1041 1081 );
1042 1082 // render library page
1043 1083 $render = new Visualizer_Render_Library();
@@ -1054,10 +1094,14 @@
1054 1094 'type' => 'array',
1055 1095 )
1056 1096 );
1057 1097
1058 - $this->load_survey();
1098 + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );
1059 1099
1100 + if ( ! apply_filters( 'visualizer_is_business', false ) ) {
1101 + do_action( 'themeisle_sdk_load_banner', 'visualizer' );
1102 + }
1103 +
1060 1104 $render->render();
1061 1105 }
1062 1106
1063 1107 /**
@@ -1108,9 +1152,9 @@
1108 1152 );
1109 1153 // flattr link
1110 1154 $plugin_meta[] = sprintf(
1111 1155 '<a style="color:red" href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'pluginrow' ) . '" target="_blank">%s</a>',
1112 - esc_html__( 'Pro Addon', 'visualizer' )
1156 + esc_html__( 'Get Visualizer Pro', 'visualizer' )
1113 1157 );
1114 1158 }
1115 1159
1116 1160 return $plugin_meta;
@@ -1189,72 +1233,75 @@
1189 1233
1190 1234 /**
1191 1235 * Get the survey metadata.
1192 1236 *
1237 + * @param array $data The data for survey in Formbricks format.
1238 + * @param string $page_slug The slug of the loaded page.
1239 + *
1193 1240 * @return array The survey metadata.
1194 1241 */
1195 - private function get_survey_metadata() {
1196 - $install_date = get_option( 'visualizer_install', false );
1197 - $install_category = 0;
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 );
1198 1245
1199 - if ( false !== $install_date ) {
1200 - $days_since_install = round( ( time() - $install_date ) / DAY_IN_SECONDS );
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 );
1201 1249
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 1250 $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false );
1216 1251 $plugin_version = '';
1252 +
1217 1253 if ( ! empty( $plugin_data['Version'] ) ) {
1218 1254 $plugin_version = $plugin_data['Version'];
1219 1255 }
1220 1256
1221 - $user_id = 'visualizer_' . preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID.
1257 + $count_charts_cache_key = 'visualizer_count_charts';
1258 + $charts_number = get_transient( $count_charts_cache_key );
1222 1259
1223 - $license_data = get_option( 'visualizer_pro_license_data', false );
1224 - if ( false !== $license_data ) {
1225 - $user_id = 'visualizer_' . $license_data->key;
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 );
1226 1265 }
1227 1266
1228 - return array(
1229 - 'userId' => $user_id,
1267 + $data = array(
1268 + 'environmentId' => 'cltef8cut1s7wyyfxy3rlxzs5',
1230 1269 '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' ),
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,
1235 1275 ),
1236 1276 );
1237 - }
1238 1277
1239 - /**
1240 - * Load the survey.
1241 - */
1242 - private function load_survey() {
1278 + if ( ! empty( $license_plan ) ) {
1279 + $data['attributes']['plan'] = $license_plan;
1280 + }
1243 1281
1244 - if ( defined( 'TI_CYPRESS_TESTING' ) ) {
1245 - return;
1282 + if ( ! empty( $license_key ) ) {
1283 + $data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_key );
1246 1284 }
1247 1285
1248 - $survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' );
1286 + return $data;
1287 + }
1249 1288
1250 - if ( empty( $survey_handler ) ) {
1251 - return;
1252 - }
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 + );
1253 1303
1254 - $metadata = $this->get_survey_metadata();
1255 -
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 );
1304 + $query = new WP_Query( $args);
1305 + return $query->post_count;
1259 1306 }
1260 1307 }