PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.9.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.9.0
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 +96 -24 3.8.13.9.0 View file →
@@ -134,8 +134,22 @@
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 +
138 152 delete_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE );
139 153
140 154 if ( -1 < $time ) {
141 155 add_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, $time );
@@ -245,8 +259,16 @@
245 259 if ( ! empty( $params['paging'] ) ) {
246 260 add_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_PAGING, $params['paging'] );
247 261 }
248 262
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 +
249 271 $time = filter_input(
250 272 INPUT_POST,
251 273 'time',
252 274 FILTER_VALIDATE_INT,
@@ -438,9 +460,22 @@
438 460 $success = $chart && $chart->post_type === Visualizer_Plugin::CPT_VISUALIZER;
439 461 }
440 462 }
441 463 if ( $success ) {
442 - wp_delete_post( $chart_id, true );
464 + if ( Visualizer_Module::is_pro() && function_exists( 'icl_get_languages' ) ) {
465 + global $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 + }
443 478 }
444 479 if ( $is_post ) {
445 480 self::_sendResponse(
446 481 array(
@@ -497,34 +532,70 @@
497 532 set_current_screen( 'visualizer_render_chart' );
498 533 // check chart, if chart not exists, will create new one and redirects to the same page with proper chart id
499 534 $chart_id = isset( $_GET['chart'] ) ? filter_var( $_GET['chart'], FILTER_VALIDATE_INT ) : '';
500 535 if ( ! $chart_id || ! ( $chart = get_post( $chart_id ) ) || $chart->post_type !== Visualizer_Plugin::CPT_VISUALIZER ) {
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,
536 + if ( empty( $_GET['lang'] ) || empty( $_GET['parent_chart_id'] ) ) {
537 + $this->deleteOldCharts();
538 + $default_type = isset( $_GET['type'] ) && ! empty( $_GET['type'] ) ? $_GET['type'] : 'line';
539 + $source = new Visualizer_Source_Csv( VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples' . DIRECTORY_SEPARATOR . $default_type . '.csv' );
540 + $source->fetch();
541 + $chart_id = wp_insert_post(
523 542 array(
524 - 'focusTarget' => 'datum',
543 + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
544 + 'post_title' => 'Visualization',
545 + 'post_author' => get_current_user_id(),
546 + 'post_status' => 'auto-draft',
547 + 'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ),
525 548 )
526 549 );
550 + if ( $chart_id && ! is_wp_error( $chart_id ) ) {
551 + add_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, $default_type );
552 + add_post_meta( $chart_id, Visualizer_Plugin::CF_DEFAULT_DATA, 1 );
553 + add_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, $source->getSourceName() );
554 + add_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $source->getSeries() );
555 + add_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, '' );
556 + add_post_meta(
557 + $chart_id,
558 + Visualizer_Plugin::CF_SETTINGS,
559 + array(
560 + 'focusTarget' => 'datum',
561 + )
562 + );
563 +
564 + do_action( 'visualizer_pro_new_chart_defaults', $chart_id );
565 + }
566 + } else {
567 + if ( current_user_can( 'edit_posts' ) ) {
568 + $parent_chart_id = isset( $_GET['parent_chart_id'] ) ? filter_var( $_GET['parent_chart_id'], FILTER_VALIDATE_INT ) : '';
569 + $success = false;
570 + if ( $parent_chart_id ) {
571 + $parent_chart = get_post( $parent_chart_id );
572 + $success = $parent_chart && $parent_chart->post_type === Visualizer_Plugin::CPT_VISUALIZER;
573 + }
574 + if ( $success ) {
575 + $new_chart_id = wp_insert_post(
576 + array(
577 + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
578 + 'post_title' => 'Visualization',
579 + 'post_author' => get_current_user_id(),
580 + 'post_status' => $parent_chart->post_status,
581 + 'post_content' => $parent_chart->post_content,
582 + )
583 + );
584 +
585 + if ( is_wp_error( $new_chart_id ) ) {
586 + 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__ );
587 + } else {
588 + $post_meta = get_post_meta( $parent_chart_id );
589 + $chart_id = $new_chart_id;
590 + foreach ( $post_meta as $key => $value ) {
591 + if ( strpos( $key, 'visualizer-' ) !== false ) {
592 + add_post_meta( $new_chart_id, $key, maybe_unserialize( $value[0] ) );
593 + }
594 + }
595 + }
596 + }
597 + }
527 598 do_action( 'visualizer_pro_new_chart_defaults', $chart_id );
528 599 }
529 600 wp_redirect( esc_url_raw( add_query_arg( 'chart', (int) $chart_id ) ) );
530 601
@@ -831,8 +902,9 @@
831 902 'page_type' => 'chart',
832 903 'json_tag_separator' => Visualizer_Source_Json::TAG_SEPARATOR,
833 904 'json_tag_separator_view' => Visualizer_Source_Json::TAG_SEPARATOR_VIEW,
834 905 'is_front' => false,
906 + 'rest_base' => get_rest_url( null, 'wc/v3/reports/' ),
835 907 )
836 908 );
837 909
838 910 $render = new Visualizer_Render_Page_Data();