PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.3.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.3.4
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/Page/Data.php +250 -43 3.0.93.3.4 View file →
@@ -37,19 +37,29 @@
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::is_pro() ) {
42 + do_action( 'visualizer_add_editor_etc', $this->chart->ID );
43 +
44 + if ( Visualizer_Module::is_pro() && Visualizer_Module::is_pro_older_than( '1.9.0' ) ) {
45 + global $Visualizer_Pro;
46 + $Visualizer_Pro->_addEditor( $this->chart->ID );
47 + if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) {
48 + $Visualizer_Pro->_addFilterWizard( $this->chart->ID );
49 + }
46 50 }
51 + } else {
52 + Visualizer_Render_Layout::show( 'simple-editor-screen', $this->chart->ID );
47 53 }
54 +
55 + $this->add_additional_content();
56 +
48 57 // Added by Ash/Upwork
49 58 echo '<div id="canvas">';
50 59 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
51 60 echo '</div>';
61 + echo $this->custom_css;
52 62 }
53 63
54 64 /**
55 65 * Renders sidebar content.
@@ -63,12 +73,24 @@
63 73 array(
64 74 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
65 75 'nonce' => wp_create_nonce(),
66 76 'chart' => $this->chart->ID,
67 - ), admin_url( 'admin-ajax.php' )
77 + ),
78 + admin_url( 'admin-ajax.php' )
68 79 );
80 +
81 + // this will allow us to open the correct source tab by default.
82 + $source_of_chart = strtolower( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SOURCE, true ) );
83 + // both import from wp and import from db have the same source so we need to differentiate.
84 + $filter_config = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_FILTER_CONFIG, true );
85 + // if filter config is present, then its import from wp.
86 + if ( ! empty( $filter_config ) ) {
87 + $source_of_chart .= '_wp';
88 + }
89 + $type = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
90 + $lib = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_LIBRARY, true );
69 91 ?>
70 - <span id="visualizer-chart-id" data-id="<?php echo $this->chart->ID; ?>"></span>
92 + <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>
71 93 <iframe id="thehole" name="thehole"></iframe>
72 94 <ul class="viz-group-wrapper full-height">
73 95 <li class="viz-group viz-group-category open" id="vz-chart-source">
74 96 <div class="viz-group-header">
@@ -75,13 +97,13 @@
75 97 <h2 class="viz-group-title viz-main-group"><?php _e( 'Chart Data', 'visualizer' ); ?></h2>
76 98 </div>
77 99 <ul class="viz-group-content">
78 100 <ul class="viz-group-wrapper">
79 - <li class="viz-group">
101 + <li class="viz-group visualizer_source_csv">
80 102 <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
81 103 <div class="viz-group-content">
82 104 <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>
83 - <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>
105 + <p class="viz-group-description"><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>
84 106 <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
85 107 target="thehole" enctype="multipart/form-data">
86 108 <input type="hidden" id="remote-data" name="remote_data">
87 109 <div class="">
@@ -91,9 +113,9 @@
91 113 value="<?php _e( 'Import', 'visualizer' ); ?>">
92 114 </form>
93 115 </div>
94 116 </li>
95 - <li class="viz-group visualizer-import-url">
117 + <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json">
96 118 <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
97 119 <ul class="viz-group-content">
98 120 <li class="viz-subsection">
99 121 <span class="viz-section-title"><?php _e( 'One time import', 'visualizer' ); ?></span>
@@ -99,10 +121,10 @@
99 121 <span class="viz-section-title"><?php _e( 'One time import', 'visualizer' ); ?></span>
100 122
101 123 <div class="viz-section-items section-items">
102 124 <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>
103 - <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>
104 - <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>
125 + <p class="viz-group-description"><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 have 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>
126 + <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>
105 127 <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
106 128 target="thehole" enctype="multipart/form-data">
107 129 <div class="remote-file-section">
108 130 <input type="url" id="remote-data" name="remote_data"
@@ -120,15 +142,15 @@
120 142 <span
121 143 class="dashicons dashicons-lock"></span></span>
122 144 <div class="viz-section-items section-items">
123 145 <p class="viz-group-description"><?php _e( 'You can choose here to synchronize your chart data with a remote CSV file.', 'visualizer' ); ?> </p>
124 - <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>
125 - <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>
146 + <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>
147 + <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>
126 148 <form id="vz-schedule-import" action="<?php echo $upload_link; ?>" method="post"
127 149 target="thehole" enctype="multipart/form-data">
128 150 <div class="remote-file-section">
129 151 <input type="url" id="vz-schedule-url" name="remote_data"
130 - value="<?php echo get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ); ?>"
152 + value="<?php echo esc_url( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ) ); ?>"
131 153 placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
132 154 class="visualizer-input visualizer-remote-url">
133 155 <p class="viz-group-description"><?php _e( 'How often do you want to check the url', 'visualizer' ); ?></p>
134 156 <select name="vz-import-time" id="vz-import-time"
@@ -134,15 +156,20 @@
134 156 <select name="vz-import-time" id="vz-import-time"
135 157 class="visualizer-select">
136 158 <?php
137 159 $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
138 - $schedules = array(
139 - '1' => __( 'Each hour', 'visualizer' ),
140 - '12' => __( 'Each 12 hours', 'visualizer' ),
141 - '24' => __( 'Each day', 'visualizer' ),
142 - '36' => __( 'Each 3 days', 'visualizer' ),
160 + $schedules = apply_filters(
161 + 'visualizer_chart_schedules', array(
162 + '1' => __( 'Each hour', 'visualizer' ),
163 + '12' => __( 'Each 12 hours', 'visualizer' ),
164 + '24' => __( 'Each day', 'visualizer' ),
165 + '72' => __( 'Each 3 days', 'visualizer' ),
166 + ),
167 + 'csv',
168 + $this->chart->ID
143 169 );
144 170 foreach ( $schedules as $num => $name ) {
171 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
145 172 $extra = $num == $hours ? 'selected' : '';
146 173 ?>
147 174 <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
148 175 <?php
@@ -156,11 +183,63 @@
156 183 <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
157 184 </form>
158 185 </div>
159 186 </li>
187 +
188 + <li class="viz-subsection">
189 + <span class="viz-section-title visualizer_source_json"><?php _e( 'Import from JSON', 'visualizer' ); ?>
190 + <span class="dashicons dashicons-lock"></span></span>
191 + <div class="viz-section-items section-items">
192 + <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>
193 + <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
194 + <div class="remote-file-section">
195 + <?php
196 + $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
197 + if ( Visualizer_Module::is_pro() ) {
198 + ?>
199 + <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
200 + <select name="vz-json-time" id="vz-json-time" class="visualizer-select" data-chart="<?php echo $this->chart->ID; ?>">
201 + <?php
202 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
203 + $schedules = apply_filters(
204 + 'visualizer_chart_schedules', array(
205 + '-1' => __( 'One-time', 'visualizer' ),
206 + ),
207 + 'json',
208 + $this->chart->ID
209 + );
210 + foreach ( $schedules as $num => $name ) {
211 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
212 + $extra = $num == $hours ? 'selected' : '';
213 + ?>
214 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
215 + <?php
216 + }
217 + ?>
218 + </select>
219 + <?php
220 + }
221 + ?>
222 + </div>
223 +
224 + <input type="button" id="json-chart-button" class="button button-secondary show-chart-toggle"
225 + value="<?php echo $bttn_label; ?>" data-current="chart"
226 + data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
227 + data-t-chart="<?php echo $bttn_label; ?>">
228 + <?php
229 + if ( Visualizer_Module::is_pro() ) {
230 + ?>
231 + <input type="button" id="json-chart-save-button" class="button button-primary "
232 + value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
233 + <?php
234 + }
235 + ?>
236 + </form>
237 + </div>
238 + </li>
160 239 </ul>
161 240 </li>
162 - <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
241 + <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
163 242 <h2 class="viz-group-title viz-sub-group"
164 243 data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
165 244 class="dashicons dashicons-lock"></span></h2>
166 245 <div class="viz-group-content edit-data-content">
@@ -170,11 +249,12 @@
170 249 <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
171 250 <?php
172 251 $fetch_link = add_query_arg(
173 252 array(
174 - 'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '',
253 + 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '',
175 254 'nonce' => wp_create_nonce(),
176 - ), admin_url( 'admin-ajax.php' )
255 + ),
256 + admin_url( 'admin-ajax.php' )
177 257 );
178 258 $query_args_charts = array(
179 259 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
180 260 'posts_per_page' => 300,
@@ -184,10 +264,23 @@
184 264 $query = new WP_Query( $query_args_charts );
185 265 while ( $query->have_posts() ) {
186 266 $chart = $query->next_post();
187 267 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
268 +
269 + $title = '#' . $chart->ID;
270 + if ( ! empty( $settings['title'] ) ) {
271 + $title = $settings['title'];
272 + }
273 + // for ChartJS, title is an array.
274 + if ( is_array( $title ) && isset( $title['text'] ) ) {
275 + $title = $title['text'];
276 + }
277 + if ( empty( $title ) ) {
278 + $title = '#' . $chart->ID;
279 + }
280 +
188 281 ?>
189 - <option value="<?php echo $chart->ID; ?>"><?php echo empty( $settings['title'] ) ? '#' . $chart->ID : $settings['title']; ?></option>
282 + <option value="<?php echo $chart->ID; ?>"><?php echo $title; ?></option>
190 283 <?php
191 284 }
192 285 ?>
193 286
@@ -200,18 +293,52 @@
200 293 </div>
201 294 </div>
202 295 </li>
203 296
204 - <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?> ">
297 + <?php
298 + $save_filter = add_query_arg(
299 + array(
300 + 'action' => Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY,
301 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY . Visualizer_Plugin::VERSION ),
302 + 'chart' => $this->chart->ID,
303 + ), admin_url( 'admin-ajax.php' )
304 + );
305 + ?>
306 + <li class="viz-group visualizer_source_query_wp <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?> ">
205 307 <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
206 308 class="dashicons dashicons-lock"></span></h2>
207 309 <div class="viz-group-content edit-data-content">
208 310 <div>
209 - <p class="viz-group-description"><?php _e( 'You can import here data from WordPress', 'visualizer' ); ?></p>
210 - <input type="button" id="filter-chart-button" class="button button-primary "
211 - value="<?php _e( 'Create Filters', 'visualizer' ); ?>" data-current="chart"
212 - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
213 - data-t-chart="<?php _e( 'Create Filters', 'visualizer' ); ?>">
311 + <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p>
312 + <form id="vz-filter-wizard" action="<?php echo $save_filter; ?>" method="post" target="thehole">
313 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from WordPress.', 'visualizer' ); ?></p>
314 + <select name="refresh" id="vz-filter-import-time" class="visualizer-select">
315 + <?php
316 + $bttn_label = 'visualizer_source_query_wp' === $source_of_chart ? __( 'Modify Filter', 'visualizer' ) : __( 'Create Filter', 'visualizer' );
317 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
318 + $schedules = apply_filters(
319 + 'visualizer_schedules', array(
320 + '0' => __( 'Live', 'visualizer' ),
321 + '1' => __( 'Each hour', 'visualizer' ),
322 + '12' => __( 'Each 12 hours', 'visualizer' ),
323 + '24' => __( 'Each day', 'visualizer' ),
324 + '72' => __( 'Each 3 days', 'visualizer' ),
325 + )
326 + );
327 + foreach ( $schedules as $num => $name ) {
328 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
329 + $extra = $num == $hours ? 'selected' : '';
330 + ?>
331 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
332 + <?php
333 + }
334 + ?>
335 + </select>
336 +
337 + <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; ?>">
338 + <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
339 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
340 + </form>
214 341 <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
215 342 </div>
216 343 </div>
217 344 </li>
@@ -216,12 +343,60 @@
216 343 </div>
217 344 </li>
218 345
219 346 <?php
220 - // we will auto-open the manual data feature but only when pro is active.
221 - $pro_class = apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' );
347 + $save_query = add_query_arg(
348 + array(
349 + 'action' => Visualizer_Plugin::ACTION_SAVE_DB_QUERY,
350 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_DB_QUERY . Visualizer_Plugin::VERSION ),
351 + 'chart' => $this->chart->ID,
352 + ), admin_url( 'admin-ajax.php' )
353 + );
222 354 ?>
223 - <li class="viz-group <?php echo $pro_class; ?> <?php echo empty( $pro_class ) ? 'open' : ''; ?> ">
355 + <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>">
356 + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span
357 + class="dashicons dashicons-lock"></span></h2>
358 + <div class="viz-group-content edit-data-content">
359 + <div>
360 + <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p>
361 + <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole">
362 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p>
363 + <select name="refresh" id="vz-db-import-time" class="visualizer-select">
364 + <?php
365 + $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' );
366 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
367 + $schedules = apply_filters(
368 + 'visualizer_schedules', array(
369 + '0' => __( 'Live', 'visualizer' ),
370 + '1' => __( 'Each hour', 'visualizer' ),
371 + '12' => __( 'Each 12 hours', 'visualizer' ),
372 + '24' => __( 'Each day', 'visualizer' ),
373 + '72' => __( 'Each 3 days', 'visualizer' ),
374 + )
375 + );
376 + foreach ( $schedules as $num => $name ) {
377 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
378 + $extra = $num == $hours ? 'selected' : '';
379 + ?>
380 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
381 + <?php
382 + }
383 + ?>
384 + </select>
385 + <input type="hidden" name="params" id="viz-db-wizard-params">
386 +
387 + <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; ?>">
388 + <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
389 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
390 + </form>
391 + </div>
392 + </div>
393 + </li>
394 +
395 + <?php
396 + // we will auto-open the manual data feature only when source is empty.
397 + ?>
398 + <li class="viz-group <?php echo empty( $source_of_chart ) ? 'open' : ''; ?> ">
224 399 <h2 class="viz-group-title viz-sub-group visualizer-editor-tab"
225 400 data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?><span
226 401 class="dashicons dashicons-lock"></span></h2>
227 402 <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
@@ -230,15 +405,18 @@
230 405 </form>
231 406
232 407 <div class="viz-group-content edit-data-content">
233 408 <div>
234 - <p class="viz-group-description"><?php _e( 'You can manually edit the chart data using the spreadsheet like editor.', 'visualizer' ); ?></p>
409 + <p class="viz-group-description"><?php echo sprintf( __( 'You can manually edit the chart data using the %s editor.', 'visualizer' ), Visualizer_Module::is_pro() ? 'spreadsheet like' : 'simple' ); ?></p>
410 + <?php if ( ! Visualizer_Module::is_pro() ) { ?>
411 + <p class="viz-group-description simple-editor-type"><input type="checkbox" id="simple-editor-type" value="textarea"><label for="simple-editor-type"><?php _e( 'Use text area editor instead', 'visualizer' ); ?></label></p>
412 + <?php } ?>
235 413 <input type="button" id="editor-chart-button" class="button button-primary "
236 414 value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
237 415 data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
238 416 data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>">
239 417
240 - <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
418 + <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>
241 419 </div>
242 420 </div>
243 421 </li>
244 422 </ul>
@@ -261,11 +439,20 @@
261 439 </form>
262 440 </ul>
263 441 </li>
264 442
443 + <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-docs">
444 + <h2><span class="dashicons dashicons-editor-help"></span><a href="<?php echo VISUALIZER_MAIN_DOC; ?>" target="_blank"><?php _e( 'Docs', 'visualizer' ); ?></a></h2>
445 + </li>
446 +
265 447 <?php $this->getPermissionsLink( $this->chart->ID ); ?>
266 448
267 - <li class="viz-group bottom-fixed" id="vz-chart-copyright">Visualizer &copy; <?php echo date( 'Y', current_time( 'timestamp' ) ); ?></li>
449 + <li class="viz-group bottom-fixed" id="vz-chart-copyright">Visualizer &copy;
450 + <?php
451 + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date, WordPress.DateTime.CurrentTimeTimestamp.Requested
452 + echo date( 'Y', current_time( 'timestamp' ) );
453 + ?>
454 + </li>
268 455 </ul>
269 456 <?php
270 457 // changed by Ash/Upwork
271 458 }
@@ -282,9 +469,9 @@
282 469 foreach ( $permissions as $k => $v ) {
283 470 $this->$k = $v;
284 471 }
285 472 }
286 -?>
473 + ?>
287 474 <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-permissions">
288 475 <h2><span class="dashicons dashicons-admin-users"></span><?php _e( 'Permissions', 'visualizer' ); ?></h2>
289 476 <div class="viz-group-header">
290 477 <button class="customize-section-back" tabindex="0"></button>
@@ -296,17 +483,18 @@
296 483 echo add_query_arg(
297 484 array(
298 485 'nonce' => wp_create_nonce(),
299 486 'tab' => 'permissions',
300 - ), remove_query_arg( 'tab', $_SERVER['REQUEST_URI'] )
487 + ),
488 + remove_query_arg( 'tab', $_SERVER['REQUEST_URI'] )
301 489 );
302 -?>
490 + ?>
303 491 " method="post">
304 492 <?php $this->permissionsSidebar(); ?>
305 493 </form>
306 494 </ul>
307 495 </li>
308 -<?php
496 + <?php
309 497 }
310 498
311 499 /**
312 500 * Generates the permissions form.
@@ -319,9 +507,11 @@
319 507 return;
320 508 }
321 509 Visualizer_Render_Sidebar::_renderGroupStart(
322 510 esc_html__( 'Who can see this chart?', 'visualizer' ) . '<span
323 - class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
511 + class="dashicons dashicons-lock"></span>',
512 + '',
513 + 'viz-chart-perm-view ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
324 514 );
325 515 Visualizer_Render_Sidebar::_renderSectionStart();
326 516 Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can view the chart on the front-end.', 'visualizer' ) );
327 517
@@ -361,9 +551,11 @@
361 551 Visualizer_Render_Sidebar::_renderGroupEnd();
362 552
363 553 Visualizer_Render_Sidebar::_renderGroupStart(
364 554 esc_html__( 'Who can edit this chart?', 'visualizer' ) . '<span
365 - class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
555 + class="dashicons dashicons-lock"></span>',
556 + '',
557 + 'viz-chart-perm-edit ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
366 558 );
367 559 Visualizer_Render_Sidebar::_renderSectionStart();
368 560 Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can edit the chart on the front-end.', 'visualizer' ) );
369 561
@@ -423,9 +615,24 @@
423 615 echo '</div>';
424 616 }
425 617 echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">';
426 618 if ( isset( $this->cancel_button ) ) {
427 - echo '<input type="submit" id="cancel-button" class="button button-secondary button-large push-right" value="', $this->cancel_button, '">';
619 + echo '<input type="submit" id="cancel-button" class="button button-secondary button-large push-left" value="', $this->cancel_button, '">';
428 620 }
621 + }
622 +
623 + /**
624 + * Renders the additional content.
625 + *
626 + * @access private
627 + */
628 + private function add_additional_content() {
629 + $source = strtolower( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SOURCE, true ) );
630 + $query = '';
631 + if ( 'visualizer_source_query' === $source ) {
632 + $query = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_QUERY, true );
633 + }
634 + Visualizer_Render_Layout::show( 'db-query', $query );
635 + Visualizer_Render_Layout::show( 'json-screen', $this->chart->ID );
429 636 }
430 637
431 638 }