PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.2
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 +26 -708 3.10.143.4.2 View file →
@@ -104,9 +104,9 @@
104 104 </tr>
105 105 </thead>
106 106 <tfoot>
107 107 </tfoot>
108 - <tbody>
108 + <tbody>
109 109 <?php
110 110 foreach ( $results as $result ) {
111 111 echo '<tr>';
112 112 foreach ( $result as $r ) {
@@ -127,34 +127,25 @@
127 127 * @access public
128 128 */
129 129 public static function _renderJsonScreen( $args ) {
130 130 $id = $args[1];
131 - $action = esc_url(
132 - add_query_arg(
133 - array(
134 - 'action' => Visualizer_Plugin::ACTION_JSON_SET_DATA,
135 - 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_JSON_SET_DATA . Visualizer_Plugin::VERSION ),
136 - 'chart' => $id,
137 - ),
138 - admin_url( 'admin-ajax.php' )
139 - )
131 + $action = add_query_arg(
132 + array(
133 + 'action' => Visualizer_Plugin::ACTION_JSON_SET_DATA,
134 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_JSON_SET_DATA . Visualizer_Plugin::VERSION ),
135 + 'chart' => $id,
136 + ),
137 + admin_url( 'admin-ajax.php' )
140 138 );
141 139
142 - $is_wc_source = get_post_meta( $id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE, true );
143 140 $url = get_post_meta( $id, Visualizer_Plugin::CF_JSON_URL, true );
144 141 $root = get_post_meta( $id, Visualizer_Plugin::CF_JSON_ROOT, true );
145 142 $paging = get_post_meta( $id, Visualizer_Plugin::CF_JSON_PAGING, true );
146 143 $headers = get_post_meta( $id, Visualizer_Plugin::CF_JSON_HEADERS, true );
147 - if ( empty( $headers ) ) {
148 - $headers = array();
149 - }
150 - if ( $headers && empty( $headers['method'] ) ) {
144 + if ( empty( $headers['method'] ) ) {
151 145 $headers['method'] = 'get';
152 146 }
153 147 $methods = apply_filters( 'visualizer_json_request_methods', array( 'GET', 'POST' ) );
154 -
155 - // open the headers by default?
156 - $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'] ) );
157 148 ?>
158 149 <div id="visualizer-json-screen" style="display: none">
159 150 <div class="visualizer-json-form">
160 151 <h3 class="viz-step step1"><?php _e( 'STEP 1: Specify the JSON endpoint/URL', 'visualizer' ); ?></h3>
@@ -171,15 +162,13 @@
171 162 id="vz-import-json-url"
172 163 name="url"
173 164 value="<?php echo esc_url( $url ); ?>"
174 165 placeholder="<?php esc_html_e( 'Please enter the URL', 'visualizer' ); ?>"
175 - class="visualizer-input json-form-element"
176 - <?php echo $is_wc_source ? 'readonly' : ''; ?>
177 - >
166 + class="visualizer-input json-form-element">
178 167 <button class="button button-secondary button-small" id="visualizer-json-fetch"><?php esc_html_e( 'Fetch Endpoint', 'visualizer' ); ?></button>
179 -
168 +
180 169 <div class="visualizer-json-subform">
181 - <h3 class="viz-substep <?php echo $headers_open ? 'open' : ''; ?>"><?php _e( 'Headers', 'visualizer' ); ?></h3>
170 + <h3 class="viz-substep"><?php _e( 'Headers', 'visualizer' ); ?></h3>
182 171 <div class="json-wizard-headers">
183 172 <div class="json-wizard-header">
184 173 <div><?php _e( 'Request Type', 'visualizer' ); ?></div>
185 174 <div>
@@ -184,9 +173,9 @@
184 173 <div><?php _e( 'Request Type', 'visualizer' ); ?></div>
185 174 <div>
186 175 <select name="method" class="json-form-element">
187 176 <?php foreach ( $methods as $method ) { ?>
188 - <option value="<?php echo $method; ?>" <?php $headers && selected( $headers['method'], $method ); ?>><?php echo $method; ?></option>
177 + <option value="<?php echo $method; ?>" <?php selected( $headers['method'], $method ); ?>><?php echo $method; ?></option>
189 178 <?php } ?>
190 179 </select>
191 180 </div>
192 181 </div>
@@ -198,9 +187,9 @@
198 187 id="vz-import-json-username"
199 188 name="username"
200 189 value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'username', $headers['auth'] ) ? $headers['auth']['username'] : '' ); ?>"
201 190 placeholder="<?php esc_html_e( 'Username/Access Key', 'visualizer' ); ?>"
202 - class="json-form-element">
191 + class="json-form-element">
203 192 &
204 193 <input
205 194 type="password"
206 195 id="vz-import-json-password"
@@ -206,9 +195,9 @@
206 195 id="vz-import-json-password"
207 196 name="password"
208 197 value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'password', $headers['auth'] ) ? $headers['auth']['password'] : '' ); ?>"
209 198 placeholder="<?php esc_html_e( 'Password/Secret Key', 'visualizer' ); ?>"
210 - class="json-form-element">
199 + class="json-form-element">
211 200 </div>
212 201 </div>
213 202 <div class="json-wizard-header">
214 203 <div></div>
@@ -220,19 +209,13 @@
220 209 <input
221 210 type="text"
222 211 id="vz-import-json-auth"
223 212 name="auth"
224 - value="<?php echo ( array_key_exists( 'auth', $headers ) && is_string( $headers['auth'] ) ? $headers['auth'] : '' ); ?>"
213 + value="<?php echo ( ! empty( $headers ) && array_key_exists( 'auth', $headers ) ? $headers['auth']['auth'] : '' ); ?>"
225 214 placeholder="<?php esc_html_e( 'e.g. SharedKey <AccountName>:<Signature>', 'visualizer' ); ?>"
226 215 class="visualizer-input json-form-element">
227 216 </div>
228 217 </div>
229 - <div class="json-wizard-header">
230 - <div class="field-title"><?php esc_html_e( 'Additional headers', 'visualizer' ); ?></div>
231 - <div>
232 - <textarea name="additional_headers" class="visualizer-input" placeholder="<?php esc_html_e( 'Key:Value, Key2:Value2,...', 'visualizer' ); ?>"><?php echo isset( $headers['additional_headers'] ) ? $headers['additional_headers'] : ''; ?></textarea>
233 - </div>
234 - </div>
235 218 </div>
236 219 </div>
237 220 </form>
238 221 </div>
@@ -310,17 +293,15 @@
310 293 * @access public
311 294 */
312 295 public static function _renderSimpleEditorScreen( $args ) {
313 296 $chart_id = $args[1];
314 - $action = esc_url(
315 - add_query_arg(
316 - array(
317 - 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
318 - 'nonce' => wp_create_nonce(),
319 - 'chart' => $chart_id,
320 - ),
321 - admin_url( 'admin-ajax.php' )
322 - )
297 + $action = add_query_arg(
298 + array(
299 + 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
300 + 'nonce' => wp_create_nonce(),
301 + 'chart' => $chart_id,
302 + ),
303 + admin_url( 'admin-ajax.php' )
323 304 );
324 305 ?>
325 306 <div class="viz-simple-editor">
326 307 <div class="viz-simple-editor-type viz-table-editor">
@@ -357,9 +338,9 @@
357 338 $chart_id = $args[1];
358 339 $csv = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA_AS, array(), $chart_id, 'csv-display' );
359 340 $data = '';
360 341 if ( ! empty( $csv ) && isset( $csv['string'] ) ) {
361 - $data = str_replace( PHP_EOL, "\n", stripslashes( $csv['string'] ) );
342 + $data = str_replace( PHP_EOL, "\n", $csv['string'] );
362 343 }
363 344 ?>
364 345 <div class="viz-simple-editor-type viz-text-editor">
365 346 <textarea id="edited_text"><?php echo $data; ?></textarea>
@@ -386,9 +367,9 @@
386 367 $headers[] = $column['label'];
387 368 }
388 369 $chart = get_post( $chart_id );
389 370 $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
390 - $data = Visualizer_Module::get_chart_data( $chart, $type );
371 + $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( str_replace( "'", "\'", html_entity_decode( $chart->post_content ) ) ), $type );
391 372 } else {
392 373 $headers = array_keys( $data[0] );
393 374 }
394 375
@@ -419,9 +400,9 @@
419 400 }
420 401 ?>
421 402 </tr>
422 403 </thead>
423 - <tbody>
404 + <tbody>
424 405 <tr>
425 406 <th><?php _e( 'Data Type', 'visualizer' ); ?></th>
426 407 <?php
427 408 $index = 0;
@@ -475,669 +456,6 @@
475 456 <?php
476 457 if ( ! $echo ) {
477 458 return ob_get_clean();
478 459 }
479 - }
480 -
481 - /**
482 - * Generates the permissions tab.
483 - *
484 - * @access private
485 - */
486 - private static function _renderPermissions( $args ) {
487 - $chart_id = $args[1];
488 -
489 - // ignore for unit tests because Travis throws the error "Indirect modification of overloaded property Visualizer_Render_Page_Data::$permissions has no effect".
490 - if ( defined( 'WP_TESTS_DOMAIN' ) ) {
491 - return;
492 - }
493 -
494 - $permissions = apply_filters( 'visualizer_pro_get_permissions', null, $chart_id );
495 - if ( is_array( $permissions ) ) {
496 - $permissions = $permissions['permissions'];
497 - } else {
498 - $permissions = array();
499 - }
500 - if ( ! isset( $permissions['read'] ) ) {
501 - $permissions['read'] = 'all';
502 - }
503 - if ( ! isset( $permissions['edit'] ) ) {
504 - $permissions['edit'] = 'roles';
505 - $permissions['edit-specific'] = 'administrator';
506 - }
507 -
508 - 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' );
509 - echo '<div style="position: relative">';
510 - Visualizer_Render_Sidebar::_renderSectionStart();
511 - Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Configure permissions for the chart.', 'visualizer' ) );
512 - Visualizer_Render_Sidebar::_renderSectionEnd();
513 -
514 - Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'Who can see this chart?', 'visualizer' ), false );
515 - Visualizer_Render_Sidebar::_renderSelectItem(
516 - '',
517 - 'permissions[read]',
518 - $permissions['read'],
519 - array(
520 - 'all' => esc_html__( 'All Users', 'visualizer' ),
521 - 'users' => esc_html__( 'Select Users', 'visualizer' ),
522 - 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
523 - ),
524 - '',
525 - false,
526 - array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-read' ),
527 - array(
528 - 'permission-type' => 'read',
529 - )
530 - );
531 -
532 - $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $permissions['read'] ) ? $permissions['read'] : 'roles' );
533 -
534 - Visualizer_Render_Sidebar::_renderSelectItem(
535 - '',
536 - 'permissions[read-specific][]',
537 - isset( $permissions['read-specific'] ) ? $permissions['read-specific'] : array(),
538 - $options,
539 - '',
540 - true,
541 - array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-read-specific' )
542 - );
543 - Visualizer_Render_Sidebar::_renderSectionEnd();
544 -
545 - Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'Who can edit this chart?', 'visualizer' ), false );
546 - Visualizer_Render_Sidebar::_renderSelectItem(
547 - '',
548 - 'permissions[edit]',
549 - $permissions['edit'],
550 - array(
551 - 'all' => esc_html__( 'All Users', 'visualizer' ),
552 - 'users' => esc_html__( 'Select Users', 'visualizer' ),
553 - 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
554 - ),
555 - '',
556 - false,
557 - array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-edit' ),
558 - array(
559 - 'permission-type' => 'edit',
560 - )
561 - );
562 -
563 - $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $permissions['edit'] ) ? $permissions['edit'] : 'roles' );
564 -
565 - Visualizer_Render_Sidebar::_renderSelectItem(
566 - '',
567 - 'permissions[edit-specific][]',
568 - isset( $permissions['edit-specific'] ) ? $permissions['edit-specific'] : array(),
569 - $options,
570 - '',
571 - true,
572 - array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-edit-specific' )
573 - );
574 - Visualizer_Render_Sidebar::_renderSectionEnd();
575 - echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions' );
576 - echo '</div>';
577 - Visualizer_Render_Sidebar::_renderGroupEnd();
578 - }
579 -
580 - /**
581 - * Show the Settings tab for this chart.
582 - *
583 - * @access public
584 - */
585 - public static function _renderTabAdvanced( $args ) {
586 - $sidebar = $args[2];
587 - ?>
588 - <ul class="viz-group-wrapper full-height">
589 - <li class="viz-group open" id="vz-chart-settings">
590 - <ul class="viz-group-content">
591 - <ul class="viz-group-wrapper">
592 - <form id="settings-form" action="<?php echo esc_url( add_query_arg( 'nonce', wp_create_nonce() ) ); ?>" method="post">
593 - <input type="hidden" id="chart-img" name="chart-img">
594 - <?php echo $sidebar; ?>
595 - <?php self::_renderPermissions( $args ); ?>
596 - <input type="hidden" name="save" value="1">
597 - </form>
598 - <form id="cancel-form" action="<?php echo esc_url( add_query_arg( 'nonce', wp_create_nonce() ) ); ?>" method="post">
599 - <input type="hidden" name="cancel" value="1">
600 - </form>
601 - </ul>
602 - </ul>
603 - </li>
604 - <?php
605 - }
606 -
607 - /**
608 - * Show the Docs tab for this chart.
609 - *
610 - * @access public
611 - */
612 - public static function _renderTabHelp( $args ) {
613 - $chart_id = $args[1];
614 - $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
615 - switch ( $type ) {
616 - case 'tabular':
617 - $type = 'table';
618 - break;
619 - case 'polarArea':
620 - $type = 'polar-area';
621 - break;
622 - case 'radar':
623 - $type = 'radar-spider';
624 - break;
625 - }
626 -
627 - $displayType = str_replace( '-', '/', $type );
628 - ?>
629 - <ul class="viz-group-wrapper full-height">
630 - <li class="viz-group open" id="vz-chart-help">
631 - <ul class="viz-group-wrapper">
632 - <?php
633 - // open this tab by default.
634 - Visualizer_Render_Sidebar::_renderGroupStart( esc_html__( 'Documentation', 'visualizer' ), '', 'open' );
635 - Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'General', 'visualizer' ), true );
636 - ?>
637 - <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>
638 - <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>
639 - <?php
640 - Visualizer_Render_Sidebar::_renderSectionEnd();
641 - Visualizer_Render_Sidebar::_renderSectionStart( sprintf( __( '%s chart', 'visualizer' ), ucwords( $displayType ) ), true );
642 - ?>
643 - <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>
644 - <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>
645 - <?php
646 - Visualizer_Render_Sidebar::_renderSectionEnd();
647 - Visualizer_Render_Sidebar::_renderGroupEnd();
648 - ?>
649 - </ul>
650 - </li>
651 - </ul>
652 -
653 - <?php
654 - }
655 -
656 - /**
657 - * Show the Data Source tab for this chart.
658 - *
659 - * @access public
660 - */
661 - public static function _renderTabBasic( $args ) {
662 - $chart_id = $args[1];
663 -
664 - $upload_link = esc_url(
665 - add_query_arg(
666 - array(
667 - 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
668 - 'nonce' => wp_create_nonce(),
669 - 'chart' => $chart_id,
670 - ),
671 - admin_url( 'admin-ajax.php' )
672 - )
673 - );
674 -
675 - // this will allow us to open the correct source tab by default.
676 - $source_of_chart = strtolower( get_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, true ) );
677 - // Import from woocommerce report.
678 - $is_woocommerce_source = strtolower( get_post_meta( $chart_id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE, true ) );
679 - if ( ! empty( $is_woocommerce_source ) ) {
680 - $source_of_chart .= '_wc';
681 - }
682 - // both import from wp and import from db have the same source so we need to differentiate.
683 - $filter_config = get_post_meta( $chart_id, Visualizer_Plugin::CF_FILTER_CONFIG, true );
684 - // if filter config is present, then its import from wp.
685 - if ( ! empty( $filter_config ) ) {
686 - $source_of_chart .= '_wp';
687 - }
688 - $editor_type = get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITOR, true );
689 - if ( $editor_type ) {
690 - $source_of_chart = 'visualizer_source_manual';
691 - }
692 -
693 - $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
694 - $lib = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, true );
695 - ?>
696 - <ul class="viz-group-wrapper full-height">
697 - <li class="viz-group open" id="vz-chart-source">
698 - <ul class="viz-group-content">
699 - <ul class="viz-group-wrapper">
700 - <!-- import from file -->
701 - <li class="viz-group visualizer_source_csv">
702 - <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
703 - <div class="viz-group-content">
704 - <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>
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-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
707 - target="thehole" enctype="multipart/form-data">
708 - <input type="hidden" id="remote-data" name="remote_data">
709 - <div class="">
710 - <input type="file" id="csv-file" name="local_data">
711 - </div>
712 - <input type="button" class="button button-primary" id="vz-import-file"
713 - value="<?php _e( 'Import', 'visualizer' ); ?>">
714 - </form>
715 - </div>
716 - </li>
717 - <!-- import from url -->
718 - <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json">
719 - <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
720 - <ul class="viz-group-content">
721 - <!-- import from csv url -->
722 - <li class="viz-subsection">
723 - <span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span>
724 - <div class="viz-section-items section-items">
725 - <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>
726 - <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>
727 - <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
728 - target="thehole" enctype="multipart/form-data">
729 - <div class="remote-file-section">
730 - <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">
731 - </div>
732 - <select name="vz-import-time" id="vz-import-time" class="visualizer-select">
733 - <?php
734 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
735 - $schedules = apply_filters(
736 - 'visualizer_chart_schedules', array(
737 - '-1' => __( 'One-time', 'visualizer' ),
738 - ),
739 - 'csv',
740 - $chart_id
741 - );
742 - foreach ( $schedules as $num => $name ) {
743 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
744 - $extra = $num == $hours ? 'selected' : '';
745 - ?>
746 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
747 - <?php
748 - }
749 - do_action( 'visualizer_chart_schedules_spl', 'csv', $chart_id, 1 );
750 - ?>
751 - </select>
752 -
753 - <?php
754 - if ( ! Visualizer_Module::is_pro() ) {
755 - ?>
756 - <input type="button" id="view-remote-file" class="button button-primary" value="<?php _e( 'Import', 'visualizer' ); ?>">
757 - <?php
758 - } else {
759 - ?>
760 - <input type="button" id="vz-save-schedule" class="button button-primary" value="<?php _e( 'Import & Save schedule', 'visualizer' ); ?>">
761 - <?php
762 - }
763 - ?>
764 - </form>
765 - </div>
766 - </li>
767 - <!-- import from json url -->
768 - <li class="viz-subsection">
769 - <span class="viz-section-title visualizer_source_json"><?php _e( 'Import from JSON', 'visualizer' ); ?></span>
770 - <div class="viz-section-items section-items">
771 - <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>
772 - <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
773 - <div class="remote-file-section">
774 - <?php
775 - $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
776 - if ( Visualizer_Module::is_pro() ) {
777 - ?>
778 - <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
779 - <select name="time" id="vz-json-time" class="visualizer-select json-form-element" data-chart="<?php echo $chart_id; ?>">
780 - <?php
781 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
782 - $schedules = apply_filters(
783 - 'visualizer_chart_schedules', array(
784 - '-1' => __( 'One-time', 'visualizer' ),
785 - ),
786 - 'json',
787 - $chart_id
788 - );
789 - foreach ( $schedules as $num => $name ) {
790 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
791 - $extra = $num == $hours ? 'selected' : '';
792 - ?>
793 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
794 - <?php
795 - }
796 - do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
797 - ?>
798 - </select>
799 - <?php
800 - }
801 - ?>
802 - </div>
803 -
804 - <input type="button" id="json-chart-button" class="button button-secondary show-chart-toggle"
805 - value="<?php echo $bttn_label; ?>" data-current="chart"
806 - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
807 - data-t-chart="<?php echo $bttn_label; ?>">
808 - <?php
809 - if ( Visualizer_Module::is_pro() ) {
810 - ?>
811 - <input type="button" id="json-chart-save-button" class="button button-primary "
812 - value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
813 - <?php
814 - }
815 - ?>
816 - </form>
817 - </div>
818 - </li>
819 - </ul>
820 - </li>
821 - <!-- import from chart -->
822 - <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
823 - <h2 class="viz-group-title viz-sub-group"
824 - data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
825 - class="dashicons dashicons-lock"></span></h2>
826 - <div class="viz-group-content edit-data-content">
827 - <div>
828 - <p class="viz-group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p>
829 - <form>
830 - <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
831 - <?php
832 - $fetch_link = esc_url(
833 - add_query_arg(
834 - array(
835 - 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '',
836 - 'nonce' => wp_create_nonce(),
837 - ),
838 - admin_url( 'admin-ajax.php' )
839 - )
840 - );
841 - $query_args_charts = array(
842 - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
843 - 'posts_per_page' => 300,
844 - 'no_found_rows' => true,
845 - );
846 - $charts = array();
847 - $query = new WP_Query( $query_args_charts );
848 - while ( $query->have_posts() ) {
849 - $chart = $query->next_post();
850 - $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
851 -
852 - $title = '#' . $chart->ID;
853 - if ( ! empty( $settings['title'] ) ) {
854 - $title = $settings['title'];
855 - }
856 - // for ChartJS, title is an array.
857 - if ( is_array( $title ) && isset( $title['text'] ) ) {
858 - $title = $title['text'];
859 - }
860 - if ( empty( $title ) ) {
861 - $title = '#' . $chart->ID;
862 - }
863 -
864 - ?>
865 - <option value="<?php echo $chart->ID; ?>"><?php echo $title; ?></option>
866 - <?php
867 - }
868 - ?>
869 -
870 - </select>
871 - </form>
872 - <input type="button" id="existing-chart" class="button button-primary"
873 - value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
874 - data-viz-link="<?php echo $fetch_link; ?>">
875 - <?php
876 - if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
877 - echo apply_filters( 'visualizer_pro_upsell', '', 'import-chart' );
878 - }
879 - ?>
880 - </div>
881 - </div>
882 - </li>
883 -
884 - <?php
885 - $save_filter = esc_url(
886 - add_query_arg(
887 - array(
888 - 'action' => Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY,
889 - 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY . Visualizer_Plugin::VERSION ),
890 - 'chart' => $chart_id,
891 - ), admin_url( 'admin-ajax.php' )
892 - )
893 - );
894 - ?>
895 - <!-- import from WordPress -->
896 - <li class="viz-group visualizer_source_query_wp <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wp' ); ?> ">
897 - <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
898 - class="dashicons dashicons-lock"></span></h2>
899 - <div class="viz-group-content edit-data-content">
900 - <div>
901 - <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p>
902 - <form id="vz-filter-wizard" action="<?php echo $save_filter; ?>" method="post" target="thehole">
903 - <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from WordPress.', 'visualizer' ); ?></p>
904 - <select name="refresh" id="vz-filter-import-time" class="visualizer-select">
905 - <?php
906 - $bttn_label = 'visualizer_source_query_wp' === $source_of_chart ? __( 'Modify Filter', 'visualizer' ) : __( 'Create Filter', 'visualizer' );
907 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
908 - $schedules = apply_filters(
909 - 'visualizer_chart_schedules', array(
910 - '-1' => __( 'One-time', 'visualizer' ),
911 - ),
912 - 'wp',
913 - $chart_id
914 - );
915 - foreach ( $schedules as $num => $name ) {
916 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
917 - $extra = $num == $hours ? 'selected' : '';
918 - ?>
919 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
920 - <?php
921 - }
922 - do_action( 'visualizer_chart_schedules_spl', 'wp', $chart_id, 1 );
923 - ?>
924 - </select>
925 -
926 - <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; ?>">
927 - <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
928 - </form>
929 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
930 - </div>
931 - </div>
932 - </li>
933 -
934 - <!-- import from WooCommerce -->
935 - <?php
936 - if ( class_exists( 'WooCommerce', false ) ) :
937 - $wc_source = strtolower( get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_WOOCOMMERCE_SOURCE, true ) );
938 - $wc_source_list = apply_filters(
939 - 'visualizer_woocommerce_report_endpoints',
940 - array(
941 - array(
942 - 'name' => esc_html__( 'Sales', 'visualizer' ),
943 - 'endpoint' => esc_attr( 'sales' ),
944 - ),
945 - array(
946 - 'name' => esc_html__( 'Top Sellers', 'visualizer' ),
947 - 'endpoint' => esc_attr( 'top_sellers' ),
948 - ),
949 - array(
950 - 'name' => esc_html__( 'Coupons Totals', 'visualizer' ),
951 - 'endpoint' => esc_attr( 'coupons/totals' ),
952 - ),
953 - array(
954 - 'name' => esc_html__( 'Customers Totals', 'visualizer' ),
955 - 'endpoint' => esc_attr( 'customers/totals' ),
956 - ),
957 - array(
958 - 'name' => esc_html__( 'Orders Totals', 'visualizer' ),
959 - 'endpoint' => esc_attr( 'orders/totals' ),
960 - ),
961 - array(
962 - 'name' => esc_html__( 'Products Totals', 'visualizer' ),
963 - 'endpoint' => esc_attr( 'products/totals' ),
964 - ),
965 - array(
966 - 'name' => esc_html__( 'Reviews Totals', 'visualizer' ),
967 - 'endpoint' => esc_attr( 'reviews/totals' ),
968 - ),
969 - )
970 - );
971 - ?>
972 - <li class="viz-group visualizer_woocommerce_source<?php echo 'visualizer_source_json_wc' === $source_of_chart ? ' open' : ''; ?> <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wc-report' ); ?> ">
973 - <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WooCommerce Reports', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2>
974 - <div class="viz-group-content edit-data-content">
975 - <div>
976 - <p class="viz-group-description"><?php _e( 'You can choose here to import/synchronize your chart data with a WooCommerce report API. For more info check <a href="https://woocommerce.github.io/woocommerce-rest-api-docs/?shell#reports" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
977 - <form id="vz-import-woo-report" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
978 - <div class="remote-file-section">
979 - <?php
980 - $bttn_label = 'visualizer_source_json_wc' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
981 - ?>
982 - <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
983 - <select name="time" id="vz-woo-time" class="visualizer-select json-form-element" data-chart="<?php echo $chart_id; ?>">
984 - <?php
985 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
986 - $schedules = apply_filters(
987 - 'visualizer_chart_schedules', array(
988 - '-1' => __( 'One-time', 'visualizer' ),
989 - ),
990 - 'json',
991 - $chart_id
992 - );
993 - foreach ( $schedules as $num => $name ) {
994 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
995 - $extra = $num == $hours ? 'selected' : '';
996 - ?>
997 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
998 - <?php
999 - }
1000 - do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
1001 - ?>
1002 - </select>
1003 - <p class="viz-group-description"><?php _e( 'Select report endpoint', 'visualizer' ); ?></p>
1004 - <select name="vz_woo_source" id="vz-woo-source" class="visualizer-select json-form-element" data-chart="<?php echo $chart_id; ?>">
1005 - <option value=""></option>
1006 - <?php
1007 - if ( ! empty( $wc_source_list ) ) {
1008 - foreach ( $wc_source_list as $api ) {
1009 - if ( isset( $api['name'] ) && $api['endpoint'] ) {
1010 - echo sprintf( '<option value="%2$s" %3$s>%1$s</option>', $api['name'], $api['endpoint'], selected( $wc_source, $api['endpoint'], false ) ); // phpcs:ignore
1011 - }
1012 - }
1013 - }
1014 - ?>
1015 - </select>
1016 - </div>
1017 -
1018 - <input type="button" id="woo-chart-button" class="button button-secondary show-chart-toggle"
1019 - value="<?php echo $bttn_label; ?>" data-current="chart"
1020 - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
1021 - data-t-chart="<?php echo $bttn_label; ?>"
1022 - <?php empty( $wc_source ) ? 'disabled' : ''; ?>
1023 - >
1024 - <input type="button" id="woo-chart-save-button" class="button button-primary "
1025 - value="<?php _e( 'Save Schedule', 'visualizer' ); ?>" <?php empty( $wc_source ) ? 'disabled' : ''; ?>>
1026 - </form>
1027 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wc-report' ); ?>
1028 - </div>
1029 - </div>
1030 - </li>
1031 - <?php endif; ?>
1032 - <?php
1033 - $save_query = esc_url(
1034 - add_query_arg(
1035 - array(
1036 - 'action' => Visualizer_Plugin::ACTION_SAVE_DB_QUERY,
1037 - 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_DB_QUERY . Visualizer_Plugin::VERSION ),
1038 - 'chart' => $chart_id,
1039 - ), admin_url( 'admin-ajax.php' )
1040 - )
1041 - );
1042 - ?>
1043 - <!-- import from db -->
1044 - <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>">
1045 - <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span
1046 - class="dashicons dashicons-lock"></span></h2>
1047 - <div class="viz-group-content edit-data-content">
1048 - <div>
1049 - <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p>
1050 - <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole">
1051 - <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p>
1052 - <select name="refresh" id="vz-db-import-time" class="visualizer-select">
1053 - <?php
1054 - $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' );
1055 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
1056 - $schedules = apply_filters(
1057 - 'visualizer_chart_schedules', array(
1058 - '-1' => __( 'One-time', 'visualizer' ),
1059 - ),
1060 - 'db',
1061 - $chart_id
1062 - );
1063 - foreach ( $schedules as $num => $name ) {
1064 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
1065 - $extra = $num == $hours ? 'selected' : '';
1066 - ?>
1067 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
1068 - <?php
1069 - }
1070 - do_action( 'visualizer_chart_schedules_spl', 'db', $chart_id, 1 );
1071 - ?>
1072 - </select>
1073 - <input type="hidden" name="params" id="viz-db-wizard-params">
1074 -
1075 - <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; ?>">
1076 - <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
1077 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
1078 - </form>
1079 - </div>
1080 - </div>
1081 - </li>
1082 -
1083 - <!-- manual -->
1084 - <li class="viz-group visualizer_source_manual <?php echo ! Visualizer_Module_Admin::proFeaturesLocked() ? apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ) : ''; ?>">
1085 - <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?>
1086 - <span class="dashicons dashicons-lock"></span>
1087 - </h2>
1088 - <div class="viz-group-content edit-data-content">
1089 - <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
1090 - <input type="hidden" id="chart-data" name="chart_data">
1091 - <input type="hidden" id="chart-data-src" name="chart_data_src">
1092 -
1093 - <?php if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { ?>
1094 - <div>
1095 - <p class="viz-group-description viz-editor-selection">
1096 - <?php _e( 'Use the', 'visualizer' ); ?>
1097 - <select name="editor-type" id="viz-editor-type">
1098 - <?php
1099 - if ( empty( $editor_type ) ) {
1100 - $editor_type = Visualizer_Module::is_pro() ? 'excel' : 'text';
1101 - }
1102 - foreach ( apply_filters( 'visualizer_editors', array( 'text' => __( 'Text', 'visualizer' ), 'table' => __( 'Simple', 'visualizer' ) ) ) as $e_type => $e_label ) {
1103 - ?>
1104 - <option value="<?php echo $e_type; ?>" <?php selected( $editor_type, $e_type ); ?> ><?php echo $e_label; ?></option>
1105 - <?php } ?>
1106 - </select>
1107 - <?php _e( 'editor to manually edit the chart data.', 'visualizer' ); ?>
1108 - </p>
1109 - <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
1110 - <input type="button" id="editor-button" class="button button-primary "
1111 - value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart"
1112 - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
1113 - data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>"
1114 - >
1115 - <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>
1116 - </div>
1117 - <?php } else { ?>
1118 - <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
1119 - <input type="button" id="editor-chart-button" class="button button-primary "
1120 - value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
1121 - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
1122 - data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"
1123 - >
1124 - <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>
1125 - <?php } ?>
1126 - <?php
1127 - if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
1128 - echo apply_filters( 'visualizer_pro_upsell', '', 'manual-data' );
1129 - }
1130 - ?>
1131 - </form>
1132 - </div>
1133 - </li>
1134 - </ul>
1135 - </li>
1136 - </ul>
1137 - </ul>
1138 -
1139 - <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>
1140 - <iframe id="thehole" name="thehole"></iframe>
1141 - <?php
1142 460 }
1143 461 }