PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.2
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | classes/Visualizer/Render/Page/Data.php +321 -91 3.0.53.4.2 View file →
@@ -37,19 +37,31 @@
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::can_show_feature( 'simple-editor' ) ) {
42 + Visualizer_Render_Layout::show( 'simple-editor-screen', $this->chart->ID );
43 + }
44 +
45 + if ( Visualizer_Module::is_pro() ) {
46 + do_action( 'visualizer_add_editor_etc', $this->chart->ID );
47 +
48 + if ( Visualizer_Module::is_pro() && Visualizer_Module::is_pro_older_than( '1.9.0' ) ) {
49 + global $Visualizer_Pro;
50 + $Visualizer_Pro->_addEditor( $this->chart->ID );
51 + if ( method_exists( $Visualizer_Pro, '_addFilterWizard' ) ) {
52 + $Visualizer_Pro->_addFilterWizard( $this->chart->ID );
53 + }
46 54 }
47 55 }
56 +
57 + $this->add_additional_content();
58 +
48 59 // Added by Ash/Upwork
49 60 echo '<div id="canvas">';
50 61 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
51 62 echo '</div>';
63 + echo $this->custom_css;
52 64 }
53 65
54 66 /**
55 67 * Renders sidebar content.
@@ -63,12 +75,29 @@
63 75 array(
64 76 'action' => Visualizer_Plugin::ACTION_UPLOAD_DATA,
65 77 'nonce' => wp_create_nonce(),
66 78 'chart' => $this->chart->ID,
67 - ), admin_url( 'admin-ajax.php' )
79 + ),
80 + admin_url( 'admin-ajax.php' )
68 81 );
82 +
83 + // this will allow us to open the correct source tab by default.
84 + $source_of_chart = strtolower( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SOURCE, true ) );
85 + // both import from wp and import from db have the same source so we need to differentiate.
86 + $filter_config = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_FILTER_CONFIG, true );
87 + // if filter config is present, then its import from wp.
88 + if ( ! empty( $filter_config ) ) {
89 + $source_of_chart .= '_wp';
90 + }
91 + $editor_type = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_EDITOR, true );
92 + if ( $editor_type ) {
93 + $source_of_chart = 'visualizer_source_manual';
94 + }
95 +
96 + $type = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
97 + $lib = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_LIBRARY, true );
69 98 ?>
70 - <span id="visualizer-chart-id" data-id="<?php echo $this->chart->ID; ?>"></span>
99 + <span id="visualizer-chart-id" data-id="<?php echo $this->chart->ID; ?>" data-chart-source="<?php echo esc_attr( $source_of_chart ); ?>" data-chart-type="<?php echo esc_attr( $type ); ?>" data-chart-lib="<?php echo esc_attr( $lib ); ?>"></span>
71 100 <iframe id="thehole" name="thehole"></iframe>
72 101 <ul class="viz-group-wrapper full-height">
73 102 <li class="viz-group viz-group-category open" id="vz-chart-source">
74 103 <div class="viz-group-header">
@@ -75,13 +104,14 @@
75 104 <h2 class="viz-group-title viz-main-group"><?php _e( 'Chart Data', 'visualizer' ); ?></h2>
76 105 </div>
77 106 <ul class="viz-group-content">
78 107 <ul class="viz-group-wrapper">
79 - <li class="viz-group">
108 + <!-- import from file -->
109 + <li class="viz-group visualizer_source_csv">
80 110 <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from file', 'visualizer' ); ?></h2>
81 111 <div class="viz-group-content">
82 112 <p class="viz-group-description"><?php esc_html_e( 'Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' ); ?></p>
83 - <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>
113 + <p class="viz-group-description viz-info-msg"><b><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></b></p>
84 114 <form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
85 115 target="thehole" enctype="multipart/form-data">
86 116 <input type="hidden" id="remote-data" name="remote_data">
87 117 <div class="">
@@ -91,76 +121,113 @@
91 121 value="<?php _e( 'Import', 'visualizer' ); ?>">
92 122 </form>
93 123 </div>
94 124 </li>
95 - <li class="viz-group visualizer-import-url">
125 + <!-- import from url -->
126 + <li class="viz-group visualizer-import-url visualizer_source_csv_remote visualizer_source_json">
96 127 <h2 class="viz-group-title viz-sub-group visualizer-src-tab"><?php _e( 'Import data from URL', 'visualizer' ); ?></h2>
97 128 <ul class="viz-group-content">
129 + <!-- import from csv url -->
98 130 <li class="viz-subsection">
99 - <span class="viz-section-title"><?php _e( 'One time import', 'visualizer' ); ?></span>
100 -
131 + <span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span>
101 132 <div class="viz-section-items section-items">
102 - <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>
103 - <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>
104 - <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>
133 + <p class="viz-group-description"><?php echo sprintf( __( 'You can use this to import data from a remote CSV file or %1$sGoogle Spreadsheet%2$s.', 'visualizer' ), '<a href="https://docs.themeisle.com/article/607-how-can-i-populate-data-from-google-spreadsheet" target="_blank" >', '</a>' ); ?> </p>
134 + <p class="viz-group-description viz-info-msg"><b><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $this->type . '.csv" target="_blank">', $this->type, '.csv</a>' ); ?></b></p>
105 135 <form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
106 136 target="thehole" enctype="multipart/form-data">
107 137 <div class="remote-file-section">
108 - <input type="url" id="remote-data" name="remote_data"
109 - placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
110 - class="visualizer-input">
138 + <input type="url" id="vz-schedule-url" name="remote_data" value="<?php echo esc_attr( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ) ); ?>" placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>" class="visualizer-input visualizer-remote-url">
139 + </div>
140 + <select name="vz-import-time" id="vz-import-time" class="visualizer-select">
141 + <?php
142 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
143 + $schedules = apply_filters(
144 + 'visualizer_chart_schedules', array(
145 + '-1' => __( 'One-time', 'visualizer' ),
146 + ),
147 + 'csv',
148 + $this->chart->ID
149 + );
150 + foreach ( $schedules as $num => $name ) {
151 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
152 + $extra = $num == $hours ? 'selected' : '';
153 + ?>
154 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
155 + <?php
156 + }
157 + do_action( 'visualizer_chart_schedules_spl', 'csv', $this->chart->ID, 1 );
158 + ?>
159 + </select>
111 160
112 - </div>
113 - <input type="button" id="view-remote-file" class="button button-primary"
114 - value="<?php _e( 'Import', 'visualizer' ); ?>">
161 + <input type="button" id="view-remote-file" class="button <?php echo Visualizer_Module::is_pro() ? 'button-secondary' : 'button-primary'; ?>" value="<?php _e( 'Import', 'visualizer' ); ?>">
162 + <?php
163 + if ( Visualizer_Module::is_pro() ) {
164 + ?>
165 + <input type="button" id="vz-save-schedule" class="button button-primary" value="<?php _e( 'Save schedule', 'visualizer' ); ?>">
166 + <?php
167 + }
168 + ?>
115 169 </form>
116 170 </div>
117 171 </li>
118 - <li class="viz-subsection <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?>">
119 - <span class="viz-section-title visualizer-import-url-schedule"><?php _e( 'Schedule Import', 'visualizer' ); ?>
120 - <span
121 - class="dashicons dashicons-lock"></span></span>
172 + <!-- import from json url -->
173 + <li class="viz-subsection">
174 + <span class="viz-section-title visualizer_source_json"><?php _e( 'Import from JSON', 'visualizer' ); ?>
175 + <span class="dashicons dashicons-lock"></span></span>
122 176 <div class="viz-section-items section-items">
123 - <p class="viz-group-description"><?php _e( 'You can choose here to synchronize your chart data with a remote CSV file.', 'visualizer' ); ?> </p>
124 - <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>
125 - <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>
126 - <form id="vz-schedule-import" action="<?php echo $upload_link; ?>" method="post"
127 - target="thehole" enctype="multipart/form-data">
177 + <p class="viz-group-description"><?php _e( 'You can choose here to import/synchronize your chart data with a remote JSON source. For more info check <a href="https://docs.themeisle.com/article/1052-how-to-generate-charts-from-json-data-rest-endpoints" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
178 + <form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
128 179 <div class="remote-file-section">
129 - <input type="url" id="vz-schedule-url" name="remote_data"
130 - value="<?php echo get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_URL, true ); ?>"
131 - placeholder="<?php esc_html_e( 'Please enter the URL of CSV file', 'visualizer' ); ?>"
132 - class="visualizer-input visualizer-remote-url">
133 - <p class="viz-group-description"><?php _e( 'How often do you want to check the url', 'visualizer' ); ?></p>
134 - <select name="vz-import-time" id="vz-import-time"
135 - class="visualizer-select">
136 180 <?php
137 - $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_CHART_SCHEDULE, true );
138 - $schedules = array(
139 - '1' => __( 'Each hour', 'visualizer' ),
140 - '12' => __( 'Each 12 hours', 'visualizer' ),
141 - '24' => __( 'Each day', 'visualizer' ),
142 - '36' => __( 'Each 3 days', 'visualizer' ),
143 - );
144 - foreach ( $schedules as $num => $name ) {
145 - $extra = $num == $hours ? 'selected' : '';
181 + $bttn_label = 'visualizer_source_json' === $source_of_chart ? __( 'Modify Parameters', 'visualizer' ) : __( 'Create Parameters', 'visualizer' );
182 + if ( Visualizer_Module::is_pro() ) {
146 183 ?>
147 - <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
184 + <p class="viz-group-description"><?php _e( 'How often do you want to check the URL', 'visualizer' ); ?></p>
185 + <select name="time" id="vz-json-time" class="visualizer-select json-form-element" data-chart="<?php echo $this->chart->ID; ?>">
148 186 <?php
187 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_JSON_SCHEDULE, true );
188 + $schedules = apply_filters(
189 + 'visualizer_chart_schedules', array(
190 + '-1' => __( 'One-time', 'visualizer' ),
191 + ),
192 + 'json',
193 + $this->chart->ID
194 + );
195 + foreach ( $schedules as $num => $name ) {
196 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
197 + $extra = $num == $hours ? 'selected' : '';
198 + ?>
199 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
200 + <?php
201 + }
202 + do_action( 'visualizer_chart_schedules_spl', 'json', $this->chart->ID, 1 );
203 + ?>
204 + </select>
205 + <?php
149 206 }
150 207 ?>
151 - </select>
152 208 </div>
153 - <input type="button" id="vz-save-schedule" class="button button-primary"
154 - value="<?php _e( 'Save schedule', 'visualizer' ); ?>">
155 209
156 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
210 + <input type="button" id="json-chart-button" class="button button-secondary show-chart-toggle"
211 + value="<?php echo $bttn_label; ?>" data-current="chart"
212 + data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
213 + data-t-chart="<?php echo $bttn_label; ?>">
214 + <?php
215 + if ( Visualizer_Module::is_pro() ) {
216 + ?>
217 + <input type="button" id="json-chart-save-button" class="button button-primary "
218 + value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
219 + <?php
220 + }
221 + ?>
157 222 </form>
158 223 </div>
159 224 </li>
160 225 </ul>
161 226 </li>
162 - <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', '' ); ?> ">
227 + <!-- import from chart -->
228 + <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
229 + <li class="viz-group viz-import-from-other <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
163 230 <h2 class="viz-group-title viz-sub-group"
164 231 data-current="chart"><?php _e( 'Import from other chart', 'visualizer' ); ?><span
165 232 class="dashicons dashicons-lock"></span></h2>
166 233 <div class="viz-group-content edit-data-content">
@@ -170,11 +237,12 @@
170 237 <select name="vz-import-from-chart" id="chart-id" class="visualizer-select">
171 238 <?php
172 239 $fetch_link = add_query_arg(
173 240 array(
174 - 'action' => ( VISUALIZER_PRO ) ? Visualizer_Pro::ACTION_FETCH_DATA : '',
241 + 'action' => Visualizer_Module::is_pro() ? Visualizer_Pro::ACTION_FETCH_DATA : '',
175 242 'nonce' => wp_create_nonce(),
176 - ), admin_url( 'admin-ajax.php' )
243 + ),
244 + admin_url( 'admin-ajax.php' )
177 245 );
178 246 $query_args_charts = array(
179 247 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
180 248 'posts_per_page' => 300,
@@ -184,10 +252,23 @@
184 252 $query = new WP_Query( $query_args_charts );
185 253 while ( $query->have_posts() ) {
186 254 $chart = $query->next_post();
187 255 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
256 +
257 + $title = '#' . $chart->ID;
258 + if ( ! empty( $settings['title'] ) ) {
259 + $title = $settings['title'];
260 + }
261 + // for ChartJS, title is an array.
262 + if ( is_array( $title ) && isset( $title['text'] ) ) {
263 + $title = $title['text'];
264 + }
265 + if ( empty( $title ) ) {
266 + $title = '#' . $chart->ID;
267 + }
268 +
188 269 ?>
189 - <option value="<?php echo $chart->ID; ?>"><?php echo empty( $settings['title'] ) ? '#' . $chart->ID : $settings['title']; ?></option>
270 + <option value="<?php echo $chart->ID; ?>"><?php echo $title; ?></option>
190 271 <?php
191 272 }
192 273 ?>
193 274
@@ -200,42 +281,150 @@
200 281 </div>
201 282 </div>
202 283 </li>
203 284
204 - <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'schedule-chart' ); ?> ">
285 + <?php
286 + $save_filter = add_query_arg(
287 + array(
288 + 'action' => Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY,
289 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_FILTER_QUERY . Visualizer_Plugin::VERSION ),
290 + 'chart' => $this->chart->ID,
291 + ), admin_url( 'admin-ajax.php' )
292 + );
293 + ?>
294 + <!-- import from WordPress -->
295 + <li class="viz-group visualizer_source_query_wp <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'import-wp' ); ?> ">
205 296 <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from WordPress', 'visualizer' ); ?><span
206 297 class="dashicons dashicons-lock"></span></h2>
207 298 <div class="viz-group-content edit-data-content">
208 299 <div>
209 - <p class="viz-group-description"><?php _e( 'You can import here data from WordPress', 'visualizer' ); ?></p>
210 - <input type="button" id="filter-chart-button" class="button button-primary "
211 - value="<?php _e( 'Create Filters', 'visualizer' ); ?>" data-current="chart"
212 - data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>"
213 - data-t-chart="<?php _e( 'Create Filters', 'visualizer' ); ?>">
214 - <?php echo apply_filters( 'visualizer_pro_upsell', '', 'schedule-chart' ); ?>
300 + <p class="viz-group-description"><?php _e( 'You can import data from WordPress here.', 'visualizer' ); ?></p>
301 + <form id="vz-filter-wizard" action="<?php echo $save_filter; ?>" method="post" target="thehole">
302 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from WordPress.', 'visualizer' ); ?></p>
303 + <select name="refresh" id="vz-filter-import-time" class="visualizer-select">
304 + <?php
305 + $bttn_label = 'visualizer_source_query_wp' === $source_of_chart ? __( 'Modify Filter', 'visualizer' ) : __( 'Create Filter', 'visualizer' );
306 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
307 + $schedules = apply_filters(
308 + 'visualizer_chart_schedules', array(
309 + '-1' => __( 'One-time', 'visualizer' ),
310 + ),
311 + 'wp',
312 + $this->chart->ID
313 + );
314 + foreach ( $schedules as $num => $name ) {
315 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
316 + $extra = $num == $hours ? 'selected' : '';
317 + ?>
318 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
319 + <?php
320 + }
321 + do_action( 'visualizer_chart_schedules_spl', 'wp', $this->chart->ID, 1 );
322 + ?>
323 + </select>
324 +
325 + <input type="button" id="filter-chart-button" class="button button-secondary show-chart-toggle" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
326 + <input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
327 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
328 + </form>
329 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
215 330 </div>
216 331 </div>
217 332 </li>
218 333
219 - <li class="viz-group <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature' ); ?>">
220 - <h2 class="viz-group-title viz-sub-group visualizer-editor-tab"
221 - data-current="chart"><?php _e( 'Add data manually', 'visualizer' ); ?><span
222 - class="dashicons dashicons-lock"></span></h2>
223 - <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
224 - <input type="hidden" id="chart-data" name="chart_data">
225 - <input type="hidden" id="chart-data-src" name="chart_data_src">
334 + <?php
335 + $save_query = add_query_arg(
336 + array(
337 + 'action' => Visualizer_Plugin::ACTION_SAVE_DB_QUERY,
338 + 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_SAVE_DB_QUERY . Visualizer_Plugin::VERSION ),
339 + 'chart' => $this->chart->ID,
340 + ), admin_url( 'admin-ajax.php' )
341 + );
342 + ?>
343 + <!-- import from db -->
344 + <li class="viz-group visualizer_source_query <?php echo apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ); ?>">
345 + <h2 class="viz-group-title viz-sub-group"><?php _e( 'Import from database', 'visualizer' ); ?><span
346 + class="dashicons dashicons-lock"></span></h2>
347 + <div class="viz-group-content edit-data-content">
348 + <div>
349 + <p class="viz-group-description"><?php _e( 'You can import data from the database here.', 'visualizer' ); ?></p>
350 + <form id="vz-db-wizard" action="<?php echo $save_query; ?>" method="post" target="thehole">
351 + <p class="viz-group-description"><?php _e( 'How often do you want to refresh the data from the database.', 'visualizer' ); ?></p>
352 + <select name="refresh" id="vz-db-import-time" class="visualizer-select">
353 + <?php
354 + $bttn_label = 'visualizer_source_query' === $source_of_chart ? __( 'Modify Query', 'visualizer' ) : __( 'Create Query', 'visualizer' );
355 + $hours = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_SCHEDULE, true );
356 + $schedules = apply_filters(
357 + 'visualizer_chart_schedules', array(
358 + '-1' => __( 'One-time', 'visualizer' ),
359 + ),
360 + 'db',
361 + $this->chart->ID
362 + );
363 + foreach ( $schedules as $num => $name ) {
364 + // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
365 + $extra = $num == $hours ? 'selected' : '';
366 + ?>
367 + <option value="<?php echo $num; ?>" <?php echo $extra; ?>><?php echo $name; ?></option>
368 + <?php
369 + }
370 + do_action( 'visualizer_chart_schedules_spl', 'db', $this->chart->ID, 1 );
371 + ?>
372 + </select>
373 + <input type="hidden" name="params" id="viz-db-wizard-params">
374 +
375 + <input type="button" id="db-chart-button" class="button button-secondary show-chart-toggle" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
376 + <input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
377 + <?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
226 378 </form>
379 + </div>
380 + </div>
381 + </li>
227 382
383 + <!-- manual -->
384 + <li class="viz-group visualizer_source_manual">
385 + <h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?>
386 + <span class="dashicons dashicons-lock"></span>
387 + </h2>
228 388 <div class="viz-group-content edit-data-content">
229 - <div>
230 - <p class="viz-group-description"><?php _e( 'You can manually edit the chart data using the spreadsheet like editor.', 'visualizer' ); ?></p>
231 - <input type="button" id="editor-chart-button" class="button button-primary "
232 - value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
233 - data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
234 - data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>">
389 + <form id="editor-form" action="<?php echo $upload_link; ?>" method="post" target="thehole">
390 + <input type="hidden" id="chart-data" name="chart_data">
391 + <input type="hidden" id="chart-data-src" name="chart_data_src">
235 392
236 - <?php echo apply_filters( 'visualizer_pro_upsell', '' ); ?>
237 - </div>
393 + <?php if ( Visualizer_Module::can_show_feature( 'simple-editor' ) ) { ?>
394 + <div>
395 + <p class="viz-group-description viz-editor-selection">
396 + <?php _e( 'Use the', 'visualizer' ); ?>
397 + <select name="editor-type" id="viz-editor-type">
398 + <?php
399 + if ( empty( $editor_type ) ) {
400 + $editor_type = Visualizer_Module::is_pro() ? 'excel' : 'text';
401 + }
402 + foreach ( apply_filters( 'visualizer_editors', array( 'text' => __( 'Text', 'visualizer' ), 'table' => __( 'Simple', 'visualizer' ) ) ) as $e_type => $e_label ) {
403 + ?>
404 + <option value="<?php echo $e_type; ?>" <?php selected( $editor_type, $e_type ); ?> ><?php echo $e_label; ?></option>
405 + <?php } ?>
406 + </select>
407 + <?php _e( 'editor to manually edit the chart data.', 'visualizer' ); ?>
408 + </p>
409 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
410 + <input type="button" id="editor-button" class="button button-primary "
411 + value="<?php _e( 'Edit Data', 'visualizer' ); ?>" data-current="chart"
412 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
413 + data-t-chart="<?php _e( 'Edit Data', 'visualizer' ); ?>"
414 + >
415 + <p class="viz-group-description viz-info-msg"><?php echo sprintf( __( 'Please make sure you click \'Show Chart\' before you save the chart.', 'visualizer' ) ); ?></p>
416 + </div>
417 + <?php } else { ?>
418 + <input type="button" id="editor-undo" class="button button-secondary" style="display: none" value="<?php _e( 'Undo Changes', 'visualizer' ); ?>">
419 + <input type="button" id="editor-chart-button" class="button button-primary "
420 + value="<?php _e( 'View Editor', 'visualizer' ); ?>" data-current="chart"
421 + data-t-editor="<?php _e( 'Show Chart', 'visualizer' ); ?>"
422 + data-t-chart="<?php _e( 'View Editor', 'visualizer' ); ?>"
423 + >
424 + <p class="viz-group-description viz-info-msg"><?php echo sprintf( __( 'Please make sure you click \'Show Chart\' before you save the chart.', 'visualizer' ) ); ?></p>
425 + <?php } ?>
426 + </form>
238 427 </div>
239 428 </li>
240 429 </ul>
241 430 </li>
@@ -249,15 +438,28 @@
249 438 <ul class="viz-group-content">
250 439 <form id="settings-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>"
251 440 method="post">
252 441 <?php echo $this->sidebar; ?>
442 + <input type="hidden" name="save" value="1">
253 443 </form>
444 + <form id="cancel-form" action="<?php echo add_query_arg( 'nonce', wp_create_nonce() ); ?>" method="post">
445 + <input type="hidden" name="cancel" value="1">
446 + </form>
254 447 </ul>
255 448 </li>
256 449
450 + <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-docs">
451 + <h2><span class="dashicons dashicons-editor-help"></span><a href="<?php echo VISUALIZER_MAIN_DOC; ?>" target="_blank"><?php _e( 'Docs', 'visualizer' ); ?></a></h2>
452 + </li>
453 +
257 454 <?php $this->getPermissionsLink( $this->chart->ID ); ?>
258 455
259 - <li class="viz-group bottom-fixed" id="vz-chart-copyright">Visualizer &copy; <?php echo date( 'Y', current_time( 'timestamp' ) ); ?></li>
456 + <li class="viz-group bottom-fixed" id="vz-chart-copyright">Visualizer &copy;
457 + <?php
458 + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date, WordPress.DateTime.CurrentTimeTimestamp.Requested
459 + echo date( 'Y', current_time( 'timestamp' ) );
460 + ?>
461 + </li>
260 462 </ul>
261 463 <?php
262 464 // changed by Ash/Upwork
263 465 }
@@ -274,9 +476,9 @@
274 476 foreach ( $permissions as $k => $v ) {
275 477 $this->$k = $v;
276 478 }
277 479 }
278 -?>
480 + ?>
279 481 <li class="viz-group viz-group-category bottom-fixed sidebar-footer-link" id="vz-chart-permissions">
280 482 <h2><span class="dashicons dashicons-admin-users"></span><?php _e( 'Permissions', 'visualizer' ); ?></h2>
281 483 <div class="viz-group-header">
282 484 <button class="customize-section-back" tabindex="0"></button>
@@ -288,17 +490,18 @@
288 490 echo add_query_arg(
289 491 array(
290 492 'nonce' => wp_create_nonce(),
291 493 'tab' => 'permissions',
292 - ), remove_query_arg( 'tab', $_SERVER['REQUEST_URI'] )
494 + ),
495 + remove_query_arg( 'tab', $_SERVER['REQUEST_URI'] )
293 496 );
294 -?>
497 + ?>
295 498 " method="post">
296 499 <?php $this->permissionsSidebar(); ?>
297 500 </form>
298 501 </ul>
299 502 </li>
300 -<?php
503 + <?php
301 504 }
302 505
303 506 /**
304 507 * Generates the permissions form.
@@ -305,11 +508,17 @@
305 508 *
306 509 * @access private
307 510 */
308 511 private function permissionsSidebar() {
512 + // ignore for unit tests because Travis throws the error "Indirect modification of overloaded property Visualizer_Render_Page_Data::$permissions has no effect".
513 + if ( defined( 'WP_TESTS_DOMAIN' ) ) {
514 + return;
515 + }
309 516 Visualizer_Render_Sidebar::_renderGroupStart(
310 517 esc_html__( 'Who can see this chart?', 'visualizer' ) . '<span
311 - class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
518 + class="dashicons dashicons-lock"></span>',
519 + '',
520 + 'viz-chart-perm-view ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
312 521 );
313 522 Visualizer_Render_Sidebar::_renderSectionStart();
314 523 Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can view the chart on the front-end.', 'visualizer' ) );
315 524
@@ -349,9 +558,11 @@
349 558 Visualizer_Render_Sidebar::_renderGroupEnd();
350 559
351 560 Visualizer_Render_Sidebar::_renderGroupStart(
352 561 esc_html__( 'Who can edit this chart?', 'visualizer' ) . '<span
353 - class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
562 + class="dashicons dashicons-lock"></span>',
563 + '',
564 + 'viz-chart-perm-edit ' . apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-permissions' )
354 565 );
355 566 Visualizer_Render_Sidebar::_renderSectionStart();
356 567 Visualizer_Render_Sidebar::_renderSectionDescription( esc_html__( 'Select who can edit the chart on the front-end.', 'visualizer' ) );
357 568
@@ -400,16 +611,35 @@
400 611 *
401 612 * @access protected
402 613 */
403 614 protected function _renderToolbar() {
404 - // changed by Ash/Upwork
405 - echo '<div class="toolbar-div">';
406 - echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">';
407 - esc_html_e( 'Back', 'visualizer' );
408 - echo '</a>';
409 - echo '</div>';
615 + // don't show back button at all.
616 + // NOTE: We can't be selective on the post_status here because when a new chart reaches the settings screen, its status changes to publish.
617 + if ( ! VISUALIZER_SKIP_CHART_TYPE_PAGE ) {
618 + echo '<div class="toolbar-div">';
619 + echo '<a class="button button-large" href="', add_query_arg( 'tab', 'types' ), '">';
620 + esc_html_e( 'Back', 'visualizer' );
621 + echo '</a>';
622 + echo '</div>';
623 + }
410 624 echo '<input type="submit" id="settings-button" class="button button-primary button-large push-right" value="', $this->button, '">';
411 - echo '</div>';
625 + if ( isset( $this->cancel_button ) ) {
626 + echo '<input type="submit" id="cancel-button" class="button button-secondary button-large push-right" value="', $this->cancel_button, '">';
627 + }
628 + }
412 629
630 + /**
631 + * Renders the additional content.
632 + *
633 + * @access private
634 + */
635 + private function add_additional_content() {
636 + $source = strtolower( get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_SOURCE, true ) );
637 + $query = '';
638 + if ( 'visualizer_source_query' === $source ) {
639 + $query = get_post_meta( $this->chart->ID, Visualizer_Plugin::CF_DB_QUERY, true );
640 + }
641 + Visualizer_Render_Layout::show( 'db-query', $query, $this->chart->ID );
642 + Visualizer_Render_Layout::show( 'json-screen', $this->chart->ID );
413 643 }
414 644
415 645 }