PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.7
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.7
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 3.10.4 All 148 releases
← All changes | classes/Visualizer/Render/Layout.php +224 -160 3.10.43.11.7 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,11 @@
71 88 </div>
72 89 </div>
73 90 <div class='db-wizard-hints'>
74 91 <ul>
92 + <li><?php echo __( 'Your database prefix is:', 'visualizer' ); ?> <span class="visualizer-emboss"><?php echo $wpdb->prefix; ?></span></li>
75 93 <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>
94 + <li><?php echo sprintf( __( 'Use %1$sShift+Space%2$s for autocompleting keywords or table names.', 'visualizer' ), '<span class="visualizer-emboss">', '</span>' ); ?></li>
77 95 <?php do_action( 'visualizer_db_query_add_hints', $args ); ?>
78 96 </ul>
79 97 </div>
80 98 <div class='db-wizard-results'></div>
@@ -104,9 +122,9 @@
104 122 </tr>
105 123 </thead>
106 124 <tfoot>
107 125 </tfoot>
108 - <tbody>
126 + <tbody>
109 127 <?php
110 128 foreach ( $results as $result ) {
111 129 echo '<tr>';
112 130 foreach ( $result as $r ) {
@@ -198,9 +216,9 @@
198 216 id="vz-import-json-username"
199 217 name="username"
200 218 value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'username', $headers['auth'] ) ? $headers['auth']['username'] : '' ); ?>"
201 219 placeholder="<?php esc_html_e( 'Username/Access Key', 'visualizer' ); ?>"
202 - class="json-form-element">
220 + class="json-form-element">
203 221 &
204 222 <input
205 223 type="password"
206 224 id="vz-import-json-password"
@@ -206,9 +224,9 @@
206 224 id="vz-import-json-password"
207 225 name="password"
208 226 value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'password', $headers['auth'] ) ? $headers['auth']['password'] : '' ); ?>"
209 227 placeholder="<?php esc_html_e( 'Password/Secret Key', 'visualizer' ); ?>"
210 - class="json-form-element">
228 + class="json-form-element">
211 229 </div>
212 230 </div>
213 231 <div class="json-wizard-header">
214 232 <div></div>
@@ -419,9 +437,9 @@
419 437 }
420 438 ?>
421 439 </tr>
422 440 </thead>
423 - <tbody>
441 + <tbody>
424 442 <tr>
425 443 <th><?php _e( 'Data Type', 'visualizer' ); ?></th>
426 444 <?php
427 445 $index = 0;
@@ -582,9 +600,14 @@
582 600 *
583 601 * @access public
584 602 */
585 603 public static function _renderTabAdvanced( $args ) {
586 - $sidebar = $args[2];
604 + $chart_id = $args[1];
605 + $sidebar = $args[2];
606 +
607 + $chart_options = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true );
608 + $backend_title = isset( $chart_options['backend-title'] ) && ! empty( $chart_options['backend-title'] ) ? $chart_options['backend-title'] : '';
609 +
587 610 ?>
588 611 <ul class="viz-group-wrapper full-height">
589 612 <li class="viz-group open" id="vz-chart-settings">
590 613 <ul class="viz-group-content">
@@ -590,8 +613,9 @@
590 613 <ul class="viz-group-content">
591 614 <ul class="viz-group-wrapper">
592 615 <form id="settings-form" action="<?php echo esc_url( add_query_arg( 'nonce', wp_create_nonce() ) ); ?>" method="post">
593 616 <input type="hidden" id="chart-img" name="chart-img">
617 + <input type="hidden" id="backend-title" name="backend-title" value="<?php echo esc_html( $backend_title ); ?>">
594 618 <?php echo $sidebar; ?>
595 619 <?php self::_renderPermissions( $args ); ?>
596 620 <input type="hidden" name="save" value="1">
597 621 </form>
@@ -685,9 +709,12 @@
685 709 if ( ! empty( $filter_config ) ) {
686 710 $source_of_chart .= '_wp';
687 711 }
688 712 $editor_type = get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITOR, true );
689 - if ( $editor_type ) {
713 + if (
714 + $editor_type ||
715 + ! Visualizer_Module::is_pro() // Use Manual Source for non-pro users since it is the only unlocked source.
716 + ) {
690 717 $source_of_chart = 'visualizer_source_manual';
691 718 }
692 719
693 720 $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
@@ -696,125 +723,179 @@
696 723 <ul class="viz-group-wrapper full-height">
697 724 <li class="viz-group open" id="vz-chart-source">
698 725 <ul class="viz-group-content">
699 726 <ul class="viz-group-wrapper">
727 + <!-- manual -->
728 + <li class="viz-group visualizer_source_manual">
729 + <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?></h2>
730 + <div class="viz-group-content edit-data-content">
731 + <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
732 + <input type="hidden" id="chart-data" name="chart_data">
733 + <input type="hidden" id="chart-data-src" name="chart_data_src">
734 +
735 + <?php if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { ?>
736 + <div>
737 + <p class="viz-group-description viz-editor-selection">
738 + <?php _e( 'Use the', 'visualizer' ); ?>
739 + <select name="editor-type" id="viz-editor-type">
740 + <?php
741 + if ( empty( $editor_type ) ) {
742 + $editor_type = Visualizer_Module::is_pro() ? 'excel' : 'text';
743 + }
744 + foreach ( apply_filters( 'visualizer_editors', array( 'text' => __( 'Text', 'visualizer' ), 'table' => __( 'Simple', 'visualizer' ) ) ) as $e_type => $e_label ) {
745 + ?>
746 + <option value="<?php echo $e_type; ?>" <?php selected( $editor_type, $e_type ); ?> ><?php echo $e_label; ?></option>
747 + <?php } ?>
748 + </select>
749 + <?php _e( 'editor to manually edit the chart data.', 'visualizer' ); ?>
750 + </p>
751 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
752 + <input type="button" id="editor-button" class="button button-primary "
753 + value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart"
754 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
755 + data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>"
756 + >
757 + <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>
758 + </div>
759 + <?php } else { ?>
760 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
761 + <input type="button" id="editor-chart-button" class="button button-primary "
762 + value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
763 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
764 + data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"
765 + >
766 + <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>
767 + <?php } ?>
768 + </form>
769 + </div>
770 + </li>
771 +
700 772 <!-- 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>
773 + <li class="viz-group visualizer_source_csv <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-file' ); ?> ">
774 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2>
703 775 <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>
776 + <div>
777 + <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>
778 + <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>
779 + <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
780 + target="thehole" enctype="multipart/form-data">
781 + <input type="hidden" id="remote-data" name="remote_data">
782 + <div class="">
783 + <input type="file" id="csv-file" name="local_data">
784 + </div>
785 + <input type="button" class="button button-primary" id="vz-import-file"
786 + value="<?php _e( 'Import', 'visualizer' ); ?>">
787 + </form>
788 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-file' ); ?>
789 + </div>
715 790 </div>
716 791 </li>
717 792 <!-- 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>
793 + <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' ); ?> ">
794 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2>
720 795 <ul class="viz-group-content">
721 796 <!-- import from csv url -->
722 797 <li class="viz-subsection">
723 798 <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' : '';
799 + <div class="only-pro-anchor">
800 + <div class="viz-section-items section-items">
801 + <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>
802 + <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>
803 + <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
804 + target="thehole" enctype="multipart/form-data">
805 + <div class="remote-file-section">
806 + <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">
807 + </div>
808 + <select name="vz-import-time" id="vz-import-time" class="visualizer-select">
809 + <?php
810 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
811 + $schedules = apply_filters(
812 + 'visualizer_chart_schedules', array(
813 + '-1' => __( 'One-time', 'visualizer' ),
814 + ),
815 + 'csv',
816 + $chart_id
817 + );
818 + foreach ( $schedules as $num => $name ) {
819 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
820 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
821 + ?>
822 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
823 + <?php
824 + }
825 + do_action( 'visualizer_chart_schedules_spl', 'csv', $chart_id, 1 );
745 826 ?>
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>
827 + </select>
752 828
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 829 <?php
758 - } else {
830 + if ( ! Visualizer_Module::is_pro() ) {
831 + ?>
832 + <input type="button" id="view-remote-file" class="button button-primary" value="<?php _e( 'Import', 'visualizer' ); ?>">
833 + <?php
834 + } else {
835 + ?>
836 + <input type="button" id="vz-save-schedule" class="button button-primary" value="<?php _e( 'Import & Save schedule', 'visualizer' ); ?>">
837 + <?php
838 + }
759 839 ?>
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>
840 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-url' ); ?>
841 + </form>
842 + </div>
765 843 </div>
766 844 </li>
767 845 <!-- import from json url -->
768 846 <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; ?>">
847 + <span class="viz-section-title visualizer_source_json"><?php _e( 'Import from JSON', 'visualizer' ); ?></span>
848 + <div class="only-pro-anchor">
849 + <div class="viz-section-items section-items">
850 + <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>
851 + <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
852 + <div class="remote-file-section">
780 853 <?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' : '';
854 + $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
855 + if ( Visualizer_Module::is_pro() ) {
792 856 ?>
793 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
857 + <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
858 + <select name="time" id="vz-json-time" class="visualizer-select json-form-element" data-chart="<?php echo $chart_id; ?>">
794 859 <?php
860 + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
861 + $schedules = apply_filters(
862 + 'visualizer_chart_schedules', array(
863 + '-1' => __( 'One-time', 'visualizer' ),
864 + ),
865 + 'json',
866 + $chart_id
867 + );
868 + foreach ( $schedules as $num => $name ) {
869 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
870 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
871 + ?>
872 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
873 + <?php
874 + }
875 + do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
876 + ?>
877 + </select>
878 + <?php
795 879 }
796 - do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
797 880 ?>
798 - </select>
799 - <?php
800 - }
881 + </div>
882 +
883 + <input type="button" id="json-chart-button" class="button button-secondary show-chart-toggle"
884 + value="<?php echo $bttn_label; ?>" data-current="chart"
885 + data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
886 + data-t-chart="<?php echo $bttn_label; ?>">
887 + <?php
888 + if ( Visualizer_Module::is_pro() ) {
801 889 ?>
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() ) {
890 + <input type="button" id="json-chart-save-button" class="button button-primary "
891 + value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
892 + <?php
893 + }
810 894 ?>
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>
895 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-url' ); ?>
896 + </form>
897 + </div>
817 898 </div>
818 899 </li>
819 900 </ul>
820 901 </li>
@@ -871,9 +952,13 @@
871 952 </form>
872 953 <input type="button" id="existing-chart" class="button button-primary"
873 954 value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
874 955 data-viz-link="<?php echo $fetch_link; ?>">
875 - <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
956 + <?php
957 + if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
958 + echo apply_filters( 'visualizer_pro_upsell', '', 'import-chart' );
959 + }
960 + ?>
876 961 </div>
877 962 </div>
878 963 </li>
879 964
@@ -908,10 +993,9 @@
908 993 'wp',
909 994 $chart_id
910 995 );
911 996 foreach ( $schedules as $num => $name ) {
912 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
913 - $extra = $num == $hours ? 'selected' : '';
997 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
914 998 ?>
915 999 <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
916 1000 <?php
917 1001 }
@@ -920,9 +1004,8 @@
920 1004 </select>
921 1005
922 1006 <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; ?>">
923 1007 <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
924 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
925 1008 </form>
926 1009 <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
927 1010 </div>
928 1011 </div>
@@ -987,10 +1070,9 @@
987 1070 'json',
988 1071 $chart_id
989 1072 );
990 1073 foreach ( $schedules as $num => $name ) {
991 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
992 - $extra = $num == $hours ? 'selected' : '';
1074 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
993 1075 ?>
994 1076 <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
995 1077 <?php
996 1078 }
@@ -1057,10 +1139,9 @@
1057 1139 'db',
1058 1140 $chart_id
1059 1141 );
1060 1142 foreach ( $schedules as $num => $name ) {
1061 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
1062 - $extra = $num == $hours ? 'selected' : '';
1143 + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : '';
1063 1144 ?>
1064 1145 <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
1065 1146 <?php
1066 1147 }
@@ -1075,60 +1156,8 @@
1075 1156 </form>
1076 1157 </div>
1077 1158 </div>
1078 1159 </li>
1079 -
1080 - <!-- manual -->
1081 - <li class="viz-group visualizer_source_manual <?php echo ! Visualizer_Module_Admin::proFeaturesLocked() ? apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ) : ''; ?>">
1082 - <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?>
1083 - <span class="dashicons dashicons-lock"></span>
1084 - </h2>
1085 - <div class="viz-group-content edit-data-content">
1086 - <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
1087 - <input type="hidden" id="chart-data" name="chart_data">
1088 - <input type="hidden" id="chart-data-src" name="chart_data_src">
1089 -
1090 - <?php if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { ?>
1091 - <div>
1092 - <p class="viz-group-description viz-editor-selection">
1093 - <?php _e( 'Use the', 'visualizer' ); ?>
1094 - <select name="editor-type" id="viz-editor-type">
1095 - <?php
1096 - if ( empty( $editor_type ) ) {
1097 - $editor_type = Visualizer_Module::is_pro() ? 'excel' : 'text';
1098 - }
1099 - foreach ( apply_filters( 'visualizer_editors', array( 'text' => __( 'Text', 'visualizer' ), 'table' => __( 'Simple', 'visualizer' ) ) ) as $e_type => $e_label ) {
1100 - ?>
1101 - <option value="<?php echo $e_type; ?>" <?php selected( $editor_type, $e_type ); ?> ><?php echo $e_label; ?></option>
1102 - <?php } ?>
1103 - </select>
1104 - <?php _e( 'editor to manually edit the chart data.', 'visualizer' ); ?>
1105 - </p>
1106 - <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
1107 - <input type="button" id="editor-button" class="button button-primary "
1108 - value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart"
1109 - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
1110 - data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>"
1111 - >
1112 - <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>
1113 - </div>
1114 - <?php } else { ?>
1115 - <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
1116 - <input type="button" id="editor-chart-button" class="button button-primary "
1117 - value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
1118 - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
1119 - data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"
1120 - >
1121 - <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>
1122 - <?php } ?>
1123 - <?php
1124 - if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
1125 - echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' );
1126 - }
1127 - ?>
1128 - </form>
1129 - </div>
1130 - </li>
1131 1160 </ul>
1132 1161 </li>
1133 1162 </ul>
1134 1163 </ul>
@@ -1135,6 +1164,41 @@
1135 1164
1136 1165 <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>
1137 1166 <iframe id="thehole" name="thehole"></iframe>
1138 1167 <?php
1168 + }
1169 +
1170 + /**
1171 + * Check if the given hour is selected.
1172 + *
1173 + * @param int|float|string $hour The hour.
1174 + * @param int|float|string $reference The number.
1175 + *
1176 + * @return bool
1177 + */
1178 + public static function is_hour_selected( $hour, $reference ) {
1179 +
1180 + if ( ! is_numeric( $hour ) || ! is_numeric( $reference ) ) {
1181 + return false;
1182 + }
1183 +
1184 + $hour = floatval( $hour );
1185 + $reference = floatval( $reference );
1186 +
1187 + if ( self::is_live_update_option( $reference ) ) {
1188 + $reference = self::$live_option_fallback_hour;
1189 + }
1190 +
1191 + return abs( $hour - $reference ) < 0.000001;
1192 + }
1193 +
1194 + /**
1195 + * Check if the reference option is deprecated live update option.
1196 + *
1197 + * @param float $reference_hour The reference hour.
1198 + *
1199 + * @return bool
1200 + */
1201 + public static function is_live_update_option( $reference_hour ) {
1202 + return abs( $reference_hour ) < 0.000001;
1139 1203 }
1140 1204 }