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/Page/Data.php +250 -121 3.1.23.4.2 View file →
@@ -37,16 +37,22 @@
37 37 * @access protected
38 38 */
39 39 protected function _renderContent() {
40 40 // Added by Ash/Upwork
41 - if ( VISUALIZER_PRO ) {
42 - global $Visualizer_Pro;
43 - $Visualizer_Pro->_addEditor( $this->chart->ID );
44 - if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) {
45 - $Visualizer_Pro->_addFilterWizard( $this->chart->ID );
41 + if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) {
42 + Visualizer_Render_Layout::show( 'simple-editor-screen', $this->chart->ID );
43 + }
44 +
45 + if ( Visualizer_Module::is_pro() ) {
46 + do_action( 'visualizer_add_editor_etc', $this->chart->ID );
47 +
48 + if ( Visualizer_Module::is_pro() && Visualizer_Module::is_pro_older_than( '1.9.0' ) ) {
49 + global $Visualizer_Pro;
50 + $Visualizer_Pro->_addEditor( $this->chart->ID );
51 + if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) {
52 + $Visualizer_Pro->_addFilterWizard( $this->chart->ID );
53 + }
46 54 }
47 - } else {
48 - Visualizer_Render_Layout::show( 'faux-editor' );
49 55 }
50 56
51 57 $this->add_additional_content();
52 58
@@ -75,11 +81,23 @@
75 81 );
76 82
77 83 // this will allow us to open the correct source tab by default.
78 84 $source_of_chart = strtolower( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SOURCE, true ) );
85 + // both import from wp and import from db have the same source so we need to differentiate.
86 + $filter_config = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_FILTER_CONFIG, true );
87 + // if filter config is present, then its import from wp.
88 + if ( ! empty( $filter_config ) ) {
89 + $source_of_chart .= '_wp';
90 + }
91 + $editor_type = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_EDITOR, true );
92 + if ( $editor_type ) {
93 + $source_of_chart = 'visualizer_source_manual';
94 + }
95 +
79 96 $type = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
97 + $lib = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_LIBRARY, true );
80 98 ?>
81 - <span id="visualizer-chart-id" data-id="<?php echo $this->chart->ID; ?>" data-chart-source="<?php echo $source_of_chart; ?>" data-chart-type="<?php echo $type; ?>"></span>
99 + <span id="visualizer-chart-id" data-id="<?php echo $this->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>
82 100 <iframe id="thehole" name="thehole"></iframe>
83 101 <ul class="viz-group-wrapper full-height">
84 102 <li class="viz-group viz-group-category open" id="vz-chart-source">
85 103 <div class="viz-group-header">
@@ -86,13 +104,14 @@
86 104 <h2 class="viz-group-title viz-main-group"><?php _e( 'Chart Data', 'visualizer' ); ?></h2>
87 105 </div>
88 106 <ul class="viz-group-content">
89 107 <ul class="viz-group-wrapper">
108 + <!-- import from file -->
90 109 <li class="viz-group visualizer_source_csv">
91 110 <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
92 111 <div class="viz-group-content">
93 112 <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>
94 - <p class="viz-group-description"><?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', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></p>
113 + <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/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></b></p>
95 114 <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
96 115 target="thehole" enctype="multipart/form-data">
97 116 <input type="hidden" id="remote-data" name="remote_data">
98 117 <div class="">
@@ -102,78 +121,113 @@
102 121 value="<?php _e( 'Import', 'visualizer' ); ?>">
103 122 </form>
104 123 </div>
105 124 </li>
106 - <li class="viz-group visualizer-import-url visualizer_source_csv_remote">
125 + <!-- import from url -->
126 + <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json">
107 127 <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
108 128 <ul class="viz-group-content">
129 + <!-- import from csv url -->
109 130 <li class="viz-subsection">
110 - <span class="viz-section-title"><?php _e( 'One time import', 'visualizer' ); ?></span>
111 -
131 + <span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span>
112 132 <div class="viz-section-items section-items">
113 - <p class="viz-group-description"><?php _e( 'You can use this to import data from a remote CSV file. 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>
114 - <p class="viz-group-description"><?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', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></p>
115 - <p class="viz-group-description"> <?php _e( 'You can also import data from Google Spreadsheet, for more info check <a href="https://github.com/Codeinwp/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
133 + <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>
134 + <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/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></b></p>
116 135 <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
117 136 target="thehole" enctype="multipart/form-data">
118 137 <div class="remote-file-section">
119 - <input type="url" id="remote-data" name="remote_data"
120 - placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
121 - class="visualizer-input">
138 + <input type="url" id="vz-schedule-url" name="remote_data" value="<?php echo esc_attr( get_post_meta( $this->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">
139 + </div>
140 + <select name="vz-import-time" id="vz-import-time" class="visualizer-select">
141 + <?php
142 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
143 + $schedules = apply_filters(
144 + 'visualizer_chart_schedules', array(
145 + '-1' => __( 'One-time', 'visualizer' ),
146 + ),
147 + 'csv',
148 + $this->chart->ID
149 + );
150 + foreach ( $schedules as $num => $name ) {
151 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
152 + $extra = $num == $hours ? 'selected' : '';
153 + ?>
154 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
155 + <?php
156 + }
157 + do_action( 'visualizer_chart_schedules_spl', 'csv', $this->chart->ID, 1 );
158 + ?>
159 + </select>
122 160
123 - </div>
124 - <input type="button" id="view-remote-file" class="button button-primary"
125 - value="<?php _e( 'Import', 'visualizer' ); ?>">
161 + <input type="button" id="view-remote-file" class="button <?php echo Visualizer_Module::is_pro() ? 'button-secondary' : 'button-primary'; ?>" value="<?php _e( 'Import', 'visualizer' ); ?>">
162 + <?php
163 + if ( Visualizer_Module::is_pro() ) {
164 + ?>
165 + <input type="button" id="vz-save-schedule" class="button button-primary" value="<?php _e( 'Save schedule', 'visualizer' ); ?>">
166 + <?php
167 + }
168 + ?>
126 169 </form>
127 170 </div>
128 171 </li>
129 - <li class="viz-subsection <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?>">
130 - <span class="viz-section-title visualizer-import-url-schedule"><?php _e( 'Schedule Import', 'visualizer' ); ?>
131 - <span
132 - class="dashicons dashicons-lock"></span></span>
172 + <!-- import from json url -->
173 + <li class="viz-subsection">
174 + <span class="viz-section-title visualizer_source_json"><?php _e( 'Import from JSON', 'visualizer' ); ?>
175 + <span class="dashicons dashicons-lock"></span></span>
133 176 <div class="viz-section-items section-items">
134 - <p class="viz-group-description"><?php _e( 'You can choose here to synchronize your chart data with a remote CSV file.', 'visualizer' ); ?> </p>
135 - <p class="viz-group-description"> <?php _e( 'You can also synchronize with your Google Spreadsheet file, for more info check <a href="https://github.com/Codeinwp/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
136 - <p class="viz-group-description"> <?php _e( 'We will update the chart data based on your time interval preference by overwritting the current data with the one from the URL.', 'visualizer' ); ?></p>
137 - <form id="vz-schedule-import" action="<?php echo $upload_link; ?>" method="post"
138 - target="thehole" enctype="multipart/form-data">
177 + <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>
178 + <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
139 179 <div class="remote-file-section">
140 - <input type="url" id="vz-schedule-url" name="remote_data"
141 - value="<?php echo get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ); ?>"
142 - placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
143 - class="visualizer-input visualizer-remote-url">
144 - <p class="viz-group-description"><?php _e( 'How often do you want to check the url', 'visualizer' ); ?></p>
145 - <select name="vz-import-time" id="vz-import-time"
146 - class="visualizer-select">
147 180 <?php
148 - $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
149 - $schedules = apply_filters(
150 - 'visualizer_chart_schedules', array(
151 - '1' => __( 'Each hour', 'visualizer' ),
152 - '12' => __( 'Each 12 hours', 'visualizer' ),
153 - '24' => __( 'Each day', 'visualizer' ),
154 - '72' => __( 'Each 3 days', 'visualizer' ),
155 - )
156 - );
157 - foreach ( $schedules as $num => $name ) {
158 - $extra = $num == $hours ? 'selected' : '';
181 + $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
182 + if ( Visualizer_Module::is_pro() ) {
159 183 ?>
160 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
184 + <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
185 + <select name="time" id="vz-json-time" class="visualizer-select json-form-element" data-chart="<?php echo $this->chart->ID; ?>">
161 186 <?php
187 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
188 + $schedules = apply_filters(
189 + 'visualizer_chart_schedules', array(
190 + '-1' => __( 'One-time', 'visualizer' ),
191 + ),
192 + 'json',
193 + $this->chart->ID
194 + );
195 + foreach ( $schedules as $num => $name ) {
196 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
197 + $extra = $num == $hours ? 'selected' : '';
198 + ?>
199 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
200 + <?php
201 + }
202 + do_action( 'visualizer_chart_schedules_spl', 'json', $this->chart->ID, 1 );
203 + ?>
204 + </select>
205 + <?php
162 206 }
163 207 ?>
164 - </select>
165 208 </div>
166 - <input type="button" id="vz-save-schedule" class="button button-primary"
167 - value="<?php _e( 'Save schedule', 'visualizer' ); ?>">
168 209
169 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
210 + <input type="button" id="json-chart-button" class="button button-secondary show-chart-toggle"
211 + value="<?php echo $bttn_label; ?>" data-current="chart"
212 + data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
213 + data-t-chart="<?php echo $bttn_label; ?>">
214 + <?php
215 + if ( Visualizer_Module::is_pro() ) {
216 + ?>
217 + <input type="button" id="json-chart-save-button" class="button button-primary "
218 + value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
219 + <?php
220 + }
221 + ?>
170 222 </form>
171 223 </div>
172 224 </li>
173 225 </ul>
174 226 </li>
175 - <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
227 + <!-- import from chart -->
228 + <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
229 + <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
176 230 <h2 class="viz-group-title viz-sub-group"
177 231 data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
178 232 class="dashicons dashicons-lock"></span></h2>
179 233 <div class="viz-group-content edit-data-content">
@@ -183,9 +237,9 @@
183 237 <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
184 238 <?php
185 239 $fetch_link = add_query_arg(
186 240 array(
187 - 'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '',
241 + 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '',
188 242 'nonce' => wp_create_nonce(),
189 243 ),
190 244 admin_url( 'admin-ajax.php' )
191 245 );
@@ -198,10 +252,23 @@
198 252 $query = new WP_Query( $query_args_charts );
199 253 while ( $query->have_posts() ) {
200 254 $chart = $query->next_post();
201 255 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
256 +
257 + $title = '#' . $chart->ID;
258 + if ( ! empty( $settings['title'] ) ) {
259 + $title = $settings['title'];
260 + }
261 + // for ChartJS, title is an array.
262 + if ( is_array( $title ) && isset( $title['text'] ) ) {
263 + $title = $title['text'];
264 + }
265 + if ( empty( $title ) ) {
266 + $title = '#' . $chart->ID;
267 + }
268 +
202 269 ?>
203 - <option value="<?php echo $chart->ID; ?>"><?php echo empty( $settings['title'] ) ? '#' . $chart->ID : $settings['title']; ?></option>
270 + <option value="<?php echo $chart->ID; ?>"><?php echo $title; ?></option>
204 271 <?php
205 272 }
206 273 ?>
207 274
@@ -214,19 +281,53 @@
214 281 </div>
215 282 </div>
216 283 </li>
217 284
218 - <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?> ">
285 + <?php
286 + $save_filter = add_query_arg(
287 + array(
288 + 'action' => Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY,
289 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY . Visualizer_Plugin::VERSION ),
290 + 'chart' => $this->chart->ID,
291 + ), admin_url( 'admin-ajax.php' )
292 + );
293 + ?>
294 + <!-- import from WordPress -->
295 + <li class="viz-group visualizer_source_query_wp <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wp' ); ?> ">
219 296 <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
220 297 class="dashicons dashicons-lock"></span></h2>
221 298 <div class="viz-group-content edit-data-content">
222 299 <div>
223 300 <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p>
224 - <input type="button" id="filter-chart-button" class="button button-primary "
225 - value="<?php _e( 'Create Filters', 'visualizer' ); ?>" data-current="chart"
226 - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
227 - data-t-chart="<?php _e( 'Create Filters', 'visualizer' ); ?>">
228 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
301 + <form id="vz-filter-wizard" action="<?php echo $save_filter; ?>" method="post" target="thehole">
302 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from WordPress.', 'visualizer' ); ?></p>
303 + <select name="refresh" id="vz-filter-import-time" class="visualizer-select">
304 + <?php
305 + $bttn_label = 'visualizer_source_query_wp' === $source_of_chart ? __( 'Modify Filter', 'visualizer' ) : __( 'Create Filter', 'visualizer' );
306 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
307 + $schedules = apply_filters(
308 + 'visualizer_chart_schedules', array(
309 + '-1' => __( 'One-time', 'visualizer' ),
310 + ),
311 + 'wp',
312 + $this->chart->ID
313 + );
314 + foreach ( $schedules as $num => $name ) {
315 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
316 + $extra = $num == $hours ? 'selected' : '';
317 + ?>
318 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
319 + <?php
320 + }
321 + do_action( 'visualizer_chart_schedules_spl', 'wp', $this->chart->ID, 1 );
322 + ?>
323 + </select>
324 +
325 + <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; ?>">
326 + <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
327 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
328 + </form>
329 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
229 330 </div>
230 331 </div>
231 332 </li>
232 333
@@ -238,74 +339,92 @@
238 339 'chart' => $this->chart->ID,
239 340 ), admin_url( 'admin-ajax.php' )
240 341 );
241 342 ?>
343 + <!-- import from db -->
242 344 <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>">
243 345 <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span
244 346 class="dashicons dashicons-lock"></span></h2>
245 347 <div class="viz-group-content edit-data-content">
246 348 <div>
247 - <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p>
248 - <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole">
249 - <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p>
250 - <select name="refresh" id="vz-db-import-time" class="visualizer-select">
251 - <?php
252 - $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' );
253 - $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
254 - $schedules = apply_filters(
255 - 'visualizer_schedules', array(
256 - '0' => __( 'Live', 'visualizer' ),
257 - '1' => __( 'Each hour', 'visualizer' ),
258 - '12' => __( 'Each 12 hours', 'visualizer' ),
259 - '24' => __( 'Each day', 'visualizer' ),
260 - '72' => __( 'Each 3 days', 'visualizer' ),
261 - )
262 - );
263 - foreach ( $schedules as $num => $name ) {
264 - $extra = $num == $hours ? 'selected' : '';
349 + <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p>
350 + <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole">
351 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p>
352 + <select name="refresh" id="vz-db-import-time" class="visualizer-select">
353 + <?php
354 + $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' );
355 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
356 + $schedules = apply_filters(
357 + 'visualizer_chart_schedules', array(
358 + '-1' => __( 'One-time', 'visualizer' ),
359 + ),
360 + 'db',
361 + $this->chart->ID
362 + );
363 + foreach ( $schedules as $num => $name ) {
364 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
365 + $extra = $num == $hours ? 'selected' : '';
366 + ?>
367 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
368 + <?php
369 + }
370 + do_action( 'visualizer_chart_schedules_spl', 'db', $this->chart->ID, 1 );
265 371 ?>
266 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
267 - <?php
268 - }
269 - ?>
270 - </select>
271 - <input type="hidden" name="params" id="viz-db-wizard-params">
372 + </select>
373 + <input type="hidden" name="params" id="viz-db-wizard-params">
272 374
273 - <input type="button" id="db-chart-button" class="button button-secondary "
274 - value="<?php echo $bttn_label; ?>" data-current="chart"
275 - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
276 - data-t-chart="<?php echo $bttn_label; ?>">
277 - <input type="button" id="db-chart-save-button" class="button button-primary "
278 - value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
375 + <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; ?>">
376 + <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
279 377 <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
280 - </form>
281 - </div>
282 - </div>
378 + </form>
379 + </div>
380 + </div>
283 381 </li>
284 382
285 - <?php
286 - // we will auto-open the manual data feature but only when pro is active and source is empty.
287 - $pro_class = apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' );
288 - ?>
289 - <li class="viz-group <?php echo $pro_class; ?> <?php echo empty( $source_of_chart ) && empty( $pro_class ) ? 'open' : ''; ?> ">
290 - <h2 class="viz-group-title viz-sub-group visualizer-editor-tab"
291 - data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?><span
292 - class="dashicons dashicons-lock"></span></h2>
293 - <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
294 - <input type="hidden" id="chart-data" name="chart_data">
295 - <input type="hidden" id="chart-data-src" name="chart_data_src">
296 - </form>
297 -
383 + <!-- manual -->
384 + <li class="viz-group visualizer_source_manual">
385 + <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?>
386 + <span class="dashicons dashicons-lock"></span>
387 + </h2>
298 388 <div class="viz-group-content edit-data-content">
299 - <div>
300 - <p class="viz-group-description"><?php _e( 'You can manually edit the chart data using the spreadsheet like editor.', 'visualizer' ); ?></p>
301 - <input type="button" id="editor-chart-button" class="button button-primary "
302 - value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
303 - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
304 - data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>">
389 + <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
390 + <input type="hidden" id="chart-data" name="chart_data">
391 + <input type="hidden" id="chart-data-src" name="chart_data_src">
305 392
306 - <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
307 - </div>
393 + <?php if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { ?>
394 + <div>
395 + <p class="viz-group-description viz-editor-selection">
396 + <?php _e( 'Use the', 'visualizer' ); ?>
397 + <select name="editor-type" id="viz-editor-type">
398 + <?php
399 + if ( empty( $editor_type ) ) {
400 + $editor_type = Visualizer_Module::is_pro() ? 'excel' : 'text';
401 + }
402 + foreach ( apply_filters( 'visualizer_editors', array( 'text' => __( 'Text', 'visualizer' ), 'table' => __( 'Simple', 'visualizer' ) ) ) as $e_type => $e_label ) {
403 + ?>
404 + <option value="<?php echo $e_type; ?>" <?php selected( $editor_type, $e_type ); ?> ><?php echo $e_label; ?></option>
405 + <?php } ?>
406 + </select>
407 + <?php _e( 'editor to manually edit the chart data.', 'visualizer' ); ?>
408 + </p>
409 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
410 + <input type="button" id="editor-button" class="button button-primary "
411 + value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart"
412 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
413 + data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>"
414 + >
415 + <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>
416 + </div>
417 + <?php } else { ?>
418 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
419 + <input type="button" id="editor-chart-button" class="button button-primary "
420 + value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
421 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
422 + data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"
423 + >
424 + <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>
425 + <?php } ?>
426 + </form>
308 427 </div>
309 428 </li>
310 429 </ul>
311 430 </li>
@@ -327,11 +446,20 @@
327 446 </form>
328 447 </ul>
329 448 </li>
330 449
450 + <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-docs">
451 + <h2><span class="dashicons dashicons-editor-help"></span><a href="<?php echo VISUALIZER_MAIN_DOC; ?>" target="_blank"><?php _e( 'Docs', 'visualizer' ); ?></a></h2>
452 + </li>
453 +
331 454 <?php $this->getPermissionsLink( $this->chart->ID ); ?>
332 455
333 - <li class="viz-group bottom-fixed" id="vz-chart-copyright">Visualizer &copy; <?php echo date( 'Y', current_time( 'timestamp' ) ); ?></li>
456 + <li class="viz-group bottom-fixed" id="vz-chart-copyright">Visualizer &copy;
457 + <?php
458 + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date, WordPress.DateTime.CurrentTimeTimestamp.Requested
459 + echo date( 'Y', current_time( 'timestamp' ) );
460 + ?>
461 + </li>
334 462 </ul>
335 463 <?php
336 464 // changed by Ash/Upwork
337 465 }
@@ -388,9 +516,9 @@
388 516 Visualizer_Render_Sidebar::_renderGroupStart(
389 517 esc_html__( 'Who can see this chart?', 'visualizer' ) . '<span
390 518 class="dashicons dashicons-lock"></span>',
391 519 '',
392 - apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
520 + 'viz-chart-perm-view ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
393 521 );
394 522 Visualizer_Render_Sidebar::_renderSectionStart();
395 523 Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can view the chart on the front-end.', 'visualizer' ) );
396 524
@@ -432,9 +560,9 @@
432 560 Visualizer_Render_Sidebar::_renderGroupStart(
433 561 esc_html__( 'Who can edit this chart?', 'visualizer' ) . '<span
434 562 class="dashicons dashicons-lock"></span>',
435 563 '',
436 - apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
564 + 'viz-chart-perm-edit ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
437 565 );
438 566 Visualizer_Render_Sidebar::_renderSectionStart();
439 567 Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can edit the chart on the front-end.', 'visualizer' ) );
440 568
@@ -494,9 +622,9 @@
494 622 echo '</div>';
495 623 }
496 624 echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">';
497 625 if ( isset( $this->cancel_button ) ) {
498 - echo '<input type="submit" id="cancel-button" class="button button-secondary button-large push-left" value="', $this->cancel_button, '">';
626 + echo '<input type="submit" id="cancel-button" class="button button-secondary button-large push-right" value="', $this->cancel_button, '">';
499 627 }
500 628 }
501 629
502 630 /**
@@ -509,8 +637,9 @@
509 637 $query = '';
510 638 if ( 'visualizer_source_query' === $source ) {
511 639 $query = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_QUERY, true );
512 640 }
513 - Visualizer_Render_Layout::show( 'db-query', $query );
641 + Visualizer_Render_Layout::show( 'db-query', $query, $this->chart->ID );
642 + Visualizer_Render_Layout::show( 'json-screen', $this->chart->ID );
514 643 }
515 644
516 645 }