| @@ -37,16 +37,20 @@ | ||
| 37 | 37 | * @access protected |
| 38 | 38 | */ |
| 39 | 39 | protected function _renderContent() { |
| 40 | 40 | // Added by Ash/Upwork |
| 41 | - if ( VISUALIZER_PRO ) { | |
| 42 | - global $Visualizer_Pro; | |
| 43 | - $Visualizer_Pro->_addEditor( $this->chart->ID ); | |
| 44 | - if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) { | |
| 45 | - $Visualizer_Pro->_addFilterWizard( $this->chart->ID ); | |
| 41 | + if ( Visualizer_Module::is_pro() ) { | |
| 42 | + do_action( 'visualizer_add_editor_etc', $this->chart->ID ); | |
| 43 | + | |
| 44 | + if ( Visualizer_Module::is_pro() && Visualizer_Module::is_pro_older_than( '1.9.0' ) ) { | |
| 45 | + global $Visualizer_Pro; | |
| 46 | + $Visualizer_Pro->_addEditor( $this->chart->ID ); | |
| 47 | + if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) { | |
| 48 | + $Visualizer_Pro->_addFilterWizard( $this->chart->ID ); | |
| 49 | + } | |
| 46 | 50 | } |
| 47 | 51 | } else { |
| 48 | - Visualizer_Render_Layout::show( 'faux-editor' ); | |
| 52 | + Visualizer_Render_Layout::show( 'simple-editor-screen', $this->chart->ID ); | |
| 49 | 53 | } |
| 50 | 54 | |
| 51 | 55 | $this->add_additional_content(); |
| 52 | 56 | |
| @@ -75,11 +79,18 @@ | ||
| 75 | 79 | ); |
| 76 | 80 | |
| 77 | 81 | // this will allow us to open the correct source tab by default. |
| 78 | 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 | + } | |
| 79 | 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 ); | |
| 80 | 91 | ?> |
| 81 | - <span id="visualizer-chart-id" data-id="<?php echo $this->chart->ID; ?>" data-chart-source="<?php echo $source_of_chart; ?>" data-chart-type="<?php echo $type; ?>"></span> | |
| 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> | |
| 82 | 93 | <iframe id="thehole" name="thehole"></iframe> |
| 83 | 94 | <ul class="viz-group-wrapper full-height"> |
| 84 | 95 | <li class="viz-group viz-group-category open" id="vz-chart-source"> |
| 85 | 96 | <div class="viz-group-header"> |
| @@ -90,9 +101,9 @@ | ||
| 90 | 101 | <li class="viz-group visualizer_source_csv"> |
| 91 | 102 | <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2> |
| 92 | 103 | <div class="viz-group-content"> |
| 93 | 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> |
| 94 | - <p class="viz-group-description"><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></p> | |
| 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> | |
| 95 | 106 | <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post" |
| 96 | 107 | target="thehole" enctype="multipart/form-data"> |
| 97 | 108 | <input type="hidden" id="remote-data" name="remote_data"> |
| 98 | 109 | <div class=""> |
| @@ -102,9 +113,9 @@ | ||
| 102 | 113 | value="<?php _e( 'Import', 'visualizer' ); ?>"> |
| 103 | 114 | </form> |
| 104 | 115 | </div> |
| 105 | 116 | </li> |
| 106 | - <li class="viz-group visualizer-import-url visualizer_source_csv_remote"> | |
| 117 | + <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json"> | |
| 107 | 118 | <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2> |
| 108 | 119 | <ul class="viz-group-content"> |
| 109 | 120 | <li class="viz-subsection"> |
| 110 | 121 | <span class="viz-section-title"><?php _e( 'One time import', 'visualizer' ); ?></span> |
| @@ -110,10 +121,10 @@ | ||
| 110 | 121 | <span class="viz-section-title"><?php _e( 'One time import', 'visualizer' ); ?></span> |
| 111 | 122 | |
| 112 | 123 | <div class="viz-section-items section-items"> |
| 113 | 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> |
| 114 | - <p class="viz-group-description"><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></p> | |
| 115 | - <p class="viz-group-description"> <?php _e( 'You can also import data from Google Spreadsheet, for more info check <a href="https://github.com/Codeinwp/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank" >this</a> tutorial', '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> | |
| 116 | 127 | <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post" |
| 117 | 128 | target="thehole" enctype="multipart/form-data"> |
| 118 | 129 | <div class="remote-file-section"> |
| 119 | 130 | <input type="url" id="remote-data" name="remote_data" |
| @@ -131,15 +142,15 @@ | ||
| 131 | 142 | <span |
| 132 | 143 | class="dashicons dashicons-lock"></span></span> |
| 133 | 144 | <div class="viz-section-items section-items"> |
| 134 | 145 | <p class="viz-group-description"><?php _e( 'You can choose here to synchronize your chart data with a remote CSV file.', 'visualizer' ); ?> </p> |
| 135 | - <p class="viz-group-description"> <?php _e( 'You can also synchronize with your Google Spreadsheet file, for more info check <a href="https://github.com/Codeinwp/visualizer/wiki/How-can-I-populate-data-from-Google-Spreadsheet%3F" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p> | |
| 136 | - <p class="viz-group-description"> <?php _e( 'We will update the chart data based on your time interval preference by overwritting the current data with the one from the URL.', '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> | |
| 137 | 148 | <form id="vz-schedule-import" action="<?php echo $upload_link; ?>" method="post" |
| 138 | 149 | target="thehole" enctype="multipart/form-data"> |
| 139 | 150 | <div class="remote-file-section"> |
| 140 | 151 | <input type="url" id="vz-schedule-url" name="remote_data" |
| 141 | - value="<?php echo get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ); ?>" | |
| 152 | + value="<?php echo esc_url( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ) ); ?>" | |
| 142 | 153 | placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>" |
| 143 | 154 | class="visualizer-input visualizer-remote-url"> |
| 144 | 155 | <p class="viz-group-description"><?php _e( 'How often do you want to check the url', 'visualizer' ); ?></p> |
| 145 | 156 | <select name="vz-import-time" id="vz-import-time" |
| @@ -151,11 +162,14 @@ | ||
| 151 | 162 | '1' => __( 'Each hour', 'visualizer' ), |
| 152 | 163 | '12' => __( 'Each 12 hours', 'visualizer' ), |
| 153 | 164 | '24' => __( 'Each day', 'visualizer' ), |
| 154 | 165 | '72' => __( 'Each 3 days', 'visualizer' ), |
| 155 | - ) | |
| 166 | + ), | |
| 167 | + 'csv', | |
| 168 | + $this->chart->ID | |
| 156 | 169 | ); |
| 157 | 170 | foreach ( $schedules as $num => $name ) { |
| 171 | + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison | |
| 158 | 172 | $extra = $num == $hours ? 'selected' : ''; |
| 159 | 173 | ?> |
| 160 | 174 | <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option> |
| 161 | 175 | <?php |
| @@ -169,11 +183,63 @@ | ||
| 169 | 183 | <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?> |
| 170 | 184 | </form> |
| 171 | 185 | </div> |
| 172 | 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> | |
| 173 | 239 | </ul> |
| 174 | 240 | </li> |
| 175 | - <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>"> | |
| 241 | + <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>"> | |
| 176 | 242 | <h2 class="viz-group-title viz-sub-group" |
| 177 | 243 | data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span |
| 178 | 244 | class="dashicons dashicons-lock"></span></h2> |
| 179 | 245 | <div class="viz-group-content edit-data-content"> |
| @@ -183,9 +249,9 @@ | ||
| 183 | 249 | <select name="vz-import-from-chart" id="chart-id" class="visualizer-select"> |
| 184 | 250 | <?php |
| 185 | 251 | $fetch_link = add_query_arg( |
| 186 | 252 | array( |
| 187 | - 'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '', | |
| 253 | + 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '', | |
| 188 | 254 | 'nonce' => wp_create_nonce(), |
| 189 | 255 | ), |
| 190 | 256 | admin_url( 'admin-ajax.php' ) |
| 191 | 257 | ); |
| @@ -198,10 +264,23 @@ | ||
| 198 | 264 | $query = new WP_Query( $query_args_charts ); |
| 199 | 265 | while ( $query->have_posts() ) { |
| 200 | 266 | $chart = $query->next_post(); |
| 201 | 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 | + | |
| 202 | 281 | ?> |
| 203 | - <option value="<?php echo $chart->ID; ?>"><?php echo empty( $settings['title'] ) ? '#' . $chart->ID : $settings['title']; ?></option> | |
| 282 | + <option value="<?php echo $chart->ID; ?>"><?php echo $title; ?></option> | |
| 204 | 283 | <?php |
| 205 | 284 | } |
| 206 | 285 | ?> |
| 207 | 286 | |
| @@ -214,18 +293,52 @@ | ||
| 214 | 293 | </div> |
| 215 | 294 | </div> |
| 216 | 295 | </li> |
| 217 | 296 | |
| 218 | - <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?> "> | |
| 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' ); ?> "> | |
| 219 | 307 | <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span |
| 220 | 308 | class="dashicons dashicons-lock"></span></h2> |
| 221 | 309 | <div class="viz-group-content edit-data-content"> |
| 222 | 310 | <div> |
| 223 | 311 | <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p> |
| 224 | - <input type="button" id="filter-chart-button" class="button button-primary " | |
| 225 | - value="<?php _e( 'Create Filters', 'visualizer' ); ?>" data-current="chart" | |
| 226 | - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" | |
| 227 | - data-t-chart="<?php _e( 'Create Filters', 'visualizer' ); ?>"> | |
| 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> | |
| 228 | 341 | <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?> |
| 229 | 342 | </div> |
| 230 | 343 | </div> |
| 231 | 344 | </li> |
| @@ -243,51 +356,47 @@ | ||
| 243 | 356 | <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span |
| 244 | 357 | class="dashicons dashicons-lock"></span></h2> |
| 245 | 358 | <div class="viz-group-content edit-data-content"> |
| 246 | 359 | <div> |
| 247 | - <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p> | |
| 248 | - <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole"> | |
| 249 | - <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p> | |
| 250 | - <select name="refresh" id="vz-db-import-time" class="visualizer-select"> | |
| 251 | - <?php | |
| 252 | - $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' ); | |
| 253 | - $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true ); | |
| 254 | - $schedules = apply_filters( | |
| 255 | - 'visualizer_schedules', array( | |
| 256 | - '0' => __( 'Live', 'visualizer' ), | |
| 257 | - '1' => __( 'Each hour', 'visualizer' ), | |
| 258 | - '12' => __( 'Each 12 hours', 'visualizer' ), | |
| 259 | - '24' => __( 'Each day', 'visualizer' ), | |
| 260 | - '72' => __( 'Each 3 days', 'visualizer' ), | |
| 261 | - ) | |
| 262 | - ); | |
| 263 | - foreach ( $schedules as $num => $name ) { | |
| 264 | - $extra = $num == $hours ? 'selected' : ''; | |
| 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 | + } | |
| 265 | 383 | ?> |
| 266 | - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option> | |
| 267 | - <?php | |
| 268 | - } | |
| 269 | - ?> | |
| 270 | - </select> | |
| 271 | - <input type="hidden" name="params" id="viz-db-wizard-params"> | |
| 384 | + </select> | |
| 385 | + <input type="hidden" name="params" id="viz-db-wizard-params"> | |
| 272 | 386 | |
| 273 | - <input type="button" id="db-chart-button" class="button button-secondary " | |
| 274 | - value="<?php echo $bttn_label; ?>" data-current="chart" | |
| 275 | - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" | |
| 276 | - data-t-chart="<?php echo $bttn_label; ?>"> | |
| 277 | - <input type="button" id="db-chart-save-button" class="button button-primary " | |
| 278 | - value="<?php _e( 'Save Schedule', 'visualizer' ); ?>"> | |
| 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' ); ?>"> | |
| 279 | 389 | <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?> |
| 280 | - </form> | |
| 281 | - </div> | |
| 282 | - </div> | |
| 390 | + </form> | |
| 391 | + </div> | |
| 392 | + </div> | |
| 283 | 393 | </li> |
| 284 | 394 | |
| 285 | 395 | <?php |
| 286 | - // we will auto-open the manual data feature but only when pro is active and source is empty. | |
| 287 | - $pro_class = apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); | |
| 396 | + // we will auto-open the manual data feature only when source is empty. | |
| 288 | 397 | ?> |
| 289 | - <li class="viz-group <?php echo $pro_class; ?> <?php echo empty( $source_of_chart ) && empty( $pro_class ) ? 'open' : ''; ?> "> | |
| 398 | + <li class="viz-group <?php echo empty( $source_of_chart ) ? 'open' : ''; ?> "> | |
| 290 | 399 | <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" |
| 291 | 400 | data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?><span |
| 292 | 401 | class="dashicons dashicons-lock"></span></h2> |
| 293 | 402 | <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole"> |
| @@ -296,15 +405,18 @@ | ||
| 296 | 405 | </form> |
| 297 | 406 | |
| 298 | 407 | <div class="viz-group-content edit-data-content"> |
| 299 | 408 | <div> |
| 300 | - <p class="viz-group-description"><?php _e( 'You can manually edit the chart data using the spreadsheet like editor.', 'visualizer' ); ?></p> | |
| 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 } ?> | |
| 301 | 413 | <input type="button" id="editor-chart-button" class="button button-primary " |
| 302 | 414 | value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart" |
| 303 | 415 | data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>" |
| 304 | 416 | data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"> |
| 305 | 417 | |
| 306 | - <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?> | |
| 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> | |
| 307 | 419 | </div> |
| 308 | 420 | </div> |
| 309 | 421 | </li> |
| 310 | 422 | </ul> |
| @@ -327,11 +439,20 @@ | ||
| 327 | 439 | </form> |
| 328 | 440 | </ul> |
| 329 | 441 | </li> |
| 330 | 442 | |
| 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 | + | |
| 331 | 447 | <?php $this->getPermissionsLink( $this->chart->ID ); ?> |
| 332 | 448 | |
| 333 | - <li class="viz-group bottom-fixed" id="vz-chart-copyright">Visualizer © <?php echo date( 'Y', current_time( 'timestamp' ) ); ?></li> | |
| 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> | |
| 334 | 455 | </ul> |
| 335 | 456 | <?php |
| 336 | 457 | // changed by Ash/Upwork |
| 337 | 458 | } |
| @@ -388,9 +509,9 @@ | ||
| 388 | 509 | Visualizer_Render_Sidebar::_renderGroupStart( |
| 389 | 510 | esc_html__( 'Who can see this chart?', 'visualizer' ) . '<span |
| 390 | 511 | class="dashicons dashicons-lock"></span>', |
| 391 | 512 | '', |
| 392 | - apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' ) | |
| 513 | + 'viz-chart-perm-view ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' ) | |
| 393 | 514 | ); |
| 394 | 515 | Visualizer_Render_Sidebar::_renderSectionStart(); |
| 395 | 516 | Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can view the chart on the front-end.', 'visualizer' ) ); |
| 396 | 517 | |
| @@ -432,9 +553,9 @@ | ||
| 432 | 553 | Visualizer_Render_Sidebar::_renderGroupStart( |
| 433 | 554 | esc_html__( 'Who can edit this chart?', 'visualizer' ) . '<span |
| 434 | 555 | class="dashicons dashicons-lock"></span>', |
| 435 | 556 | '', |
| 436 | - apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' ) | |
| 557 | + 'viz-chart-perm-edit ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' ) | |
| 437 | 558 | ); |
| 438 | 559 | Visualizer_Render_Sidebar::_renderSectionStart(); |
| 439 | 560 | Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can edit the chart on the front-end.', 'visualizer' ) ); |
| 440 | 561 | |
| @@ -510,7 +631,8 @@ | ||
| 510 | 631 | if ( 'visualizer_source_query' === $source ) { |
| 511 | 632 | $query = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_QUERY, true ); |
| 512 | 633 | } |
| 513 | 634 | Visualizer_Render_Layout::show( 'db-query', $query ); |
| 635 | + Visualizer_Render_Layout::show( 'json-screen', $this->chart->ID ); | |
| 514 | 636 | } |
| 515 | 637 | |
| 516 | 638 | } |