| @@ -66,9 +66,9 @@ | ||
| 66 | 66 | /** |
| 67 | 67 | * Enqueue front end and editor JavaScript and CSS |
| 68 | 68 | */ |
| 69 | 69 | public function enqueue_gutenberg_scripts() { |
| 70 | - global $wp_version, $pagenow; | |
| 70 | + global $wp_version; | |
| 71 | 71 | |
| 72 | 72 | $blockPath = VISUALIZER_ABSURL . 'classes/Visualizer/Gutenberg/build/block.js'; |
| 73 | 73 | $handsontableJS = VISUALIZER_ABSURL . 'classes/Visualizer/Gutenberg/build/handsontable.js'; |
| 74 | 74 | $stylePath = VISUALIZER_ABSURL . 'classes/Visualizer/Gutenberg/build/block.css'; |
| @@ -79,19 +79,11 @@ | ||
| 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 | - wp_enqueue_script( 'visualizer-gutenberg-block', $blockPath, array( 'wp-api', 'handsontable', 'visualizer-datatables', 'moment', 'lodash' ), $version, true ); | |
| 85 | + wp_enqueue_script( 'visualizer-gutenberg-block', $blockPath, array( 'wp-api', 'handsontable', 'visualizer-datatables', 'moment' ), $version, true ); | |
| 94 | 86 | |
| 95 | 87 | $type = 'community'; |
| 96 | 88 | |
| 97 | 89 | if ( Visualizer_Module::is_pro() ) { |
| @@ -104,16 +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 | - 'isFullSiteEditor' => 'site-editor.php' === $pagenow, | |
| 116 | 106 | ); |
| 117 | 107 | wp_localize_script( 'visualizer-gutenberg-block', 'visualizerLocalize', $translation_array ); |
| 118 | 108 | |
| 119 | 109 | // Enqueue frontend and editor block styles |
| @@ -351,11 +341,9 @@ | ||
| 351 | 341 | $data['visualizer-default-data'] = get_post_meta( $post_id, Visualizer_Plugin::CF_DEFAULT_DATA, true ); |
| 352 | 342 | |
| 353 | 343 | // faetch and update settings |
| 354 | 344 | $data['visualizer-settings'] = get_post_meta( $post_id, Visualizer_Plugin::CF_SETTINGS, true ); |
| 355 | - if ( empty( $data['visualizer-settings']['pagination'] ) ) { | |
| 356 | - $data['visualizer-settings']['pageSize'] = ''; | |
| 357 | - } | |
| 345 | + | |
| 358 | 346 | // handle series filter hooks |
| 359 | 347 | $data['visualizer-series'] = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $post_id, Visualizer_Plugin::CF_SERIES, true ), $post_id, $data['visualizer-chart-type'] ); |
| 360 | 348 | |
| 361 | 349 | // handle settings filter hooks |
| @@ -369,12 +357,8 @@ | ||
| 369 | 357 | if ( in_array( $data['visualizer-chart-type'], array( 'tabular' ), true ) ) { |
| 370 | 358 | $data['visualizer-data'] = $this->format_chart_data( $data['visualizer-data'], $data['visualizer-series'] ); |
| 371 | 359 | } |
| 372 | 360 | |
| 373 | - if ( ! isset( $data['visualizer-settings']['hAxis']['format'] ) ) { | |
| 374 | - $data['visualizer-settings']['hAxis']['format'] = ''; | |
| 375 | - } | |
| 376 | - | |
| 377 | 361 | $data['visualizer-data-exploded'] = ''; |
| 378 | 362 | // handle annotations for google charts |
| 379 | 363 | if ( 'GoogleCharts' === $library ) { |
| 380 | 364 | // this will contain the data of both axis. |
| @@ -441,10 +425,10 @@ | ||
| 441 | 425 | $json_root = get_post_meta( $post_id, Visualizer_Plugin::CF_JSON_ROOT, true ); |
| 442 | 426 | |
| 443 | 427 | $json_paging = get_post_meta( $post_id, Visualizer_Plugin::CF_JSON_PAGING, true ); |
| 444 | 428 | |
| 445 | - if ( ! empty( $import ) && $schedule >= 0 ) { | |
| 446 | - $data['visualizer-chart-url'] = $import; | |
| 429 | + if ( ! empty( $import ) && ! empty( $schedule ) ) { | |
| 430 | + $data['visualizer-chart-url'] = $import; | |
| 447 | 431 | $data['visualizer-chart-schedule'] = $schedule; |
| 448 | 432 | } |
| 449 | 433 | |
| 450 | 434 | if ( ! empty( $db_schedule ) && ! empty( $db_query ) ) { |
| @@ -597,9 +581,9 @@ | ||
| 597 | 581 | update_post_meta( $data['id'], Visualizer_Plugin::CF_DEFAULT_DATA, $data['visualizer-default-data'] ); |
| 598 | 582 | update_post_meta( $data['id'], Visualizer_Plugin::CF_SERIES, $data['visualizer-series'] ); |
| 599 | 583 | update_post_meta( $data['id'], Visualizer_Plugin::CF_SETTINGS, $data['visualizer-settings'] ); |
| 600 | 584 | |
| 601 | - if ( $data['visualizer-chart-url'] && $data['visualizer-chart-schedule'] >= 0 ) { | |
| 585 | + if ( $data['visualizer-chart-url'] && $data['visualizer-chart-schedule'] ) { | |
| 602 | 586 | $chart_url = esc_url_raw( $data['visualizer-chart-url'] ); |
| 603 | 587 | $chart_schedule = intval( $data['visualizer-chart-schedule'] ); |
| 604 | 588 | update_post_meta( $data['id'], Visualizer_Plugin::CF_CHART_URL, $chart_url ); |
| 605 | 589 | apply_filters( 'visualizer_pro_chart_schedule', $data['id'], $chart_url, $chart_schedule ); |
| @@ -620,18 +604,8 @@ | ||
| 620 | 604 | } else { |
| 621 | 605 | delete_post_meta( $data['id'], Visualizer_Plugin::CF_DB_SCHEDULE ); |
| 622 | 606 | delete_post_meta( $data['id'], Visualizer_Plugin::CF_DB_QUERY ); |
| 623 | 607 | } |
| 624 | - | |
| 625 | - if ( 'Visualizer_Source_Csv_Remote' === $source_type ) { | |
| 626 | - $schedule_url = $data['visualizer-chart-url']; | |
| 627 | - $schedule_id = $data['visualizer-chart-schedule']; | |
| 628 | - update_post_meta( $data['id'], Visualizer_Plugin::CF_CHART_URL, $schedule_url ); | |
| 629 | - update_post_meta( $data['id'], Visualizer_Plugin::CF_CHART_SCHEDULE, $schedule_id ); | |
| 630 | - } else { | |
| 631 | - delete_post_meta( $data['id'], Visualizer_Plugin::CF_CHART_URL ); | |
| 632 | - delete_post_meta( $data['id'], Visualizer_Plugin::CF_CHART_SCHEDULE ); | |
| 633 | - } | |
| 634 | 608 | } |
| 635 | 609 | |
| 636 | 610 | if ( $source_type === 'Visualizer_Source_Json' ) { |
| 637 | 611 | $json_schedule = intval( $data['visualizer-json-schedule'] ); |
| @@ -676,14 +650,8 @@ | ||
| 676 | 650 | ); |
| 677 | 651 | |
| 678 | 652 | wp_update_post( $chart ); |
| 679 | 653 | |
| 680 | - // Clear existing chart cache. | |
| 681 | - $cache_key = Visualizer_Plugin::CF_CHART_CACHE . '_' . $data['id']; | |
| 682 | - if ( get_transient( $cache_key ) ) { | |
| 683 | - delete_transient( $cache_key ); | |
| 684 | - } | |
| 685 | - | |
| 686 | 654 | $revisions = wp_get_post_revisions( $data['id'], array( 'order' => 'ASC' ) ); |
| 687 | 655 | |
| 688 | 656 | if ( count( $revisions ) > 1 ) { |
| 689 | 657 | $revision_ids = array_keys( $revisions ); |
| @@ -766,14 +734,10 @@ | ||
| 766 | 734 | if ( ! current_user_can( 'edit_posts' ) ) { |
| 767 | 735 | return false; |
| 768 | 736 | } |
| 769 | 737 | |
| 770 | - $remote_data = false; | |
| 771 | - if ( isset( $data['url'] ) && function_exists( 'wp_http_validate_url' ) ) { | |
| 772 | - $remote_data = wp_http_validate_url( $data['url'] ); | |
| 773 | - } | |
| 774 | - if ( false !== $remote_data && ! is_wp_error( $remote_data ) ) { | |
| 775 | - $source = new Visualizer_Source_Csv_Remote( $remote_data ); | |
| 738 | + if ( $data['url'] && ! is_wp_error( $data['url'] ) && filter_var( $data['url'], FILTER_VALIDATE_URL ) ) { | |
| 739 | + $source = new Visualizer_Source_Csv_Remote( $data['url'] ); | |
| 776 | 740 | if ( $source->fetch() ) { |
| 777 | 741 | $temp = $source->getData(); |
| 778 | 742 | if ( is_string( $temp ) && is_array( unserialize( $temp ) ) ) { |
| 779 | 743 | $content['series'] = $source->getSeries(); |