| @@ -60,9 +60,8 @@ | ||
| 60 | 60 | $this->_addAjaxAction( Visualizer_Plugin::ACTION_EXPORT_DATA, 'exportData' ); |
| 61 | 61 | |
| 62 | 62 | $this->_addAjaxAction( Visualizer_Plugin::ACTION_FETCH_DB_DATA, 'getQueryData' ); |
| 63 | 63 | $this->_addAjaxAction( Visualizer_Plugin::ACTION_SAVE_DB_QUERY, 'saveQuery' ); |
| 64 | - $this->_addAjaxAction( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY, 'saveFilter' ); | |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | 66 | /** |
| 68 | 67 | * Fetches charts from database. |
| @@ -163,10 +162,8 @@ | ||
| 163 | 162 | $css = $arguments[0]; |
| 164 | 163 | $settings = $arguments[1]; |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | - $date_formats = Visualizer_Source::get_date_formats_if_exists( $series, $data ); | |
| 168 | - | |
| 169 | 166 | return array( |
| 170 | 167 | 'type' => $type, |
| 171 | 168 | 'series' => $series, |
| 172 | 169 | 'settings' => $settings, |
| @@ -172,9 +169,8 @@ | ||
| 172 | 169 | 'settings' => $settings, |
| 173 | 170 | 'data' => $data, |
| 174 | 171 | 'library' => $library, |
| 175 | 172 | 'css' => $css, |
| 176 | - 'date_formats' => $date_formats, | |
| 177 | 173 | ); |
| 178 | 174 | } |
| 179 | 175 | |
| 180 | 176 | /** |
| @@ -237,36 +233,8 @@ | ||
| 237 | 233 | exit; |
| 238 | 234 | } |
| 239 | 235 | |
| 240 | 236 | /** |
| 241 | - * Delete charts that are still in auto-draft mode. | |
| 242 | - */ | |
| 243 | - private function deleteOldCharts() { | |
| 244 | - $query = new WP_Query( | |
| 245 | - array( | |
| 246 | - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 247 | - 'post_status' => 'auto-draft', | |
| 248 | - 'fields' => 'ids', | |
| 249 | - 'update_post_meta_cache' => false, | |
| 250 | - 'update_post_term_cache' => false, | |
| 251 | - 'posts_per_page' => 50, | |
| 252 | - 'date_query' => array( | |
| 253 | - array( | |
| 254 | - 'before' => 'today', | |
| 255 | - ), | |
| 256 | - ), | |
| 257 | - ) | |
| 258 | - ); | |
| 259 | - | |
| 260 | - if ( $query->have_posts() ) { | |
| 261 | - $ids = array(); | |
| 262 | - while ( $query->have_posts() ) { | |
| 263 | - wp_delete_post( $query->next_post(), true ); | |
| 264 | - } | |
| 265 | - } | |
| 266 | - } | |
| 267 | - | |
| 268 | - /** | |
| 269 | 237 | * Renders appropriate page for chart builder. Creates new auto draft chart |
| 270 | 238 | * if no chart has been specified. |
| 271 | 239 | * |
| 272 | 240 | * @since 1.0.0 |
| @@ -277,9 +245,8 @@ | ||
| 277 | 245 | defined( 'IFRAME_REQUEST' ) || define( 'IFRAME_REQUEST', 1 ); |
| 278 | 246 | // check chart, if chart not exists, will create new one and redirects to the same page with proper chart id |
| 279 | 247 | $chart_id = isset( $_GET['chart'] ) ? filter_var( $_GET['chart'], FILTER_VALIDATE_INT ) : ''; |
| 280 | 248 | if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) { |
| 281 | - $this->deleteOldCharts(); | |
| 282 | 249 | $default_type = isset( $_GET['type'] ) && ! empty( $_GET['type'] ) ? $_GET['type'] : 'line'; |
| 283 | 250 | $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' ); |
| 284 | 251 | $source->fetch(); |
| 285 | 252 | $chart_id = wp_insert_post( |
| @@ -621,11 +588,9 @@ | ||
| 621 | 588 | } |
| 622 | 589 | |
| 623 | 590 | if ( ! isset( $_POST['chart_data_src'] ) || Visualizer_Plugin::CF_SOURCE_FILTER !== $_POST['chart_data_src'] ) { |
| 624 | 591 | // delete the filters in case this chart is being uploaded from other data sources |
| 625 | - delete_post_meta( $chart_id, Visualizer_Plugin::CF_FILTER_CONFIG ); | |
| 626 | - delete_post_meta( $chart_id, '__transient-' . Visualizer_Plugin::CF_FILTER_CONFIG ); | |
| 627 | - delete_post_meta( $chart_id, '__transient-' . Visualizer_Plugin::CF_DB_QUERY ); | |
| 592 | + delete_post_meta( $chart_id, 'visualizer-filter-config' ); | |
| 628 | 593 | |
| 629 | 594 | // delete "import from db" specific parameters. |
| 630 | 595 | delete_post_meta( $chart_id, Visualizer_Plugin::CF_DB_QUERY ); |
| 631 | 596 | delete_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE ); |
| @@ -640,9 +605,9 @@ | ||
| 640 | 605 | } |
| 641 | 606 | } elseif ( isset( $_FILES['local_data'] ) && $_FILES['local_data']['error'] == 0 ) { |
| 642 | 607 | $source = new Visualizer_Source_Csv( $_FILES['local_data']['tmp_name'] ); |
| 643 | 608 | } elseif ( isset( $_POST['chart_data'] ) && strlen( $_POST['chart_data'] ) > 0 ) { |
| 644 | - $source = apply_filters( 'visualizer_pro_handle_chart_data', $_POST['chart_data'], '', $chart_id, $_POST ); | |
| 609 | + $source = apply_filters( 'visualizer_pro_handle_chart_data', $_POST['chart_data'], '' ); | |
| 645 | 610 | } else { |
| 646 | 611 | $render->message = esc_html__( 'CSV file with chart data was not uploaded. Please, try again.', 'visualizer' ); |
| 647 | 612 | } |
| 648 | 613 | if ( $source ) { |
| @@ -873,37 +838,8 @@ | ||
| 873 | 838 | $render->message = $error; |
| 874 | 839 | } |
| 875 | 840 | } |
| 876 | 841 | $render->render(); |
| 877 | - if ( ! ( defined( 'VISUALIZER_DO_NOT_DIE' ) && VISUALIZER_DO_NOT_DIE ) ) { | |
| 878 | - defined( 'WP_TESTS_DOMAIN' ) ? wp_die() : exit(); | |
| 879 | - } | |
| 880 | - } | |
| 881 | - | |
| 882 | - | |
| 883 | - /** | |
| 884 | - * Saves the filter query and the schedule. | |
| 885 | - * | |
| 886 | - * @access public | |
| 887 | - */ | |
| 888 | - public function saveFilter() { | |
| 889 | - check_ajax_referer( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY . Visualizer_Plugin::VERSION, 'security' ); | |
| 890 | - | |
| 891 | - $chart_id = filter_input( | |
| 892 | - INPUT_GET, | |
| 893 | - 'chart', | |
| 894 | - FILTER_VALIDATE_INT, | |
| 895 | - array( | |
| 896 | - 'options' => array( | |
| 897 | - 'min_range' => 1, | |
| 898 | - ), | |
| 899 | - ) | |
| 900 | - ); | |
| 901 | - | |
| 902 | - $hours = $_POST['refresh']; | |
| 903 | - | |
| 904 | - do_action( 'visualizer_save_filter', $chart_id, $hours ); | |
| 905 | - | |
| 906 | 842 | if ( ! ( defined( 'VISUALIZER_DO_NOT_DIE' ) && VISUALIZER_DO_NOT_DIE ) ) { |
| 907 | 843 | defined( 'WP_TESTS_DOMAIN' ) ? wp_die() : exit(); |
| 908 | 844 | } |
| 909 | 845 | } |