PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 4.0.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v4.0.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 +193 -34 3.10.04.0.2 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
@@ -167,9 +168,9 @@
167 168 * Setup wizard process.
168 169 */
169 170 public function visualizer_wizard_step_process() {
170 171 check_ajax_referer( VISUALIZER_ABSPATH, 'security' );
171 - $step = ! empty( $_POST['step'] ) ? filter_input( INPUT_POST, 'step', FILTER_SANITIZE_STRING ) : 1;
172 + $step = ! empty( $_POST['step'] ) ? sanitize_text_field( wp_unslash( $_POST['step'] ) ) : 1;
172 173 switch ( $step ) {
173 174 case 'step_2':
174 175 $this->setup_wizard_import_chart();
175 176 break;
@@ -192,9 +193,9 @@
192 193 * Step: 2 import chart.
193 194 */
194 195 private function setup_wizard_import_chart() {
195 196 // phpcs:ignore WordPress.Security.NonceVerification.Missing
196 - $chart_type = ! empty( $_POST['chart_type'] ) ? filter_input( INPUT_POST, 'chart_type', FILTER_SANITIZE_STRING ) : '';
197 + $chart_type = ! empty( $_POST['chart_type'] ) ? sanitize_text_field( wp_unslash( $_POST['chart_type'] ) ) : '';
197 198 $chart_status = Visualizer_Module_Admin::checkChartStatus( $chart_type );
198 199 if ( ! $chart_status ) {
199 200 wp_send_json(
200 201 array(
@@ -205,19 +206,21 @@
205 206 }
206 207
207 208 $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $chart_type . '.csv' );
208 209 $source->fetch();
210 + $series = $source->getSeries();
209 211 $response = array(
210 212 'success' => 2,
211 213 'message' => __( 'Something went wrong while importing the chart', 'visualizer' ),
212 214 );
213 215
216 + $data = $source->getData();
214 217 $args = array(
215 218 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
216 219 'post_title' => 'Visualization',
217 220 'post_author' => get_current_user_id(),
218 221 'post_status' => 'publish',
219 - 'post_content' => $source->getData(),
222 + 'post_content' => $data,
220 223 );
221 224 $chart_id = wp_insert_post( $args );
222 225
223 226 if ( $chart_id && ! is_wp_error( $chart_id ) ) {
@@ -227,15 +230,156 @@
227 230
228 231 update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, $chart_type );
229 232 update_post_meta( $chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, 1 );
230 233 update_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() );
231 - update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $source->getSeries() );
234 + update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $series );
232 235 update_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, '' );
236 +
237 + $data = maybe_unserialize( $data );
238 + $setting_series = array();
239 + $setting_slices = array();
240 + foreach ( $data as $s ) {
241 + $setting_series[] = array(
242 + 'visibleInLegend' => '',
243 + 'lineWidth' => '',
244 + 'pointSize' => '',
245 + 'format' => '',
246 + 'curveType' => '',
247 + 'color' => '',
248 + 'role' => '',
249 + );
250 + $setting_slices[] = array(
251 + 'offset' => 0,
252 + 'color' => '',
253 + );
254 + }
233 255 update_post_meta(
234 256 $chart_id,
235 257 Visualizer_Plugin::CF_SETTINGS,
236 258 array(
237 - 'focusTarget' => 'datum',
259 + 'title' => '',
260 + 'titlePosition' => '',
261 + 'titleTextStyle' => array(
262 + 'color' => '#000',
263 + ),
264 + 'legend' => array(
265 + 'position' => 'right',
266 + 'alignment' => 15,
267 + 'textStyle' => array(
268 + 'color' => '#000',
269 + 'text' => 'both',
270 + ),
271 + ),
272 + 'tooltip' => array(
273 + 'trigger' => 'focus',
274 + 'showColorCode' => 0,
275 + 'showColorCode' => 0,
276 + ),
277 + 'animation' => array(
278 + 'startup' => 0,
279 + 'duration' => '',
280 + 'easing' => 'linear',
281 + ),
282 + 'width' => '',
283 + 'height' => '',
284 + 'keepAspectRatio' => false,
285 + 'isStacked' => false,
286 + 'lazy_load_chart' => true,
287 + 'backgroundColor' => array(
288 + 'strokeWidth' => '',
289 + 'stroke' => '',
290 + 'fill' => '',
291 + ),
292 + 'chartArea' => array(
293 + 'left' => '',
294 + 'top' => '',
295 + 'width' => '',
296 + 'height' => '',
297 + ),
298 + 'focusTarget' => 'datum',
299 + 'series' => $setting_series,
300 + 'slices' => $setting_slices,
301 + 'vAxis' => array(
302 + 'title' => '',
303 + 'textPosition' => '',
304 + 'direction' => 1,
305 + 'baselineColor' => '#000',
306 + 'textStyle' => array(
307 + 'color' => '#000',
308 + ),
309 + 'format' => '',
310 + 'gridlines' => array(
311 + 'count' => '',
312 + 'color' => '#ccc',
313 + ),
314 + 'minorGridlines' => array(
315 + 'count' => '',
316 + 'color' => '',
317 + ),
318 + 'viewWindow' => array(
319 + 'max' => '',
320 + 'min' => '',
321 + ),
322 + ),
323 + 'hAxis' => array(
324 + 'title' => '',
325 + 'textPosition' => '',
326 + 'direction' => 1,
327 + 'baselineColor' => '#000',
328 + 'textStyle' => array(
329 + 'color' => '#000',
330 + ),
331 + 'format' => '',
332 + 'gridlines' => array(
333 + 'count' => '',
334 + 'color' => '#ccc',
335 + ),
336 + 'minorGridlines' => array(
337 + 'count' => '',
338 + 'color' => '',
339 + ),
340 + 'viewWindow' => array(
341 + 'max' => '',
342 + 'min' => '',
343 + ),
344 + ),
345 + 'customcss' => array(
346 + 'headerRow' => array(
347 + 'background-color' => '',
348 + 'color' => '',
349 + 'transform' => '',
350 + ),
351 + 'tableRow' => array(
352 + 'background-color' => '',
353 + 'color' => '',
354 + 'transform' => '',
355 + ),
356 + 'oddTableRow' => array(
357 + 'background-color' => '',
358 + 'color' => '',
359 + 'transform' => '',
360 + ),
361 + 'selectedTableRow' => array(
362 + 'background-color' => '',
363 + 'color' => '',
364 + 'transform' => '',
365 + ),
366 + 'hoverTableRow' => array(
367 + 'background-color' => '',
368 + 'color' => '',
369 + 'transform' => '',
370 + ),
371 + 'headerCell' => array(
372 + 'background-color' => '',
373 + 'color' => '',
374 + 'transform' => '',
375 + ),
376 + 'tableCell' => array(
377 + 'background-color' => '',
378 + 'color' => '',
379 + 'transform' => '',
380 + ),
381 + ),
238 382 )
239 383 );
240 384 $wizard_data = array(
241 385 'chart_type' => $chart_type,
@@ -242,9 +386,10 @@
242 386 'chart_id' => $chart_id,
243 387 );
244 388 $this->update_wizard_data( $wizard_data, false );
245 389 $response = array(
246 - 'success' => 1,
390 + 'success' => 1,
391 + 'chart_id' => $chart_id,
247 392 );
248 393 }
249 394 wp_send_json( $response );
250 395 exit;
@@ -272,9 +417,9 @@
272 417 */
273 418 private function setup_wizard_create_draft_page( $return_page_id = false ) {
274 419 $add_basic_shortcode = ! empty( $_POST['add_basic_shortcode'] ) ? sanitize_text_field( wp_unslash( $_POST['add_basic_shortcode'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
275 420 $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
421 + $basic_shortcode = ! empty( $_POST['basic_shortcode'] ) ? sanitize_text_field( wp_unslash( $_POST['basic_shortcode'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
277 422
278 423 if ( ! $add_basic_shortcode ) {
279 424 wp_send_json(
280 425 array(
@@ -332,9 +477,9 @@
332 477 * Step: 3 Install plugin.
333 478 */
334 479 private function setup_wizard_install_plugin() {
335 480 // phpcs:ignore WordPress.Security.NonceVerification.Missing
336 - $slug = ! empty( $_POST['slug'] ) ? filter_input( INPUT_POST, 'slug', FILTER_SANITIZE_STRING ) : '';
481 + $slug = ! empty( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : '';
337 482 if ( empty( $slug ) ) {
338 483 wp_send_json(
339 484 array(
340 485 'status' => 0,
@@ -352,10 +497,12 @@
352 497 );
353 498 }
354 499
355 500 if ( ! empty( $slug ) ) {
501 + $wizard_data = get_option( self::OPTION_NAME, array() );
356 502 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
357 503 include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
504 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
358 505
359 506 $api = plugins_api(
360 507 'plugin_information',
361 508 array(
@@ -415,13 +562,38 @@
415 562
416 563 wp_send_json( $status );
417 564 }
418 565
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 );
566 + $installed_plugins = get_plugins( '/' . sanitize_key( wp_unslash( $slug ) ) );
567 + if ( ! empty( $installed_plugins ) ) {
568 + $plugin_files = array_keys( $installed_plugins );
569 + $plugin_file = sanitize_key( wp_unslash( $slug ) ) . '/' . $plugin_files[0];
570 + activate_plugin( $plugin_file );
571 + }
572 + $wizard_data_updated = false;
573 + if ( 'optimole-wp' === $slug ) {
574 + delete_transient( 'optml_fresh_install' );
575 + // Update wizard data.
576 + $wizard_data['enable_perfomance'] = true;
577 + $wizard_data_updated = true;
578 + }
579 + if ( 'otter-blocks' === $slug ) {
580 + // Update wizard data.
581 + $wizard_data['enable_otter_blocks'] = true;
582 + $wizard_data_updated = true;
583 + // Suppress Otter's post-activation redirects so the user stays in Visualizer.
584 + update_option( 'themeisle_blocks_settings_redirect', '0' );
585 + update_option( 'themeisle_blocks_settings_onboarding', '0' );
586 + }
587 + if ( 'wp-cloudflare-page-cache' === $slug ) {
588 + // Update wizard data.
589 + $wizard_data['enable_page_cache'] = true;
590 + $wizard_data_updated = true;
591 + update_option( 'swcfpc_dashboard_redirect', false );
592 + }
593 + if ( $wizard_data_updated ) {
594 + $this->update_wizard_data( $wizard_data );
595 + }
424 596
425 597 wp_send_json(
426 598 array(
427 599 'status' => 1,
@@ -470,18 +642,19 @@
470 642 );
471 643 }
472 644
473 645 if ( $with_subscribe && is_email( $email ) ) {
474 - $request_res = wp_remote_post(
646 + wp_remote_post(
475 647 VISUALIZER_SUBSCRIBE_API,
476 648 array(
477 - 'timeout' => 100,
478 - 'headers' => array(
649 + 'timeout' => 5,
650 + 'blocking' => false,
651 + 'headers' => array(
479 652 'Content-Type' => 'application/json',
480 653 'Cache-Control' => 'no-cache',
481 654 'Accept' => 'application/json, */*;q=0.1',
482 655 ),
483 - 'body' => wp_json_encode(
656 + 'body' => wp_json_encode(
484 657 array(
485 658 'slug' => 'visualizer',
486 659 'site' => home_url(),
487 660 'email' => $email,
@@ -491,26 +664,12 @@
491 664 )
492 665 ),
493 666 )
494 667 );
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 668 }
669 +
670 + $this->dismissWizard( false );
671 + wp_send_json( $response );
513 672 }
514 673
515 674 /**
516 675 * Filter chart setting.