PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.4
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 +120 -20 3.10.23.11.4 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,41 @@
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 +
79 82 if ( defined( 'TI_CYPRESS_TESTING' ) ) {
80 83 $this->load_cypress_hooks();
81 84 }
82 85
83 86 }
87 + /**
88 + * Display review notice.
89 + */
90 + public function render_review_notice( $footer_text ) {
91 + $current_screen = get_current_screen();
84 92
93 + $visualizer_page_ids = ['toplevel_page_visualizer', 'visualizer_page_viz-support', 'visualizer_page_ti-about-visualizer' ];
94 +
95 + if ( ! empty( $current_screen ) && isset( $current_screen->id ) ) {
96 + foreach ( $visualizer_page_ids as $page_to_check ) {
97 + if ( strpos( $current_screen->id, $page_to_check ) !== false ) {
98 + $footer_text = sprintf(
99 + __( 'Enjoying %1$s? %2$s %3$s rating. Thank you for being so supportive!', 'visualizer' ),
100 + '<b>Visualizer</b>',
101 + esc_html__( 'You can help us by leaving a', 'visualizer' ),
102 + '<a href="https://wordpress.org/support/plugin/visualizer/reviews/" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
103 + );
104 + break;
105 + }
106 + }
107 + }
108 +
109 + return $footer_text;
110 + }
111 +
112 +
85 113 /**
86 114 * Define the hooks that are needed for cypress.
87 115 *
88 116 * @since 3.4.0
@@ -113,23 +141,16 @@
113 141 if ( apply_filters( 'visualizer_is_business', false ) ) {
114 142 return;
115 143 }
116 144
117 - $license = __( 'PRO', 'visualizer' );
118 - if ( Visualizer_Module::is_pro() ) {
119 - switch ( $plan ) {
120 - case 1:
121 - $license = __( 'Developer', 'visualizer' );
122 - break;
123 - }
124 - }
145 + $is_new_personal = apply_filters( 'visualizer_is_new_personal', false );
125 146
126 147 $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' ),
148 + '0.16' => __( '10 minutes', 'visualizer' ),
149 + '1' => __( 'Each hour', 'visualizer' ),
150 + '12' => __( 'Each 12 hours', 'visualizer' ),
151 + '24' => __( 'Each day', 'visualizer' ),
152 + '72' => __( 'Each 3 days', 'visualizer' ),
132 153 );
133 154
134 155 switch ( $feature ) {
135 156 case 'json':
@@ -134,9 +155,9 @@
134 155 switch ( $feature ) {
135 156 case 'json':
136 157 case 'csv':
137 158 // no more schedules if pro is already active.
138 - if ( Visualizer_Module::is_pro() ) {
159 + if ( Visualizer_Module::is_pro() && ! $is_new_personal ) {
139 160 return;
140 161 }
141 162 break;
142 163 case 'wp':
@@ -146,9 +167,9 @@
146 167 default:
147 168 return;
148 169 }
149 170
150 - echo '<optgroup disabled label="' . sprintf( __( 'More in the %s version', 'visualizer' ), $license ) . '">';
171 + echo '<optgroup disabled label="' . __( 'Upgrade required', 'visualizer' ) . '">';
151 172 foreach ( $hours as $hour => $desc ) {
152 173 echo '<option disabled>' . $desc . '</option>';
153 174 }
154 175 echo '</optgroup>';
@@ -309,9 +330,11 @@
309 330 * @access public
310 331 */
311 332 public function enqueueMediaScripts() {
312 333 global $typenow;
313 - if ( post_type_supports( $typenow, 'editor' ) ) {
334 + global $current_screen;
335 +
336 + if ( post_type_supports( $typenow, 'editor' ) || $current_screen->id === 'widgets' || $current_screen->id === 'customize' ) {
314 337 wp_enqueue_style( 'visualizer-media', VISUALIZER_ABSURL . 'css/media.css', array( 'media-views' ), Visualizer_Plugin::VERSION );
315 338
316 339 // Load all the assets for the different libraries we support.
317 340 $deps = array(
@@ -403,14 +426,14 @@
403 426 ),
404 427 'pie' => array(
405 428 'name' => esc_html__( 'Pie/Donut', 'visualizer' ),
406 429 'enabled' => true,
407 - 'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ),
430 + 'supports' => array( 'Google Charts', 'ChartJS' ),
408 431 ),
409 432 'line' => array(
410 433 'name' => esc_html__( 'Line', 'visualizer' ),
411 434 'enabled' => true,
412 - 'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ),
435 + 'supports' => array( 'Google Charts', 'ChartJS' ),
413 436 ),
414 437 'bar' => array(
415 438 'name' => esc_html__( 'Bar', 'visualizer' ),
416 439 'enabled' => true,
@@ -670,9 +693,9 @@
670 693 Visualizer_Plugin::NAME,
671 694 __( 'Chart Library', 'visualizer' ),
672 695 __( 'Chart Library', 'visualizer' ),
673 696 'edit_posts',
674 - admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME )
697 + 'admin.php?page=' . Visualizer_Plugin::NAME
675 698 );
676 699 add_submenu_page(
677 700 Visualizer_Plugin::NAME,
678 701 __( 'Add New Chart', 'visualizer' ),
@@ -677,9 +700,9 @@
677 700 Visualizer_Plugin::NAME,
678 701 __( 'Add New Chart', 'visualizer' ),
679 702 __( 'Add New Chart', 'visualizer' ),
680 703 'edit_posts',
681 - admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew' )
704 + 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew'
682 705 );
683 706 add_submenu_page(
684 707 Visualizer_Plugin::NAME,
685 708 __( 'Support', 'visualizer' ),
@@ -899,8 +922,9 @@
899 922 * @access public
900 923 */
901 924 public function renderSupportPage() {
902 925 wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION );
926 + $this->load_survey();
903 927 include_once VISUALIZER_ABSPATH . '/templates/support.php';
904 928 }
905 929
906 930 /**
@@ -997,8 +1021,9 @@
997 1021 );
998 1022 }
999 1023 // enqueue charts array
1000 1024 $ajaxurl = admin_url( 'admin-ajax.php' );
1025 +
1001 1026 wp_localize_script(
1002 1027 'visualizer-library',
1003 1028 'visualizer',
1004 1029 array(
@@ -1035,8 +1060,9 @@
1035 1060 'i10n' => array(
1036 1061 'copied' => __( 'The shortcode has been copied to your clipboard. Hit Ctrl-V/Cmd-V to paste it.', 'visualizer' ),
1037 1062 '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' ),
1038 1063 ),
1064 + 'is_pro_user' => Visualizer_Module::is_pro(),
1039 1065 )
1040 1066 );
1041 1067 // render library page
1042 1068 $render = new Visualizer_Render_Library();
@@ -1052,8 +1078,11 @@
1052 1078 'total' => $query->max_num_pages,
1053 1079 'type' => 'array',
1054 1080 )
1055 1081 );
1082 +
1083 + $this->load_survey();
1084 +
1056 1085 $render->render();
1057 1086 }
1058 1087
1059 1088 /**
@@ -1180,6 +1209,77 @@
1180 1209 if ( isset( $types[ $type ] ) ) {
1181 1210 return ! empty( $types[ $type ]['enabled'] );
1182 1211 }
1183 1212 return false;
1213 + }
1214 +
1215 + /**
1216 + * Get the survey metadata.
1217 + *
1218 + * @return array The survey metadata.
1219 + */
1220 + private function get_survey_metadata() {
1221 + $install_date = get_option( 'visualizer_install', false );
1222 + $install_category = 0;
1223 +
1224 + if ( false !== $install_date ) {
1225 + $days_since_install = round( ( time() - $install_date ) / DAY_IN_SECONDS );
1226 +
1227 + if ( 0 === $days_since_install || 1 === $days_since_install ) {
1228 + $install_category = 0;
1229 + } elseif ( 1 < $days_since_install && 8 > $days_since_install ) {
1230 + $install_category = 7;
1231 + } elseif ( 8 <= $days_since_install && 31 > $days_since_install ) {
1232 + $install_category = 30;
1233 + } elseif ( 30 < $days_since_install && 90 > $days_since_install ) {
1234 + $install_category = 90;
1235 + } elseif ( 90 <= $days_since_install ) {
1236 + $install_category = 91;
1237 + }
1238 + }
1239 +
1240 + $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false );
1241 + $plugin_version = '';
1242 + if ( ! empty( $plugin_data['Version'] ) ) {
1243 + $plugin_version = $plugin_data['Version'];
1244 + }
1245 +
1246 + $user_id = 'visualizer_' . preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID.
1247 +
1248 + $license_data = get_option( 'visualizer_pro_license_data', false );
1249 + if ( false !== $license_data && isset( $license_data->key ) ) {
1250 + $user_id = 'visualizer_' . $license_data->key;
1251 + }
1252 +
1253 + return array(
1254 + 'userId' => $user_id,
1255 + 'attributes' => array(
1256 + 'days_since_install' => strval( $install_category ),
1257 + 'free_version' => $plugin_version,
1258 + 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '',
1259 + 'license_status' => apply_filters( 'product_visualizer_license_status', 'invalid' ),
1260 + ),
1261 + );
1262 + }
1263 +
1264 + /**
1265 + * Load the survey.
1266 + */
1267 + private function load_survey() {
1268 +
1269 + if ( defined( 'TI_CYPRESS_TESTING' ) ) {
1270 + return;
1271 + }
1272 +
1273 + $survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' );
1274 +
1275 + if ( empty( $survey_handler ) ) {
1276 + return;
1277 + }
1278 +
1279 + $metadata = $this->get_survey_metadata();
1280 +
1281 + do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' );
1282 + wp_enqueue_script( 'visualizer_chart_survey', VISUALIZER_ABSURL . 'js/survey.js', array( $survey_handler ), $metadata['attributes']['free_version'], true );
1283 + wp_localize_script( 'visualizer_chart_survey', 'visualizerSurveyData', $metadata );
1184 1284 }
1185 1285 }