PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.10.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.10.2
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 +34 -103 4.0.83.10.2 View file →
@@ -72,9 +72,8 @@
72 72 add_action( "load-$hook", array( $this, 'visualizer_load_setup_wizard_page' ) );
73 73 }
74 74 }
75 75
76 -
77 76 /**
78 77 * Method to register the setup wizard page.
79 78 *
80 79 * @access public
@@ -152,14 +151,8 @@
152 151 * @param bool $redirect_to_dashboard Redirect to dashboard.
153 152 * @return bool|void
154 153 */
155 154 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 - }
162 155 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
163 156 $status = isset( $_REQUEST['status'] ) ? (int) $_REQUEST['status'] : 0;
164 157 update_option( 'visualizer_fresh_install', $status );
165 158 delete_option( 'visualizer_wizard_data' );
@@ -174,12 +167,9 @@
174 167 * Setup wizard process.
175 168 */
176 169 public function visualizer_wizard_step_process() {
177 170 check_ajax_referer( VISUALIZER_ABSPATH, 'security' );
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;
171 + $step = ! empty( $_POST['step'] ) ? filter_input( INPUT_POST, 'step', FILTER_SANITIZE_STRING ) : 1;
182 172 switch ( $step ) {
183 173 case 'step_2':
184 174 $this->setup_wizard_import_chart();
185 175 break;
@@ -202,9 +192,9 @@
202 192 * Step: 2 import chart.
203 193 */
204 194 private function setup_wizard_import_chart() {
205 195 // phpcs:ignore WordPress.Security.NonceVerification.Missing
206 - $chart_type = ! empty( $_POST['chart_type'] ) ? sanitize_text_field( wp_unslash( $_POST['chart_type'] ) ) : '';
196 + $chart_type = ! empty( $_POST['chart_type'] ) ? filter_input( INPUT_POST, 'chart_type', FILTER_SANITIZE_STRING ) : '';
207 197 $chart_status = Visualizer_Module_Admin::checkChartStatus( $chart_type );
208 198 if ( ! $chart_status ) {
209 199 wp_send_json(
210 200 array(
@@ -221,15 +211,14 @@
221 211 'success' => 2,
222 212 'message' => __( 'Something went wrong while importing the chart', 'visualizer' ),
223 213 );
224 214
225 - $data = $source->getData();
226 215 $args = array(
227 216 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
228 217 'post_title' => 'Visualization',
229 218 'post_author' => get_current_user_id(),
230 219 'post_status' => 'publish',
231 - 'post_content' => $data,
220 + 'post_content' => $source->getData(),
232 221 );
233 222 $chart_id = wp_insert_post( $args );
234 223
235 224 if ( $chart_id && ! is_wp_error( $chart_id ) ) {
@@ -242,12 +231,10 @@
242 231 update_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() );
243 232 update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $series );
244 233 update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, '' );
245 234
246 - $data = Visualizer_Module::decode_content( $data );
247 235 $setting_series = array();
248 - $setting_slices = array();
249 - foreach ( $data as $s ) {
236 + foreach ( $series as $s ) {
250 237 $setting_series[] = array(
251 238 'visibleInLegend' => '',
252 239 'lineWidth' => '',
253 240 'pointSize' => '',
@@ -255,12 +242,8 @@
255 242 'curveType' => '',
256 243 'color' => '',
257 244 'role' => '',
258 245 );
259 - $setting_slices[] = array(
260 - 'offset' => 0,
261 - 'color' => '',
262 - );
263 246 }
264 247 update_post_meta(
265 248 $chart_id,
266 249 Visualizer_Plugin::CF_SETTINGS,
@@ -305,9 +288,9 @@
305 288 'height' => '',
306 289 ),
307 290 'focusTarget' => 'datum',
308 291 'series' => $setting_series,
309 - 'slices' => $setting_slices,
292 + 'slices' => array(),
310 293 'vAxis' => array(
311 294 'title' => '',
312 295 'textPosition' => '',
313 296 'direction' => 1,
@@ -350,45 +333,8 @@
350 333 'max' => '',
351 334 'min' => '',
352 335 ),
353 336 ),
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 - ),
391 337 )
392 338 );
393 339 $wizard_data = array(
394 340 'chart_type' => $chart_type,
@@ -395,10 +341,9 @@
395 341 'chart_id' => $chart_id,
396 342 );
397 343 $this->update_wizard_data( $wizard_data, false );
398 344 $response = array(
399 - 'success' => 1,
400 - 'chart_id' => $chart_id,
345 + 'success' => 1,
401 346 );
402 347 }
403 348 wp_send_json( $response );
404 349 exit;
@@ -426,9 +371,9 @@
426 371 */
427 372 private function setup_wizard_create_draft_page( $return_page_id = false ) {
428 373 $add_basic_shortcode = ! empty( $_POST['add_basic_shortcode'] ) ? sanitize_text_field( wp_unslash( $_POST['add_basic_shortcode'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
429 374 $add_basic_shortcode = 'true' === $add_basic_shortcode ? true : false;
430 - $basic_shortcode = ! empty( $_POST['basic_shortcode'] ) ? sanitize_text_field( wp_unslash( $_POST['basic_shortcode'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
375 + $basic_shortcode = ! empty( $_POST['basic_shortcode'] ) ? filter_input( INPUT_POST, 'basic_shortcode', FILTER_SANITIZE_STRING ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
431 376
432 377 if ( ! $add_basic_shortcode ) {
433 378 wp_send_json(
434 379 array(
@@ -486,9 +431,9 @@
486 431 * Step: 3 Install plugin.
487 432 */
488 433 private function setup_wizard_install_plugin() {
489 434 // phpcs:ignore WordPress.Security.NonceVerification.Missing
490 - $slug = ! empty( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : '';
435 + $slug = ! empty( $_POST['slug'] ) ? filter_input( INPUT_POST, 'slug', FILTER_SANITIZE_STRING ) : '';
491 436 if ( empty( $slug ) ) {
492 437 wp_send_json(
493 438 array(
494 439 'status' => 0,
@@ -506,12 +451,10 @@
506 451 );
507 452 }
508 453
509 454 if ( ! empty( $slug ) ) {
510 - $wizard_data = get_option( self::OPTION_NAME, array() );
511 455 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
512 456 include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
513 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
514 457
515 458 $api = plugins_api(
516 459 'plugin_information',
517 460 array(
@@ -571,38 +514,13 @@
571 514
572 515 wp_send_json( $status );
573 516 }
574 517
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 - }
518 + activate_plugin( 'optimole-wp/optimole-wp.php' );
519 + delete_transient( 'optml_fresh_install' );
520 + // Update wizard data.
521 + $wizard_data['enable_perfomance'] = true;
522 + $this->update_wizard_data( $wizard_data );
605 523
606 524 wp_send_json(
607 525 array(
608 526 'status' => 1,
@@ -651,19 +569,18 @@
651 569 );
652 570 }
653 571
654 572 if ( $with_subscribe && is_email( $email ) ) {
655 - wp_remote_post(
573 + $request_res = wp_remote_post(
656 574 VISUALIZER_SUBSCRIBE_API,
657 575 array(
658 - 'timeout' => 5,
659 - 'blocking' => false,
660 - 'headers' => array(
576 + 'timeout' => 100,
577 + 'headers' => array(
661 578 'Content-Type' => 'application/json',
662 579 'Cache-Control' => 'no-cache',
663 580 'Accept' => 'application/json, */*;q=0.1',
664 581 ),
665 - 'body' => wp_json_encode(
582 + 'body' => wp_json_encode(
666 583 array(
667 584 'slug' => 'visualizer',
668 585 'site' => home_url(),
669 586 'email' => $email,
@@ -673,12 +590,26 @@
673 590 )
674 591 ),
675 592 )
676 593 );
594 + if ( ! is_wp_error( $request_res ) ) {
595 + $body = json_decode( wp_remote_retrieve_body( $request_res ) );
596 + if ( 'success' === $body->code ) {
597 + $this->dismissWizard( false );
598 + wp_send_json( $response );
599 + }
600 + }
601 + wp_send_json(
602 + array(
603 + 'status' => 0,
604 + 'redirect_to' => '',
605 + 'message' => '',
606 + )
607 + );
608 + } else {
609 + $this->dismissWizard( false );
610 + wp_send_json( $response );
677 611 }
678 -
679 - $this->dismissWizard( false );
680 - wp_send_json( $response );
681 612 }
682 613
683 614 /**
684 615 * Filter chart setting.