PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.9
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.9
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | classes/Visualizer/Module/Chart.php +44 -9 3.0.53.0.9 View file →
@@ -56,11 +56,9 @@
56 56 $this->_addAjaxAction( Visualizer_Plugin::ACTION_CREATE_CHART, 'renderChartPages' );
57 57 $this->_addAjaxAction( Visualizer_Plugin::ACTION_EDIT_CHART, 'renderChartPages' );
58 58 $this->_addAjaxAction( Visualizer_Plugin::ACTION_UPLOAD_DATA, 'uploadData' );
59 59 $this->_addAjaxAction( Visualizer_Plugin::ACTION_CLONE_CHART, 'cloneChart' );
60 - // Added by Ash/Upwork
61 60 $this->_addAjaxAction( Visualizer_Plugin::ACTION_EXPORT_DATA, 'exportData' );
62 - // Added by Ash/Upwork
63 61 }
64 62
65 63 /**
66 64 * Fetches charts from database.
@@ -82,8 +80,13 @@
82 80 )
83 81 ),
84 82 );
85 83 $filter = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING );
84 + if ( empty( $filter ) ) {
85 + // 'filter' is from the modal from the add media button.
86 + $filter = filter_input( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
87 + }
88 +
86 89 if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) {
87 90 $query_args['meta_query'] = array(
88 91 array(
89 92 'key' => Visualizer_Plugin::CF_CHART_TYPE,
@@ -205,9 +208,9 @@
205 208 defined( 'IFRAME_REQUEST' ) || define( 'IFRAME_REQUEST', 1 );
206 209 // check chart, if chart not exists, will create new one and redirects to the same page with proper chart id
207 210 $chart_id = isset( $_GET['chart'] ) ? filter_var( $_GET['chart'], FILTER_VALIDATE_INT ) : '';
208 211 if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
209 - $default_type = 'line';
212 + $default_type = isset( $_GET['type'] ) && ! empty( $_GET['type'] ) ? $_GET['type'] : 'line';
210 213 $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' );
211 214 $source->fetch();
212 215 $chart_id = wp_insert_post(
213 216 array(
@@ -261,11 +264,27 @@
261 264 }
262 265 // dispatch pages
263 266 $this->_chart = get_post( $chart_id );
264 267 $tab = isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ? $_GET['tab'] : 'visualizer';
268 +
269 + // skip chart type pages only for existing charts.
270 + if ( VISUALIZER_SKIP_CHART_TYPE_PAGE && 'auto-draft' !== $this->_chart->post_status && ( ! empty( $_GET['tab'] ) && 'visualizer' === $_GET['tab'] ) ) {
271 + $tab = 'settings';
272 + }
273 +
274 + if ( isset( $_POST['cancel'] ) && 1 === intval( $_POST['cancel'] ) ) {
275 + // if the cancel button is clicked.
276 + $this->undoRevisions( $chart_id, true );
277 + } elseif ( isset( $_POST['save'] ) && 1 === intval( $_POST['save'] ) ) {
278 + // if the save button is clicked.
279 + $this->undoRevisions( $chart_id, false );
280 + } else {
281 + // if the edit button is clicked.
282 + $this->_chart = $this->handleExistingRevisions( $chart_id, $this->_chart );
283 + }
284 +
265 285 switch ( $tab ) {
266 286 case 'settings':
267 - // changed by Ash/Upwork
268 287 $this->_handleDataAndSettingsPage();
269 288 break;
270 289 case 'type': // fall through.
271 290 case 'visualizer': // fall through.
@@ -325,8 +344,9 @@
325 344 ),
326 345 'charts' => array(
327 346 'canvas' => $data,
328 347 ),
348 + 'language' => $this->get_language(),
329 349 'map_api_key' => get_option( 'visualizer-map-api-key' ),
330 350 'ajax' => array(
331 351 'url' => admin_url( 'admin-ajax.php' ),
332 352 'nonces' => array(
@@ -345,8 +365,11 @@
345 365 if ( filter_input( INPUT_GET, 'library', FILTER_VALIDATE_BOOLEAN ) ) {
346 366 $render->button = filter_input( INPUT_GET, 'action' ) == Visualizer_Plugin::ACTION_EDIT_CHART
347 367 ? esc_html__( 'Save Chart', 'visualizer' )
348 368 : esc_html__( 'Create Chart', 'visualizer' );
369 + if ( filter_input( INPUT_GET, 'action' ) == Visualizer_Plugin::ACTION_EDIT_CHART ) {
370 + $render->cancel_button = esc_html__( 'Cancel', 'visualizer' );
371 + }
349 372 } else {
350 373 $render->button = esc_attr__( 'Insert Chart', 'visualizer' );
351 374 }
352 375 if ( VISUALIZER_PRO ) {
@@ -414,20 +437,32 @@
414 437 *
415 438 * @access public
416 439 */
417 440 public function uploadData() {
441 + // if this is being called internally from pro and VISUALIZER_DO_NOT_DIE is set.
442 + // otherwise, assume this is a normal web request.
443 + $can_die = ! ( defined( 'VISUALIZER_DO_NOT_DIE' ) && VISUALIZER_DO_NOT_DIE );
444 +
418 445 // validate nonce
419 - // do not use filter_input as it does not work for phpunit test cases, use filter_var instead
420 446 if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'] ) ) {
447 + if ( ! $can_die ) {
448 + return;
449 + }
421 450 status_header( 403 );
422 451 exit;
423 452 }
453 +
424 454 // check chart, if chart exists
455 + // do not use filter_input as it does not work for phpunit test cases, use filter_var instead
425 456 $chart_id = isset( $_GET['chart'] ) ? filter_var( $_GET['chart'], FILTER_VALIDATE_INT ) : '';
426 457 if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
458 + if ( ! $can_die ) {
459 + return;
460 + }
427 461 status_header( 400 );
428 462 exit;
429 463 }
464 +
430 465 if ( ! isset( $_POST['vz-import-time'] ) ) {
431 466 apply_filters( 'visualizer_pro_remove_schedule', $chart_id );
432 467 }
433 468
@@ -444,12 +479,10 @@
444 479 apply_filters( 'visualizer_pro_chart_schedule', $chart_id, $_POST['remote_data'], $_POST['vz-import-time'] );
445 480 }
446 481 } elseif ( isset( $_FILES['local_data'] ) && $_FILES['local_data']['error'] == 0 ) {
447 482 $source = new Visualizer_Source_Csv( $_FILES['local_data']['tmp_name'] );
448 - // Added by Ash/Upwork
449 483 } elseif ( isset( $_POST['chart_data'] ) && strlen( $_POST['chart_data'] ) > 0 ) {
450 484 $source = apply_filters( 'visualizer_pro_handle_chart_data', $_POST['chart_data'], '' );
451 - // Added by Ash/Upwork
452 485 } else {
453 486 $render->message = esc_html__( 'CSV file with chart data was not uploaded. Please, try again.', 'visualizer' );
454 487 }
455 488 if ( $source ) {
@@ -465,11 +498,12 @@
465 498 $render->message = esc_html__( 'CSV file is broken or invalid. Please, try again.', 'visualizer' );
466 499 }
467 500 }
468 501 $render->render();
469 - if ( ! ( defined( 'VISUALIZER_DO_NOT_DIE' ) && VISUALIZER_DO_NOT_DIE ) ) {
470 - defined( 'WP_TESTS_DOMAIN' ) ? wp_die() : exit();
502 + if ( ! $can_die ) {
503 + return;
471 504 }
505 + defined( 'WP_TESTS_DOMAIN' ) ? wp_die() : exit();
472 506 }
473 507
474 508 /**
475 509 * Clones the chart.
@@ -587,5 +621,6 @@
587 621 // Added by Ash/Upwork
588 622 $this->_addAction( 'admin_head', 'renderFlattrScript' );
589 623 wp_iframe( array( $render, 'render' ) );
590 624 }
625 +
591 626 }