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 +526 -24 3.10.123.4.2 View file →
@@ -56,18 +56,11 @@
56 56
57 57 $this->add_additional_content();
58 58
59 59 // 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 60 echo '<div id="canvas">';
65 61 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
66 62 echo '</div>';
67 - if ( Visualizer_Module::is_pro() ) {
68 - echo '</div>';
69 - }
70 63 echo $this->custom_css;
71 64 }
72 65
73 66 /**
@@ -77,33 +70,542 @@
77 70 *
78 71 * @access protected
79 72 */
80 73 protected function _renderSidebarContent() {
74 + $upload_link = add_query_arg(
75 + array(
76 + 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
77 + 'nonce' => wp_create_nonce(),
78 + 'chart' => $this->chart->ID,
79 + ),
80 + admin_url( 'admin-ajax.php' )
81 + );
82 +
83 + // this will allow us to open the correct source tab by default.
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 +
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 );
81 98 ?>
82 - <div id="viz-tabs">
83 - <ul>
84 - <li><a href="#viz-tab-basic-content" id="viz-tab-basic"><?php _e( 'Source', 'visualizer' ); ?></a></li>
85 - <li><a href="#viz-tab-advanced-content" id="viz-tab-advanced"><?php _e( 'Settings', 'visualizer' ); ?></a></li>
86 - <li><a href="#viz-tab-help-content" id="viz-tab-help"><?php _e( 'Help', 'visualizer' ); ?></a></li>
87 - </ul>
88 - <div id="viz-tab-basic-content"><?php Visualizer_Render_Layout::show( 'tab-basic', $this->chart->ID ); ?></div>
89 - <div id="viz-tab-advanced-content"><?php Visualizer_Render_Layout::show( 'tab-advanced', $this->chart->ID, $this->sidebar ); ?></div>
90 - <div id="viz-tab-help-content"><?php Visualizer_Render_Layout::show( 'tab-help', $this->chart->ID ); ?></div>
91 - </div>
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>
100 + <iframe id="thehole" name="thehole"></iframe>
101 + <ul class="viz-group-wrapper full-height">
102 + <li class="viz-group viz-group-category open" id="vz-chart-source">
103 + <div class="viz-group-header">
104 + <h2 class="viz-group-title viz-main-group"><?php _e( 'Chart Data', 'visualizer' ); ?></h2>
105 + </div>
106 + <ul class="viz-group-content">
107 + <ul class="viz-group-wrapper">
108 + <!-- import from file -->
109 + <li class="viz-group visualizer_source_csv">
110 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
111 + <div class="viz-group-content">
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>
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>
114 + <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
115 + target="thehole" enctype="multipart/form-data">
116 + <input type="hidden" id="remote-data" name="remote_data">
117 + <div class="">
118 + <input type="file" id="csv-file" name="local_data">
119 + </div>
120 + <input type="button" class="button button-primary" id="vz-import-file"
121 + value="<?php _e( 'Import', 'visualizer' ); ?>">
122 + </form>
123 + </div>
124 + </li>
125 + <!-- import from url -->
126 + <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json">
127 + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
128 + <ul class="viz-group-content">
129 + <!-- import from csv url -->
130 + <li class="viz-subsection">
131 + <span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span>
132 + <div class="viz-section-items section-items">
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>
135 + <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
136 + target="thehole" enctype="multipart/form-data">
137 + <div class="remote-file-section">
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>
92 160
93 - <li class="viz-group bottom-fixed" id="vz-chart-copyright">
94 - Hate it? Love it? <a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank">Rate it!</a>
95 - <br/>
96 - Visualizer &copy;
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 + ?>
169 + </form>
170 + </div>
171 + </li>
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>
176 + <div class="viz-section-items section-items">
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">
179 + <div class="remote-file-section">
180 + <?php
181 + $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
182 + if ( Visualizer_Module::is_pro() ) {
183 + ?>
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; ?>">
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
206 + }
207 + ?>
208 + </div>
209 +
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 + ?>
222 + </form>
223 + </div>
224 + </li>
225 + </ul>
226 + </li>
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' ); ?>">
230 + <h2 class="viz-group-title viz-sub-group"
231 + data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
232 + class="dashicons dashicons-lock"></span></h2>
233 + <div class="viz-group-content edit-data-content">
234 + <div>
235 + <p class="viz-group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p>
236 + <form>
237 + <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
238 + <?php
239 + $fetch_link = add_query_arg(
240 + array(
241 + 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '',
242 + 'nonce' => wp_create_nonce(),
243 + ),
244 + admin_url( 'admin-ajax.php' )
245 + );
246 + $query_args_charts = array(
247 + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
248 + 'posts_per_page' => 300,
249 + 'no_found_rows' => true,
250 + );
251 + $charts = array();
252 + $query = new WP_Query( $query_args_charts );
253 + while ( $query->have_posts() ) {
254 + $chart = $query->next_post();
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 +
269 + ?>
270 + <option value="<?php echo $chart->ID; ?>"><?php echo $title; ?></option>
271 + <?php
272 + }
273 + ?>
274 +
275 + </select>
276 + </form>
277 + <input type="button" id="existing-chart" class="button button-primary"
278 + value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
279 + data-viz-link="<?php echo $fetch_link; ?>">
280 + <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
281 + </div>
282 + </div>
283 + </li>
284 +
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' ); ?> ">
296 + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
297 + class="dashicons dashicons-lock"></span></h2>
298 + <div class="viz-group-content edit-data-content">
299 + <div>
300 + <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p>
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' ); ?>
330 + </div>
331 + </div>
332 + </li>
333 +
334 + <?php
335 + $save_query = add_query_arg(
336 + array(
337 + 'action' => Visualizer_Plugin::ACTION_SAVE_DB_QUERY,
338 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_DB_QUERY . Visualizer_Plugin::VERSION ),
339 + 'chart' => $this->chart->ID,
340 + ), admin_url( 'admin-ajax.php' )
341 + );
342 + ?>
343 + <!-- import from db -->
344 + <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>">
345 + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span
346 + class="dashicons dashicons-lock"></span></h2>
347 + <div class="viz-group-content edit-data-content">
348 + <div>
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 );
371 + ?>
372 + </select>
373 + <input type="hidden" name="params" id="viz-db-wizard-params">
374 +
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' ); ?>">
377 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
378 + </form>
379 + </div>
380 + </div>
381 + </li>
382 +
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>
388 + <div class="viz-group-content edit-data-content">
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">
392 +
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>
427 + </div>
428 + </li>
429 + </ul>
430 + </li>
431 + </ul>
432 + <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-settings">
433 + <h2><span class="dashicons dashicons-admin-tools"></span><?php _e( 'Advanced', 'visualizer' ); ?></h2>
434 + <div class="viz-group-header">
435 + <button class="customize-section-back" tabindex="0"></button>
436 + <h3 class="viz-group-title viz-main-group"><?php _e( 'Chart Settings', 'visualizer' ); ?></h3>
437 + </div>
438 + <ul class="viz-group-content">
439 + <form id="settings-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>"
440 + method="post">
441 + <?php echo $this->sidebar; ?>
442 + <input type="hidden" name="save" value="1">
443 + </form>
444 + <form id="cancel-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>" method="post">
445 + <input type="hidden" name="cancel" value="1">
446 + </form>
447 + </ul>
448 + </li>
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 +
454 + <?php $this->getPermissionsLink( $this->chart->ID ); ?>
455 +
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>
462 + </ul>
97 463 <?php
98 - // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date, WordPress.DateTime.CurrentTimeTimestamp.Requested
99 - echo date( 'Y', current_time( 'timestamp' ) );
464 + // changed by Ash/Upwork
465 + }
466 +
467 + /**
468 + * Generates the permissions link.
469 + *
470 + * @access private
471 + * @param int $id The chart id.
472 + */
473 + private function getPermissionsLink( $id ) {
474 + $permissions = apply_filters( 'visualizer_pro_get_permissions', null, $id );
475 + if ( $permissions ) {
476 + foreach ( $permissions as $k => $v ) {
477 + $this->$k = $v;
478 + }
479 + }
100 480 ?>
481 + <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-permissions">
482 + <h2><span class="dashicons dashicons-admin-users"></span><?php _e( 'Permissions', 'visualizer' ); ?></h2>
483 + <div class="viz-group-header">
484 + <button class="customize-section-back" tabindex="0"></button>
485 + <h3 class="viz-group-title viz-main-group"><?php _e( 'Chart Settings', 'visualizer' ); ?></h3>
486 + </div>
487 + <ul class="viz-group-content">
488 + <form id="permissions-form" target="thehole" action="
489 + <?php
490 + echo add_query_arg(
491 + array(
492 + 'nonce' => wp_create_nonce(),
493 + 'tab' => 'permissions',
494 + ),
495 + remove_query_arg( 'tab', $_SERVER['REQUEST_URI'] )
496 + );
497 + ?>
498 +" method="post">
499 + <?php $this->permissionsSidebar(); ?>
500 + </form>
501 + </ul>
101 502 </li>
102 503 <?php
103 504 }
104 505
105 506 /**
507 + * Generates the permissions form.
508 + *
509 + * @access private
510 + */
511 + private function permissionsSidebar() {
512 + // ignore for unit tests because Travis throws the error "Indirect modification of overloaded property Visualizer_Render_Page_Data::$permissions has no effect".
513 + if ( defined( 'WP_TESTS_DOMAIN' ) ) {
514 + return;
515 + }
516 + Visualizer_Render_Sidebar::_renderGroupStart(
517 + esc_html__( 'Who can see this chart?', 'visualizer' ) . '<span
518 + class="dashicons dashicons-lock"></span>',
519 + '',
520 + 'viz-chart-perm-view ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
521 + );
522 + Visualizer_Render_Sidebar::_renderSectionStart();
523 + Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can view the chart on the front-end.', 'visualizer' ) );
524 +
525 + if ( ! isset( $this->permissions['read'] ) ) {
526 + $this->permissions['read'] = 'all';
527 + }
528 +
529 + Visualizer_Render_Sidebar::_renderSelectItem(
530 + '',
531 + 'permissions[read]',
532 + $this->permissions['read'],
533 + array(
534 + 'all' => esc_html__( 'All Users', 'visualizer' ),
535 + 'users' => esc_html__( 'Select Users', 'visualizer' ),
536 + 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
537 + ),
538 + '',
539 + false,
540 + array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-read' ),
541 + array(
542 + 'permission-type' => 'read',
543 + )
544 + );
545 +
546 + $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $this->permissions['read'] ) ? $this->permissions['read'] : 'roles' );
547 +
548 + Visualizer_Render_Sidebar::_renderSelectItem(
549 + '',
550 + 'permissions[read-specific][]',
551 + isset( $this->permissions['read-specific'] ) ? $this->permissions['read-specific'] : array(),
552 + $options,
553 + '',
554 + true,
555 + array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-read-specific' )
556 + );
557 + Visualizer_Render_Sidebar::_renderSectionEnd( apply_filters( 'visualizer_pro_upsell', 'only-pro-feature', 'chart-permissions' ) );
558 + Visualizer_Render_Sidebar::_renderGroupEnd();
559 +
560 + Visualizer_Render_Sidebar::_renderGroupStart(
561 + esc_html__( 'Who can edit this chart?', 'visualizer' ) . '<span
562 + class="dashicons dashicons-lock"></span>',
563 + '',
564 + 'viz-chart-perm-edit ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
565 + );
566 + Visualizer_Render_Sidebar::_renderSectionStart();
567 + Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can edit the chart on the front-end.', 'visualizer' ) );
568 +
569 + if ( ! isset( $this->permissions['edit'] ) ) {
570 + $this->permissions['edit'] = 'roles';
571 + $this->permissions['edit-specific'] = 'administrator';
572 + }
573 +
574 + Visualizer_Render_Sidebar::_renderSelectItem(
575 + '',
576 + 'permissions[edit]',
577 + $this->permissions['edit'],
578 + array(
579 + 'all' => esc_html__( 'All Users', 'visualizer' ),
580 + 'users' => esc_html__( 'Select Users', 'visualizer' ),
581 + 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
582 + ),
583 + '',
584 + false,
585 + array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-edit' ),
586 + array(
587 + 'permission-type' => 'edit',
588 + )
589 + );
590 +
591 + $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $this->permissions['edit'] ) ? $this->permissions['edit'] : 'roles' );
592 +
593 + Visualizer_Render_Sidebar::_renderSelectItem(
594 + '',
595 + 'permissions[edit-specific][]',
596 + isset( $this->permissions['edit-specific'] ) ? $this->permissions['edit-specific'] : array(),
597 + $options,
598 + '',
599 + true,
600 + array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-edit-specific' )
601 + );
602 + Visualizer_Render_Sidebar::_renderSectionEnd( apply_filters( 'visualizer_pro_upsell', 'only-pro-feature', 'chart-permissions' ) );
603 + Visualizer_Render_Sidebar::_renderGroupEnd();
604 +
605 + }
606 +
607 + /**
106 608 * Renders toolbar content.
107 609 *
108 610 * @since 1.0.0
109 611 *
@@ -113,9 +615,9 @@
113 615 // don't show back button at all.
114 616 // 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.
115 617 if ( ! VISUALIZER_SKIP_CHART_TYPE_PAGE ) {
116 618 echo '<div class="toolbar-div">';
117 - echo '<a class="button button-large" href="', esc_url( add_query_arg( 'tab', 'types' ) ), '">';
619 + echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">';
118 620 esc_html_e( 'Back', 'visualizer' );
119 621 echo '</a>';
120 622 echo '</div>';
121 623 }