PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.2.0
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 +508 -52 4.0.33.2.0 View file →
@@ -37,37 +37,24 @@
37 37 * @access protected
38 38 */
39 39 protected function _renderContent() {
40 40 // Added by Ash/Upwork
41 - if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) {
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 );
46 + }
47 + } else {
42 48 Visualizer_Render_Layout::show( 'simple-editor-screen', $this->chart->ID );
43 49 }
44 50
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 - }
54 - }
55 - }
56 -
57 51 $this->add_additional_content();
58 52
59 53 // Added by Ash/Upwork
60 - if ( Visualizer_Module::is_pro() ) {
61 - echo '<div id="chart_wrapper_canvas">';
62 - echo '<div id="control_wrapper_canvas"></div>';
63 - }
64 54 echo '<div id="canvas">';
65 55 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
66 56 echo '</div>';
67 - if ( Visualizer_Module::is_pro() ) {
68 - echo '</div>';
69 - }
70 57 echo $this->custom_css;
71 58 }
72 59
73 60 /**
@@ -77,48 +64,516 @@
77 64 *
78 65 * @access protected
79 66 */
80 67 protected function _renderSidebarContent() {
68 + $upload_link = add_query_arg(
69 + array(
70 + 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
71 + 'nonce' => wp_create_nonce(),
72 + 'chart' => $this->chart->ID,
73 + ),
74 + admin_url( 'admin-ajax.php' )
75 + );
81 76
82 - $chartSettings = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
83 - $hasTitle = isset( $chartSettings['backend-title'] ) && '' !== $chartSettings['backend-title'];
77 + // this will allow us to open the correct source tab by default.
78 + $source_of_chart = strtolower( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SOURCE, true ) );
79 + // both import from wp and import from db have the same source so we need to differentiate.
80 + $filter_config = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_FILTER_CONFIG, true );
81 + // if filter config is present, then its import from wp.
82 + if ( ! empty( $filter_config ) ) {
83 + $source_of_chart .= '_wp';
84 + }
85 + $type = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
86 + ?>
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>
88 + <iframe id="thehole" name="thehole"></iframe>
89 + <ul class="viz-group-wrapper full-height">
90 + <li class="viz-group viz-group-category open" id="vz-chart-source">
91 + <div class="viz-group-header">
92 + <h2 class="viz-group-title viz-main-group"><?php _e( 'Chart Data', 'visualizer' ); ?></h2>
93 + </div>
94 + <ul class="viz-group-content">
95 + <ul class="viz-group-wrapper">
96 + <li class="viz-group visualizer_source_csv">
97 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
98 + <div class="viz-group-content">
99 + <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>
101 + <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
102 + target="thehole" enctype="multipart/form-data">
103 + <input type="hidden" id="remote-data" name="remote_data">
104 + <div class="">
105 + <input type="file" id="csv-file" name="local_data">
106 + </div>
107 + <input type="button" class="button button-primary" id="vz-import-file"
108 + value="<?php _e( 'Import', 'visualizer' ); ?>">
109 + </form>
110 + </div>
111 + </li>
112 + <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json">
113 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
114 + <ul class="viz-group-content">
115 + <li class="viz-subsection">
116 + <span class="viz-section-title"><?php _e( 'One time import', 'visualizer' ); ?></span>
84 117
85 - ?>
86 - <div class="viz-info-panel">
87 - <div class="viz-info-item">
88 - <label for="viz-shortcode"><?php _e( 'Shortcode', 'visualizer' ); ?></label>
89 - <div class="viz-info-row">
90 - <input type="text" id="viz-shortcode" value="[visualizer id=&quot;<?php echo $this->chart->ID; ?>&quot; class='']" readonly>
91 - <button class="button" id="viz-copy-shortcode"><?php _e( 'Copy', 'visualizer' ); ?></button>
118 + <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>
122 + <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
123 + target="thehole" enctype="multipart/form-data">
124 + <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">
128 +
129 + </div>
130 + <input type="button" id="view-remote-file" class="button button-primary"
131 + value="<?php _e( 'Import', 'visualizer' ); ?>">
132 + </form>
133 + </div>
134 + </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>
139 + <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">
145 + <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 + <?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 + 'csv',
163 + $this->chart->ID
164 + );
165 + foreach ( $schedules as $num => $name ) {
166 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
167 + $extra = $num == $hours ? 'selected' : '';
168 + ?>
169 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
170 + <?php
171 + }
172 + ?>
173 + </select>
174 + </div>
175 + <input type="button" id="vz-save-schedule" class="button button-primary"
176 + value="<?php _e( 'Save schedule', 'visualizer' ); ?>">
177 +
178 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
179 + </form>
180 + </div>
181 + </li>
182 +
183 + <li class="viz-subsection">
184 + <span class="viz-section-title visualizer_source_json"><?php _e( 'Import from JSON/REST', 'visualizer' ); ?>
185 + <span class="dashicons dashicons-lock"></span></span>
186 + <div class="viz-section-items section-items">
187 + <p class="viz-group-description"><?php _e( 'You can choose here to import/synchronize your chart data with a remote JSON/REST 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>
188 + <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
189 + <div class="remote-file-section">
190 + <?php
191 + $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
192 + if ( VISUALIZER_PRO ) {
193 + ?>
194 + <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
195 + <select name="vz-json-time" id="vz-json-time" class="visualizer-select" data-chart="<?php echo $this->chart->ID; ?>">
196 + <?php
197 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
198 + $schedules = apply_filters(
199 + 'visualizer_chart_schedules', array(
200 + '-1' => __( 'One-time', 'visualizer' ),
201 + ),
202 + 'json',
203 + $this->chart->ID
204 + );
205 + foreach ( $schedules as $num => $name ) {
206 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
207 + $extra = $num == $hours ? 'selected' : '';
208 + ?>
209 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
210 + <?php
211 + }
212 + ?>
213 + </select>
214 + <?php
215 + }
216 + ?>
217 + </div>
218 +
219 + <input type="button" id="json-chart-button" class="button button-secondary "
220 + value="<?php echo $bttn_label; ?>" data-current="chart"
221 + data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
222 + data-t-chart="<?php echo $bttn_label; ?>">
223 + <?php
224 + if ( VISUALIZER_PRO ) {
225 + ?>
226 + <input type="button" id="json-chart-save-button" class="button button-primary "
227 + value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
228 + <?php
229 + }
230 + ?>
231 + </form>
232 + </div>
233 + </li>
234 + </ul>
235 + </li>
236 + <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
237 + <h2 class="viz-group-title viz-sub-group"
238 + data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
239 + class="dashicons dashicons-lock"></span></h2>
240 + <div class="viz-group-content edit-data-content">
241 + <div>
242 + <p class="viz-group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p>
243 + <form>
244 + <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
245 + <?php
246 + $fetch_link = add_query_arg(
247 + array(
248 + 'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '',
249 + 'nonce' => wp_create_nonce(),
250 + ),
251 + admin_url( 'admin-ajax.php' )
252 + );
253 + $query_args_charts = array(
254 + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
255 + 'posts_per_page' => 300,
256 + 'no_found_rows' => true,
257 + );
258 + $charts = array();
259 + $query = new WP_Query( $query_args_charts );
260 + while ( $query->have_posts() ) {
261 + $chart = $query->next_post();
262 + $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
263 + ?>
264 + <option value="<?php echo $chart->ID; ?>"><?php echo empty( $settings['title'] ) ? '#' . $chart->ID : $settings['title']; ?></option>
265 + <?php
266 + }
267 + ?>
268 +
269 + </select>
270 + </form>
271 + <input type="button" id="existing-chart" class="button button-primary"
272 + value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
273 + data-viz-link="<?php echo $fetch_link; ?>">
274 + <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
275 + </div>
276 + </div>
277 + </li>
278 +
279 + <?php
280 + $save_filter = add_query_arg(
281 + array(
282 + 'action' => Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY,
283 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY . Visualizer_Plugin::VERSION ),
284 + 'chart' => $this->chart->ID,
285 + ), admin_url( 'admin-ajax.php' )
286 + );
287 + ?>
288 + <li class="viz-group visualizer_source_query_wp <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?> ">
289 + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
290 + class="dashicons dashicons-lock"></span></h2>
291 + <div class="viz-group-content edit-data-content">
292 + <div>
293 + <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p>
294 + <form id="vz-filter-wizard" action="<?php echo $save_filter; ?>" method="post" target="thehole">
295 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from WordPress.', 'visualizer' ); ?></p>
296 + <select name="refresh" id="vz-filter-import-time" class="visualizer-select">
297 + <?php
298 + $bttn_label = 'visualizer_source_query_wp' === $source_of_chart ? __( 'Modify Filter', 'visualizer' ) : __( 'Create Filter', 'visualizer' );
299 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
300 + $schedules = apply_filters(
301 + 'visualizer_schedules', array(
302 + '0' => __( 'Live', 'visualizer' ),
303 + '1' => __( 'Each hour', 'visualizer' ),
304 + '12' => __( 'Each 12 hours', 'visualizer' ),
305 + '24' => __( 'Each day', 'visualizer' ),
306 + '72' => __( 'Each 3 days', 'visualizer' ),
307 + )
308 + );
309 + foreach ( $schedules as $num => $name ) {
310 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
311 + $extra = $num == $hours ? 'selected' : '';
312 + ?>
313 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
314 + <?php
315 + }
316 + ?>
317 + </select>
318 +
319 + <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; ?>">
320 + <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
321 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
322 + </form>
323 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
324 + </div>
325 + </div>
326 + </li>
327 +
328 + <?php
329 + $save_query = add_query_arg(
330 + array(
331 + 'action' => Visualizer_Plugin::ACTION_SAVE_DB_QUERY,
332 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_DB_QUERY . Visualizer_Plugin::VERSION ),
333 + 'chart' => $this->chart->ID,
334 + ), admin_url( 'admin-ajax.php' )
335 + );
336 + ?>
337 + <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>">
338 + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span
339 + class="dashicons dashicons-lock"></span></h2>
340 + <div class="viz-group-content edit-data-content">
341 + <div>
342 + <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p>
343 + <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole">
344 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p>
345 + <select name="refresh" id="vz-db-import-time" class="visualizer-select">
346 + <?php
347 + $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' );
348 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
349 + $schedules = apply_filters(
350 + 'visualizer_schedules', array(
351 + '0' => __( 'Live', 'visualizer' ),
352 + '1' => __( 'Each hour', 'visualizer' ),
353 + '12' => __( 'Each 12 hours', 'visualizer' ),
354 + '24' => __( 'Each day', 'visualizer' ),
355 + '72' => __( 'Each 3 days', 'visualizer' ),
356 + )
357 + );
358 + foreach ( $schedules as $num => $name ) {
359 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
360 + $extra = $num == $hours ? 'selected' : '';
361 + ?>
362 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
363 + <?php
364 + }
365 + ?>
366 + </select>
367 + <input type="hidden" name="params" id="viz-db-wizard-params">
368 +
369 + <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; ?>">
370 + <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
371 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
372 + </form>
373 + </div>
374 + </div>
375 + </li>
376 +
377 + <?php
378 + // we will auto-open the manual data feature only when source is empty.
379 + ?>
380 + <li class="viz-group <?php echo empty( $source_of_chart ) ? 'open' : ''; ?> ">
381 + <h2 class="viz-group-title viz-sub-group visualizer-editor-tab"
382 + data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?><span
383 + class="dashicons dashicons-lock"></span></h2>
384 + <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
385 + <input type="hidden" id="chart-data" name="chart_data">
386 + <input type="hidden" id="chart-data-src" name="chart_data_src">
387 + </form>
388 +
389 + <div class="viz-group-content edit-data-content">
390 + <div>
391 + <p class="viz-group-description"><?php echo sprintf( __( 'You can manually edit the chart data using the %s editor.', 'visualizer' ), VISUALIZER_PRO ? 'spreadsheet like' : 'simple' ); ?></p>
392 + <?php if ( ! VISUALIZER_PRO ) { ?>
393 + <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>
394 + <?php } ?>
395 + <input type="button" id="editor-chart-button" class="button button-primary "
396 + value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
397 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
398 + data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>">
399 + </div>
400 + </div>
401 + </li>
402 + </ul>
403 + </li>
404 + </ul>
405 + <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-settings">
406 + <h2><span class="dashicons dashicons-admin-tools"></span><?php _e( 'Advanced', 'visualizer' ); ?></h2>
407 + <div class="viz-group-header">
408 + <button class="customize-section-back" tabindex="0"></button>
409 + <h3 class="viz-group-title viz-main-group"><?php _e( 'Chart Settings', 'visualizer' ); ?></h3>
92 410 </div>
93 - </div>
94 - <div class="viz-info-item">
95 - <label for="viz-backend-name"><?php _e( 'Backend chart title for internal usage', 'visualizer' ); ?></label>
96 - <input type="text" id="viz-backend-name" value="<?php echo $hasTitle ? $chartSettings['backend-title'] : ( '#' . esc_attr( $this->chart->ID ) ); ?>">
97 - </div>
98 - </div>
99 - <div id="viz-tabs">
100 - <ul>
101 - <li><a href="#viz-tab-basic-content" id="viz-tab-basic"><?php _e( 'Source', 'visualizer' ); ?></a></li>
102 - <li><a href="#viz-tab-advanced-content" id="viz-tab-advanced"><?php _e( 'Settings', 'visualizer' ); ?></a></li>
103 - <li><a href="#viz-tab-help-content" id="viz-tab-help"><?php _e( 'Help', 'visualizer' ); ?></a></li>
104 - </ul>
105 - <div id="viz-tab-basic-content"><?php Visualizer_Render_Layout::show( 'tab-basic', $this->chart->ID ); ?></div>
106 - <div id="viz-tab-advanced-content"><?php Visualizer_Render_Layout::show( 'tab-advanced', $this->chart->ID, $this->sidebar ); ?></div>
107 - <div id="viz-tab-help-content"><?php Visualizer_Render_Layout::show( 'tab-help', $this->chart->ID ); ?></div>
108 - </div>
411 + <ul class="viz-group-content">
412 + <form id="settings-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>"
413 + method="post">
414 + <?php echo $this->sidebar; ?>
415 + <input type="hidden" name="save" value="1">
416 + </form>
417 + <form id="cancel-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>" method="post">
418 + <input type="hidden" name="cancel" value="1">
419 + </form>
420 + </ul>
421 + </li>
109 422
110 - <li class="viz-group bottom-fixed" id="vz-chart-copyright">
111 - <?php _e( 'Hate it? Love it?', 'visualizer' ); ?> <a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank"><?php _e( 'Rate it!', 'visualizer' ); ?></a>
423 + <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-docs">
424 + <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>
425 + </li>
426 +
427 + <?php $this->getPermissionsLink( $this->chart->ID ); ?>
428 +
429 + <li class="viz-group bottom-fixed" id="vz-chart-copyright">Visualizer &copy; <?php echo date( 'Y', current_time( 'timestamp' ) ); ?></li>
430 + </ul>
112 431 <?php
113 - // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date, WordPress.DateTime.CurrentTimeTimestamp.Requested
114 - echo date( 'Y', current_time( 'timestamp' ) );
432 + // changed by Ash/Upwork
433 + }
434 +
435 + /**
436 + * Generates the permissions link.
437 + *
438 + * @access private
439 + * @param int $id The chart id.
440 + */
441 + private function getPermissionsLink( $id ) {
442 + $permissions = apply_filters( 'visualizer_pro_get_permissions', null, $id );
443 + if ( $permissions ) {
444 + foreach ( $permissions as $k => $v ) {
445 + $this->$k = $v;
446 + }
447 + }
115 448 ?>
449 + <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-permissions">
450 + <h2><span class="dashicons dashicons-admin-users"></span><?php _e( 'Permissions', 'visualizer' ); ?></h2>
451 + <div class="viz-group-header">
452 + <button class="customize-section-back" tabindex="0"></button>
453 + <h3 class="viz-group-title viz-main-group"><?php _e( 'Chart Settings', 'visualizer' ); ?></h3>
454 + </div>
455 + <ul class="viz-group-content">
456 + <form id="permissions-form" target="thehole" action="
457 + <?php
458 + echo add_query_arg(
459 + array(
460 + 'nonce' => wp_create_nonce(),
461 + 'tab' => 'permissions',
462 + ),
463 + remove_query_arg( 'tab', $_SERVER['REQUEST_URI'] )
464 + );
465 + ?>
466 +" method="post">
467 + <?php $this->permissionsSidebar(); ?>
468 + </form>
469 + </ul>
116 470 </li>
117 471 <?php
118 472 }
119 473
120 474 /**
475 + * Generates the permissions form.
476 + *
477 + * @access private
478 + */
479 + private function permissionsSidebar() {
480 + // ignore for unit tests because Travis throws the error "Indirect modification of overloaded property Visualizer_Render_Page_Data::$permissions has no effect".
481 + if ( defined( 'WP_TESTS_DOMAIN' ) ) {
482 + return;
483 + }
484 + Visualizer_Render_Sidebar::_renderGroupStart(
485 + esc_html__( 'Who can see this chart?', 'visualizer' ) . '<span
486 + class="dashicons dashicons-lock"></span>',
487 + '',
488 + apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
489 + );
490 + Visualizer_Render_Sidebar::_renderSectionStart();
491 + Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can view the chart on the front-end.', 'visualizer' ) );
492 +
493 + if ( ! isset( $this->permissions['read'] ) ) {
494 + $this->permissions['read'] = 'all';
495 + }
496 +
497 + Visualizer_Render_Sidebar::_renderSelectItem(
498 + '',
499 + 'permissions[read]',
500 + $this->permissions['read'],
501 + array(
502 + 'all' => esc_html__( 'All Users', 'visualizer' ),
503 + 'users' => esc_html__( 'Select Users', 'visualizer' ),
504 + 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
505 + ),
506 + '',
507 + false,
508 + array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-read' ),
509 + array(
510 + 'permission-type' => 'read',
511 + )
512 + );
513 +
514 + $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $this->permissions['read'] ) ? $this->permissions['read'] : 'roles' );
515 +
516 + Visualizer_Render_Sidebar::_renderSelectItem(
517 + '',
518 + 'permissions[read-specific][]',
519 + isset( $this->permissions['read-specific'] ) ? $this->permissions['read-specific'] : array(),
520 + $options,
521 + '',
522 + true,
523 + array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-read-specific' )
524 + );
525 + Visualizer_Render_Sidebar::_renderSectionEnd( apply_filters( 'visualizer_pro_upsell', 'only-pro-feature', 'chart-permissions' ) );
526 + Visualizer_Render_Sidebar::_renderGroupEnd();
527 +
528 + Visualizer_Render_Sidebar::_renderGroupStart(
529 + esc_html__( 'Who can edit this chart?', 'visualizer' ) . '<span
530 + class="dashicons dashicons-lock"></span>',
531 + '',
532 + apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
533 + );
534 + Visualizer_Render_Sidebar::_renderSectionStart();
535 + Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can edit the chart on the front-end.', 'visualizer' ) );
536 +
537 + if ( ! isset( $this->permissions['edit'] ) ) {
538 + $this->permissions['edit'] = 'roles';
539 + $this->permissions['edit-specific'] = 'administrator';
540 + }
541 +
542 + Visualizer_Render_Sidebar::_renderSelectItem(
543 + '',
544 + 'permissions[edit]',
545 + $this->permissions['edit'],
546 + array(
547 + 'all' => esc_html__( 'All Users', 'visualizer' ),
548 + 'users' => esc_html__( 'Select Users', 'visualizer' ),
549 + 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
550 + ),
551 + '',
552 + false,
553 + array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-edit' ),
554 + array(
555 + 'permission-type' => 'edit',
556 + )
557 + );
558 +
559 + $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $this->permissions['edit'] ) ? $this->permissions['edit'] : 'roles' );
560 +
561 + Visualizer_Render_Sidebar::_renderSelectItem(
562 + '',
563 + 'permissions[edit-specific][]',
564 + isset( $this->permissions['edit-specific'] ) ? $this->permissions['edit-specific'] : array(),
565 + $options,
566 + '',
567 + true,
568 + array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-edit-specific' )
569 + );
570 + Visualizer_Render_Sidebar::_renderSectionEnd( apply_filters( 'visualizer_pro_upsell', 'only-pro-feature', 'chart-permissions' ) );
571 + Visualizer_Render_Sidebar::_renderGroupEnd();
572 +
573 + }
574 +
575 + /**
121 576 * Renders toolbar content.
122 577 *
123 578 * @since 1.0.0
124 579 *
@@ -128,9 +583,9 @@
128 583 // don't show back button at all.
129 584 // NOTE: We can't be selective on the post_status here because when a new chart reaches the settings screen, its status changes to publish.
130 585 if ( ! VISUALIZER_SKIP_CHART_TYPE_PAGE ) {
131 586 echo '<div class="toolbar-div">';
132 - echo '<a class="button button-large" href="', esc_url( add_query_arg( 'tab', 'types' ) ), '">';
587 + echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">';
133 588 esc_html_e( 'Back', 'visualizer' );
134 589 echo '</a>';
135 590 echo '</div>';
136 591 }
@@ -135,9 +590,9 @@
135 590 echo '</div>';
136 591 }
137 592 echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">';
138 593 if ( isset( $this->cancel_button ) ) {
139 - echo '<input type="submit" id="cancel-button" class="button button-secondary button-large push-right" value="', $this->cancel_button, '">';
594 + echo '<input type="submit" id="cancel-button" class="button button-secondary button-large push-left" value="', $this->cancel_button, '">';
140 595 }
141 596 }
142 597
143 598 /**
@@ -150,8 +605,9 @@
150 605 $query = '';
151 606 if ( 'visualizer_source_query' === $source ) {
152 607 $query = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_QUERY, true );
153 608 }
154 - Visualizer_Render_Layout::show( 'db-query', $query, $this->chart->ID );
609 + Visualizer_Render_Layout::show( 'db-query', $query );
155 610 Visualizer_Render_Layout::show( 'json-screen', $this->chart->ID );
156 611 }
612 +
157 613 }