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/Layout.php +36 -778 3.10.143.3.4 View file →
@@ -59,10 +59,8 @@
59 59 <div id='visualizer-db-query' style="display: none">
60 60 <div class="visualizer-db-query-form">
61 61 <div>
62 62 <form id='db-query-form'>
63 - <input type="hidden" name="chart_id" value="<?php echo $args[2]; ?>">
64 - <?php do_action( 'visualizer_db_query_add_layout', $args ); ?>
65 63 <textarea name='query' class='visualizer-db-query' placeholder="<?php _e( 'Your query goes here', 'visualizer' ); ?>"><?php echo $query; ?></textarea>
66 64 </form>
67 65 <div class='db-wizard-error'></div>
68 66 </div>
@@ -73,9 +71,8 @@
73 71 <div class='db-wizard-hints'>
74 72 <ul>
75 73 <li><?php echo sprintf( __( 'For examples of queries and links to resources that you can use with this feature, please click %1$shere%2$s', 'visualizer' ), '<a href="' . VISUALIZER_DB_QUERY_DOC_URL . '" target="_blank">', '</a>' ); ?></li>
76 74 <li><?php echo sprintf( __( 'Use %1$sControl+Space%2$s for autocompleting keywords or table names.', 'visualizer' ), '<span class="visualizer-emboss">', '</span>' ); ?></li>
77 - <?php do_action( 'visualizer_db_query_add_hints', $args ); ?>
78 75 </ul>
79 76 </div>
80 77 <div class='db-wizard-results'></div>
81 78
@@ -104,9 +101,9 @@
104 101 </tr>
105 102 </thead>
106 103 <tfoot>
107 104 </tfoot>
108 - <tbody>
105 + <tbody>
109 106 <?php
110 107 foreach ( $results as $result ) {
111 108 echo '<tr>';
112 109 foreach ( $result as $r ) {
@@ -127,34 +124,21 @@
127 124 * @access public
128 125 */
129 126 public static function _renderJsonScreen( $args ) {
130 127 $id = $args[1];
131 - $action = esc_url(
132 - add_query_arg(
133 - array(
134 - 'action' => Visualizer_Plugin::ACTION_JSON_SET_DATA,
135 - 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_JSON_SET_DATA . Visualizer_Plugin::VERSION ),
136 - 'chart' => $id,
137 - ),
138 - admin_url( 'admin-ajax.php' )
139 - )
128 + $action = add_query_arg(
129 + array(
130 + 'action' => Visualizer_Plugin::ACTION_JSON_SET_DATA,
131 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_JSON_SET_DATA . Visualizer_Plugin::VERSION ),
132 + 'chart' => $id,
133 + ),
134 + admin_url( 'admin-ajax.php' )
140 135 );
141 136
142 - $is_wc_source = get_post_meta( $id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE, true );
143 137 $url = get_post_meta( $id, Visualizer_Plugin::CF_JSON_URL, true );
144 138 $root = get_post_meta( $id, Visualizer_Plugin::CF_JSON_ROOT, true );
145 139 $paging = get_post_meta( $id, Visualizer_Plugin::CF_JSON_PAGING, true );
146 - $headers = get_post_meta( $id, Visualizer_Plugin::CF_JSON_HEADERS, true );
147 - if ( empty( $headers ) ) {
148 - $headers = array();
149 - }
150 - if ( $headers && empty( $headers['method'] ) ) {
151 - $headers['method'] = 'get';
152 - }
153 - $methods = apply_filters( 'visualizer_json_request_methods', array( 'GET', 'POST' ) );
154 140
155 - // open the headers by default?
156 - $headers_open = $headers && array_key_exists( 'auth', $headers ) && ( array_key_exists( 'username', $headers['auth'] ) && ! empty( $headers['auth']['username'] ) ) || ( ! empty( $headers['auth'] ) && is_string( $headers['auth'] ) );
157 141 ?>
158 142 <div id="visualizer-json-screen" style="display: none">
159 143 <div class="visualizer-json-form">
160 144 <h3 class="viz-step step1"><?php _e( 'STEP 1: Specify the JSON endpoint/URL', 'visualizer' ); ?></h3>
@@ -161,9 +145,9 @@
161 145 <div>
162 146 <form id="json-endpoint-form">
163 147 <div class="json-wizard-hints">
164 148 <ul class="info">
165 - <li><?php echo sprintf( __( 'If you want to add authentication or headers to the endpoint or change the request in any way, please refer to our document %1$shere%2$s.', 'visualizer' ), '<a href="https://docs.themeisle.com/article/1043-visualizer-how-to-extend-rest-endpoints-with-json-response" target="_blank">', '</a>' ); ?></li>
149 + <li><?php echo sprintf( __( 'If you want to add authentication, add headers to the endpoint or change the request in any way, please refer to our document %1$shere%2$s.', 'visualizer' ), '<a href="https://docs.themeisle.com/article/1043-visualizer-how-to-extend-rest-endpoints-with-json-response" target="_blank">', '</a>' ); ?></li>
166 150 </ul>
167 151 </div>
168 152
169 153 <input
@@ -171,70 +155,10 @@
171 155 id="vz-import-json-url"
172 156 name="url"
173 157 value="<?php echo esc_url( $url ); ?>"
174 158 placeholder="<?php esc_html_e( 'Please enter the URL', 'visualizer' ); ?>"
175 - class="visualizer-input json-form-element"
176 - <?php echo $is_wc_source ? 'readonly' : ''; ?>
177 - >
159 + class="visualizer-input">
178 160 <button class="button button-secondary button-small" id="visualizer-json-fetch"><?php esc_html_e( 'Fetch Endpoint', 'visualizer' ); ?></button>
179 -
180 - <div class="visualizer-json-subform">
181 - <h3 class="viz-substep <?php echo $headers_open ? 'open' : ''; ?>"><?php _e( 'Headers', 'visualizer' ); ?></h3>
182 - <div class="json-wizard-headers">
183 - <div class="json-wizard-header">
184 - <div><?php _e( 'Request Type', 'visualizer' ); ?></div>
185 - <div>
186 - <select name="method" class="json-form-element">
187 - <?php foreach ( $methods as $method ) { ?>
188 - <option value="<?php echo $method; ?>" <?php $headers && selected( $headers['method'], $method ); ?>><?php echo $method; ?></option>
189 - <?php } ?>
190 - </select>
191 - </div>
192 - </div>
193 - <div class="json-wizard-header">
194 - <div><?php _e( 'Credentials', 'visualizer' ); ?></div>
195 - <div>
196 - <input
197 - type="text"
198 - id="vz-import-json-username"
199 - name="username"
200 - value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'username', $headers['auth'] ) ? $headers['auth']['username'] : '' ); ?>"
201 - placeholder="<?php esc_html_e( 'Username/Access Key', 'visualizer' ); ?>"
202 - class="json-form-element">
203 - &
204 - <input
205 - type="password"
206 - id="vz-import-json-password"
207 - name="password"
208 - value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'password', $headers['auth'] ) ? $headers['auth']['password'] : '' ); ?>"
209 - placeholder="<?php esc_html_e( 'Password/Secret Key', 'visualizer' ); ?>"
210 - class="json-form-element">
211 - </div>
212 - </div>
213 - <div class="json-wizard-header">
214 - <div></div>
215 - <div><?php esc_html_e( 'OR', 'visualizer' ); ?></div>
216 - </div>
217 - <div class="json-wizard-header">
218 - <div><?php esc_html_e( 'Authorization', 'visualizer' ); ?></div>
219 - <div>
220 - <input
221 - type="text"
222 - id="vz-import-json-auth"
223 - name="auth"
224 - value="<?php echo ( array_key_exists( 'auth', $headers ) && is_string( $headers['auth'] ) ? $headers['auth'] : '' ); ?>"
225 - placeholder="<?php esc_html_e( 'e.g. SharedKey <AccountName>:<Signature>', 'visualizer' ); ?>"
226 - class="visualizer-input json-form-element">
227 - </div>
228 - </div>
229 - <div class="json-wizard-header">
230 - <div class="field-title"><?php esc_html_e( 'Additional headers', 'visualizer' ); ?></div>
231 - <div>
232 - <textarea name="additional_headers" class="visualizer-input" placeholder="<?php esc_html_e( 'Key:Value, Key2:Value2,...', 'visualizer' ); ?>"><?php echo isset( $headers['additional_headers'] ) ? $headers['additional_headers'] : ''; ?></textarea>
233 - </div>
234 - </div>
235 - </div>
236 - </div>
237 161 </form>
238 162 </div>
239 163 <h3 class="viz-step step2 <?php echo empty( $url ) ? 'ui-state-disabled' : ''; ?> json-root-form"><?php _e( 'STEP 2: Choose the JSON root', 'visualizer' ); ?></h3>
240 164 <div>
@@ -239,9 +163,9 @@
239 163 <h3 class="viz-step step2 <?php echo empty( $url ) ? 'ui-state-disabled' : ''; ?> json-root-form"><?php _e( 'STEP 2: Choose the JSON root', 'visualizer' ); ?></h3>
240 164 <div>
241 165 <form id="json-root-form">
242 166 <input type="hidden" name="chart" value="<?php echo $id; ?>">
243 - <select name="root" id="vz-import-json-root" class="json-form-element">
167 + <select name="root" id="vz-import-json-root">
244 168 <?php
245 169 if ( ! empty( $root ) ) {
246 170 ?>
247 171 <option value="<?php echo esc_attr( $root ); ?>"><?php echo str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $root ); ?></option>
@@ -248,8 +172,9 @@
248 172 <?php
249 173 }
250 174 ?>
251 175 </select>
176 + <input type="hidden" name="url" value="<?php echo $url; ?>">
252 177 <button class="button button-secondary button-small" id="visualizer-json-parse"><?php esc_html_e( 'Parse Endpoint', 'visualizer' ); ?></button>
253 178 </form>
254 179 </div>
255 180 <h3 class="viz-step step3 <?php echo empty( $root ) ? 'ui-state-disabled' : ''; ?>"><?php _e( 'STEP 3: Specify miscellaneous parameters', 'visualizer' ); ?></h3>
@@ -256,14 +181,14 @@
256 181 <div>
257 182 <form id="json-conclude-form-helper">
258 183 <div class="<?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
259 184 <div class="json-pagination">
260 - <select name="paging" id="vz-import-json-paging" class="json-form-element" data-template='<?php echo sprintf( 'Get results from the first %d pages using %s', apply_filters( 'visualizer_json_fetch_pages', 5, $url ), '?' ); ?>'>
261 - <option value="0" class="static"><?php _e( 'Get results from the first page only', 'visualizer' ); ?></option>
185 + <select name="paging" id="vz-import-json-paging" class="json-form-element" data-template='<?php echo sprintf( 'Get first %d pages using %s', apply_filters( 'visualizer_json_fetch_pages', 5, $url ), '?' ); ?>'>
186 + <option value="0" class="static"><?php _e( 'Don\'t use pagination', 'visualizer' ); ?></option>
262 187 <?php
263 188 if ( ! empty( $paging ) ) {
264 189 ?>
265 - <option value="<?php echo esc_attr( $paging ); ?>"><?php echo sprintf( 'Get results from the first %d pages using %s', apply_filters( 'visualizer_json_fetch_pages', 5, $url ), str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $paging ) ); ?></option>
190 + <option value="<?php echo esc_attr( $paging ); ?>"><?php echo sprintf( 'Get first %d pages using %s', apply_filters( 'visualizer_json_fetch_pages', 5, $url ), str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $paging ) ); ?></option>
266 191 <?php
267 192 }
268 193 ?>
269 194 </select>
@@ -284,20 +209,22 @@
284 209 </div>
285 210 <h3 class="viz-step step4 ui-state-disabled"><?php _e( 'STEP 4: Select the data to display in the chart', 'visualizer' ); ?></h3>
286 211 <div>
287 212 <form id="json-conclude-form" action="<?php echo $action; ?>" method="post" target="thehole">
213 + <input type="hidden" name="url">
214 + <input type="hidden" name="root">
215 + <input type="hidden" name="chart" value="<?php echo $id; ?>">
216 +
288 217 <div class="json-wizard-hints html-table-editor-hints">
289 218 <ul class="info">
290 - <li><?php _e( 'If you see Invalid Data in the table, you may have selected the wrong root to fetch data from. Please select an alternative from the JSON root dropdown.', 'visualizer' ); ?></li>
291 219 <li><?php _e( 'Select whether to include the data in the chart. Each column selected will form one series.', 'visualizer' ); ?></li>
292 220 <li><?php _e( 'If a column is selected to be included, specify its data type.', 'visualizer' ); ?></li>
293 221 <li><?php _e( 'You can use drag/drop to reorder the columns but this column position is not saved. So when you reload the table, you may have to reorder again.', 'visualizer' ); ?></li>
294 222 <li><?php _e( 'You can select any number of columns but the chart type selected will determine how many will display in the chart.', 'visualizer' ); ?></li>
295 - <li><?php _e( 'Once you have made your selection, click \'Show Chart\' on the right to view the chart.', 'visualizer' ); ?></li>
296 223 </ul>
297 224 </div>
298 225 <div class="json-table"></div>
299 - <button class="button button-primary" style="display: none" id="visualizer-json-conclude"></button>
226 + <button class="button button-primary" id="visualizer-json-conclude"><?php esc_html_e( 'Save &amp; Show Chart', 'visualizer' ); ?></button>
300 227 </form>
301 228 </div>
302 229 </div>
303 230 </div>
@@ -310,17 +237,15 @@
310 237 * @access public
311 238 */
312 239 public static function _renderSimpleEditorScreen( $args ) {
313 240 $chart_id = $args[1];
314 - $action = esc_url(
315 - add_query_arg(
316 - array(
317 - 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
318 - 'nonce' => wp_create_nonce(),
319 - 'chart' => $chart_id,
320 - ),
321 - admin_url( 'admin-ajax.php' )
322 - )
241 + $action = add_query_arg(
242 + array(
243 + 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
244 + 'nonce' => wp_create_nonce(),
245 + 'chart' => $chart_id,
246 + ),
247 + admin_url( 'admin-ajax.php' )
323 248 );
324 249 ?>
325 250 <div class="viz-simple-editor">
326 251 <div class="viz-simple-editor-type viz-table-editor">
@@ -336,9 +261,9 @@
336 261 <div class="viz-html-table">
337 262 <?php Visualizer_Render_Layout::show( 'editor-table', null, $chart_id, 'viz-html-table', true, true ); ?>
338 263 </div>
339 264 <input type="hidden" name="table_data" value="yes">
340 - <input type="hidden" name="editor-type" value="table">
265 + <button class="button button-primary" id="visualizer-save-html-table"><?php esc_html_e( 'Save &amp; Show Chart', 'visualizer' ); ?></button>
341 266 </form>
342 267 </div>
343 268
344 269 <?php Visualizer_Render_Layout::show( 'text-editor', $chart_id ); ?>
@@ -354,16 +279,17 @@
354 279 * @access public
355 280 */
356 281 public static function _renderTextEditor( $args ) {
357 282 $chart_id = $args[1];
358 - $csv = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA_AS, array(), $chart_id, 'csv-display' );
283 + $csv = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA_AS, array(), $chart_id, 'csv' );
359 284 $data = '';
360 285 if ( ! empty( $csv ) && isset( $csv['string'] ) ) {
361 - $data = str_replace( PHP_EOL, "\n", stripslashes( $csv['string'] ) );
286 + $data = str_replace( PHP_EOL, "\n", $csv['string'] );
362 287 }
363 288 ?>
364 289 <div class="viz-simple-editor-type viz-text-editor">
365 290 <textarea id="edited_text"><?php echo $data; ?></textarea>
291 + <button id="viz-text-editor-button" class="button button-primary"><?php _e( 'Save &amp; Show Chart', 'visualizer' ); ?></button>
366 292 </div>
367 293 <?php
368 294 }
369 295
@@ -386,9 +312,9 @@
386 312 $headers[] = $column['label'];
387 313 }
388 314 $chart = get_post( $chart_id );
389 315 $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
390 - $data = Visualizer_Module::get_chart_data( $chart, $type );
316 + $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $type );
391 317 } else {
392 318 $headers = array_keys( $data[0] );
393 319 }
394 320
@@ -419,9 +345,9 @@
419 345 }
420 346 ?>
421 347 </tr>
422 348 </thead>
423 - <tbody>
349 + <tbody>
424 350 <tr>
425 351 <th><?php _e( 'Data Type', 'visualizer' ); ?></th>
426 352 <?php
427 353 $index = 0;
@@ -430,9 +356,9 @@
430 356 if ( $editable_data ) {
431 357 echo '<select name="type[]">';
432 358 } else {
433 359 echo '<input name="header[]" type="hidden" value="' . $header . '">';
434 - echo '<select name="type[' . $header . ']" class="viz-select-data-type">';
360 + echo '<select name="type[' . $header . ']">';
435 361 }
436 362 echo '<option value="" title="' . __( 'Exclude from chart', 'visualizer' ) . '">' . __( 'Exclude', 'visualizer' ) . '</option>';
437 363 echo '<option value="0" disabled title="' . __( 'Include in chart and select data type', 'visualizer' ) . '">--' . __( 'OR', 'visualizer' ) . '--</option>';
438 364
@@ -449,22 +375,17 @@
449 375 // for remote sources, the data exists inside 'data'.
450 376 if ( array_key_exists( 'data', $data ) ) {
451 377 $data = $data['data'];
452 378 }
453 -
454 379 foreach ( $data as $row ) {
455 380 echo '<tr>';
456 381 echo '<th>' . __( 'Value', 'visualizer' ) . '</th>';
457 382 $index = 0;
458 - if ( empty( $row ) ) {
459 - echo '<td></td>';
460 - continue;
461 - }
462 383 foreach ( array_values( $row ) as $value ) {
463 384 if ( $editable_data ) {
464 - echo '<td><input type="text" name="data' . $index++ . '[]" value="' . esc_attr( stripslashes( $value ) ) . '"></td>';
385 + echo '<td><input type="text" name="data' . $index++ . '[]" value="' . esc_attr( $value ) . '"></td>';
465 386 } else {
466 - echo '<td>' . ( is_array( $value ) ? __( 'Invalid Data', 'visualizer' ) : $value ) . '</td>';
387 + echo '<td>' . $value . '</td>';
467 388 }
468 389 }
469 390
470 391 echo '</tr>';
@@ -475,669 +396,6 @@
475 396 <?php
476 397 if ( ! $echo ) {
477 398 return ob_get_clean();
478 399 }
479 - }
480 -
481 - /**
482 - * Generates the permissions tab.
483 - *
484 - * @access private
485 - */
486 - private static function _renderPermissions( $args ) {
487 - $chart_id = $args[1];
488 -
489 - // ignore for unit tests because Travis throws the error "Indirect modification of overloaded property Visualizer_Render_Page_Data::$permissions has no effect".
490 - if ( defined( 'WP_TESTS_DOMAIN' ) ) {
491 - return;
492 - }
493 -
494 - $permissions = apply_filters( 'visualizer_pro_get_permissions', null, $chart_id );
495 - if ( is_array( $permissions ) ) {
496 - $permissions = $permissions['permissions'];
497 - } else {
498 - $permissions = array();
499 - }
500 - if ( ! isset( $permissions['read'] ) ) {
501 - $permissions['read'] = 'all';
502 - }
503 - if ( ! isset( $permissions['edit'] ) ) {
504 - $permissions['edit'] = 'roles';
505 - $permissions['edit-specific'] = 'administrator';
506 - }
507 -
508 - Visualizer_Render_Sidebar::_renderGroupStart( esc_html__( 'Permissions', 'visualizer' ) . '<span class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' ), 'vz-permissions' );
509 - echo '<div style="position: relative">';
510 - Visualizer_Render_Sidebar::_renderSectionStart();
511 - Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Configure permissions for the chart.', 'visualizer' ) );
512 - Visualizer_Render_Sidebar::_renderSectionEnd();
513 -
514 - Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'Who can see this chart?', 'visualizer' ), false );
515 - Visualizer_Render_Sidebar::_renderSelectItem(
516 - '',
517 - 'permissions[read]',
518 - $permissions['read'],
519 - array(
520 - 'all' => esc_html__( 'All Users', 'visualizer' ),
521 - 'users' => esc_html__( 'Select Users', 'visualizer' ),
522 - 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
523 - ),
524 - '',
525 - false,
526 - array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-read' ),
527 - array(
528 - 'permission-type' => 'read',
529 - )
530 - );
531 -
532 - $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $permissions['read'] ) ? $permissions['read'] : 'roles' );
533 -
534 - Visualizer_Render_Sidebar::_renderSelectItem(
535 - '',
536 - 'permissions[read-specific][]',
537 - isset( $permissions['read-specific'] ) ? $permissions['read-specific'] : array(),
538 - $options,
539 - '',
540 - true,
541 - array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-read-specific' )
542 - );
543 - Visualizer_Render_Sidebar::_renderSectionEnd();
544 -
545 - Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'Who can edit this chart?', 'visualizer' ), false );
546 - Visualizer_Render_Sidebar::_renderSelectItem(
547 - '',
548 - 'permissions[edit]',
549 - $permissions['edit'],
550 - array(
551 - 'all' => esc_html__( 'All Users', 'visualizer' ),
552 - 'users' => esc_html__( 'Select Users', 'visualizer' ),
553 - 'roles' => esc_html__( 'Select Roles', 'visualizer' ),
554 - ),
555 - '',
556 - false,
557 - array( 'visualizer-permission', 'visualizer-permission-type', 'visualizer-permission-edit' ),
558 - array(
559 - 'permission-type' => 'edit',
560 - )
561 - );
562 -
563 - $options = apply_filters( 'visualizer_pro_get_permissions_data', array(), isset( $permissions['edit'] ) ? $permissions['edit'] : 'roles' );
564 -
565 - Visualizer_Render_Sidebar::_renderSelectItem(
566 - '',
567 - 'permissions[edit-specific][]',
568 - isset( $permissions['edit-specific'] ) ? $permissions['edit-specific'] : array(),
569 - $options,
570 - '',
571 - true,
572 - array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-edit-specific' )
573 - );
574 - Visualizer_Render_Sidebar::_renderSectionEnd();
575 - echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions' );
576 - echo '</div>';
577 - Visualizer_Render_Sidebar::_renderGroupEnd();
578 - }
579 -
580 - /**
581 - * Show the Settings tab for this chart.
582 - *
583 - * @access public
584 - */
585 - public static function _renderTabAdvanced( $args ) {
586 - $sidebar = $args[2];
587 - ?>
588 - <ul class="viz-group-wrapper full-height">
589 - <li class="viz-group open" id="vz-chart-settings">
590 - <ul class="viz-group-content">
591 - <ul class="viz-group-wrapper">
592 - <form id="settings-form" action="<?php echo esc_url( add_query_arg( 'nonce', wp_create_nonce() ) ); ?>" method="post">
593 - <input type="hidden" id="chart-img" name="chart-img">
594 - <?php echo $sidebar; ?>
595 - <?php self::_renderPermissions( $args ); ?>
596 - <input type="hidden" name="save" value="1">
597 - </form>
598 - <form id="cancel-form" action="<?php echo esc_url( add_query_arg( 'nonce', wp_create_nonce() ) ); ?>" method="post">
599 - <input type="hidden" name="cancel" value="1">
600 - </form>
601 - </ul>
602 - </ul>
603 - </li>
604 - <?php
605 - }
606 -
607 - /**
608 - * Show the Docs tab for this chart.
609 - *
610 - * @access public
611 - */
612 - public static function _renderTabHelp( $args ) {
613 - $chart_id = $args[1];
614 - $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
615 - switch ( $type ) {
616 - case 'tabular':
617 - $type = 'table';
618 - break;
619 - case 'polarArea':
620 - $type = 'polar-area';
621 - break;
622 - case 'radar':
623 - $type = 'radar-spider';
624 - break;
625 - }
626 -
627 - $displayType = str_replace( '-', '/', $type );
628 - ?>
629 - <ul class="viz-group-wrapper full-height">
630 - <li class="viz-group open" id="vz-chart-help">
631 - <ul class="viz-group-wrapper">
632 - <?php
633 - // open this tab by default.
634 - Visualizer_Render_Sidebar::_renderGroupStart( esc_html__( 'Documentation', 'visualizer' ), '', 'open' );
635 - Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'General', 'visualizer' ), true );
636 - ?>
637 - <h4><span class="dashicons dashicons-editor-help"></span><a href="<?php echo VISUALIZER_MAIN_DOC; ?>" target="_blank"><?php _e( 'Main documentation page', 'visualizer' ); ?></a></h4>
638 - <h4><span class="dashicons dashicons-media-code"></span><a href="<?php echo VISUALIZER_CODE_SNIPPETS_URL; ?>" target="_blank"><?php _e( 'Custom code snippets', 'visualizer' ); ?></a></h4>
639 - <?php
640 - Visualizer_Render_Sidebar::_renderSectionEnd();
641 - Visualizer_Render_Sidebar::_renderSectionStart( sprintf( __( '%s chart', 'visualizer' ), ucwords( $displayType ) ), true );
642 - ?>
643 - <h4><span class="dashicons dashicons-video-alt2"></span>&nbsp;<a href="<?php echo str_replace( '#', "$type-chart", VISUALIZER_DEMO_URL ); ?>" target="_blank"><?php _e( 'View demo', 'visualizer' ); ?></a></h4>
644 - <h4><span class="dashicons dashicons-search"></span><a href="<?php echo str_replace( '#', $type, VISUALIZER_DOC_COLLECTION ); ?>" target="_blank"><?php echo sprintf( __( 'Articles containing "%s"', 'visualizer' ), $displayType ); ?></a></h4>
645 - <?php
646 - Visualizer_Render_Sidebar::_renderSectionEnd();
647 - Visualizer_Render_Sidebar::_renderGroupEnd();
648 - ?>
649 - </ul>
650 - </li>
651 - </ul>
652 -
653 - <?php
654 - }
655 -
656 - /**
657 - * Show the Data Source tab for this chart.
658 - *
659 - * @access public
660 - */
661 - public static function _renderTabBasic( $args ) {
662 - $chart_id = $args[1];
663 -
664 - $upload_link = esc_url(
665 - add_query_arg(
666 - array(
667 - 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
668 - 'nonce' => wp_create_nonce(),
669 - 'chart' => $chart_id,
670 - ),
671 - admin_url( 'admin-ajax.php' )
672 - )
673 - );
674 -
675 - // this will allow us to open the correct source tab by default.
676 - $source_of_chart = strtolower( get_post_meta( $chart_id, Visualizer_Plugin::CF_SOURCE, true ) );
677 - // Import from woocommerce report.
678 - $is_woocommerce_source = strtolower( get_post_meta( $chart_id, Visualizer_Plugin::CF_IS_WOOCOMMERCE_SOURCE, true ) );
679 - if ( ! empty( $is_woocommerce_source ) ) {
680 - $source_of_chart .= '_wc';
681 - }
682 - // both import from wp and import from db have the same source so we need to differentiate.
683 - $filter_config = get_post_meta( $chart_id, Visualizer_Plugin::CF_FILTER_CONFIG, true );
684 - // if filter config is present, then its import from wp.
685 - if ( ! empty( $filter_config ) ) {
686 - $source_of_chart .= '_wp';
687 - }
688 - $editor_type = get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITOR, true );
689 - if ( $editor_type ) {
690 - $source_of_chart = 'visualizer_source_manual';
691 - }
692 -
693 - $type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true );
694 - $lib = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, true );
695 - ?>
696 - <ul class="viz-group-wrapper full-height">
697 - <li class="viz-group open" id="vz-chart-source">
698 - <ul class="viz-group-content">
699 - <ul class="viz-group-wrapper">
700 - <!-- import from file -->
701 - <li class="viz-group visualizer_source_csv">
702 - <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
703 - <div class="viz-group-content">
704 - <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>
705 - <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/' . $type . '.csv" target="_blank">', $type, '.csv</a>' ); ?></b></p>
706 - <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
707 - target="thehole" enctype="multipart/form-data">
708 - <input type="hidden" id="remote-data" name="remote_data">
709 - <div class="">
710 - <input type="file" id="csv-file" name="local_data">
711 - </div>
712 - <input type="button" class="button button-primary" id="vz-import-file"
713 - value="<?php _e( 'Import', 'visualizer' ); ?>">
714 - </form>
715 - </div>
716 - </li>
717 - <!-- import from url -->
718 - <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json">
719 - <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
720 - <ul class="viz-group-content">
721 - <!-- import from csv url -->
722 - <li class="viz-subsection">
723 - <span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span>
724 - <div class="viz-section-items section-items">
725 - <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>
726 - <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/' . $type . '.csv" target="_blank">', $type, '.csv</a>' ); ?></b></p>
727 - <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
728 - target="thehole" enctype="multipart/form-data">
729 - <div class="remote-file-section">
730 - <input type="url" id="vz-schedule-url" name="remote_data" value="<?php echo esc_attr( get_post_meta( $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">
731 - </div>
732 - <select name="vz-import-time" id="vz-import-time" class="visualizer-select">
733 - <?php
734 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
735 - $schedules = apply_filters(
736 - 'visualizer_chart_schedules', array(
737 - '-1' => __( 'One-time', 'visualizer' ),
738 - ),
739 - 'csv',
740 - $chart_id
741 - );
742 - foreach ( $schedules as $num => $name ) {
743 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
744 - $extra = $num == $hours ? 'selected' : '';
745 - ?>
746 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
747 - <?php
748 - }
749 - do_action( 'visualizer_chart_schedules_spl', 'csv', $chart_id, 1 );
750 - ?>
751 - </select>
752 -
753 - <?php
754 - if ( ! Visualizer_Module::is_pro() ) {
755 - ?>
756 - <input type="button" id="view-remote-file" class="button button-primary" value="<?php _e( 'Import', 'visualizer' ); ?>">
757 - <?php
758 - } else {
759 - ?>
760 - <input type="button" id="vz-save-schedule" class="button button-primary" value="<?php _e( 'Import & Save schedule', 'visualizer' ); ?>">
761 - <?php
762 - }
763 - ?>
764 - </form>
765 - </div>
766 - </li>
767 - <!-- import from json url -->
768 - <li class="viz-subsection">
769 - <span class="viz-section-title visualizer_source_json"><?php _e( 'Import from JSON', 'visualizer' ); ?></span>
770 - <div class="viz-section-items section-items">
771 - <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>
772 - <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
773 - <div class="remote-file-section">
774 - <?php
775 - $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
776 - if ( Visualizer_Module::is_pro() ) {
777 - ?>
778 - <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
779 - <select name="time" id="vz-json-time" class="visualizer-select json-form-element" data-chart="<?php echo $chart_id; ?>">
780 - <?php
781 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
782 - $schedules = apply_filters(
783 - 'visualizer_chart_schedules', array(
784 - '-1' => __( 'One-time', 'visualizer' ),
785 - ),
786 - 'json',
787 - $chart_id
788 - );
789 - foreach ( $schedules as $num => $name ) {
790 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
791 - $extra = $num == $hours ? 'selected' : '';
792 - ?>
793 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
794 - <?php
795 - }
796 - do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
797 - ?>
798 - </select>
799 - <?php
800 - }
801 - ?>
802 - </div>
803 -
804 - <input type="button" id="json-chart-button" class="button button-secondary show-chart-toggle"
805 - value="<?php echo $bttn_label; ?>" data-current="chart"
806 - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
807 - data-t-chart="<?php echo $bttn_label; ?>">
808 - <?php
809 - if ( Visualizer_Module::is_pro() ) {
810 - ?>
811 - <input type="button" id="json-chart-save-button" class="button button-primary "
812 - value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
813 - <?php
814 - }
815 - ?>
816 - </form>
817 - </div>
818 - </li>
819 - </ul>
820 - </li>
821 - <!-- import from chart -->
822 - <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
823 - <h2 class="viz-group-title viz-sub-group"
824 - data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
825 - class="dashicons dashicons-lock"></span></h2>
826 - <div class="viz-group-content edit-data-content">
827 - <div>
828 - <p class="viz-group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p>
829 - <form>
830 - <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
831 - <?php
832 - $fetch_link = esc_url(
833 - add_query_arg(
834 - array(
835 - 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '',
836 - 'nonce' => wp_create_nonce(),
837 - ),
838 - admin_url( 'admin-ajax.php' )
839 - )
840 - );
841 - $query_args_charts = array(
842 - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
843 - 'posts_per_page' => 300,
844 - 'no_found_rows' => true,
845 - );
846 - $charts = array();
847 - $query = new WP_Query( $query_args_charts );
848 - while ( $query->have_posts() ) {
849 - $chart = $query->next_post();
850 - $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
851 -
852 - $title = '#' . $chart->ID;
853 - if ( ! empty( $settings['title'] ) ) {
854 - $title = $settings['title'];
855 - }
856 - // for ChartJS, title is an array.
857 - if ( is_array( $title ) && isset( $title['text'] ) ) {
858 - $title = $title['text'];
859 - }
860 - if ( empty( $title ) ) {
861 - $title = '#' . $chart->ID;
862 - }
863 -
864 - ?>
865 - <option value="<?php echo $chart->ID; ?>"><?php echo $title; ?></option>
866 - <?php
867 - }
868 - ?>
869 -
870 - </select>
871 - </form>
872 - <input type="button" id="existing-chart" class="button button-primary"
873 - value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
874 - data-viz-link="<?php echo $fetch_link; ?>">
875 - <?php
876 - if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
877 - echo apply_filters( 'visualizer_pro_upsell', '', 'import-chart' );
878 - }
879 - ?>
880 - </div>
881 - </div>
882 - </li>
883 -
884 - <?php
885 - $save_filter = esc_url(
886 - add_query_arg(
887 - array(
888 - 'action' => Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY,
889 - 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY . Visualizer_Plugin::VERSION ),
890 - 'chart' => $chart_id,
891 - ), admin_url( 'admin-ajax.php' )
892 - )
893 - );
894 - ?>
895 - <!-- import from WordPress -->
896 - <li class="viz-group visualizer_source_query_wp <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wp' ); ?> ">
897 - <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
898 - class="dashicons dashicons-lock"></span></h2>
899 - <div class="viz-group-content edit-data-content">
900 - <div>
901 - <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p>
902 - <form id="vz-filter-wizard" action="<?php echo $save_filter; ?>" method="post" target="thehole">
903 - <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from WordPress.', 'visualizer' ); ?></p>
904 - <select name="refresh" id="vz-filter-import-time" class="visualizer-select">
905 - <?php
906 - $bttn_label = 'visualizer_source_query_wp' === $source_of_chart ? __( 'Modify Filter', 'visualizer' ) : __( 'Create Filter', 'visualizer' );
907 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
908 - $schedules = apply_filters(
909 - 'visualizer_chart_schedules', array(
910 - '-1' => __( 'One-time', 'visualizer' ),
911 - ),
912 - 'wp',
913 - $chart_id
914 - );
915 - foreach ( $schedules as $num => $name ) {
916 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
917 - $extra = $num == $hours ? 'selected' : '';
918 - ?>
919 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
920 - <?php
921 - }
922 - do_action( 'visualizer_chart_schedules_spl', 'wp', $chart_id, 1 );
923 - ?>
924 - </select>
925 -
926 - <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; ?>">
927 - <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
928 - </form>
929 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
930 - </div>
931 - </div>
932 - </li>
933 -
934 - <!-- import from WooCommerce -->
935 - <?php
936 - if ( class_exists( 'WooCommerce', false ) ) :
937 - $wc_source = strtolower( get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_WOOCOMMERCE_SOURCE, true ) );
938 - $wc_source_list = apply_filters(
939 - 'visualizer_woocommerce_report_endpoints',
940 - array(
941 - array(
942 - 'name' => esc_html__( 'Sales', 'visualizer' ),
943 - 'endpoint' => esc_attr( 'sales' ),
944 - ),
945 - array(
946 - 'name' => esc_html__( 'Top Sellers', 'visualizer' ),
947 - 'endpoint' => esc_attr( 'top_sellers' ),
948 - ),
949 - array(
950 - 'name' => esc_html__( 'Coupons Totals', 'visualizer' ),
951 - 'endpoint' => esc_attr( 'coupons/totals' ),
952 - ),
953 - array(
954 - 'name' => esc_html__( 'Customers Totals', 'visualizer' ),
955 - 'endpoint' => esc_attr( 'customers/totals' ),
956 - ),
957 - array(
958 - 'name' => esc_html__( 'Orders Totals', 'visualizer' ),
959 - 'endpoint' => esc_attr( 'orders/totals' ),
960 - ),
961 - array(
962 - 'name' => esc_html__( 'Products Totals', 'visualizer' ),
963 - 'endpoint' => esc_attr( 'products/totals' ),
964 - ),
965 - array(
966 - 'name' => esc_html__( 'Reviews Totals', 'visualizer' ),
967 - 'endpoint' => esc_attr( 'reviews/totals' ),
968 - ),
969 - )
970 - );
971 - ?>
972 - <li class="viz-group visualizer_woocommerce_source<?php echo 'visualizer_source_json_wc' === $source_of_chart ? ' open' : ''; ?> <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wc-report' ); ?> ">
973 - <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WooCommerce Reports', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2>
974 - <div class="viz-group-content edit-data-content">
975 - <div>
976 - <p class="viz-group-description"><?php _e( 'You can choose here to import/synchronize your chart data with a WooCommerce report API. For more info check <a href="https://woocommerce.github.io/woocommerce-rest-api-docs/?shell#reports" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
977 - <form id="vz-import-woo-report" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
978 - <div class="remote-file-section">
979 - <?php
980 - $bttn_label = 'visualizer_source_json_wc' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
981 - ?>
982 - <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
983 - <select name="time" id="vz-woo-time" class="visualizer-select json-form-element" data-chart="<?php echo $chart_id; ?>">
984 - <?php
985 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
986 - $schedules = apply_filters(
987 - 'visualizer_chart_schedules', array(
988 - '-1' => __( 'One-time', 'visualizer' ),
989 - ),
990 - 'json',
991 - $chart_id
992 - );
993 - foreach ( $schedules as $num => $name ) {
994 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
995 - $extra = $num == $hours ? 'selected' : '';
996 - ?>
997 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
998 - <?php
999 - }
1000 - do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 );
1001 - ?>
1002 - </select>
1003 - <p class="viz-group-description"><?php _e( 'Select report endpoint', 'visualizer' ); ?></p>
1004 - <select name="vz_woo_source" id="vz-woo-source" class="visualizer-select json-form-element" data-chart="<?php echo $chart_id; ?>">
1005 - <option value=""></option>
1006 - <?php
1007 - if ( ! empty( $wc_source_list ) ) {
1008 - foreach ( $wc_source_list as $api ) {
1009 - if ( isset( $api['name'] ) && $api['endpoint'] ) {
1010 - echo sprintf( '<option value="%2$s" %3$s>%1$s</option>', $api['name'], $api['endpoint'], selected( $wc_source, $api['endpoint'], false ) ); // phpcs:ignore
1011 - }
1012 - }
1013 - }
1014 - ?>
1015 - </select>
1016 - </div>
1017 -
1018 - <input type="button" id="woo-chart-button" class="button button-secondary show-chart-toggle"
1019 - value="<?php echo $bttn_label; ?>" data-current="chart"
1020 - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
1021 - data-t-chart="<?php echo $bttn_label; ?>"
1022 - <?php empty( $wc_source ) ? 'disabled' : ''; ?>
1023 - >
1024 - <input type="button" id="woo-chart-save-button" class="button button-primary "
1025 - value="<?php _e( 'Save Schedule', 'visualizer' ); ?>" <?php empty( $wc_source ) ? 'disabled' : ''; ?>>
1026 - </form>
1027 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wc-report' ); ?>
1028 - </div>
1029 - </div>
1030 - </li>
1031 - <?php endif; ?>
1032 - <?php
1033 - $save_query = esc_url(
1034 - add_query_arg(
1035 - array(
1036 - 'action' => Visualizer_Plugin::ACTION_SAVE_DB_QUERY,
1037 - 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_DB_QUERY . Visualizer_Plugin::VERSION ),
1038 - 'chart' => $chart_id,
1039 - ), admin_url( 'admin-ajax.php' )
1040 - )
1041 - );
1042 - ?>
1043 - <!-- import from db -->
1044 - <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>">
1045 - <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span
1046 - class="dashicons dashicons-lock"></span></h2>
1047 - <div class="viz-group-content edit-data-content">
1048 - <div>
1049 - <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p>
1050 - <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole">
1051 - <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p>
1052 - <select name="refresh" id="vz-db-import-time" class="visualizer-select">
1053 - <?php
1054 - $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' );
1055 - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
1056 - $schedules = apply_filters(
1057 - 'visualizer_chart_schedules', array(
1058 - '-1' => __( 'One-time', 'visualizer' ),
1059 - ),
1060 - 'db',
1061 - $chart_id
1062 - );
1063 - foreach ( $schedules as $num => $name ) {
1064 - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
1065 - $extra = $num == $hours ? 'selected' : '';
1066 - ?>
1067 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
1068 - <?php
1069 - }
1070 - do_action( 'visualizer_chart_schedules_spl', 'db', $chart_id, 1 );
1071 - ?>
1072 - </select>
1073 - <input type="hidden" name="params" id="viz-db-wizard-params">
1074 -
1075 - <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; ?>">
1076 - <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
1077 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
1078 - </form>
1079 - </div>
1080 - </div>
1081 - </li>
1082 -
1083 - <!-- manual -->
1084 - <li class="viz-group visualizer_source_manual <?php echo ! Visualizer_Module_Admin::proFeaturesLocked() ? apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ) : ''; ?>">
1085 - <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?>
1086 - <span class="dashicons dashicons-lock"></span>
1087 - </h2>
1088 - <div class="viz-group-content edit-data-content">
1089 - <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
1090 - <input type="hidden" id="chart-data" name="chart_data">
1091 - <input type="hidden" id="chart-data-src" name="chart_data_src">
1092 -
1093 - <?php if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { ?>
1094 - <div>
1095 - <p class="viz-group-description viz-editor-selection">
1096 - <?php _e( 'Use the', 'visualizer' ); ?>
1097 - <select name="editor-type" id="viz-editor-type">
1098 - <?php
1099 - if ( empty( $editor_type ) ) {
1100 - $editor_type = Visualizer_Module::is_pro() ? 'excel' : 'text';
1101 - }
1102 - foreach ( apply_filters( 'visualizer_editors', array( 'text' => __( 'Text', 'visualizer' ), 'table' => __( 'Simple', 'visualizer' ) ) ) as $e_type => $e_label ) {
1103 - ?>
1104 - <option value="<?php echo $e_type; ?>" <?php selected( $editor_type, $e_type ); ?> ><?php echo $e_label; ?></option>
1105 - <?php } ?>
1106 - </select>
1107 - <?php _e( 'editor to manually edit the chart data.', 'visualizer' ); ?>
1108 - </p>
1109 - <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
1110 - <input type="button" id="editor-button" class="button button-primary "
1111 - value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart"
1112 - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
1113 - data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>"
1114 - >
1115 - <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>
1116 - </div>
1117 - <?php } else { ?>
1118 - <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
1119 - <input type="button" id="editor-chart-button" class="button button-primary "
1120 - value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
1121 - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
1122 - data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"
1123 - >
1124 - <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>
1125 - <?php } ?>
1126 - <?php
1127 - if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
1128 - echo apply_filters( 'visualizer_pro_upsell', '', 'manual-data' );
1129 - }
1130 - ?>
1131 - </form>
1132 - </div>
1133 - </li>
1134 - </ul>
1135 - </li>
1136 - </ul>
1137 - </ul>
1138 -
1139 - <span id="visualizer-chart-id" data-id="<?php echo $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>
1140 - <iframe id="thehole" name="thehole"></iframe>
1141 - <?php
1142 400 }
1143 401 }