PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 4.0.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v4.0.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 +369 -217 3.10.144.0.2 View file →
@@ -27,8 +27,15 @@
27 27 */
28 28 class Visualizer_Render_Layout extends Visualizer_Render {
29 29
30 30 /**
31 + * Fallback time for live update option.
32 + *
33 + * @var float
34 + */
35 + public static $live_option_fallback_hour = 0.16; // 10 minutes
36 +
37 + /**
31 38 * Renders template.
32 39 *
33 40 * @since 1.0.0
34 41 *
@@ -53,9 +60,19 @@
53 60 *
54 61 * @access public
55 62 */
56 63 public static function _renderDbQuery( $args ) {
64 + global $wpdb;
57 65 $query = $args[1];
66 + if ( ! $query ) {
67 + $query = '
68 +/* List Posts published per. month */
69 +SELECT CONCAT( YEAR(post_date), "/", MONTH(post_date) ) as date, COUNT(*) AS post_count
70 +FROM ' . $wpdb->prefix . 'posts
71 +WHERE post_type = "post" AND post_status = "publish"
72 +GROUP BY YEAR(post_date), MONTH(post_date)
73 +ORDER BY YEAR(post_date) DESC, MONTH(post_date) DESC;';
74 + }
58 75 ?>
59 76 <div id='visualizer-db-query' style="display: none">
60 77 <div class="visualizer-db-query-form">
61 78 <div>
@@ -71,10 +88,29 @@
71 88 </div>
72 89 </div>
73 90 <div class='db-wizard-hints'>
74 91 <ul>
75 - <li><?php echo sprintf( __( 'For examples of queries and links to resources that you can use with this feature, please click %1$shere%2$s', 'visualizer' ), '<a href="' . VISUALIZER_DB_QUERY_DOC_URL . '" target="_blank">', '</a>' ); ?></li>
76 - <li><?php echo sprintf( __( 'Use %1$sControl+Space%2$s for autocompleting keywords or table names.', 'visualizer' ), '<span class="visualizer-emboss">', '</span>' ); ?></li>
92 + <li><?php echo __( 'Your database prefix is:', 'visualizer' ); ?> <span class="visualizer-emboss"><?php echo $wpdb->prefix; ?></span></li>
93 + <li>
94 + <?php
95 + echo sprintf(
96 + // translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
97 + __( 'For examples of queries and links to resources that you can use with this feature, please click %1$shere%2$s', 'visualizer' ),
98 + '<a href="' . VISUALIZER_DB_QUERY_DOC_URL . '" target="_blank">',
99 + '</a>'
100 + );
101 + ?>
102 + </li>
103 + <li>
104 + <?php
105 + echo sprintf(
106 + // translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
107 + __( 'Use %1$sShift+Space%2$s for autocompleting keywords or table names.', 'visualizer' ),
108 + '<span class="visualizer-emboss">',
109 + '</span>'
110 + );
111 + ?>
112 + </li>
77 113 <?php do_action( 'visualizer_db_query_add_hints', $args ); ?>
78 114 </ul>
79 115 </div>
80 116 <div class='db-wizard-results'></div>
@@ -161,9 +197,18 @@
161 197 <div>
162 198 <form id="json-endpoint-form">
163 199 <div class="json-wizard-hints">
164 200 <ul class="info">
165 - <li><?php echo sprintf( __( 'If you want to add authentication or headers to the endpoint or change the request in any way, please refer to our document %1$shere%2$s.', 'visualizer' ), '<a href="https://docs.themeisle.com/article/1043-visualizer-how-to-extend-rest-endpoints-with-json-response" target="_blank">', '</a>' ); ?></li>
201 + <li>
202 + <?php
203 + echo sprintf(
204 + // translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
205 + __( 'If you want to add authentication or headers to the endpoint or change the request in any way, please refer to our document %1$shere%2$s.', 'visualizer' ),
206 + '<a href="https://docs.themeisle.com/article/1043-visualizer-how-to-extend-rest-endpoints-with-json-response" target="_blank">',
207 + '</a>'
208 + );
209 + ?>
210 + </li>
166 211 </ul>
167 212 </div>
168 213
169 214 <input
@@ -314,9 +359,9 @@
314 359 $action = esc_url(
315 360 add_query_arg(
316 361 array(
317 362 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
318 - 'nonce' => wp_create_nonce(),
363 + 'nonce' => wp_create_nonce( 'visualizer-upload-data' ),
319 364 'chart' => $chart_id,
320 365 ),
321 366 admin_url( 'admin-ajax.php' )
322 367 )
@@ -344,9 +389,8 @@
344 389 <?php Visualizer_Render_Layout::show( 'text-editor', $chart_id ); ?>
345 390
346 391 </div>
347 392 <?php
348 -
349 393 }
350 394
351 395 /**
352 396 * Show the text area editor.
@@ -486,9 +530,9 @@
486 530 private static function _renderPermissions( $args ) {
487 531 $chart_id = $args[1];
488 532
489 533 // 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' ) ) {
534 + if ( defined( 'WP_TESTS_DOMAIN' ) && function_exists( 'tests_add_filter' ) ) {
491 535 return;
492 536 }
493 537
494 538 $permissions = apply_filters( 'visualizer_pro_get_permissions', null, $chart_id );
@@ -571,9 +615,9 @@
571 615 true,
572 616 array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-edit-specific' )
573 617 );
574 618 Visualizer_Render_Sidebar::_renderSectionEnd();
575 - echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions' );
619 + echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions', 'https://docs.themeisle.com/article/1280-how-to-customize-permissions' );
576 620 echo '</div>';
577 621 Visualizer_Render_Sidebar::_renderGroupEnd();
578 622 }
579 623
@@ -582,9 +626,14 @@
582 626 *
583 627 * @access public
584 628 */
585 629 public static function _renderTabAdvanced( $args ) {
586 - $sidebar = $args[2];
630 + $chart_id = $args[1];
631 + $sidebar = $args[2];
632 +
633 + $chart_options = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true );
634 + $backend_title = isset( $chart_options['backend-title'] ) && ! empty( $chart_options['backend-title'] ) ? $chart_options['backend-title'] : '';
635 +
587 636 ?>
588 637 <ul class="viz-group-wrapper full-height">
589 638 <li class="viz-group open" id="vz-chart-settings">
590 639 <ul class="viz-group-content">
@@ -590,8 +639,9 @@
590 639 <ul class="viz-group-content">
591 640 <ul class="viz-group-wrapper">
592 641 <form id="settings-form" action="<?php echo esc_url( add_query_arg( 'nonce', wp_create_nonce() ) ); ?>" method="post">
593 642 <input type="hidden" id="chart-img" name="chart-img">
643 + <input type="hidden" id="backend-title" name="backend-title" value="<?php echo esc_html( $backend_title ); ?>">
594 644 <?php echo $sidebar; ?>
595 645 <?php self::_renderPermissions( $args ); ?>
596 646 <input type="hidden" name="save" value="1">
597 647 </form>
@@ -637,12 +687,22 @@
637 687 <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 688 <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 689 <?php
640 690 Visualizer_Render_Sidebar::_renderSectionEnd();
691 + // translators: %s - the chart type.
641 692 Visualizer_Render_Sidebar::_renderSectionStart( sprintf( __( '%s chart', 'visualizer' ), ucwords( $displayType ) ), true );
642 693 ?>
643 694 <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>
695 + <h4><span class="dashicons dashicons-search"></span><a href="<?php echo str_replace( '#', $type, VISUALIZER_DOC_COLLECTION ); ?>" target="_blank">
696 + <?php
697 + echo sprintf(
698 + // translators: %s - the chart type.
699 + __( 'Articles containing "%s"', 'visualizer' ),
700 + $displayType
701 + );
702 + ?>
703 + </a>
704 + </h4>
645 705 <?php
646 706 Visualizer_Render_Sidebar::_renderSectionEnd();
647 707 Visualizer_Render_Sidebar::_renderGroupEnd();
648 708 ?>
@@ -664,9 +724,9 @@
664 724 $upload_link = esc_url(
665 725 add_query_arg(
666 726 array(
667 727 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
668 - 'nonce' => wp_create_nonce(),
728 + 'nonce' => wp_create_nonce( 'visualizer-upload-data' ),
669 729 'chart' => $chart_id,
670 730 ),
671 731 admin_url( 'admin-ajax.php' )
672 732 )
@@ -685,9 +745,12 @@
685 745 if ( ! empty( $filter_config ) ) {
686 746 $source_of_chart .= '_wp';
687 747 }
688 748 $editor_type = get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITOR, true );
689 - if ( $editor_type ) {
749 + if (
750 + $editor_type ||
751 + ! Visualizer_Module::is_pro() // Use Manual Source for non-pro users since it is the only unlocked source.
752 + ) {
690 753 $source_of_chart = 'visualizer_source_manual';
691 754 }
692 755
693 756 $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
@@ -696,125 +759,208 @@
696 759 <ul class="viz-group-wrapper full-height">
697 760 <li class="viz-group open" id="vz-chart-source">
698 761 <ul class="viz-group-content">
699 762 <ul class="viz-group-wrapper">
763 + <!-- manual -->
764 + <li class="viz-group visualizer_source_manual">
765 + <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart" role="button" tabindex="0"><?php _e( 'Manual Data', 'visualizer' ); ?></h2>
766 + <div class="viz-group-content edit-data-content">
767 + <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
768 + <input type="hidden" id="chart-data" name="chart_data">
769 + <input type="hidden" id="chart-data-src" name="chart_data_src">
770 +
771 + <?php if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { ?>
772 + <div>
773 + <p class="viz-group-description viz-editor-selection">
774 + <?php _e( 'Use the', 'visualizer' ); ?>
775 + <select name="editor-type" id="viz-editor-type">
776 + <?php
777 + if ( empty( $editor_type ) ) {
778 + $editor_type = Visualizer_Module::is_pro() ? 'excel' : 'text';
779 + }
780 + foreach ( apply_filters( 'visualizer_editors', array( 'text' => __( 'Text', 'visualizer' ), 'table' => __( 'Simple', 'visualizer' ) ) ) as $e_type => $e_label ) {
781 + ?>
782 + <option value="<?php echo $e_type; ?>" <?php selected( $editor_type, $e_type ); ?> ><?php echo $e_label; ?></option>
783 + <?php } ?>
784 + </select>
785 + <?php _e( 'editor to manually edit the chart data.', 'visualizer' ); ?>
786 + </p>
787 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
788 + <input type="button" id="editor-button" class="button button-primary "
789 + value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart"
790 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
791 + data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>"
792 + >
793 + <p class="viz-group-description viz-info-msg" style="display:none"><?php echo sprintf( __( 'Please make sure you click \'Show Chart\' before you save the chart.', 'visualizer' ) ); ?></p>
794 + </div>
795 + <?php } else { ?>
796 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
797 + <input type="button" id="editor-chart-button" class="button button-primary "
798 + value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
799 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
800 + data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"
801 + >
802 + <p class="viz-group-description viz-info-msg" style="display:none"><?php echo sprintf( __( 'Please make sure you click \'Show Chart\' before you save the chart.', 'visualizer' ) ); ?></p>
803 + <?php } ?>
804 + </form>
805 + </div>
806 + </li>
807 +
700 808 <!-- 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>
809 + <li class="viz-group visualizer_source_csv <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-file' ); ?> ">
810 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab" role="button" tabindex="0"><?php _e( 'Import data from file', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2>
703 811 <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>
812 + <div>
813 + <p class="viz-group-description"><?php esc_html_e( 'Select and upload your data file here. Supported formats: CSV, XLSX. The first row should contain the column headings. The second row should contain the series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' ); ?></p>
814 + <p class="viz-group-description viz-info-msg">
815 + <b>
816 + <?php
817 + echo sprintf(
818 + // translators: $s - the chart type with the link attached.
819 + __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ),
820 + '<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">' . $type . '.csv</a>'
821 + );
822 + ?>
823 + </b>
824 + </p>
825 + <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
826 + target="thehole" enctype="multipart/form-data">
827 + <input type="hidden" id="remote-data" name="remote_data">
828 + <div class="">
829 + <input type="file" id="csv-file" name="local_data" accept=".csv,.xlsx">
830 + </div>
831 + <input type="button" class="button button-primary" id="vz-import-file"
832 + value="<?php _e( 'Import', 'visualizer' ); ?>">
833 + </form>
834 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-file' ); ?>
835 + </div>
715 836 </div>
716 837 </li>
717 838 <!-- 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>
839 + <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-url' ); ?> ">
840 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab" role="button" tabindex="0"><?php _e( 'Import data from URL', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2>
720 841 <ul class="viz-group-content">
721 842 <!-- import from csv url -->
722 843 <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' : '';
844 + <span class="viz-section-title" role="button" tabindex="0"><?php _e( 'Import from CSV / XLSX', 'visualizer' ); ?></span>
845 + <div class="only-pro-anchor">
846 + <div class="viz-section-items section-items">
847 + <p class="viz-group-description">
848 + <?php
849 + echo sprintf(
850 + // translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
851 + __( 'You can use this to import data from a remote CSV or Excel (XLSX) file, or %1$sGoogle Spreadsheet%2$s.', 'visualizer' ),
852 + '<a href="https://docs.themeisle.com/article/607-how-can-i-populate-data-from-google-spreadsheet" target="_blank" >',
853 + '</a>'
854 + );
745 855 ?>
746 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
856 + </p>
857 + <p class="viz-group-description viz-info-msg">
858 + <b>
859 + <?php
860 + echo sprintf(
861 + // translators: %s - the chart type with the link attached.
862 + __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ),
863 + '<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">' . $type . '.csv</a>'
864 + );
865 + ?>
866 + </b>
867 + </p>
868 + <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
869 + target="thehole" enctype="multipart/form-data">
870 + <div class="remote-file-section">
871 + <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 a CSV or XLSX file', 'visualizer' ); ?>" class="visualizer-input visualizer-remote-url">
872 + </div>
873 + <select name="vz-import-time" id="vz-import-time" class="visualizer-select">
747 874 <?php
748 - }
749 - do_action( 'visualizer_chart_schedules_spl', 'csv', $chart_id, 1 );
750 - ?>
751 - </select>
875 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
876 + $schedules = apply_filters(
877 + 'visualizer_chart_schedules', array(
878 + '-1' => __( 'One-time', 'visualizer' ),
879 + ),
880 + 'csv',
881 + $chart_id
882 + );
883 + foreach ( $schedules as $num => $name ) {
884 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
885 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
886 + ?>
887 + <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option>
888 + <?php
889 + }
890 + do_action( 'visualizer_chart_schedules_spl', 'csv', $chart_id, 1 );
891 + ?>
892 + </select>
752 893
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 894 <?php
758 - } else {
895 + if ( ! Visualizer_Module::is_pro() ) {
896 + ?>
897 + <input type="button" id="view-remote-file" class="button button-primary" value="<?php _e( 'Import', 'visualizer' ); ?>">
898 + <?php
899 + } else {
900 + ?>
901 + <input type="button" id="vz-save-schedule" class="button button-primary" value="<?php _e( 'Import & Save schedule', 'visualizer' ); ?>">
902 + <?php
903 + }
759 904 ?>
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>
905 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-url' ); ?>
906 + </form>
907 + </div>
765 908 </div>
766 909 </li>
767 910 <!-- import from json url -->
768 911 <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; ?>">
912 + <span class="viz-section-title visualizer_source_json" role="button" tabindex="0"><?php _e( 'Import from JSON', 'visualizer' ); ?></span>
913 + <div class="only-pro-anchor">
914 + <div class="viz-section-items section-items">
915 + <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>
916 + <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
917 + <div class="remote-file-section">
780 918 <?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' : '';
919 + $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
920 + if ( Visualizer_Module::is_pro() ) {
792 921 ?>
793 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
922 + <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
923 + <select name="time" id="vz-json-time" class="visualizer-select json-form-element" data-chart="<?php echo $chart_id; ?>">
794 924 <?php
925 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
926 + $schedules = apply_filters(
927 + 'visualizer_chart_schedules', array(
928 + '-1' => __( 'One-time', 'visualizer' ),
929 + ),
930 + 'json',
931 + $chart_id
932 + );
933 + foreach ( $schedules as $num => $name ) {
934 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
935 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
936 + ?>
937 + <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option>
938 + <?php
939 + }
940 + do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
941 + ?>
942 + </select>
943 + <?php
795 944 }
796 - do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
797 945 ?>
798 - </select>
799 - <?php
800 - }
946 + </div>
947 +
948 + <input type="button" id="json-chart-button" class="button button-secondary show-chart-toggle"
949 + value="<?php echo $bttn_label; ?>" data-current="chart"
950 + data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
951 + data-t-chart="<?php echo $bttn_label; ?>">
952 + <?php
953 + if ( Visualizer_Module::is_pro() ) {
801 954 ?>
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() ) {
955 + <input type="button" id="json-chart-save-button" class="button button-primary "
956 + value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
957 + <?php
958 + }
810 959 ?>
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>
960 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-url' ); ?>
961 + </form>
962 + </div>
817 963 </div>
818 964 </li>
819 965 </ul>
820 966 </li>
@@ -820,9 +966,9 @@
820 966 </li>
821 967 <!-- import from chart -->
822 968 <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
823 969 <h2 class="viz-group-title viz-sub-group"
824 - data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
970 + data-current="chart" role="button" tabindex="0"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
825 971 class="dashicons dashicons-lock"></span></h2>
826 972 <div class="viz-group-content edit-data-content">
827 973 <div>
828 974 <p class="viz-group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p>
@@ -832,9 +978,9 @@
832 978 $fetch_link = esc_url(
833 979 add_query_arg(
834 980 array(
835 981 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '',
836 - 'nonce' => wp_create_nonce(),
982 + 'nonce' => Visualizer_Module::is_pro() ? wp_create_nonce( Visualizer_Pro::ACTION_FETCH_DATA ) : wp_create_nonce(),
837 983 ),
838 984 admin_url( 'admin-ajax.php' )
839 985 )
840 986 );
@@ -869,12 +1015,12 @@
869 1015
870 1016 </select>
871 1017 </form>
872 1018 <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; ?>">
1019 + value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
1020 + data-viz-link="<?php echo $fetch_link; ?>">
875 1021 <?php
876 - if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
1022 + if ( ! Visualizer_Module_Admin::proFeaturesEnabled() ) {
877 1023 echo apply_filters( 'visualizer_pro_upsell', '', 'import-chart' );
878 1024 }
879 1025 ?>
880 1026 </div>
@@ -892,42 +1038,54 @@
892 1038 )
893 1039 );
894 1040 ?>
895 1041 <!-- 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
1042 + <li class="viz-group visualizer_source_query_wp <?php echo esc_attr( apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wp' ) ); ?> ">
1043 + <h2 class="viz-group-title viz-sub-group" role="button" tabindex="0"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
898 1044 class="dashicons dashicons-lock"></span></h2>
899 1045 <div class="viz-group-content edit-data-content">
900 1046 <div>
901 1047 <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">
1048 + <form id="vz-filter-wizard" action="<?php echo esc_url( $save_filter ); ?>" method="post" target="thehole">
905 1049 <?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 );
1050 + $is_wp_source = 'visualizer_source_query_wp' === $source_of_chart;
1051 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
1052 + $bttn_label = $is_wp_source ? '1. ' . __( 'Modify Data Source', 'visualizer' ) : '1. ' . __( 'Choose Data Source', 'visualizer' );
923 1053 ?>
924 - </select>
925 1054
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' ); ?>">
1055 + <!-- Step 1: Choose / modify data source -->
1056 + <input type="button" id="filter-chart-button" class="button button-secondary show-chart-toggle vz-import-step-btn" value="<?php echo esc_attr( $bttn_label ); ?>" data-current="chart" data-t-filter="<?php esc_attr_e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo esc_attr( $bttn_label ); ?>">
1057 +
1058 + <!-- Step 2: Sync schedule toggle -->
1059 + <div id="vz-wp-sync-step">
1060 + <button type="button" id="vz-wp-sync-btn" class="vz-import-step-toggle" aria-expanded="<?php echo $is_wp_source ? 'true' : 'false'; ?>">
1061 + <?php echo '2. ' . __( 'Set Sync Schedule', 'visualizer' ); ?>
1062 + <span class="dashicons dashicons-arrow-down-alt2"></span>
1063 + </button>
1064 + <div id="vz-wp-sync-options"<?php echo $is_wp_source ? '' : ' style="display:none"'; ?>>
1065 + <select name="refresh" id="vz-filter-import-time" class="visualizer-select">
1066 + <?php
1067 + $schedules = apply_filters(
1068 + 'visualizer_chart_schedules', array(
1069 + '-1' => __( 'One-time', 'visualizer' ),
1070 + ),
1071 + 'wp',
1072 + $chart_id
1073 + );
1074 + foreach ( $schedules as $num => $name ) {
1075 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
1076 + ?>
1077 + <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option>
1078 + <?php
1079 + }
1080 + do_action( 'visualizer_chart_schedules_spl', 'wp', $chart_id, 1 );
1081 + ?>
1082 + </select>
1083 + <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
1084 + </div>
1085 + </div>
928 1086 </form>
929 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
1087 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp', 'https://docs.themeisle.com/article/1278-how-to-import-data-from-wordpress' ); ?>
930 1088 </div>
931 1089 </div>
932 1090 </li>
933 1091
@@ -969,9 +1127,9 @@
969 1127 )
970 1128 );
971 1129 ?>
972 1130 <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>
1131 + <h2 class="viz-group-title viz-sub-group" role="button" tabindex="0"><?php _e( 'Import from WooCommerce Reports', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2>
974 1132 <div class="viz-group-content edit-data-content">
975 1133 <div>
976 1134 <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 1135 <form id="vz-import-woo-report" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
@@ -990,12 +1148,11 @@
990 1148 'json',
991 1149 $chart_id
992 1150 );
993 1151 foreach ( $schedules as $num => $name ) {
994 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
995 - $extra = $num == $hours ? 'selected' : '';
1152 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
996 1153 ?>
997 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
1154 + <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option>
998 1155 <?php
999 1156 }
1000 1157 do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
1001 1158 ?>
@@ -1040,98 +1197,58 @@
1040 1197 )
1041 1198 );
1042 1199 ?>
1043 1200 <!-- 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
1201 + <li class="viz-group visualizer_source_query <?php echo esc_attr( apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ) ); ?>">
1202 + <h2 class="viz-group-title viz-sub-group" role="button" tabindex="0"><?php _e( 'Import from database', 'visualizer' ); ?><span
1046 1203 class="dashicons dashicons-lock"></span></h2>
1047 1204 <div class="viz-group-content edit-data-content">
1048 1205 <div>
1049 1206 <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">
1207 + <form id="vz-db-wizard" action="<?php echo esc_url( $save_query ); ?>" method="post" target="thehole">
1053 1208 <?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 );
1209 + $is_db_source = 'visualizer_source_query' === $source_of_chart;
1210 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
1211 + $bttn_label = $is_db_source ? __( '1. Modify Data Source', 'visualizer' ) : __( '1. Choose Data Source', 'visualizer' );
1071 1212 ?>
1072 - </select>
1213 +
1214 + <!-- Step 1: Choose / modify data source -->
1073 1215 <input type="hidden" name="params" id="viz-db-wizard-params">
1216 + <input type="button" id="db-chart-button" class="button button-secondary show-chart-toggle vz-import-step-btn" value="<?php echo esc_attr( $bttn_label ); ?>" data-current="chart" data-t-filter="<?php esc_attr_e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo esc_attr( $bttn_label ); ?>">
1074 1217
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' ); ?>
1218 + <!-- Step 2: Sync schedule toggle -->
1219 + <div id="vz-db-sync-step">
1220 + <button type="button" id="vz-db-sync-btn" class="vz-import-step-toggle" aria-expanded="<?php echo $is_db_source ? 'true' : 'false'; ?>">
1221 + <?php echo '2. ' . __( 'Set Sync Schedule', 'visualizer' ); ?>
1222 + <span class="dashicons dashicons-arrow-down-alt2"></span>
1223 + </button>
1224 + <div id="vz-db-sync-options"<?php echo $is_db_source ? '' : ' style="display:none"'; ?>>
1225 + <select name="refresh" id="vz-db-import-time" class="visualizer-select">
1226 + <?php
1227 + $schedules = apply_filters(
1228 + 'visualizer_chart_schedules', array(
1229 + '-1' => __( 'One-time', 'visualizer' ),
1230 + ),
1231 + 'db',
1232 + $chart_id
1233 + );
1234 + foreach ( $schedules as $num => $name ) {
1235 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
1236 + ?>
1237 + <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option>
1238 + <?php
1239 + }
1240 + do_action( 'visualizer_chart_schedules_spl', 'db', $chart_id, 1 );
1241 + ?>
1242 + </select>
1243 + <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
1244 + </div>
1245 + </div>
1246 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query', 'https://docs.themeisle.com/article/1279-how-to-import-data-from-a-database' ); ?>
1078 1247 </form>
1079 1248 </div>
1080 1249 </div>
1081 1250 </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 1251 </ul>
1135 1252 </li>
1136 1253 </ul>
1137 1254 </ul>
@@ -1138,6 +1255,41 @@
1138 1255
1139 1256 <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 1257 <iframe id="thehole" name="thehole"></iframe>
1141 1258 <?php
1259 + }
1260 +
1261 + /**
1262 + * Check if the given hour is selected.
1263 + *
1264 + * @param int|float|string $hour The hour.
1265 + * @param int|float|string $reference The number.
1266 + *
1267 + * @return bool
1268 + */
1269 + public static function is_hour_selected( $hour, $reference ) {
1270 +
1271 + if ( ! is_numeric( $hour ) || ! is_numeric( $reference ) ) {
1272 + return false;
1273 + }
1274 +
1275 + $hour = floatval( $hour );
1276 + $reference = floatval( $reference );
1277 +
1278 + if ( self::is_live_update_option( $reference ) ) {
1279 + $reference = self::$live_option_fallback_hour;
1280 + }
1281 +
1282 + return abs( $hour - $reference ) < 0.000001;
1283 + }
1284 +
1285 + /**
1286 + * Check if the reference option is deprecated live update option.
1287 + *
1288 + * @param float $reference_hour The reference hour.
1289 + *
1290 + * @return bool
1291 + */
1292 + public static function is_live_update_option( $reference_hour ) {
1293 + return abs( $reference_hour ) < 0.000001;
1142 1294 }
1143 1295 }