PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 4.0.8
Visualizer – Tables & Charts Manager with Built-in AI Generator v4.0.8
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/Wizard.php +202 -34 3.10.04.0.8 View file →
@@ -72,8 +72,9 @@
72 72 add_action( "load-$hook", array( $this, 'visualizer_load_setup_wizard_page' ) );
73 73 }
74 74 }
75 75
76 +
76 77 /**
77 78 * Method to register the setup wizard page.
78 79 *
79 80 * @access public
@@ -151,8 +152,14 @@
151 152 * @param bool $redirect_to_dashboard Redirect to dashboard.
152 153 * @return bool|void
153 154 */
154 155 public function dismissWizard( $redirect_to_dashboard = true ) {
156 + if ( ! current_user_can( 'manage_options' ) ) {
157 + wp_die( esc_html__( 'You do not have permission to perform this action.', 'visualizer' ), '', array( 'response' => 403 ) );
158 + }
159 + if ( false !== $redirect_to_dashboard ) {
160 + check_admin_referer( 'visualizer_dismiss_wizard' );
161 + }
155 162 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
156 163 $status = isset( $_REQUEST['status'] ) ? (int) $_REQUEST['status'] : 0;
157 164 update_option( 'visualizer_fresh_install', $status );
158 165 delete_option( 'visualizer_wizard_data' );
@@ -167,9 +174,12 @@
167 174 * Setup wizard process.
168 175 */
169 176 public function visualizer_wizard_step_process() {
170 177 check_ajax_referer( VISUALIZER_ABSPATH, 'security' );
171 - $step = ! empty( $_POST['step'] ) ? filter_input( INPUT_POST, 'step', FILTER_SANITIZE_STRING ) : 1;
178 + if ( ! current_user_can( 'manage_options' ) ) {
179 + wp_send_json( array( 'status' => 0 ), 403 );
180 + }
181 + $step = ! empty( $_POST['step'] ) ? sanitize_text_field( wp_unslash( $_POST['step'] ) ) : 1;
172 182 switch ( $step ) {
173 183 case 'step_2':
174 184 $this->setup_wizard_import_chart();
175 185 break;
@@ -192,9 +202,9 @@
192 202 * Step: 2 import chart.
193 203 */
194 204 private function setup_wizard_import_chart() {
195 205 // phpcs:ignore WordPress.Security.NonceVerification.Missing
196 - $chart_type = ! empty( $_POST['chart_type'] ) ? filter_input( INPUT_POST, 'chart_type', FILTER_SANITIZE_STRING ) : '';
206 + $chart_type = ! empty( $_POST['chart_type'] ) ? sanitize_text_field( wp_unslash( $_POST['chart_type'] ) ) : '';
197 207 $chart_status = Visualizer_Module_Admin::checkChartStatus( $chart_type );
198 208 if ( ! $chart_status ) {
199 209 wp_send_json(
200 210 array(
@@ -205,19 +215,21 @@
205 215 }
206 216
207 217 $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $chart_type . '.csv' );
208 218 $source->fetch();
219 + $series = $source->getSeries();
209 220 $response = array(
210 221 'success' => 2,
211 222 'message' => __( 'Something went wrong while importing the chart', 'visualizer' ),
212 223 );
213 224
225 + $data = $source->getData();
214 226 $args = array(
215 227 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
216 228 'post_title' => 'Visualization',
217 229 'post_author' => get_current_user_id(),
218 230 'post_status' => 'publish',
219 - 'post_content' => $source->getData(),
231 + 'post_content' => $data,
220 232 );
221 233 $chart_id = wp_insert_post( $args );
222 234
223 235 if ( $chart_id && ! is_wp_error( $chart_id ) ) {
@@ -227,15 +239,156 @@
227 239
228 240 update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, $chart_type );
229 241 update_post_meta( $chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, 1 );
230 242 update_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() );
231 - update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $source->getSeries() );
243 + update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $series );
232 244 update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, '' );
245 +
246 + $data = Visualizer_Module::decode_content( $data );
247 + $setting_series = array();
248 + $setting_slices = array();
249 + foreach ( $data as $s ) {
250 + $setting_series[] = array(
251 + 'visibleInLegend' => '',
252 + 'lineWidth' => '',
253 + 'pointSize' => '',
254 + 'format' => '',
255 + 'curveType' => '',
256 + 'color' => '',
257 + 'role' => '',
258 + );
259 + $setting_slices[] = array(
260 + 'offset' => 0,
261 + 'color' => '',
262 + );
263 + }
233 264 update_post_meta(
234 265 $chart_id,
235 266 Visualizer_Plugin::CF_SETTINGS,
236 267 array(
237 - 'focusTarget' => 'datum',
268 + 'title' => '',
269 + 'titlePosition' => '',
270 + 'titleTextStyle' => array(
271 + 'color' => '#000',
272 + ),
273 + 'legend' => array(
274 + 'position' => 'right',
275 + 'alignment' => 15,
276 + 'textStyle' => array(
277 + 'color' => '#000',
278 + 'text' => 'both',
279 + ),
280 + ),
281 + 'tooltip' => array(
282 + 'trigger' => 'focus',
283 + 'showColorCode' => 0,
284 + 'showColorCode' => 0,
285 + ),
286 + 'animation' => array(
287 + 'startup' => 0,
288 + 'duration' => '',
289 + 'easing' => 'linear',
290 + ),
291 + 'width' => '',
292 + 'height' => '',
293 + 'keepAspectRatio' => false,
294 + 'isStacked' => false,
295 + 'lazy_load_chart' => true,
296 + 'backgroundColor' => array(
297 + 'strokeWidth' => '',
298 + 'stroke' => '',
299 + 'fill' => '',
300 + ),
301 + 'chartArea' => array(
302 + 'left' => '',
303 + 'top' => '',
304 + 'width' => '',
305 + 'height' => '',
306 + ),
307 + 'focusTarget' => 'datum',
308 + 'series' => $setting_series,
309 + 'slices' => $setting_slices,
310 + 'vAxis' => array(
311 + 'title' => '',
312 + 'textPosition' => '',
313 + 'direction' => 1,
314 + 'baselineColor' => '#000',
315 + 'textStyle' => array(
316 + 'color' => '#000',
317 + ),
318 + 'format' => '',
319 + 'gridlines' => array(
320 + 'count' => '',
321 + 'color' => '#ccc',
322 + ),
323 + 'minorGridlines' => array(
324 + 'count' => '',
325 + 'color' => '',
326 + ),
327 + 'viewWindow' => array(
328 + 'max' => '',
329 + 'min' => '',
330 + ),
331 + ),
332 + 'hAxis' => array(
333 + 'title' => '',
334 + 'textPosition' => '',
335 + 'direction' => 1,
336 + 'baselineColor' => '#000',
337 + 'textStyle' => array(
338 + 'color' => '#000',
339 + ),
340 + 'format' => '',
341 + 'gridlines' => array(
342 + 'count' => '',
343 + 'color' => '#ccc',
344 + ),
345 + 'minorGridlines' => array(
346 + 'count' => '',
347 + 'color' => '',
348 + ),
349 + 'viewWindow' => array(
350 + 'max' => '',
351 + 'min' => '',
352 + ),
353 + ),
354 + 'customcss' => array(
355 + 'headerRow' => array(
356 + 'background-color' => '',
357 + 'color' => '',
358 + 'transform' => '',
359 + ),
360 + 'tableRow' => array(
361 + 'background-color' => '',
362 + 'color' => '',
363 + 'transform' => '',
364 + ),
365 + 'oddTableRow' => array(
366 + 'background-color' => '',
367 + 'color' => '',
368 + 'transform' => '',
369 + ),
370 + 'selectedTableRow' => array(
371 + 'background-color' => '',
372 + 'color' => '',
373 + 'transform' => '',
374 + ),
375 + 'hoverTableRow' => array(
376 + 'background-color' => '',
377 + 'color' => '',
378 + 'transform' => '',
379 + ),
380 + 'headerCell' => array(
381 + 'background-color' => '',
382 + 'color' => '',
383 + 'transform' => '',
384 + ),
385 + 'tableCell' => array(
386 + 'background-color' => '',
387 + 'color' => '',
388 + 'transform' => '',
389 + ),
390 + ),
238 391 )
239 392 );
240 393 $wizard_data = array(
241 394 'chart_type' => $chart_type,
@@ -242,9 +395,10 @@
242 395 'chart_id' => $chart_id,
243 396 );
244 397 $this->update_wizard_data( $wizard_data, false );
245 398 $response = array(
246 - 'success' => 1,
399 + 'success' => 1,
400 + 'chart_id' => $chart_id,
247 401 );
248 402 }
249 403 wp_send_json( $response );
250 404 exit;
@@ -272,9 +426,9 @@
272 426 */
273 427 private function setup_wizard_create_draft_page( $return_page_id = false ) {
274 428 $add_basic_shortcode = ! empty( $_POST['add_basic_shortcode'] ) ? sanitize_text_field( wp_unslash( $_POST['add_basic_shortcode'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
275 429 $add_basic_shortcode = 'true' === $add_basic_shortcode ? true : false;
276 - $basic_shortcode = ! empty( $_POST['basic_shortcode'] ) ? filter_input( INPUT_POST, 'basic_shortcode', FILTER_SANITIZE_STRING ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
430 + $basic_shortcode = ! empty( $_POST['basic_shortcode'] ) ? sanitize_text_field( wp_unslash( $_POST['basic_shortcode'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
277 431
278 432 if ( ! $add_basic_shortcode ) {
279 433 wp_send_json(
280 434 array(
@@ -332,9 +486,9 @@
332 486 * Step: 3 Install plugin.
333 487 */
334 488 private function setup_wizard_install_plugin() {
335 489 // phpcs:ignore WordPress.Security.NonceVerification.Missing
336 - $slug = ! empty( $_POST['slug'] ) ? filter_input( INPUT_POST, 'slug', FILTER_SANITIZE_STRING ) : '';
490 + $slug = ! empty( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : '';
337 491 if ( empty( $slug ) ) {
338 492 wp_send_json(
339 493 array(
340 494 'status' => 0,
@@ -352,10 +506,12 @@
352 506 );
353 507 }
354 508
355 509 if ( ! empty( $slug ) ) {
510 + $wizard_data = get_option( self::OPTION_NAME, array() );
356 511 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
357 512 include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
513 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
358 514
359 515 $api = plugins_api(
360 516 'plugin_information',
361 517 array(
@@ -415,13 +571,38 @@
415 571
416 572 wp_send_json( $status );
417 573 }
418 574
419 - activate_plugin( 'optimole-wp/optimole-wp.php' );
420 - delete_transient( 'optml_fresh_install' );
421 - // Update wizard data.
422 - $wizard_data['enable_perfomance'] = true;
423 - $this->update_wizard_data( $wizard_data );
575 + $installed_plugins = get_plugins( '/' . sanitize_key( wp_unslash( $slug ) ) );
576 + if ( ! empty( $installed_plugins ) ) {
577 + $plugin_files = array_keys( $installed_plugins );
578 + $plugin_file = sanitize_key( wp_unslash( $slug ) ) . '/' . $plugin_files[0];
579 + activate_plugin( $plugin_file );
580 + }
581 + $wizard_data_updated = false;
582 + if ( 'optimole-wp' === $slug ) {
583 + delete_transient( 'optml_fresh_install' );
584 + // Update wizard data.
585 + $wizard_data['enable_perfomance'] = true;
586 + $wizard_data_updated = true;
587 + }
588 + if ( 'otter-blocks' === $slug ) {
589 + // Update wizard data.
590 + $wizard_data['enable_otter_blocks'] = true;
591 + $wizard_data_updated = true;
592 + // Suppress Otter's post-activation redirects so the user stays in Visualizer.
593 + update_option( 'themeisle_blocks_settings_redirect', '0' );
594 + update_option( 'themeisle_blocks_settings_onboarding', '0' );
595 + }
596 + if ( 'wp-cloudflare-page-cache' === $slug ) {
597 + // Update wizard data.
598 + $wizard_data['enable_page_cache'] = true;
599 + $wizard_data_updated = true;
600 + update_option( 'swcfpc_dashboard_redirect', false );
601 + }
602 + if ( $wizard_data_updated ) {
603 + $this->update_wizard_data( $wizard_data );
604 + }
424 605
425 606 wp_send_json(
426 607 array(
427 608 'status' => 1,
@@ -470,18 +651,19 @@
470 651 );
471 652 }
472 653
473 654 if ( $with_subscribe && is_email( $email ) ) {
474 - $request_res = wp_remote_post(
655 + wp_remote_post(
475 656 VISUALIZER_SUBSCRIBE_API,
476 657 array(
477 - 'timeout' => 100,
478 - 'headers' => array(
658 + 'timeout' => 5,
659 + 'blocking' => false,
660 + 'headers' => array(
479 661 'Content-Type' => 'application/json',
480 662 'Cache-Control' => 'no-cache',
481 663 'Accept' => 'application/json, */*;q=0.1',
482 664 ),
483 - 'body' => wp_json_encode(
665 + 'body' => wp_json_encode(
484 666 array(
485 667 'slug' => 'visualizer',
486 668 'site' => home_url(),
487 669 'email' => $email,
@@ -491,26 +673,12 @@
491 673 )
492 674 ),
493 675 )
494 676 );
495 - if ( ! is_wp_error( $request_res ) ) {
496 - $body = json_decode( wp_remote_retrieve_body( $request_res ) );
497 - if ( 'success' === $body->code ) {
498 - $this->dismissWizard( false );
499 - wp_send_json( $response );
500 - }
501 - }
502 - wp_send_json(
503 - array(
504 - 'status' => 0,
505 - 'redirect_to' => '',
506 - 'message' => '',
507 - )
508 - );
509 - } else {
510 - $this->dismissWizard( false );
511 - wp_send_json( $response );
512 677 }
678 +
679 + $this->dismissWizard( false );
680 + wp_send_json( $response );
513 681 }
514 682
515 683 /**
516 684 * Filter chart setting.