PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.5
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.5
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/Gutenberg/Block.php +42 -84 3.10.03.4.5 View file →
@@ -79,16 +79,8 @@
79 79 } else {
80 80 $version = $this->version;
81 81 }
82 82
83 - if ( ! wp_script_is( 'visualizer-datatables', 'registered' ) ) {
84 - wp_register_script( 'visualizer-datatables', VISUALIZER_ABSURL . 'js/lib/datatables.min.js', array( 'jquery-ui-core' ), Visualizer_Plugin::VERSION );
85 - }
86 -
87 - if ( ! wp_style_is( 'visualizer-datatables', 'registered' ) ) {
88 - wp_register_style( 'visualizer-datatables', VISUALIZER_ABSURL . 'css/lib/datatables.min.css', array(), Visualizer_Plugin::VERSION );
89 - }
90 -
91 83 // Enqueue the bundled block JS file
92 84 wp_enqueue_script( 'handsontable', $handsontableJS );
93 85 wp_enqueue_script( 'visualizer-gutenberg-block', $blockPath, array( 'wp-api', 'handsontable', 'visualizer-datatables', 'moment' ), $version, true );
94 86
@@ -104,15 +96,14 @@
104 96 $table_col_mapping = Visualizer_Source_Query_Params::get_all_db_tables_column_mapping( null, false );
105 97
106 98 $translation_array = array(
107 99 'isPro' => $type,
108 - 'proTeaser' => tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'blockupsell'),
100 + 'proTeaser' => Visualizer_Plugin::PRO_TEASER_URL,
109 101 'absurl' => VISUALIZER_ABSURL,
110 102 'charts' => Visualizer_Module_Admin::_getChartTypesLocalized(),
111 103 'adminPage' => menu_page_url( 'visualizer', false ),
112 104 'sqlTable' => $table_col_mapping,
113 105 'chartsPerPage' => defined( 'TI_CYPRESS_TESTING' ) ? 20 : 6,
114 - 'proFeaturesLocked' => Visualizer_Module_Admin::proFeaturesLocked(),
115 106 );
116 107 wp_localize_script( 'visualizer-gutenberg-block', 'visualizerLocalize', $translation_array );
117 108
118 109 // Enqueue frontend and editor block styles
@@ -360,14 +351,8 @@
360 351
361 352 // handle data filter hooks
362 353 $data['visualizer-data'] = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( get_the_content( $post_id ) ) ), $post_id, $data['visualizer-chart-type'] );
363 354
364 - // we are going to format only for tabular charts, because we are not sure of the effect on others.
365 - // this is to solve the case where boolean data shows up as all-ticks on gutenberg.
366 - if ( in_array( $data['visualizer-chart-type'], array( 'tabular' ), true ) ) {
367 - $data['visualizer-data'] = $this->format_chart_data( $data['visualizer-data'], $data['visualizer-series'] );
368 - }
369 -
370 355 $data['visualizer-data-exploded'] = '';
371 356 // handle annotations for google charts
372 357 if ( 'GoogleCharts' === $library ) {
373 358 // this will contain the data of both axis.
@@ -384,12 +369,8 @@
384 369 if ( ! empty( $serie['role'] ) ) {
385 370 // this series is some kind of annotation, so let's collect its index.
386 371 // the index will be +1 because the X axis value is index 0, which is being ignored.
387 372 $annotations[ 'role' . ( intval( $index ) + 1 ) ] = $serie['role'];
388 -
389 - if ( isset( $data['visualizer-series'][ intval( $index ) + 1 ] ) ) {
390 - $data['visualizer-series'][ intval( $index ) + 1 ]['role'] = $serie['role'];
391 - }
392 373 }
393 374 }
394 375 }
395 376 if ( ! empty( $annotations ) ) {
@@ -458,18 +439,11 @@
458 439
459 440 if ( Visualizer_Module::is_pro() ) {
460 441 $permissions = get_post_meta( $post_id, Visualizer_PRO::CF_PERMISSIONS, true );
461 442
462 - if ( empty( $permissions ) ) {
463 - $permissions = array( 'permissions' => array(
464 - 'read' => 'all',
465 - 'edit' => 'roles',
466 - 'edit-specific' => array( 'administrator' ),
467 - ),
468 - );
443 + if ( ! empty( $permissions ) ) {
444 + $data['visualizer-permissions'] = $permissions;
469 445 }
470 -
471 - $data['visualizer-permissions'] = $permissions;
472 446 }
473 447
474 448 return $data;
475 449 }
@@ -600,21 +574,16 @@
600 574 delete_post_meta( $data['id'], Visualizer_Plugin::CF_CHART_URL );
601 575 apply_filters( 'visualizer_pro_remove_schedule', $data['id'] );
602 576 }
603 577
604 - // let's check if this is not an external db chart
605 - // as there is no support for that in the block editor interface
606 - $external_params = get_post_meta( $data['id'], Visualizer_Plugin::CF_REMOTE_DB_PARAMS, true );
607 - if ( empty( $external_params ) ) {
608 - if ( $source_type === 'Visualizer_Source_Query' ) {
609 - $db_schedule = intval( $data['visualizer-db-schedule'] );
610 - $db_query = $data['visualizer-db-query'];
611 - update_post_meta( $data['id'], Visualizer_Plugin::CF_DB_SCHEDULE, $db_schedule );
612 - update_post_meta( $data['id'], Visualizer_Plugin::CF_DB_QUERY, stripslashes( $db_query ) );
613 - } else {
614 - delete_post_meta( $data['id'], Visualizer_Plugin::CF_DB_SCHEDULE );
615 - delete_post_meta( $data['id'], Visualizer_Plugin::CF_DB_QUERY );
616 - }
578 + if ( $source_type === 'Visualizer_Source_Query' ) {
579 + $db_schedule = intval( $data['visualizer-db-schedule'] );
580 + $db_query = $data['visualizer-db-query'];
581 + update_post_meta( $data['id'], Visualizer_Plugin::CF_DB_SCHEDULE, $db_schedule );
582 + update_post_meta( $data['id'], Visualizer_Plugin::CF_DB_QUERY, stripslashes( $db_query ) );
583 + } else {
584 + delete_post_meta( $data['id'], Visualizer_Plugin::CF_DB_SCHEDULE );
585 + delete_post_meta( $data['id'], Visualizer_Plugin::CF_DB_QUERY );
617 586 }
618 587
619 588 if ( $source_type === 'Visualizer_Source_Json' ) {
620 589 $json_schedule = intval( $data['visualizer-json-schedule'] );
@@ -659,14 +628,8 @@
659 628 );
660 629
661 630 wp_update_post( $chart );
662 631
663 - // Clear existing chart cache.
664 - $cache_key = Visualizer_Plugin::CF_CHART_CACHE . '_' . $data['id'];
665 - if ( get_transient( $cache_key ) ) {
666 - delete_transient( $cache_key );
667 - }
668 -
669 632 $revisions = wp_get_post_revisions( $data['id'], array( 'order' => 'ASC' ) );
670 633
671 634 if ( count( $revisions ) > 1 ) {
672 635 $revision_ids = array_keys( $revisions );
@@ -682,10 +645,8 @@
682 645 }
683 646
684 647 /**
685 648 * Format chart data.
686 - *
687 - * Note: No matter how tempted, don't use the similar method from Visualizer_Source. That works on a different structure.
688 649 */
689 650 public function format_chart_data( $data, $series ) {
690 651 foreach ( $series as $i => $row ) {
691 652 // if no value exists for the seires, then add null
@@ -696,38 +657,39 @@
696 657 if ( is_null( $series[ $i ] ) ) {
697 658 continue;
698 659 }
699 660
700 - switch ( $row['type'] ) {
701 - case 'number':
702 - foreach ( $data as $o => $col ) {
703 - $data[ $o ][ $i ] = ( is_numeric( $col[ $i ] ) ) ? floatval( $col[ $i ] ) : ( is_numeric( str_replace( ',', '', $col[ $i ] ) ) ? floatval( str_replace( ',', '', $col[ $i ] ) ) : null );
661 + if ( $row['type'] === 'number' ) {
662 + foreach ( $data as $o => $col ) {
663 + $data[ $o ][ $i ] = ( is_numeric( $col[ $i ] ) ) ? floatval( $col[ $i ] ) : ( is_numeric( str_replace( ',', '', $col[ $i ] ) ) ? floatval( str_replace( ',', '', $col[ $i ] ) ) : null );
664 + }
665 + }
666 +
667 + if ( $row['type'] === 'boolean' ) {
668 + foreach ( $data as $o => $col ) {
669 + $data[ $o ][ $i ] = ! empty( $col[ $i ] ) ? filter_var( $col[ $i ], FILTER_VALIDATE_BOOLEAN ) : null;
670 + }
671 + }
672 +
673 + if ( $row['type'] === 'timeofday' ) {
674 + foreach ( $data as $o => $col ) {
675 + $date = new DateTime( '1984-03-16T' . $col[ $i ] );
676 + if ( $date ) {
677 + $data[ $o ][ $i ] = array(
678 + intval( $date->format( 'H' ) ),
679 + intval( $date->format( 'i' ) ),
680 + intval( $date->format( 's' ) ),
681 + 0,
682 + );
704 683 }
705 - break;
706 - case 'boolean':
707 - foreach ( $data as $o => $col ) {
708 - $data[ $o ][ $i ] = ! empty( $col[ $i ] ) ? filter_var( $col[ $i ], FILTER_VALIDATE_BOOLEAN ) : false;
709 - }
710 - break;
711 - case 'timeofday':
712 - foreach ( $data as $o => $col ) {
713 - $date = new DateTime( '1984-03-16T' . $col[ $i ] );
714 - if ( $date ) {
715 - $data[ $o ][ $i ] = array(
716 - intval( $date->format( 'H' ) ),
717 - intval( $date->format( 'i' ) ),
718 - intval( $date->format( 's' ) ),
719 - 0,
720 - );
721 - }
722 - }
723 - break;
724 - case 'string':
725 - foreach ( $data as $o => $col ) {
726 - $data[ $o ][ $i ] = $this->toUTF8( $col[ $i ] );
727 - }
728 - break;
684 + }
729 685 }
686 +
687 + if ( $row['type'] === 'string' ) {
688 + foreach ( $data as $o => $col ) {
689 + $data[ $o ][ $i ] = $this->toUTF8( $col[ $i ] );
690 + }
691 + }
730 692 }
731 693
732 694 return $data;
733 695 }
@@ -749,14 +711,10 @@
749 711 if ( ! current_user_can( 'edit_posts' ) ) {
750 712 return false;
751 713 }
752 714
753 - $remote_data = false;
754 - if ( isset( $data['url'] ) && function_exists( 'wp_http_validate_url' ) ) {
755 - $remote_data = wp_http_validate_url( $data['url'] );
756 - }
757 - if ( false !== $remote_data && ! is_wp_error( $remote_data ) ) {
758 - $source = new Visualizer_Source_Csv_Remote( $remote_data );
715 + if ( $data['url'] && ! is_wp_error( $data['url'] ) && filter_var( $data['url'], FILTER_VALIDATE_URL ) ) {
716 + $source = new Visualizer_Source_Csv_Remote( $data['url'] );
759 717 if ( $source->fetch() ) {
760 718 $temp = $source->getData();
761 719 if ( is_string( $temp ) && is_array( unserialize( $temp ) ) ) {
762 720 $content['series'] = $source->getSeries();