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