| @@ -187,15 +187,10 @@ | ||
| 187 | 187 | $headers['method'] = 'get'; |
| 188 | 188 | } |
| 189 | 189 | $methods = apply_filters( 'visualizer_json_request_methods', array( 'GET', 'POST' ) ); |
| 190 | 190 | |
| 191 | - $auth = isset( $headers['auth'] ) ? $headers['auth'] : ''; | |
| 192 | - $auth_username = is_array( $auth ) && isset( $auth['username'] ) ? $auth['username'] : ''; | |
| 193 | - $auth_password = is_array( $auth ) && isset( $auth['password'] ) ? $auth['password'] : ''; | |
| 194 | - $auth_string = is_string( $auth ) ? $auth : ''; | |
| 195 | - | |
| 196 | 191 | // open the headers by default? |
| 197 | - $headers_open = ! empty( $auth_username ) || ! empty( $auth_string ); | |
| 192 | + $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'] ) ); | |
| 198 | 193 | ?> |
| 199 | 194 | <div id="visualizer-json-screen" style="display: none"> |
| 200 | 195 | <div class="visualizer-json-form"> |
| 201 | 196 | <h3 class="viz-step step1"><?php _e( 'STEP 1: Specify the JSON endpoint/URL', 'visualizer' ); ?></h3> |
| @@ -246,9 +241,9 @@ | ||
| 246 | 241 | <input |
| 247 | 242 | type="text" |
| 248 | 243 | id="vz-import-json-username" |
| 249 | 244 | name="username" |
| 250 | - value="<?php echo esc_attr( $auth_username ); ?>" | |
| 245 | + value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'username', $headers['auth'] ) ? $headers['auth']['username'] : '' ); ?>" | |
| 251 | 246 | placeholder="<?php esc_html_e( 'Username/Access Key', 'visualizer' ); ?>" |
| 252 | 247 | class="json-form-element"> |
| 253 | 248 | & |
| 254 | 249 | <input |
| @@ -254,9 +249,9 @@ | ||
| 254 | 249 | <input |
| 255 | 250 | type="password" |
| 256 | 251 | id="vz-import-json-password" |
| 257 | 252 | name="password" |
| 258 | - value="<?php echo esc_attr( $auth_password ); ?>" | |
| 253 | + value="<?php echo ( array_key_exists( 'auth', $headers ) && array_key_exists( 'password', $headers['auth'] ) ? $headers['auth']['password'] : '' ); ?>" | |
| 259 | 254 | placeholder="<?php esc_html_e( 'Password/Secret Key', 'visualizer' ); ?>" |
| 260 | 255 | class="json-form-element"> |
| 261 | 256 | </div> |
| 262 | 257 | </div> |
| @@ -270,9 +265,9 @@ | ||
| 270 | 265 | <input |
| 271 | 266 | type="text" |
| 272 | 267 | id="vz-import-json-auth" |
| 273 | 268 | name="auth" |
| 274 | - value="<?php echo esc_attr( $auth_string ); ?>" | |
| 269 | + value="<?php echo ( array_key_exists( 'auth', $headers ) && is_string( $headers['auth'] ) ? $headers['auth'] : '' ); ?>" | |
| 275 | 270 | placeholder="<?php esc_html_e( 'e.g. SharedKey <AccountName>:<Signature>', 'visualizer' ); ?>" |
| 276 | 271 | class="visualizer-input json-form-element"> |
| 277 | 272 | </div> |
| 278 | 273 | </div> |
| @@ -278,9 +273,9 @@ | ||
| 278 | 273 | </div> |
| 279 | 274 | <div class="json-wizard-header"> |
| 280 | 275 | <div class="field-title"><?php esc_html_e( 'Additional headers', 'visualizer' ); ?></div> |
| 281 | 276 | <div> |
| 282 | - <textarea name="additional_headers" class="visualizer-input" placeholder="<?php esc_html_e( 'Key:Value, Key2:Value2,...', 'visualizer' ); ?>"><?php echo esc_textarea( isset( $headers['additional_headers'] ) ? $headers['additional_headers'] : '' ); ?></textarea> | |
| 277 | + <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> | |
| 283 | 278 | </div> |
| 284 | 279 | </div> |
| 285 | 280 | </div> |
| 286 | 281 | </div> |
| @@ -293,9 +288,9 @@ | ||
| 293 | 288 | <select name="root" id="vz-import-json-root" class="json-form-element"> |
| 294 | 289 | <?php |
| 295 | 290 | if ( ! empty( $root ) ) { |
| 296 | 291 | ?> |
| 297 | - <option value="<?php echo esc_attr( $root ); ?>"><?php echo esc_html( str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $root ) ); ?></option> | |
| 292 | + <option value="<?php echo esc_attr( $root ); ?>"><?php echo str_replace( Visualizer_Source_Json::TAG_SEPARATOR, Visualizer_Source_Json::TAG_SEPARATOR_VIEW, $root ); ?></option> | |
| 298 | 293 | <?php |
| 299 | 294 | } |
| 300 | 295 | ?> |
| 301 | 296 | </select> |
| @@ -311,9 +306,9 @@ | ||
| 311 | 306 | <option value="0" class="static"><?php _e( 'Get results from the first page only', 'visualizer' ); ?></option> |
| 312 | 307 | <?php |
| 313 | 308 | if ( ! empty( $paging ) ) { |
| 314 | 309 | ?> |
| 315 | - <option value="<?php echo esc_attr( $paging ); ?>"><?php echo esc_html( 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> | |
| 310 | + <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> | |
| 316 | 311 | <?php |
| 317 | 312 | } |
| 318 | 313 | ?> |
| 319 | 314 | </select> |
| @@ -364,9 +359,9 @@ | ||
| 364 | 359 | $action = esc_url( |
| 365 | 360 | add_query_arg( |
| 366 | 361 | array( |
| 367 | 362 | 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA, |
| 368 | - 'nonce' => wp_create_nonce( 'visualizer-upload-data' ), | |
| 363 | + 'nonce' => wp_create_nonce(), | |
| 369 | 364 | 'chart' => $chart_id, |
| 370 | 365 | ), |
| 371 | 366 | admin_url( 'admin-ajax.php' ) |
| 372 | 367 | ) |
| @@ -394,8 +389,9 @@ | ||
| 394 | 389 | <?php Visualizer_Render_Layout::show( 'text-editor', $chart_id ); ?> |
| 395 | 390 | |
| 396 | 391 | </div> |
| 397 | 392 | <?php |
| 393 | + | |
| 398 | 394 | } |
| 399 | 395 | |
| 400 | 396 | /** |
| 401 | 397 | * Show the text area editor. |
| @@ -535,9 +531,9 @@ | ||
| 535 | 531 | private static function _renderPermissions( $args ) { |
| 536 | 532 | $chart_id = $args[1]; |
| 537 | 533 | |
| 538 | 534 | // ignore for unit tests because Travis throws the error "Indirect modification of overloaded property Visualizer_Render_Page_Data::$permissions has no effect". |
| 539 | - if ( defined( 'WP_TESTS_DOMAIN' ) && function_exists( 'tests_add_filter' ) ) { | |
| 535 | + if ( defined( 'WP_TESTS_DOMAIN' ) ) { | |
| 540 | 536 | return; |
| 541 | 537 | } |
| 542 | 538 | |
| 543 | 539 | $permissions = apply_filters( 'visualizer_pro_get_permissions', null, $chart_id ); |
| @@ -620,9 +616,9 @@ | ||
| 620 | 616 | true, |
| 621 | 617 | array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-edit-specific' ) |
| 622 | 618 | ); |
| 623 | 619 | Visualizer_Render_Sidebar::_renderSectionEnd(); |
| 624 | - echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions', 'https://docs.themeisle.com/article/1280-how-to-customize-permissions' ); | |
| 620 | + echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions' ); | |
| 625 | 621 | echo '</div>'; |
| 626 | 622 | Visualizer_Render_Sidebar::_renderGroupEnd(); |
| 627 | 623 | } |
| 628 | 624 | |
| @@ -729,9 +725,9 @@ | ||
| 729 | 725 | $upload_link = esc_url( |
| 730 | 726 | add_query_arg( |
| 731 | 727 | array( |
| 732 | 728 | 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA, |
| 733 | - 'nonce' => wp_create_nonce( 'visualizer-upload-data' ), | |
| 729 | + 'nonce' => wp_create_nonce(), | |
| 734 | 730 | 'chart' => $chart_id, |
| 735 | 731 | ), |
| 736 | 732 | admin_url( 'admin-ajax.php' ) |
| 737 | 733 | ) |
| @@ -766,9 +762,9 @@ | ||
| 766 | 762 | <ul class="viz-group-content"> |
| 767 | 763 | <ul class="viz-group-wrapper"> |
| 768 | 764 | <!-- manual --> |
| 769 | 765 | <li class="viz-group visualizer_source_manual"> |
| 770 | - <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart" role="button" tabindex="0"><?php _e( 'Manual Data', 'visualizer' ); ?></h2> | |
| 766 | + <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?></h2> | |
| 771 | 767 | <div class="viz-group-content edit-data-content"> |
| 772 | 768 | <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole"> |
| 773 | 769 | <input type="hidden" id="chart-data" name="chart_data"> |
| 774 | 770 | <input type="hidden" id="chart-data-src" name="chart_data_src"> |
| @@ -790,22 +786,22 @@ | ||
| 790 | 786 | <?php _e( 'editor to manually edit the chart data.', 'visualizer' ); ?> |
| 791 | 787 | </p> |
| 792 | 788 | <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>"> |
| 793 | 789 | <input type="button" id="editor-button" class="button button-primary " |
| 794 | - value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart" | |
| 795 | - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>" | |
| 796 | - data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>" | |
| 790 | + value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart" | |
| 791 | + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>" | |
| 792 | + data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>" | |
| 797 | 793 | > |
| 798 | - <p class="viz-group-description viz-info-msg" style="display:none"><?php echo sprintf( __( 'Please make sure you click \'Show Chart\' before you save the chart.', 'visualizer' ) ); ?></p> | |
| 794 | + <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> | |
| 799 | 795 | </div> |
| 800 | 796 | <?php } else { ?> |
| 801 | 797 | <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>"> |
| 802 | 798 | <input type="button" id="editor-chart-button" class="button button-primary " |
| 803 | - value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart" | |
| 804 | - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>" | |
| 805 | - data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>" | |
| 799 | + value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart" | |
| 800 | + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>" | |
| 801 | + data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>" | |
| 806 | 802 | > |
| 807 | - <p class="viz-group-description viz-info-msg" style="display:none"><?php echo sprintf( __( 'Please make sure you click \'Show Chart\' before you save the chart.', 'visualizer' ) ); ?></p> | |
| 803 | + <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> | |
| 808 | 804 | <?php } ?> |
| 809 | 805 | </form> |
| 810 | 806 | </div> |
| 811 | 807 | </li> |
| @@ -811,12 +807,12 @@ | ||
| 811 | 807 | </li> |
| 812 | 808 | |
| 813 | 809 | <!-- import from file --> |
| 814 | 810 | <li class="viz-group visualizer_source_csv <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-file' ); ?> "> |
| 815 | - <h2 class="viz-group-title viz-sub-group visualizer-src-tab" role="button" tabindex="0"><?php _e( 'Import data from file', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2> | |
| 811 | + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2> | |
| 816 | 812 | <div class="viz-group-content"> |
| 817 | 813 | <div> |
| 818 | - <p class="viz-group-description"><?php esc_html_e( 'Select and upload your data file here. Supported formats: CSV, XLSX. The first row should contain the column headings. The second row should contain the series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' ); ?></p> | |
| 814 | + <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> | |
| 819 | 815 | <p class="viz-group-description viz-info-msg"> |
| 820 | 816 | <b> |
| 821 | 817 | <?php |
| 822 | 818 | echo sprintf( |
| @@ -830,9 +826,9 @@ | ||
| 830 | 826 | <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post" |
| 831 | 827 | target="thehole" enctype="multipart/form-data"> |
| 832 | 828 | <input type="hidden" id="remote-data" name="remote_data"> |
| 833 | 829 | <div class=""> |
| 834 | - <input type="file" id="csv-file" name="local_data" accept=".csv,.xlsx"> | |
| 830 | + <input type="file" id="csv-file" name="local_data"> | |
| 835 | 831 | </div> |
| 836 | 832 | <input type="button" class="button button-primary" id="vz-import-file" |
| 837 | 833 | value="<?php _e( 'Import', 'visualizer' ); ?>"> |
| 838 | 834 | </form> |
| @@ -841,13 +837,13 @@ | ||
| 841 | 837 | </div> |
| 842 | 838 | </li> |
| 843 | 839 | <!-- import from url --> |
| 844 | 840 | <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-url' ); ?> "> |
| 845 | - <h2 class="viz-group-title viz-sub-group visualizer-src-tab" role="button" tabindex="0"><?php _e( 'Import data from URL', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2> | |
| 841 | + <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2> | |
| 846 | 842 | <ul class="viz-group-content"> |
| 847 | 843 | <!-- import from csv url --> |
| 848 | 844 | <li class="viz-subsection"> |
| 849 | - <span class="viz-section-title" role="button" tabindex="0"><?php _e( 'Import from CSV / XLSX', 'visualizer' ); ?></span> | |
| 845 | + <span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span> | |
| 850 | 846 | <div class="only-pro-anchor"> |
| 851 | 847 | <div class="viz-section-items section-items"> |
| 852 | 848 | <p class="viz-group-description"> |
| 853 | 849 | <?php |
| @@ -852,9 +848,9 @@ | ||
| 852 | 848 | <p class="viz-group-description"> |
| 853 | 849 | <?php |
| 854 | 850 | echo sprintf( |
| 855 | 851 | // translators: %1$s - HTML link tag, %2$s - HTML closing link tag. |
| 856 | - __( 'You can use this to import data from a remote CSV or Excel (XLSX) file, or %1$sGoogle Spreadsheet%2$s.', 'visualizer' ), | |
| 852 | + __( 'You can use this to import data from a remote CSV file or %1$sGoogle Spreadsheet%2$s.', 'visualizer' ), | |
| 857 | 853 | '<a href="https://docs.themeisle.com/article/607-how-can-i-populate-data-from-google-spreadsheet" target="_blank" >', |
| 858 | 854 | '</a>' |
| 859 | 855 | ); |
| 860 | 856 | ?> |
| @@ -872,9 +868,9 @@ | ||
| 872 | 868 | </p> |
| 873 | 869 | <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post" |
| 874 | 870 | target="thehole" enctype="multipart/form-data"> |
| 875 | 871 | <div class="remote-file-section"> |
| 876 | - <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 a CSV or XLSX file', 'visualizer' ); ?>" class="visualizer-input visualizer-remote-url"> | |
| 872 | + <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"> | |
| 877 | 873 | </div> |
| 878 | 874 | <select name="vz-import-time" id="vz-import-time" class="visualizer-select"> |
| 879 | 875 | <?php |
| 880 | 876 | $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_SCHEDULE, true ); |
| @@ -888,9 +884,9 @@ | ||
| 888 | 884 | foreach ( $schedules as $num => $name ) { |
| 889 | 885 | // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
| 890 | 886 | $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : ''; |
| 891 | 887 | ?> |
| 892 | - <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option> | |
| 888 | + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option> | |
| 893 | 889 | <?php |
| 894 | 890 | } |
| 895 | 891 | do_action( 'visualizer_chart_schedules_spl', 'csv', $chart_id, 1 ); |
| 896 | 892 | ?> |
| @@ -913,9 +909,9 @@ | ||
| 913 | 909 | </div> |
| 914 | 910 | </li> |
| 915 | 911 | <!-- import from json url --> |
| 916 | 912 | <li class="viz-subsection"> |
| 917 | - <span class="viz-section-title visualizer_source_json" role="button" tabindex="0"><?php _e( 'Import from JSON', 'visualizer' ); ?></span> | |
| 913 | + <span class="viz-section-title visualizer_source_json"><?php _e( 'Import from JSON', 'visualizer' ); ?></span> | |
| 918 | 914 | <div class="only-pro-anchor"> |
| 919 | 915 | <div class="viz-section-items section-items"> |
| 920 | 916 | <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> |
| 921 | 917 | <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data"> |
| @@ -938,9 +934,9 @@ | ||
| 938 | 934 | foreach ( $schedules as $num => $name ) { |
| 939 | 935 | // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
| 940 | 936 | $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : ''; |
| 941 | 937 | ?> |
| 942 | - <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option> | |
| 938 | + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option> | |
| 943 | 939 | <?php |
| 944 | 940 | } |
| 945 | 941 | do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 ); |
| 946 | 942 | ?> |
| @@ -971,9 +967,9 @@ | ||
| 971 | 967 | </li> |
| 972 | 968 | <!-- import from chart --> |
| 973 | 969 | <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>"> |
| 974 | 970 | <h2 class="viz-group-title viz-sub-group" |
| 975 | - data-current="chart" role="button" tabindex="0"><?php _e( 'Import from other chart', 'visualizer' ); ?><span | |
| 971 | + data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span | |
| 976 | 972 | class="dashicons dashicons-lock"></span></h2> |
| 977 | 973 | <div class="viz-group-content edit-data-content"> |
| 978 | 974 | <div> |
| 979 | 975 | <p class="viz-group-description"><?php _e( 'You can import here data from your previously created charts', 'visualizer' ); ?></p> |
| @@ -983,9 +979,9 @@ | ||
| 983 | 979 | $fetch_link = esc_url( |
| 984 | 980 | add_query_arg( |
| 985 | 981 | array( |
| 986 | 982 | 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '', |
| 987 | - 'nonce' => Visualizer_Module::is_pro() ? wp_create_nonce( Visualizer_Pro::ACTION_FETCH_DATA ) : wp_create_nonce(), | |
| 983 | + 'nonce' => wp_create_nonce(), | |
| 988 | 984 | ), |
| 989 | 985 | admin_url( 'admin-ajax.php' ) |
| 990 | 986 | ) |
| 991 | 987 | ); |
| @@ -1020,12 +1016,12 @@ | ||
| 1020 | 1016 | |
| 1021 | 1017 | </select> |
| 1022 | 1018 | </form> |
| 1023 | 1019 | <input type="button" id="existing-chart" class="button button-primary" |
| 1024 | - value="<?php _e( 'Import Chart', 'visualizer' ); ?>" | |
| 1025 | - data-viz-link="<?php echo $fetch_link; ?>"> | |
| 1020 | + value="<?php _e( 'Import Chart', 'visualizer' ); ?>" | |
| 1021 | + data-viz-link="<?php echo $fetch_link; ?>"> | |
| 1026 | 1022 | <?php |
| 1027 | - if ( ! Visualizer_Module_Admin::proFeaturesEnabled() ) { | |
| 1023 | + if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) { | |
| 1028 | 1024 | echo apply_filters( 'visualizer_pro_upsell', '', 'import-chart' ); |
| 1029 | 1025 | } |
| 1030 | 1026 | ?> |
| 1031 | 1027 | </div> |
| @@ -1043,54 +1039,41 @@ | ||
| 1043 | 1039 | ) |
| 1044 | 1040 | ); |
| 1045 | 1041 | ?> |
| 1046 | 1042 | <!-- import from WordPress --> |
| 1047 | - <li class="viz-group visualizer_source_query_wp <?php echo esc_attr( apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wp' ) ); ?> "> | |
| 1048 | - <h2 class="viz-group-title viz-sub-group" role="button" tabindex="0"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span | |
| 1043 | + <li class="viz-group visualizer_source_query_wp <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wp' ); ?> "> | |
| 1044 | + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span | |
| 1049 | 1045 | class="dashicons dashicons-lock"></span></h2> |
| 1050 | 1046 | <div class="viz-group-content edit-data-content"> |
| 1051 | 1047 | <div> |
| 1052 | 1048 | <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p> |
| 1053 | - <form id="vz-filter-wizard" action="<?php echo esc_url( $save_filter ); ?>" method="post" target="thehole"> | |
| 1049 | + <form id="vz-filter-wizard" action="<?php echo $save_filter; ?>" method="post" target="thehole"> | |
| 1050 | + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from WordPress.', 'visualizer' ); ?></p> | |
| 1051 | + <select name="refresh" id="vz-filter-import-time" class="visualizer-select"> | |
| 1054 | 1052 | <?php |
| 1055 | - $is_wp_source = 'visualizer_source_query_wp' === $source_of_chart; | |
| 1056 | - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true ); | |
| 1057 | - $bttn_label = $is_wp_source ? '1. ' . __( 'Modify Data Source', 'visualizer' ) : '1. ' . __( 'Choose Data Source', 'visualizer' ); | |
| 1053 | + $bttn_label = 'visualizer_source_query_wp' === $source_of_chart ? __( 'Modify Filter', 'visualizer' ) : __( 'Create Filter', 'visualizer' ); | |
| 1054 | + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true ); | |
| 1055 | + $schedules = apply_filters( | |
| 1056 | + 'visualizer_chart_schedules', array( | |
| 1057 | + '-1' => __( 'One-time', 'visualizer' ), | |
| 1058 | + ), | |
| 1059 | + 'wp', | |
| 1060 | + $chart_id | |
| 1061 | + ); | |
| 1062 | + foreach ( $schedules as $num => $name ) { | |
| 1063 | + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : ''; | |
| 1064 | + ?> | |
| 1065 | + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option> | |
| 1066 | + <?php | |
| 1067 | + } | |
| 1068 | + do_action( 'visualizer_chart_schedules_spl', 'wp', $chart_id, 1 ); | |
| 1058 | 1069 | ?> |
| 1070 | + </select> | |
| 1059 | 1071 | |
| 1060 | - <!-- Step 1: Choose / modify data source --> | |
| 1061 | - <input type="button" id="filter-chart-button" class="button button-secondary show-chart-toggle vz-import-step-btn" value="<?php echo esc_attr( $bttn_label ); ?>" data-current="chart" data-t-filter="<?php esc_attr_e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo esc_attr( $bttn_label ); ?>"> | |
| 1062 | - | |
| 1063 | - <!-- Step 2: Sync schedule toggle --> | |
| 1064 | - <div id="vz-wp-sync-step"> | |
| 1065 | - <button type="button" id="vz-wp-sync-btn" class="vz-import-step-toggle" aria-expanded="<?php echo $is_wp_source ? 'true' : 'false'; ?>"> | |
| 1066 | - <?php echo '2. ' . __( 'Set Sync Schedule', 'visualizer' ); ?> | |
| 1067 | - <span class="dashicons dashicons-arrow-down-alt2"></span> | |
| 1068 | - </button> | |
| 1069 | - <div id="vz-wp-sync-options"<?php echo $is_wp_source ? '' : ' style="display:none"'; ?>> | |
| 1070 | - <select name="refresh" id="vz-filter-import-time" class="visualizer-select"> | |
| 1071 | - <?php | |
| 1072 | - $schedules = apply_filters( | |
| 1073 | - 'visualizer_chart_schedules', array( | |
| 1074 | - '-1' => __( 'One-time', 'visualizer' ), | |
| 1075 | - ), | |
| 1076 | - 'wp', | |
| 1077 | - $chart_id | |
| 1078 | - ); | |
| 1079 | - foreach ( $schedules as $num => $name ) { | |
| 1080 | - $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : ''; | |
| 1081 | - ?> | |
| 1082 | - <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option> | |
| 1083 | - <?php | |
| 1084 | - } | |
| 1085 | - do_action( 'visualizer_chart_schedules_spl', 'wp', $chart_id, 1 ); | |
| 1086 | - ?> | |
| 1087 | - </select> | |
| 1088 | - <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>"> | |
| 1089 | - </div> | |
| 1090 | - </div> | |
| 1072 | + <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; ?>"> | |
| 1073 | + <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>"> | |
| 1091 | 1074 | </form> |
| 1092 | - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp', 'https://docs.themeisle.com/article/1278-how-to-import-data-from-wordpress' ); ?> | |
| 1075 | + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?> | |
| 1093 | 1076 | </div> |
| 1094 | 1077 | </div> |
| 1095 | 1078 | </li> |
| 1096 | 1079 | |
| @@ -1132,9 +1115,9 @@ | ||
| 1132 | 1115 | ) |
| 1133 | 1116 | ); |
| 1134 | 1117 | ?> |
| 1135 | 1118 | <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' ); ?> "> |
| 1136 | - <h2 class="viz-group-title viz-sub-group" role="button" tabindex="0"><?php _e( 'Import from WooCommerce Reports', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2> | |
| 1119 | + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WooCommerce Reports', 'visualizer' ); ?><span class="dashicons dashicons-lock"></span></h2> | |
| 1137 | 1120 | <div class="viz-group-content edit-data-content"> |
| 1138 | 1121 | <div> |
| 1139 | 1122 | <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> |
| 1140 | 1123 | <form id="vz-import-woo-report" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data"> |
| @@ -1155,9 +1138,9 @@ | ||
| 1155 | 1138 | ); |
| 1156 | 1139 | foreach ( $schedules as $num => $name ) { |
| 1157 | 1140 | $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : ''; |
| 1158 | 1141 | ?> |
| 1159 | - <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option> | |
| 1142 | + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option> | |
| 1160 | 1143 | <?php |
| 1161 | 1144 | } |
| 1162 | 1145 | do_action( 'visualizer_chart_schedules_spl', 'json', $chart_id, 1 ); |
| 1163 | 1146 | ?> |
| @@ -1202,54 +1185,41 @@ | ||
| 1202 | 1185 | ) |
| 1203 | 1186 | ); |
| 1204 | 1187 | ?> |
| 1205 | 1188 | <!-- import from db --> |
| 1206 | - <li class="viz-group visualizer_source_query <?php echo esc_attr( apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ) ); ?>"> | |
| 1207 | - <h2 class="viz-group-title viz-sub-group" role="button" tabindex="0"><?php _e( 'Import from database', 'visualizer' ); ?><span | |
| 1189 | + <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>"> | |
| 1190 | + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span | |
| 1208 | 1191 | class="dashicons dashicons-lock"></span></h2> |
| 1209 | 1192 | <div class="viz-group-content edit-data-content"> |
| 1210 | 1193 | <div> |
| 1211 | 1194 | <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p> |
| 1212 | - <form id="vz-db-wizard" action="<?php echo esc_url( $save_query ); ?>" method="post" target="thehole"> | |
| 1195 | + <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole"> | |
| 1196 | + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p> | |
| 1197 | + <select name="refresh" id="vz-db-import-time" class="visualizer-select"> | |
| 1213 | 1198 | <?php |
| 1214 | - $is_db_source = 'visualizer_source_query' === $source_of_chart; | |
| 1215 | - $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true ); | |
| 1216 | - $bttn_label = $is_db_source ? __( '1. Modify Data Source', 'visualizer' ) : __( '1. Choose Data Source', 'visualizer' ); | |
| 1199 | + $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' ); | |
| 1200 | + $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true ); | |
| 1201 | + $schedules = apply_filters( | |
| 1202 | + 'visualizer_chart_schedules', array( | |
| 1203 | + '-1' => __( 'One-time', 'visualizer' ), | |
| 1204 | + ), | |
| 1205 | + 'db', | |
| 1206 | + $chart_id | |
| 1207 | + ); | |
| 1208 | + foreach ( $schedules as $num => $name ) { | |
| 1209 | + $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : ''; | |
| 1210 | + ?> | |
| 1211 | + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option> | |
| 1212 | + <?php | |
| 1213 | + } | |
| 1214 | + do_action( 'visualizer_chart_schedules_spl', 'db', $chart_id, 1 ); | |
| 1217 | 1215 | ?> |
| 1218 | - | |
| 1219 | - <!-- Step 1: Choose / modify data source --> | |
| 1216 | + </select> | |
| 1220 | 1217 | <input type="hidden" name="params" id="viz-db-wizard-params"> |
| 1221 | - <input type="button" id="db-chart-button" class="button button-secondary show-chart-toggle vz-import-step-btn" value="<?php echo esc_attr( $bttn_label ); ?>" data-current="chart" data-t-filter="<?php esc_attr_e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo esc_attr( $bttn_label ); ?>"> | |
| 1222 | 1218 | |
| 1223 | - <!-- Step 2: Sync schedule toggle --> | |
| 1224 | - <div id="vz-db-sync-step"> | |
| 1225 | - <button type="button" id="vz-db-sync-btn" class="vz-import-step-toggle" aria-expanded="<?php echo $is_db_source ? 'true' : 'false'; ?>"> | |
| 1226 | - <?php echo '2. ' . __( 'Set Sync Schedule', 'visualizer' ); ?> | |
| 1227 | - <span class="dashicons dashicons-arrow-down-alt2"></span> | |
| 1228 | - </button> | |
| 1229 | - <div id="vz-db-sync-options"<?php echo $is_db_source ? '' : ' style="display:none"'; ?>> | |
| 1230 | - <select name="refresh" id="vz-db-import-time" class="visualizer-select"> | |
| 1231 | - <?php | |
| 1232 | - $schedules = apply_filters( | |
| 1233 | - 'visualizer_chart_schedules', array( | |
| 1234 | - '-1' => __( 'One-time', 'visualizer' ), | |
| 1235 | - ), | |
| 1236 | - 'db', | |
| 1237 | - $chart_id | |
| 1238 | - ); | |
| 1239 | - foreach ( $schedules as $num => $name ) { | |
| 1240 | - $extra = self::is_hour_selected( $hours, $num ) ? 'selected' : ''; | |
| 1241 | - ?> | |
| 1242 | - <option value="<?php echo esc_attr( $num ); ?>" <?php echo esc_attr( $extra ); ?>><?php echo esc_html( $name ); ?></option> | |
| 1243 | - <?php | |
| 1244 | - } | |
| 1245 | - do_action( 'visualizer_chart_schedules_spl', 'db', $chart_id, 1 ); | |
| 1246 | - ?> | |
| 1247 | - </select> | |
| 1248 | - <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>"> | |
| 1249 | - </div> | |
| 1250 | - </div> | |
| 1251 | - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query', 'https://docs.themeisle.com/article/1279-how-to-import-data-from-a-database' ); ?> | |
| 1219 | + <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; ?>"> | |
| 1220 | + <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>"> | |
| 1221 | + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?> | |
| 1252 | 1222 | </form> |
| 1253 | 1223 | </div> |
| 1254 | 1224 | </div> |
| 1255 | 1225 | </li> |