| @@ -460,10 +460,10 @@ | ||
| 460 | 460 | $success = $chart && $chart->post_type === Visualizer_Plugin::CPT_VISUALIZER; |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | if ( $success ) { |
| 464 | - global $sitepress; | |
| 465 | - if ( Visualizer_Module::is_pro() && ( function_exists( 'icl_get_languages' ) && $sitepress instanceof \SitePress ) ) { | |
| 464 | + if ( Visualizer_Module::is_pro() && function_exists( 'icl_get_languages' ) ) { | |
| 465 | + global $sitepress; | |
| 466 | 466 | $trid = $sitepress->get_element_trid( $chart_id, 'post_' . Visualizer_Plugin::CPT_VISUALIZER ); |
| 467 | 467 | $translations = $sitepress->get_element_translations( $trid ); |
| 468 | 468 | if ( ! empty( $translations ) ) { |
| 469 | 469 | foreach ( $translations as $translated_post ) { |
| @@ -531,19 +531,12 @@ | ||
| 531 | 531 | // Set current screen for the render chart. |
| 532 | 532 | set_current_screen( 'visualizer_render_chart' ); |
| 533 | 533 | // check chart, if chart not exists, will create new one and redirects to the same page with proper chart id |
| 534 | 534 | $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 | 535 | if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type !== Visualizer_Plugin::CPT_VISUALIZER ) { |
| 539 | 536 | if ( empty( $_GET['lang'] ) || empty( $_GET['parent_chart_id'] ) ) { |
| 540 | 537 | $this->deleteOldCharts(); |
| 541 | 538 | $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 | 539 | $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' ); |
| 547 | 540 | $source->fetch(); |
| 548 | 541 | $chart_id = wp_insert_post( |
| 549 | 542 | array( |
| @@ -952,9 +945,9 @@ | ||
| 952 | 945 | // process post request |
| 953 | 946 | if ( $_SERVER['REQUEST_METHOD'] === 'POST' && wp_verify_nonce( filter_input( INPUT_POST, 'nonce' ) ) ) { |
| 954 | 947 | $type = filter_input( INPUT_POST, 'type' ); |
| 955 | 948 | $library = filter_input( INPUT_POST, 'chart-library' ); |
| 956 | - if ( Visualizer_Module_Admin::checkChartStatus( $type ) ) { | |
| 949 | + if ( in_array( $type, Visualizer_Plugin::getChartTypes(), true ) ) { | |
| 957 | 950 | if ( empty( $library ) ) { |
| 958 | 951 | // library cannot be empty. |
| 959 | 952 | do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'Chart library empty while creating the chart! Aborting...', 'error', __FILE__, __LINE__ ); |
| 960 | 953 | return; |
| @@ -1420,12 +1413,8 @@ | ||
| 1420 | 1413 | */ |
| 1421 | 1414 | public function getQueryData() { |
| 1422 | 1415 | check_ajax_referer( Visualizer_Plugin::ACTION_FETCH_DB_DATA . Visualizer_Plugin::VERSION, 'security' ); |
| 1423 | 1416 | |
| 1424 | - if ( ! current_user_can( 'administrator' ) ) { | |
| 1425 | - wp_send_json_error( array( 'msg' => __( 'Action not allowed for this user.', 'visualizer' ) ) ); | |
| 1426 | - } | |
| 1427 | - | |
| 1428 | 1417 | $params = wp_parse_args( $_POST['params'] ); |
| 1429 | 1418 | $chart_id = filter_var( $params['chart_id'], FILTER_VALIDATE_INT ); |
| 1430 | 1419 | |
| 1431 | 1420 | $source = new Visualizer_Source_Query( stripslashes( $params['query'] ), $chart_id, $params ); |
| @@ -1590,12 +1579,8 @@ | ||
| 1590 | 1579 | // Save the image in the uploads directory. |
| 1591 | 1580 | require_once ABSPATH . '/wp-admin/includes/file.php'; |
| 1592 | 1581 | \WP_Filesystem(); |
| 1593 | 1582 | global $wp_filesystem; |
| 1594 | - if ( ! is_a( $wp_filesystem, 'WP_Filesystem_Base' ) ) { | |
| 1595 | - $creds = request_filesystem_credentials( site_url() ); | |
| 1596 | - wp_filesystem( $creds ); | |
| 1597 | - } | |
| 1598 | 1583 | $upload_file = $wp_filesystem->put_contents( $upload_path . $hashed_filename, $decoded ); |
| 1599 | 1584 | |
| 1600 | 1585 | // Insert new chart image. |
| 1601 | 1586 | $attachment = array( |