PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.3
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/Render/Layout.php +555 -6 3.4.23.4.3 View file →
@@ -140,12 +140,18 @@
140 140 $url = get_post_meta( $id, Visualizer_Plugin::CF_JSON_URL, true );
141 141 $root = get_post_meta( $id, Visualizer_Plugin::CF_JSON_ROOT, true );
142 142 $paging = get_post_meta( $id, Visualizer_Plugin::CF_JSON_PAGING, true );
143 143 $headers = get_post_meta( $id, Visualizer_Plugin::CF_JSON_HEADERS, true );
144 - if ( empty( $headers['method'] ) ) {
144 + if ( empty( $headers ) ) {
145 + $headers = array();
146 + }
147 + if ( $headers && empty( $headers['method'] ) ) {
145 148 $headers['method'] = 'get';
146 149 }
147 150 $methods = apply_filters( 'visualizer_json_request_methods', array( 'GET', 'POST' ) );
151 +
152 + // open the headers by default?
153 + $headers_open = $headers && array_key_exists( 'auth', $headers ) && ( array_key_exists( 'username', $headers['auth'] ) && ! empty( $headers['auth']['username'] ) ) || ( ! empty( $headers['auth'] ) && is_string( $headers['auth'] ) );
148 154 ?>
149 155 <div id="visualizer-json-screen" style="display: none">
150 156 <div class="visualizer-json-form">
151 157 <h3 class="viz-step step1"><?php _e( 'STEP 1: Specify the JSON endpoint/URL', 'visualizer' ); ?></h3>
@@ -166,9 +172,9 @@
166 172 class="visualizer-input json-form-element">
167 173 <button class="button button-secondary button-small" id="visualizer-json-fetch"><?php esc_html_e( 'Fetch Endpoint', 'visualizer' ); ?></button>
168 174
169 175 <div class="visualizer-json-subform">
170 - <h3 class="viz-substep"><?php _e( 'Headers', 'visualizer' ); ?></h3>
176 + <h3 class="viz-substep <?php echo $headers_open ? 'open' : ''; ?>"><?php _e( 'Headers', 'visualizer' ); ?></h3>
171 177 <div class="json-wizard-headers">
172 178 <div class="json-wizard-header">
173 179 <div><?php _e( 'Request Type', 'visualizer' ); ?></div>
174 180 <div>
@@ -173,9 +179,9 @@
173 179 <div><?php _e( 'Request Type', 'visualizer' ); ?></div>
174 180 <div>
175 181 <select name="method" class="json-form-element">
176 182 <?php foreach ( $methods as $method ) { ?>
177 - <option value="<?php echo $method; ?>" <?php selected( $headers['method'], $method ); ?>><?php echo $method; ?></option>
183 + <option value="<?php echo $method; ?>" <?php $headers && selected( $headers['method'], $method ); ?>><?php echo $method; ?></option>
178 184 <?php } ?>
179 185 </select>
180 186 </div>
181 187 </div>
@@ -209,9 +215,9 @@
209 215 <input
210 216 type="text"
211 217 id="vz-import-json-auth"
212 218 name="auth"
213 - value="<?php echo ( ! empty( $headers ) && array_key_exists( 'auth', $headers ) ? $headers['auth']['auth'] : '' ); ?>"
219 + value="<?php echo ( array_key_exists( 'auth', $headers ) && is_string( $headers['auth'] ) ? $headers['auth'] : '' ); ?>"
214 220 placeholder="<?php esc_html_e( 'e.g. SharedKey <AccountName>:<Signature>', 'visualizer' ); ?>"
215 221 class="visualizer-input json-form-element">
216 222 </div>
217 223 </div>
@@ -338,9 +344,9 @@
338 344 $chart_id = $args[1];
339 345 $csv = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA_AS, array(), $chart_id, 'csv-display' );
340 346 $data = '';
341 347 if ( ! empty( $csv ) && isset( $csv['string'] ) ) {
342 - $data = str_replace( PHP_EOL, "\n", $csv['string'] );
348 + $data = str_replace( PHP_EOL, "\n", stripslashes( $csv['string'] ) );
343 349 }
344 350 ?>
345 351 <div class="viz-simple-editor-type viz-text-editor">
346 352 <textarea id="edited_text"><?php echo $data; ?></textarea>
@@ -367,9 +373,9 @@
367 373 $headers[] = $column['label'];
368 374 }
369 375 $chart = get_post( $chart_id );
370 376 $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
371 - $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( str_replace( "'", "\'", html_entity_decode( $chart->post_content ) ) ), $type );
377 + $data = Visualizer_Module::get_chart_data( $chart, $type );
372 378 } else {
373 379 $headers = array_keys( $data[0] );
374 380 }
375 381
@@ -456,6 +462,549 @@
456 462 <?php
457 463 if ( ! $echo ) {
458 464 return ob_get_clean();
459 465 }
466 + }
467 +
468 + /**
469 + * Generates the permissions tab.
470 + *
471 + * @access private
472 + */
473 + private static function _renderPermissions( $args ) {
474 + $chart_id = $args[1];
475 +
476 + // ignore for unit tests because Travis throws the error "Indirect modification of overloaded property Visualizer_Render_Page_Data::$permissions has no effect".
477 + if ( defined( 'WP_TESTS_DOMAIN' ) ) {
478 + return;
479 + }
480 +
481 + $permissions = apply_filters( 'visualizer_pro_get_permissions', null, $chart_id );
482 + if ( is_array( $permissions ) ) {
483 + $permissions = $permissions['permissions'];
484 + } else {
485 + $permissions = array();
486 + }
487 + if ( ! isset( $permissions['read'] ) ) {
488 + $permissions['read'] = 'all';
489 + }
490 + if ( ! isset( $permissions['edit'] ) ) {
491 + $permissions['edit'] = 'roles';
492 + $permissions['edit-specific'] = 'administrator';
493 + }
494 +
495 + Visualizer_Render_Sidebar::_renderGroupStart( esc_html__( 'Permissions', 'visualizer' ) . '<span class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' ), 'vz-permissions' );
496 + echo '<div style="position: relative">';
497 + Visualizer_Render_Sidebar::_renderSectionStart();
498 + Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Configure permissions for the chart.', 'visualizer' ) );
499 + Visualizer_Render_Sidebar::_renderSectionEnd();
500 +
501 + Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'Who can see this chart?', 'visualizer' ), false );
502 + Visualizer_Render_Sidebar::_renderSelectItem(
503 + '',
504 + 'permissions[read]',
505 + $permissions['read'],
506 + array(
507 + 'all' => esc_html__( 'All Users', 'visualizer' ),
508 + 'users' => esc_html__( 'Select Users', 'visualizer' ),
509 + 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
510 + ),
511 + '',
512 + false,
513 + array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-read' ),
514 + array(
515 + 'permission-type' => 'read',
516 + )
517 + );
518 +
519 + $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $permissions['read'] ) ? $permissions['read'] : 'roles' );
520 +
521 + Visualizer_Render_Sidebar::_renderSelectItem(
522 + '',
523 + 'permissions[read-specific][]',
524 + isset( $permissions['read-specific'] ) ? $permissions['read-specific'] : array(),
525 + $options,
526 + '',
527 + true,
528 + array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-read-specific' )
529 + );
530 + Visualizer_Render_Sidebar::_renderSectionEnd();
531 +
532 + Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'Who can edit this chart?', 'visualizer' ), false );
533 + Visualizer_Render_Sidebar::_renderSelectItem(
534 + '',
535 + 'permissions[edit]',
536 + $permissions['edit'],
537 + array(
538 + 'all' => esc_html__( 'All Users', 'visualizer' ),
539 + 'users' => esc_html__( 'Select Users', 'visualizer' ),
540 + 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
541 + ),
542 + '',
543 + false,
544 + array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-edit' ),
545 + array(
546 + 'permission-type' => 'edit',
547 + )
548 + );
549 +
550 + $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $permissions['edit'] ) ? $permissions['edit'] : 'roles' );
551 +
552 + Visualizer_Render_Sidebar::_renderSelectItem(
553 + '',
554 + 'permissions[edit-specific][]',
555 + isset( $permissions['edit-specific'] ) ? $permissions['edit-specific'] : array(),
556 + $options,
557 + '',
558 + true,
559 + array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-edit-specific' )
560 + );
561 + Visualizer_Render_Sidebar::_renderSectionEnd();
562 + echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions' );
563 + echo '</div>';
564 + Visualizer_Render_Sidebar::_renderGroupEnd();
565 + }
566 +
567 + /**
568 + * Show the Settings tab for this chart.
569 + *
570 + * @access public
571 + */
572 + public static function _renderTabAdvanced( $args ) {
573 + $sidebar = $args[2];
574 + ?>
575 + <ul class="viz-group-wrapper full-height">
576 + <li class="viz-group open" id="vz-chart-settings">
577 + <ul class="viz-group-content">
578 + <ul class="viz-group-wrapper">
579 + <form id="settings-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>" method="post">
580 + <?php echo $sidebar; ?>
581 + <?php self::_renderPermissions( $args ); ?>
582 + <input type="hidden" name="save" value="1">
583 + </form>
584 + <form id="cancel-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>" method="post">
585 + <input type="hidden" name="cancel" value="1">
586 + </form>
587 + </ul>
588 + </ul>
589 + </li>
590 + <?php
591 + }
592 +
593 + /**
594 + * Show the Docs tab for this chart.
595 + *
596 + * @access public
597 + */
598 + public static function _renderTabHelp( $args ) {
599 + $chart_id = $args[1];
600 + $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
601 + switch ( $type ) {
602 + case 'dataTable':
603 + $type = 'table';
604 + break;
605 + case 'polarArea':
606 + $type = 'polar-area';
607 + break;
608 + case 'radar':
609 + $type = 'radar-spider';
610 + break;
611 + }
612 +
613 + $displayType = str_replace( '-', '/', $type );
614 + ?>
615 + <ul class="viz-group-wrapper full-height">
616 + <li class="viz-group open" id="vz-chart-help">
617 + <ul class="viz-group-wrapper">
618 + <?php
619 + // open this tab by default.
620 + Visualizer_Render_Sidebar::_renderGroupStart( esc_html__( 'Documentation', 'visualizer' ), '', 'open' );
621 + Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'General', 'visualizer' ), true );
622 + ?>
623 + <h4><span class="dashicons dashicons-editor-help"></span><a href="<?php echo VISUALIZER_MAIN_DOC; ?>" target="_blank"><?php _e( 'Main documentation page', 'visualizer' ); ?></a></h4>
624 + <h4><span class="dashicons dashicons-media-code"></span><a href="<?php echo VISUALIZER_CODE_SNIPPETS_URL; ?>" target="_blank"><?php _e( 'Custom code snippets', 'visualizer' ); ?></a></h4>
625 + <?php
626 + Visualizer_Render_Sidebar::_renderSectionEnd();
627 + Visualizer_Render_Sidebar::_renderSectionStart( sprintf( __( '%s chart', 'visualizer' ), ucwords( $displayType ) ), true );
628 + ?>
629 + <h4><span class="dashicons dashicons-video-alt2"></span>&nbsp;<a href="<?php echo str_replace( '#', "$type-chart", VISUALIZER_DEMO_URL ); ?>" target="_blank"><?php _e( 'View demo', 'visualizer' ); ?></a></h4>
630 + <h4><span class="dashicons dashicons-search"></span><a href="<?php echo str_replace( '#', $type, VISUALIZER_DOC_COLLECTION ); ?>" target="_blank"><?php echo sprintf( __( 'Articles containing "%s"', 'visualizer' ), $displayType ); ?></a></h4>
631 + <?php
632 + Visualizer_Render_Sidebar::_renderSectionEnd();
633 + Visualizer_Render_Sidebar::_renderGroupEnd();
634 + ?>
635 + </ul>
636 + </li>
637 + </ul>
638 +
639 + <?php
640 + }
641 +
642 + /**
643 + * Show the Data Source tab for this chart.
644 + *
645 + * @access public
646 + */
647 + public static function _renderTabBasic( $args ) {
648 + $chart_id = $args[1];
649 +
650 + $upload_link = add_query_arg(
651 + array(
652 + 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
653 + 'nonce' => wp_create_nonce(),
654 + 'chart' => $chart_id,
655 + ),
656 + admin_url( 'admin-ajax.php' )
657 + );
658 +
659 + // this will allow us to open the correct source tab by default.
660 + $source_of_chart = strtolower( get_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, true ) );
661 + // both import from wp and import from db have the same source so we need to differentiate.
662 + $filter_config = get_post_meta( $chart_id, Visualizer_Plugin::CF_FILTER_CONFIG, true );
663 + // if filter config is present, then its import from wp.
664 + if ( ! empty( $filter_config ) ) {
665 + $source_of_chart .= '_wp';
666 + }
667 + $editor_type = get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITOR, true );
668 + if ( $editor_type ) {
669 + $source_of_chart = 'visualizer_source_manual';
670 + }
671 +
672 + $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
673 + $lib = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, true );
674 + ?>
675 + <ul class="viz-group-wrapper full-height">
676 + <li class="viz-group open" id="vz-chart-source">
677 + <ul class="viz-group-content">
678 + <ul class="viz-group-wrapper">
679 + <!-- import from file -->
680 + <li class="viz-group visualizer_source_csv">
681 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
682 + <div class="viz-group-content">
683 + <p class="viz-group-description"><?php esc_html_e( 'Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' ); ?></p>
684 + <p class="viz-group-description viz-info-msg"><b><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">', $type, '.csv</a>' ); ?></b></p>
685 + <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
686 + target="thehole" enctype="multipart/form-data">
687 + <input type="hidden" id="remote-data" name="remote_data">
688 + <div class="">
689 + <input type="file" id="csv-file" name="local_data">
690 + </div>
691 + <input type="button" class="button button-primary" id="vz-import-file"
692 + value="<?php _e( 'Import', 'visualizer' ); ?>">
693 + </form>
694 + </div>
695 + </li>
696 + <!-- import from url -->
697 + <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json">
698 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
699 + <ul class="viz-group-content">
700 + <!-- import from csv url -->
701 + <li class="viz-subsection">
702 + <span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span>
703 + <div class="viz-section-items section-items">
704 + <p class="viz-group-description"><?php echo sprintf( __( 'You can use this to import data from a remote CSV file or %1$sGoogle Spreadsheet%2$s.', 'visualizer' ), '<a href="https://docs.themeisle.com/article/607-how-can-i-populate-data-from-google-spreadsheet" target="_blank" >', '</a>' ); ?> </p>
705 + <p class="viz-group-description viz-info-msg"><b><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">', $type, '.csv</a>' ); ?></b></p>
706 + <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
707 + target="thehole" enctype="multipart/form-data">
708 + <div class="remote-file-section">
709 + <input type="url" id="vz-schedule-url" name="remote_data" value="<?php echo esc_attr( get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_URL, true ) ); ?>" placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>" class="visualizer-input visualizer-remote-url">
710 + </div>
711 + <select name="vz-import-time" id="vz-import-time" class="visualizer-select">
712 + <?php
713 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
714 + $schedules = apply_filters(
715 + 'visualizer_chart_schedules', array(
716 + '-1' => __( 'One-time', 'visualizer' ),
717 + ),
718 + 'csv',
719 + $chart_id
720 + );
721 + foreach ( $schedules as $num => $name ) {
722 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
723 + $extra = $num == $hours ? 'selected' : '';
724 + ?>
725 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
726 + <?php
727 + }
728 + do_action( 'visualizer_chart_schedules_spl', 'csv', $chart_id, 1 );
729 + ?>
730 + </select>
731 +
732 + <?php
733 + if ( ! Visualizer_Module::is_pro() ) {
734 + ?>
735 + <input type="button" id="view-remote-file" class="button button-primary" value="<?php _e( 'Import', 'visualizer' ); ?>">
736 + <?php
737 + } else {
738 + ?>
739 + <input type="button" id="vz-save-schedule" class="button button-primary" value="<?php _e( 'Import & Save schedule', 'visualizer' ); ?>">
740 + <?php
741 + }
742 + ?>
743 + </form>
744 + </div>
745 + </li>
746 + <!-- import from json url -->
747 + <li class="viz-subsection">
748 + <span class="viz-section-title visualizer_source_json"><?php _e( 'Import from JSON', 'visualizer' ); ?></span>
749 + <div class="viz-section-items section-items">
750 + <p class="viz-group-description"><?php _e( 'You can choose here to import/synchronize your chart data with a remote JSON source. For more info check <a href="https://docs.themeisle.com/article/1052-how-to-generate-charts-from-json-data-rest-endpoints" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
751 + <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
752 + <div class="remote-file-section">
753 + <?php
754 + $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
755 + if ( Visualizer_Module::is_pro() ) {
756 + ?>
757 + <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
758 + <select name="time" id="vz-json-time" class="visualizer-select json-form-element" data-chart="<?php echo $chart_id; ?>">
759 + <?php
760 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
761 + $schedules = apply_filters(
762 + 'visualizer_chart_schedules', array(
763 + '-1' => __( 'One-time', 'visualizer' ),
764 + ),
765 + 'json',
766 + $chart_id
767 + );
768 + foreach ( $schedules as $num => $name ) {
769 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
770 + $extra = $num == $hours ? 'selected' : '';
771 + ?>
772 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
773 + <?php
774 + }
775 + do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
776 + ?>
777 + </select>
778 + <?php
779 + }
780 + ?>
781 + </div>
782 +
783 + <input type="button" id="json-chart-button" class="button button-secondary show-chart-toggle"
784 + value="<?php echo $bttn_label; ?>" data-current="chart"
785 + data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
786 + data-t-chart="<?php echo $bttn_label; ?>">
787 + <?php
788 + if ( Visualizer_Module::is_pro() ) {
789 + ?>
790 + <input type="button" id="json-chart-save-button" class="button button-primary "
791 + value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
792 + <?php
793 + }
794 + ?>
795 + </form>
796 + </div>
797 + </li>
798 + </ul>
799 + </li>
800 + <!-- import from chart -->
801 + <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
802 + <h2 class="viz-group-title viz-sub-group"
803 + data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
804 + class="dashicons dashicons-lock"></span></h2>
805 + <div class="viz-group-content edit-data-content">
806 + <div>
807 + <p class="viz-group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p>
808 + <form>
809 + <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
810 + <?php
811 + $fetch_link = add_query_arg(
812 + array(
813 + 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '',
814 + 'nonce' => wp_create_nonce(),
815 + ),
816 + admin_url( 'admin-ajax.php' )
817 + );
818 + $query_args_charts = array(
819 + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
820 + 'posts_per_page' => 300,
821 + 'no_found_rows' => true,
822 + );
823 + $charts = array();
824 + $query = new WP_Query( $query_args_charts );
825 + while ( $query->have_posts() ) {
826 + $chart = $query->next_post();
827 + $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
828 +
829 + $title = '#' . $chart->ID;
830 + if ( ! empty( $settings['title'] ) ) {
831 + $title = $settings['title'];
832 + }
833 + // for ChartJS, title is an array.
834 + if ( is_array( $title ) && isset( $title['text'] ) ) {
835 + $title = $title['text'];
836 + }
837 + if ( empty( $title ) ) {
838 + $title = '#' . $chart->ID;
839 + }
840 +
841 + ?>
842 + <option value="<?php echo $chart->ID; ?>"><?php echo $title; ?></option>
843 + <?php
844 + }
845 + ?>
846 +
847 + </select>
848 + </form>
849 + <input type="button" id="existing-chart" class="button button-primary"
850 + value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
851 + data-viz-link="<?php echo $fetch_link; ?>">
852 + <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
853 + </div>
854 + </div>
855 + </li>
856 +
857 + <?php
858 + $save_filter = add_query_arg(
859 + array(
860 + 'action' => Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY,
861 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY . Visualizer_Plugin::VERSION ),
862 + 'chart' => $chart_id,
863 + ), admin_url( 'admin-ajax.php' )
864 + );
865 + ?>
866 + <!-- import from WordPress -->
867 + <li class="viz-group visualizer_source_query_wp <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wp' ); ?> ">
868 + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
869 + class="dashicons dashicons-lock"></span></h2>
870 + <div class="viz-group-content edit-data-content">
871 + <div>
872 + <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p>
873 + <form id="vz-filter-wizard" action="<?php echo $save_filter; ?>" method="post" target="thehole">
874 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from WordPress.', 'visualizer' ); ?></p>
875 + <select name="refresh" id="vz-filter-import-time" class="visualizer-select">
876 + <?php
877 + $bttn_label = 'visualizer_source_query_wp' === $source_of_chart ? __( 'Modify Filter', 'visualizer' ) : __( 'Create Filter', 'visualizer' );
878 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
879 + $schedules = apply_filters(
880 + 'visualizer_chart_schedules', array(
881 + '-1' => __( 'One-time', 'visualizer' ),
882 + ),
883 + 'wp',
884 + $chart_id
885 + );
886 + foreach ( $schedules as $num => $name ) {
887 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
888 + $extra = $num == $hours ? 'selected' : '';
889 + ?>
890 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
891 + <?php
892 + }
893 + do_action( 'visualizer_chart_schedules_spl', 'wp', $chart_id, 1 );
894 + ?>
895 + </select>
896 +
897 + <input type="button" id="filter-chart-button" class="button button-secondary show-chart-toggle" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
898 + <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
899 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
900 + </form>
901 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
902 + </div>
903 + </div>
904 + </li>
905 +
906 + <?php
907 + $save_query = add_query_arg(
908 + array(
909 + 'action' => Visualizer_Plugin::ACTION_SAVE_DB_QUERY,
910 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_DB_QUERY . Visualizer_Plugin::VERSION ),
911 + 'chart' => $chart_id,
912 + ), admin_url( 'admin-ajax.php' )
913 + );
914 + ?>
915 + <!-- import from db -->
916 + <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>">
917 + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span
918 + class="dashicons dashicons-lock"></span></h2>
919 + <div class="viz-group-content edit-data-content">
920 + <div>
921 + <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p>
922 + <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole">
923 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p>
924 + <select name="refresh" id="vz-db-import-time" class="visualizer-select">
925 + <?php
926 + $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' );
927 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
928 + $schedules = apply_filters(
929 + 'visualizer_chart_schedules', array(
930 + '-1' => __( 'One-time', 'visualizer' ),
931 + ),
932 + 'db',
933 + $chart_id
934 + );
935 + foreach ( $schedules as $num => $name ) {
936 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
937 + $extra = $num == $hours ? 'selected' : '';
938 + ?>
939 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
940 + <?php
941 + }
942 + do_action( 'visualizer_chart_schedules_spl', 'db', $chart_id, 1 );
943 + ?>
944 + </select>
945 + <input type="hidden" name="params" id="viz-db-wizard-params">
946 +
947 + <input type="button" id="db-chart-button" class="button button-secondary show-chart-toggle" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
948 + <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
949 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
950 + </form>
951 + </div>
952 + </div>
953 + </li>
954 +
955 + <!-- manual -->
956 + <li class="viz-group visualizer_source_manual">
957 + <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?>
958 + <span class="dashicons dashicons-lock"></span>
959 + </h2>
960 + <div class="viz-group-content edit-data-content">
961 + <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
962 + <input type="hidden" id="chart-data" name="chart_data">
963 + <input type="hidden" id="chart-data-src" name="chart_data_src">
964 +
965 + <?php if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { ?>
966 + <div>
967 + <p class="viz-group-description viz-editor-selection">
968 + <?php _e( 'Use the', 'visualizer' ); ?>
969 + <select name="editor-type" id="viz-editor-type">
970 + <?php
971 + if ( empty( $editor_type ) ) {
972 + $editor_type = Visualizer_Module::is_pro() ? 'excel' : 'text';
973 + }
974 + foreach ( apply_filters( 'visualizer_editors', array( 'text' => __( 'Text', 'visualizer' ), 'table' => __( 'Simple', 'visualizer' ) ) ) as $e_type => $e_label ) {
975 + ?>
976 + <option value="<?php echo $e_type; ?>" <?php selected( $editor_type, $e_type ); ?> ><?php echo $e_label; ?></option>
977 + <?php } ?>
978 + </select>
979 + <?php _e( 'editor to manually edit the chart data.', 'visualizer' ); ?>
980 + </p>
981 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
982 + <input type="button" id="editor-button" class="button button-primary "
983 + value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart"
984 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
985 + data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>"
986 + >
987 + <p class="viz-group-description viz-info-msg"><?php echo sprintf( __( 'Please make sure you click \'Show Chart\' before you save the chart.', 'visualizer' ) ); ?></p>
988 + </div>
989 + <?php } else { ?>
990 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
991 + <input type="button" id="editor-chart-button" class="button button-primary "
992 + value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
993 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
994 + data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"
995 + >
996 + <p class="viz-group-description viz-info-msg"><?php echo sprintf( __( 'Please make sure you click \'Show Chart\' before you save the chart.', 'visualizer' ) ); ?></p>
997 + <?php } ?>
998 + </form>
999 + </div>
1000 + </li>
1001 + </ul>
1002 + </li>
1003 + </ul>
1004 + </ul>
1005 +
1006 + <span id="visualizer-chart-id" data-id="<?php echo $chart_id; ?>" data-chart-source="<?php echo esc_attr( $source_of_chart ); ?>" data-chart-type="<?php echo esc_attr( $type ); ?>" data-chart-lib="<?php echo esc_attr( $lib ); ?>"></span>
1007 + <iframe id="thehole" name="thehole"></iframe>
1008 + <?php
460 1009 }
461 1010 }