| @@ -538,12 +538,8 @@ | ||
| 538 | 538 | if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type !== Visualizer_Plugin::CPT_VISUALIZER ) { |
| 539 | 539 | if ( empty( $_GET['lang'] ) || empty( $_GET['parent_chart_id'] ) ) { |
| 540 | 540 | $this->deleteOldCharts(); |
| 541 | 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 | 542 | $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' ); |
| 547 | 543 | $source->fetch(); |
| 548 | 544 | $chart_id = wp_insert_post( |
| 549 | 545 | array( |
| @@ -952,9 +948,9 @@ | ||
| 952 | 948 | // process post request |
| 953 | 949 | if ( $_SERVER['REQUEST_METHOD'] === 'POST' && wp_verify_nonce( filter_input( INPUT_POST, 'nonce' ) ) ) { |
| 954 | 950 | $type = filter_input( INPUT_POST, 'type' ); |
| 955 | 951 | $library = filter_input( INPUT_POST, 'chart-library' ); |
| 956 | - if ( Visualizer_Module_Admin::checkChartStatus( $type ) ) { | |
| 952 | + if ( in_array( $type, Visualizer_Plugin::getChartTypes(), true ) ) { | |
| 957 | 953 | if ( empty( $library ) ) { |
| 958 | 954 | // library cannot be empty. |
| 959 | 955 | do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'Chart library empty while creating the chart! Aborting...', 'error', __FILE__, __LINE__ ); |
| 960 | 956 | return; |
| @@ -1420,12 +1416,8 @@ | ||
| 1420 | 1416 | */ |
| 1421 | 1417 | public function getQueryData() { |
| 1422 | 1418 | check_ajax_referer( Visualizer_Plugin::ACTION_FETCH_DB_DATA . Visualizer_Plugin::VERSION, 'security' ); |
| 1423 | 1419 | |
| 1424 | - if ( ! current_user_can( 'administrator' ) ) { | |
| 1425 | - wp_send_json_error( array( 'msg' => __( 'Action not allowed for this user.', 'visualizer' ) ) ); | |
| 1426 | - } | |
| 1427 | - | |
| 1428 | 1420 | $params = wp_parse_args( $_POST['params'] ); |
| 1429 | 1421 | $chart_id = filter_var( $params['chart_id'], FILTER_VALIDATE_INT ); |
| 1430 | 1422 | |
| 1431 | 1423 | $source = new Visualizer_Source_Query( stripslashes( $params['query'] ), $chart_id, $params ); |
| @@ -1590,12 +1582,8 @@ | ||
| 1590 | 1582 | // Save the image in the uploads directory. |
| 1591 | 1583 | require_once ABSPATH . '/wp-admin/includes/file.php'; |
| 1592 | 1584 | \WP_Filesystem(); |
| 1593 | 1585 | 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 | 1586 | $upload_file = $wp_filesystem->put_contents( $upload_path . $hashed_filename, $decoded ); |
| 1599 | 1587 | |
| 1600 | 1588 | // Insert new chart image. |
| 1601 | 1589 | $attachment = array( |