| @@ -134,22 +134,8 @@ | ||
| 134 | 134 | ), |
| 135 | 135 | ) |
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | - if ( Visualizer_Module::is_pro() ) { | |
| 139 | - $is_woocommerce_report = filter_input( | |
| 140 | - INPUT_POST, | |
| 141 | - 'is_woocommerce_report', | |
| 142 | - FILTER_VALIDATE_BOOLEAN | |
| 143 | - ); | |
| 144 | - | |
| 145 | - if ( $is_woocommerce_report ) { | |
| 146 | - update_post_meta( $chart_id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE, true ); | |
| 147 | - } else { | |
| 148 | - delete_post_meta( $chart_id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE ); | |
| 149 | - } | |
| 150 | - } | |
| 151 | - | |
| 152 | 138 | delete_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE ); |
| 153 | 139 | |
| 154 | 140 | if ( -1 < $time ) { |
| 155 | 141 | add_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, $time ); |
| @@ -259,16 +245,8 @@ | ||
| 259 | 245 | if ( ! empty( $params['paging'] ) ) { |
| 260 | 246 | add_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_PAGING, $params['paging'] ); |
| 261 | 247 | } |
| 262 | 248 | |
| 263 | - if ( Visualizer_Module::is_pro() ) { | |
| 264 | - if ( ! empty( $params['vz_woo_source'] ) ) { | |
| 265 | - update_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_WOOCOMMERCE_SOURCE, $params['vz_woo_source'] ); | |
| 266 | - } else { | |
| 267 | - delete_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_WOOCOMMERCE_SOURCE ); | |
| 268 | - } | |
| 269 | - } | |
| 270 | - | |
| 271 | 249 | $time = filter_input( |
| 272 | 250 | INPUT_POST, |
| 273 | 251 | 'time', |
| 274 | 252 | FILTER_VALIDATE_INT, |
| @@ -460,22 +438,9 @@ | ||
| 460 | 438 | $success = $chart && $chart->post_type === Visualizer_Plugin::CPT_VISUALIZER; |
| 461 | 439 | } |
| 462 | 440 | } |
| 463 | 441 | if ( $success ) { |
| 464 | - global $sitepress; | |
| 465 | - if ( Visualizer_Module::is_pro() && ( function_exists( 'icl_get_languages' ) && $sitepress instanceof \SitePress ) ) { | |
| 466 | - $trid = $sitepress->get_element_trid( $chart_id, 'post_' . Visualizer_Plugin::CPT_VISUALIZER ); | |
| 467 | - $translations = $sitepress->get_element_translations( $trid ); | |
| 468 | - if ( ! empty( $translations ) ) { | |
| 469 | - foreach ( $translations as $translated_post ) { | |
| 470 | - wp_delete_post( $translated_post->element_id, true ); | |
| 471 | - } | |
| 472 | - } else { | |
| 473 | - wp_delete_post( $chart_id, true ); | |
| 474 | - } | |
| 475 | - } else { | |
| 476 | - wp_delete_post( $chart_id, true ); | |
| 477 | - } | |
| 442 | + wp_delete_post( $chart_id, true ); | |
| 478 | 443 | } |
| 479 | 444 | if ( $is_post ) { |
| 480 | 445 | self::_sendResponse( |
| 481 | 446 | array( |
| @@ -531,78 +496,35 @@ | ||
| 531 | 496 | // Set current screen for the render chart. |
| 532 | 497 | set_current_screen( 'visualizer_render_chart' ); |
| 533 | 498 | // check chart, if chart not exists, will create new one and redirects to the same page with proper chart id |
| 534 | 499 | $chart_id = isset( $_GET['chart'] ) ? filter_var( $_GET['chart'], FILTER_VALIDATE_INT ) : ''; |
| 535 | - if ( ! empty( $_POST ) ) { | |
| 536 | - $_POST = map_deep( $_POST, 'wp_strip_all_tags' ); | |
| 537 | - } | |
| 538 | 500 | if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type !== Visualizer_Plugin::CPT_VISUALIZER ) { |
| 539 | - if ( empty( $_GET['lang'] ) || empty( $_GET['parent_chart_id'] ) ) { | |
| 540 | - $this->deleteOldCharts(); | |
| 541 | - $default_type = isset( $_GET['type'] ) && ! empty( $_GET['type'] ) ? $_GET['type'] : 'line'; | |
| 542 | - $chart_status = Visualizer_Module_Admin::checkChartStatus( $default_type ); | |
| 543 | - if ( ! $chart_status ) { | |
| 544 | - $default_type = 'line'; | |
| 545 | - } | |
| 546 | - $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' ); | |
| 547 | - $source->fetch(); | |
| 548 | - $chart_id = wp_insert_post( | |
| 501 | + $this->deleteOldCharts(); | |
| 502 | + $default_type = isset( $_GET['type'] ) && ! empty( $_GET['type'] ) ? $_GET['type'] : 'line'; | |
| 503 | + $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' ); | |
| 504 | + $source->fetch(); | |
| 505 | + $chart_id = wp_insert_post( | |
| 506 | + array( | |
| 507 | + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 508 | + 'post_title' => 'Visualization', | |
| 509 | + 'post_author' => get_current_user_id(), | |
| 510 | + 'post_status' => 'auto-draft', | |
| 511 | + 'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ), | |
| 512 | + ) | |
| 513 | + ); | |
| 514 | + if ( $chart_id && ! is_wp_error( $chart_id ) ) { | |
| 515 | + add_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, $default_type ); | |
| 516 | + add_post_meta( $chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, 1 ); | |
| 517 | + add_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() ); | |
| 518 | + add_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $source->getSeries() ); | |
| 519 | + add_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, '' ); | |
| 520 | + add_post_meta( | |
| 521 | + $chart_id, | |
| 522 | + Visualizer_Plugin::CF_SETTINGS, | |
| 549 | 523 | array( |
| 550 | - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 551 | - 'post_title' => 'Visualization', | |
| 552 | - 'post_author' => get_current_user_id(), | |
| 553 | - 'post_status' => 'auto-draft', | |
| 554 | - 'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ), | |
| 524 | + 'focusTarget' => 'datum', | |
| 555 | 525 | ) |
| 556 | 526 | ); |
| 557 | - if ( $chart_id && ! is_wp_error( $chart_id ) ) { | |
| 558 | - add_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, $default_type ); | |
| 559 | - add_post_meta( $chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, 1 ); | |
| 560 | - add_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() ); | |
| 561 | - add_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $source->getSeries() ); | |
| 562 | - add_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, '' ); | |
| 563 | - add_post_meta( | |
| 564 | - $chart_id, | |
| 565 | - Visualizer_Plugin::CF_SETTINGS, | |
| 566 | - array( | |
| 567 | - 'focusTarget' => 'datum', | |
| 568 | - ) | |
| 569 | - ); | |
| 570 | - | |
| 571 | - do_action( 'visualizer_pro_new_chart_defaults', $chart_id ); | |
| 572 | - } | |
| 573 | - } else { | |
| 574 | - if ( current_user_can( 'edit_posts' ) ) { | |
| 575 | - $parent_chart_id = isset( $_GET['parent_chart_id'] ) ? filter_var( $_GET['parent_chart_id'], FILTER_VALIDATE_INT ) : ''; | |
| 576 | - $success = false; | |
| 577 | - if ( $parent_chart_id ) { | |
| 578 | - $parent_chart = get_post( $parent_chart_id ); | |
| 579 | - $success = $parent_chart && $parent_chart->post_type === Visualizer_Plugin::CPT_VISUALIZER; | |
| 580 | - } | |
| 581 | - if ( $success ) { | |
| 582 | - $new_chart_id = wp_insert_post( | |
| 583 | - array( | |
| 584 | - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 585 | - 'post_title' => 'Visualization', | |
| 586 | - 'post_author' => get_current_user_id(), | |
| 587 | - 'post_status' => $parent_chart->post_status, | |
| 588 | - 'post_content' => $parent_chart->post_content, | |
| 589 | - ) | |
| 590 | - ); | |
| 591 | - | |
| 592 | - if ( is_wp_error( $new_chart_id ) ) { | |
| 593 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Error while cloning chart %d = %s', $parent_chart_id, print_r( $new_chart_id, true ) ), 'error', __FILE__, __LINE__ ); | |
| 594 | - } else { | |
| 595 | - $post_meta = get_post_meta( $parent_chart_id ); | |
| 596 | - $chart_id = $new_chart_id; | |
| 597 | - foreach ( $post_meta as $key => $value ) { | |
| 598 | - if ( strpos( $key, 'visualizer-' ) !== false ) { | |
| 599 | - add_post_meta( $new_chart_id, $key, maybe_unserialize( $value[0] ) ); | |
| 600 | - } | |
| 601 | - } | |
| 602 | - } | |
| 603 | - } | |
| 604 | - } | |
| 605 | 527 | do_action( 'visualizer_pro_new_chart_defaults', $chart_id ); |
| 606 | 528 | } |
| 607 | 529 | wp_redirect( esc_url_raw( add_query_arg( 'chart', (int) $chart_id ) ) ); |
| 608 | 530 | |
| @@ -814,9 +736,9 @@ | ||
| 814 | 736 | if ( empty( $title ) ) { |
| 815 | 737 | $title = $this->_chart->ID; |
| 816 | 738 | } |
| 817 | 739 | $settings['internal_title'] = $title; |
| 818 | - $settings_label = isset( $settings['pieResidueSliceLabel'] ) ? $settings['pieResidueSliceLabel'] : ''; | |
| 740 | + $settings_label = $settings['pieResidueSliceLabel']; | |
| 819 | 741 | if ( empty( $settings_label ) ) { |
| 820 | 742 | $settings['pieResidueSliceLabel'] = esc_html__( 'Other', 'visualizer' ); |
| 821 | 743 | } else { |
| 822 | 744 | $settings['pieResidueSliceLabel'] = $settings_label; |
| @@ -909,9 +831,8 @@ | ||
| 909 | 831 | 'page_type' => 'chart', |
| 910 | 832 | 'json_tag_separator' => Visualizer_Source_Json::TAG_SEPARATOR, |
| 911 | 833 | 'json_tag_separator_view' => Visualizer_Source_Json::TAG_SEPARATOR_VIEW, |
| 912 | 834 | 'is_front' => false, |
| 913 | - 'rest_base' => get_rest_url( null, 'wc/v3/reports/' ), | |
| 914 | 835 | ) |
| 915 | 836 | ); |
| 916 | 837 | |
| 917 | 838 | $render = new Visualizer_Render_Page_Data(); |
| @@ -952,9 +873,9 @@ | ||
| 952 | 873 | // process post request |
| 953 | 874 | if ( $_SERVER['REQUEST_METHOD'] === 'POST' && wp_verify_nonce( filter_input( INPUT_POST, 'nonce' ) ) ) { |
| 954 | 875 | $type = filter_input( INPUT_POST, 'type' ); |
| 955 | 876 | $library = filter_input( INPUT_POST, 'chart-library' ); |
| 956 | - if ( Visualizer_Module_Admin::checkChartStatus( $type ) ) { | |
| 877 | + if ( in_array( $type, Visualizer_Plugin::getChartTypes(), true ) ) { | |
| 957 | 878 | if ( empty( $library ) ) { |
| 958 | 879 | // library cannot be empty. |
| 959 | 880 | do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'Chart library empty while creating the chart! Aborting...', 'error', __FILE__, __LINE__ ); |
| 960 | 881 | return; |
| @@ -1189,17 +1110,12 @@ | ||
| 1189 | 1110 | delete_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE ); |
| 1190 | 1111 | |
| 1191 | 1112 | $source = null; |
| 1192 | 1113 | $render = new Visualizer_Render_Page_Update(); |
| 1193 | - | |
| 1194 | - $remote_data = false; | |
| 1195 | - if ( isset( $_POST['remote_data'] ) && function_exists( 'wp_http_validate_url' ) ) { | |
| 1196 | - $remote_data = wp_http_validate_url( $_POST['remote_data'] ); | |
| 1197 | - } | |
| 1198 | - if ( false !== $remote_data ) { | |
| 1199 | - $source = new Visualizer_Source_Csv_Remote( $remote_data ); | |
| 1114 | + if ( isset( $_POST['remote_data'] ) && filter_var( $_POST['remote_data'], FILTER_VALIDATE_URL ) ) { | |
| 1115 | + $source = new Visualizer_Source_Csv_Remote( $_POST['remote_data'] ); | |
| 1200 | 1116 | if ( isset( $_POST['vz-import-time'] ) ) { |
| 1201 | - apply_filters( 'visualizer_pro_chart_schedule', $chart_id, $remote_data, $_POST['vz-import-time'] ); | |
| 1117 | + apply_filters( 'visualizer_pro_chart_schedule', $chart_id, $_POST['remote_data'], $_POST['vz-import-time'] ); | |
| 1202 | 1118 | } |
| 1203 | 1119 | // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
| 1204 | 1120 | } elseif ( isset( $_FILES['local_data'] ) && $_FILES['local_data']['error'] == 0 ) { |
| 1205 | 1121 | $source = new Visualizer_Source_Csv( $_FILES['local_data']['tmp_name'] ); |
| @@ -1323,11 +1239,9 @@ | ||
| 1323 | 1239 | 'type' => filter_input( INPUT_GET, 'type' ), |
| 1324 | 1240 | 'vaction' => false, |
| 1325 | 1241 | ), |
| 1326 | 1242 | admin_url( 'admin.php' ) |
| 1327 | - ), | |
| 1328 | - null, | |
| 1329 | - 'db' | |
| 1243 | + ) | |
| 1330 | 1244 | ); |
| 1331 | 1245 | } |
| 1332 | 1246 | } |
| 1333 | 1247 | |
| @@ -1333,8 +1247,9 @@ | ||
| 1333 | 1247 | |
| 1334 | 1248 | if ( defined( 'WP_TESTS_DOMAIN' ) ) { |
| 1335 | 1249 | wp_die(); |
| 1336 | 1250 | } |
| 1251 | + | |
| 1337 | 1252 | wp_redirect( $redirect ); |
| 1338 | 1253 | exit; |
| 1339 | 1254 | } |
| 1340 | 1255 | |