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 +191 -101 3.1.33.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
@@ -81,11 +87,17 @@
81 87 // if filter config is present, then its import from wp.
82 88 if ( ! empty( $filter_config ) ) {
83 89 $source_of_chart .= '_wp';
84 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 +
85 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 );
86 98 ?>
87 - <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>
88 100 <iframe id="thehole" name="thehole"></iframe>
89 101 <ul class="viz-group-wrapper full-height">
90 102 <li class="viz-group viz-group-category open" id="vz-chart-source">
91 103 <div class="viz-group-header">
@@ -92,13 +104,14 @@
92 104 <h2 class="viz-group-title viz-main-group"><?php _e( 'Chart Data', 'visualizer' ); ?></h2>
93 105 </div>
94 106 <ul class="viz-group-content">
95 107 <ul class="viz-group-wrapper">
108 + <!-- import from file -->
96 109 <li class="viz-group visualizer_source_csv">
97 110 <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
98 111 <div class="viz-group-content">
99 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>
100 - <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>
101 114 <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
102 115 target="thehole" enctype="multipart/form-data">
103 116 <input type="hidden" id="remote-data" name="remote_data">
104 117 <div class="">
@@ -108,78 +121,113 @@
108 121 value="<?php _e( 'Import', 'visualizer' ); ?>">
109 122 </form>
110 123 </div>
111 124 </li>
112 - <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">
113 127 <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
114 128 <ul class="viz-group-content">
129 + <!-- import from csv url -->
115 130 <li class="viz-subsection">
116 - <span class="viz-section-title"><?php _e( 'One time import', 'visualizer' ); ?></span>
117 -
131 + <span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span>
118 132 <div class="viz-section-items section-items">
119 - <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>
120 - <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>
121 - <p class="viz-group-description"> <?php _e( 'You can also import data from Google Spreadsheet, for more info check <a href="https://docs.themeisle.com/article/607-how-can-i-populate-data-from-google-spreadsheet" 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>
122 135 <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
123 136 target="thehole" enctype="multipart/form-data">
124 137 <div class="remote-file-section">
125 - <input type="url" id="remote-data" name="remote_data"
126 - placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
127 - 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>
128 160
129 - </div>
130 - <input type="button" id="view-remote-file" class="button button-primary"
131 - 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 + ?>
132 169 </form>
133 170 </div>
134 171 </li>
135 - <li class="viz-subsection <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?>">
136 - <span class="viz-section-title visualizer-import-url-schedule"><?php _e( 'Schedule Import', 'visualizer' ); ?>
137 - <span
138 - 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>
139 176 <div class="viz-section-items section-items">
140 - <p class="viz-group-description"><?php _e( 'You can choose here to synchronize your chart data with a remote CSV file.', 'visualizer' ); ?> </p>
141 - <p class="viz-group-description"> <?php _e( 'You can also synchronize with your Google Spreadsheet file, for more info check <a href="https://docs.themeisle.com/article/607-how-can-i-populate-data-from-google-spreadsheet" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
142 - <p class="viz-group-description"> <?php _e( 'We will update the chart data based on your time interval preference by overwriting the current data with the one from the URL.', 'visualizer' ); ?></p>
143 - <form id="vz-schedule-import" action="<?php echo $upload_link; ?>" method="post"
144 - 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">
145 179 <div class="remote-file-section">
146 - <input type="url" id="vz-schedule-url" name="remote_data"
147 - value="<?php echo get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ); ?>"
148 - placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
149 - class="visualizer-input visualizer-remote-url">
150 - <p class="viz-group-description"><?php _e( 'How often do you want to check the url', 'visualizer' ); ?></p>
151 - <select name="vz-import-time" id="vz-import-time"
152 - class="visualizer-select">
153 180 <?php
154 - $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
155 - $schedules = apply_filters(
156 - 'visualizer_chart_schedules', array(
157 - '1' => __( 'Each hour', 'visualizer' ),
158 - '12' => __( 'Each 12 hours', 'visualizer' ),
159 - '24' => __( 'Each day', 'visualizer' ),
160 - '72' => __( 'Each 3 days', 'visualizer' ),
161 - )
162 - );
163 - foreach ( $schedules as $num => $name ) {
164 - $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() ) {
165 183 ?>
166 - <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; ?>">
167 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
168 206 }
169 207 ?>
170 - </select>
171 208 </div>
172 - <input type="button" id="vz-save-schedule" class="button button-primary"
173 - value="<?php _e( 'Save schedule', 'visualizer' ); ?>">
174 209
175 - <?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 + ?>
176 222 </form>
177 223 </div>
178 224 </li>
179 225 </ul>
180 226 </li>
181 - <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' ); ?>">
182 230 <h2 class="viz-group-title viz-sub-group"
183 231 data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
184 232 class="dashicons dashicons-lock"></span></h2>
185 233 <div class="viz-group-content edit-data-content">
@@ -189,9 +237,9 @@
189 237 <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
190 238 <?php
191 239 $fetch_link = add_query_arg(
192 240 array(
193 - 'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '',
241 + 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '',
194 242 'nonce' => wp_create_nonce(),
195 243 ),
196 244 admin_url( 'admin-ajax.php' )
197 245 );
@@ -204,10 +252,23 @@
204 252 $query = new WP_Query( $query_args_charts );
205 253 while ( $query->have_posts() ) {
206 254 $chart = $query->next_post();
207 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 +
208 269 ?>
209 - <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>
210 271 <?php
211 272 }
212 273 ?>
213 274
@@ -229,9 +290,10 @@
229 290 'chart' => $this->chart->ID,
230 291 ), admin_url( 'admin-ajax.php' )
231 292 );
232 293 ?>
233 - <li class="viz-group visualizer_source_query_wp <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?> ">
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' ); ?> ">
234 296 <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
235 297 class="dashicons dashicons-lock"></span></h2>
236 298 <div class="viz-group-content edit-data-content">
237 299 <div>
@@ -242,30 +304,30 @@
242 304 <?php
243 305 $bttn_label = 'visualizer_source_query_wp' === $source_of_chart ? __( 'Modify Filter', 'visualizer' ) : __( 'Create Filter', 'visualizer' );
244 306 $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
245 307 $schedules = apply_filters(
246 - 'visualizer_schedules', array(
247 - '0' => __( 'Live', 'visualizer' ),
248 - '1' => __( 'Each hour', 'visualizer' ),
249 - '12' => __( 'Each 12 hours', 'visualizer' ),
250 - '24' => __( 'Each day', 'visualizer' ),
251 - '72' => __( 'Each 3 days', 'visualizer' ),
252 - )
308 + 'visualizer_chart_schedules', array(
309 + '-1' => __( 'One-time', 'visualizer' ),
310 + ),
311 + 'wp',
312 + $this->chart->ID
253 313 );
254 314 foreach ( $schedules as $num => $name ) {
315 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
255 316 $extra = $num == $hours ? 'selected' : '';
256 317 ?>
257 318 <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
258 319 <?php
259 320 }
321 + do_action( 'visualizer_chart_schedules_spl', 'wp', $this->chart->ID, 1 );
260 322 ?>
261 323 </select>
262 324
263 - <input type="button" id="filter-chart-button" class="button button-secondary" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
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; ?>">
264 326 <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
265 327 <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
266 328 </form>
267 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
329 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
268 330 </div>
269 331 </div>
270 332 </li>
271 333
@@ -277,8 +339,9 @@
277 339 'chart' => $this->chart->ID,
278 340 ), admin_url( 'admin-ajax.php' )
279 341 );
280 342 ?>
343 + <!-- import from db -->
281 344 <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>">
282 345 <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span
283 346 class="dashicons dashicons-lock"></span></h2>
284 347 <div class="viz-group-content edit-data-content">
@@ -290,27 +353,27 @@
290 353 <?php
291 354 $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' );
292 355 $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
293 356 $schedules = apply_filters(
294 - 'visualizer_schedules', array(
295 - '0' => __( 'Live', 'visualizer' ),
296 - '1' => __( 'Each hour', 'visualizer' ),
297 - '12' => __( 'Each 12 hours', 'visualizer' ),
298 - '24' => __( 'Each day', 'visualizer' ),
299 - '72' => __( 'Each 3 days', 'visualizer' ),
300 - )
357 + 'visualizer_chart_schedules', array(
358 + '-1' => __( 'One-time', 'visualizer' ),
359 + ),
360 + 'db',
361 + $this->chart->ID
301 362 );
302 363 foreach ( $schedules as $num => $name ) {
364 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
303 365 $extra = $num == $hours ? 'selected' : '';
304 366 ?>
305 367 <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
306 368 <?php
307 369 }
370 + do_action( 'visualizer_chart_schedules_spl', 'db', $this->chart->ID, 1 );
308 371 ?>
309 372 </select>
310 373 <input type="hidden" name="params" id="viz-db-wizard-params">
311 374
312 - <input type="button" id="db-chart-button" class="button button-secondary" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
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; ?>">
313 376 <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
314 377 <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
315 378 </form>
316 379 </div>
@@ -316,31 +379,52 @@
316 379 </div>
317 380 </div>
318 381 </li>
319 382
320 - <?php
321 - // we will auto-open the manual data feature but only when pro is active and source is empty.
322 - $pro_class = apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' );
323 - ?>
324 - <li class="viz-group <?php echo $pro_class; ?> <?php echo empty( $source_of_chart ) && empty( $pro_class ) ? 'open' : ''; ?> ">
325 - <h2 class="viz-group-title viz-sub-group visualizer-editor-tab"
326 - data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?><span
327 - class="dashicons dashicons-lock"></span></h2>
328 - <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
329 - <input type="hidden" id="chart-data" name="chart_data">
330 - <input type="hidden" id="chart-data-src" name="chart_data_src">
331 - </form>
332 -
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>
333 388 <div class="viz-group-content edit-data-content">
334 - <div>
335 - <p class="viz-group-description"><?php _e( 'You can manually edit the chart data using the spreadsheet like editor.', 'visualizer' ); ?></p>
336 - <input type="button" id="editor-chart-button" class="button button-primary "
337 - value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
338 - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
339 - 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">
340 392
341 - <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
342 - </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>
343 427 </div>
344 428 </li>
345 429 </ul>
346 430 </li>
@@ -363,14 +447,19 @@
363 447 </ul>
364 448 </li>
365 449
366 450 <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-docs">
367 - <h2><span class="dashicons dashicons-editor-help"></span><a href="https://docs.themeisle.com/category/657-visualizer" target="_blank"><?php _e( 'Docs', 'visualizer' ); ?></a></h2>
451 + <h2><span class="dashicons dashicons-editor-help"></span><a href="<?php echo VISUALIZER_MAIN_DOC; ?>" target="_blank"><?php _e( 'Docs', 'visualizer' ); ?></a></h2>
368 452 </li>
369 453
370 454 <?php $this->getPermissionsLink( $this->chart->ID ); ?>
371 455
372 - <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>
373 462 </ul>
374 463 <?php
375 464 // changed by Ash/Upwork
376 465 }
@@ -427,9 +516,9 @@
427 516 Visualizer_Render_Sidebar::_renderGroupStart(
428 517 esc_html__( 'Who can see this chart?', 'visualizer' ) . '<span
429 518 class="dashicons dashicons-lock"></span>',
430 519 '',
431 - 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' )
432 521 );
433 522 Visualizer_Render_Sidebar::_renderSectionStart();
434 523 Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can view the chart on the front-end.', 'visualizer' ) );
435 524
@@ -471,9 +560,9 @@
471 560 Visualizer_Render_Sidebar::_renderGroupStart(
472 561 esc_html__( 'Who can edit this chart?', 'visualizer' ) . '<span
473 562 class="dashicons dashicons-lock"></span>',
474 563 '',
475 - 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' )
476 565 );
477 566 Visualizer_Render_Sidebar::_renderSectionStart();
478 567 Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can edit the chart on the front-end.', 'visualizer' ) );
479 568
@@ -533,9 +622,9 @@
533 622 echo '</div>';
534 623 }
535 624 echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">';
536 625 if ( isset( $this->cancel_button ) ) {
537 - 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, '">';
538 627 }
539 628 }
540 629
541 630 /**
@@ -548,8 +637,9 @@
548 637 $query = '';
549 638 if ( 'visualizer_source_query' === $source ) {
550 639 $query = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_QUERY, true );
551 640 }
552 - 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 );
553 643 }
554 644
555 645 }