PluginProbe
WP Data Access – App Builder for Tables, Forms, Dashboards, Charts & Maps / 5.5.87
WP Data Access – App Builder for Tables, Forms, Dashboards, Charts & Maps v5.5.87
5.5.87 5.5.85 5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 All 162 releases
wp-data-access / WPDataAccess / Settings / WPDA_Settings_Legacy_Plugin.php

WPDA_Settings_Legacy_Plugin.php in WP Data Access – App Builder for Tables, Forms, Dashboards, Charts & Maps 5.5.87, at WPDataAccess/Settings/WPDA_Settings_Legacy_Plugin.php

444 lines 20.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPDataAccess\Settings;
4
5 use WPDataAccess\Utilities\WPDA_Message_Box;
6 use WPDataAccess\WPDA;
7 class WPDA_Settings_Legacy_Plugin extends WPDA_Settings_Legacy_Page {
8 public function show() {
9 // Add datetimepicker
10 wp_enqueue_style( 'datetimepicker' );
11 wp_enqueue_script( 'datetimepicker' );
12 if ( isset( $_REQUEST['action'] ) ) {
13 $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) );
14 // input var okay.
15 // Security check.
16 $wp_nonce = ( isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : '' );
17 // input var okay.
18 if ( !wp_verify_nonce( $wp_nonce, 'wpda-plugin-settings-' . WPDA::get_current_user_login() ) ) {
19 wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) );
20 }
21 if ( 'save' === $action ) {
22 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_POST, ( isset( $_REQUEST['wpdataaccess_post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdataaccess_post'] ) ) : 'off' ) );
23 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE, ( isset( $_REQUEST['wpdataaccess_page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdataaccess_page'] ) ) : 'off' ) );
24 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_POST, ( isset( $_REQUEST['wpdadiehard_post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadiehard_post'] ) ) : 'off' ) );
25 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_PAGE, ( isset( $_REQUEST['wpdadiehard_page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadiehard_page'] ) ) : 'off' ) );
26 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_POST, ( isset( $_REQUEST['wpdadataforms_post'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadataforms_post'] ) ) : 'off' ) );
27 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_PAGE, ( isset( $_REQUEST['wpdadataforms_page'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['wpdadataforms_page'] ) ) : 'off' ) );
28 if ( isset( $_REQUEST['date_format'] ) ) {
29 WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_FORMAT, sanitize_text_field( wp_unslash( $_REQUEST['date_format'] ) ) );
30 }
31 if ( isset( $_REQUEST['date_placeholder'] ) ) {
32 WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_PLACEHOLDER, sanitize_text_field( wp_unslash( $_REQUEST['date_placeholder'] ) ) );
33 }
34 if ( isset( $_REQUEST['time_format'] ) ) {
35 WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_FORMAT, sanitize_text_field( wp_unslash( $_REQUEST['time_format'] ) ) );
36 }
37 if ( isset( $_REQUEST['time_placeholder'] ) ) {
38 WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_PLACEHOLDER, sanitize_text_field( wp_unslash( $_REQUEST['time_placeholder'] ) ) );
39 }
40 if ( isset( $_REQUEST['set_format'] ) ) {
41 WPDA::set_option( WPDA::OPTION_PLUGIN_SET_FORMAT, sanitize_text_field( wp_unslash( $_REQUEST['set_format'] ) ) );
42 }
43 } elseif ( 'setdefaults' === $action ) {
44 // Set all back-end settings back to default.
45 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_POST );
46 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE );
47 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_POST );
48 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_PAGE );
49 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_POST );
50 WPDA::set_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_PAGE );
51 WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_FORMAT );
52 WPDA::set_option( WPDA::OPTION_PLUGIN_DATE_PLACEHOLDER );
53 WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_FORMAT );
54 WPDA::set_option( WPDA::OPTION_PLUGIN_TIME_PLACEHOLDER );
55 WPDA::set_option( WPDA::OPTION_PLUGIN_SET_FORMAT );
56 }
57 $msg = new WPDA_Message_Box(array(
58 'message_text' => __( 'Settings saved', 'wp-data-access' ),
59 ));
60 $msg->box();
61 } elseif ( isset( $_REQUEST['msg'] ) && 'ok' === $_REQUEST['msg'] ) {
62 $msg = new WPDA_Message_Box(array(
63 'message_text' => __( 'Settings saved', 'wp-data-access' ),
64 ));
65 $msg->box();
66 }
67 // Get options.
68 $wpdataaccess_post = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_POST );
69 $wpdataaccess_page = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDATAACCESS_PAGE );
70 $wpdadiehard_post = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_POST );
71 $wpdadiehard_page = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADIEHARD_PAGE );
72 $wpdadataforms_post = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_POST );
73 $wpdadataforms_page = WPDA::get_option( WPDA::OPTION_PLUGIN_WPDADATAFORMS_PAGE );
74 $date_format = WPDA::get_option( WPDA::OPTION_PLUGIN_DATE_FORMAT );
75 $date_placeholder = WPDA::get_option( WPDA::OPTION_PLUGIN_DATE_PLACEHOLDER );
76 $time_format = WPDA::get_option( WPDA::OPTION_PLUGIN_TIME_FORMAT );
77 $time_placeholder = WPDA::get_option( WPDA::OPTION_PLUGIN_TIME_PLACEHOLDER );
78 $set_format = WPDA::get_option( WPDA::OPTION_PLUGIN_SET_FORMAT );
79 ?>
80
81 <style>
82 .settings_line {
83 line-height: 2.4;
84 }
85
86 .settings_label {
87 display: inline-block;
88 width: 7em;
89 font-weight: bold;
90 }
91
92 .item_width {
93 width: 14em;
94 }
95
96 .item_label {
97 width: 14.9em;
98 display: inline-block;
99 padding-left: 0.3em;
100 }
101
102 .item_label_text {
103 width: 7em;
104 display: inline-block;
105 }
106
107 .item_label_format {
108 width: 5em;
109 padding: 0.6em;
110 border-radius: 4px;
111 }
112
113 .item_label_align {
114 float: right;
115 }
116 </style>
117
118 <script>
119 jQuery(function () {
120 jQuery('.radio_date_format').on('click', function() {
121 jQuery('#date_format').val(jQuery(this).val());
122 });
123
124 jQuery('.radio_time_format').on('click', function() {
125 jQuery('#time_format').val(jQuery(this).val());
126 });
127
128 jQuery.datetimepicker.setLocale('<?php
129 echo esc_attr( substr( get_locale(), 0, 2 ) );
130 ?>');
131 jQuery('#test_datetime').attr('autocomplete', 'off');
132 jQuery('#init_datetime').on('click', function() {
133 jQuery('#test_datetime').datetimepicker({
134 format: jQuery('#date_format').val() + ' ' + jQuery('#time_format').val(),
135 datepicker: true,
136 timepicker: true
137 });
138 jQuery('#init_datetime').toggle();
139 jQuery('#test_datetime').toggle();
140 jQuery('#test_datetime').val('');
141 jQuery('#test_datetime').attr('placeholder', jQuery('#date_placeholder').val() + ' ' + jQuery('#time_placeholder').val());
142 });
143 jQuery('#test_datetime').on('blur', function() {
144 jQuery('#test_datetime').toggle();
145 jQuery('#init_datetime').toggle();
146 });
147 });
148 </script>
149
150 <form id="wpda_settings_plugin" method="post"
151 action="?page=<?php
152 echo esc_attr( $this->page );
153 ?>&tab=legacy&vtab=plugin">
154 <table class="wpda-table-settings" id="wpda_table_plugin">
155 <tr style="border-top: 1px solid #ccc">
156 <th><?php
157 esc_html_e( 'Shortcode [wpdataaccess]', 'wp-data-access' );
158 ?></th>
159 <td>
160 <label>
161 <input type="checkbox" name="wpdataaccess_post" <?php
162 echo ( 'on' === $wpdataaccess_post ? 'checked="checked"' : '' );
163 ?>/>
164 Allow in posts
165 </label>
166 <br/>
167 <label>
168 <input type="checkbox" name="wpdataaccess_page" <?php
169 echo ( 'on' === $wpdataaccess_page ? 'checked="checked"' : '' );
170 ?>/>
171 Allow in pages
172 </label>
173 </td>
174 </tr>
175 <tr>
176 <th><?php
177 esc_html_e( 'Shortcode [wpdadiehard]', 'wp-data-access' );
178 ?></th>
179 <td>
180 <label>
181 <input type="checkbox" name="wpdadiehard_post" <?php
182 echo ( 'on' === $wpdadiehard_post ? 'checked="checked"' : '' );
183 ?>/>
184 Allow in posts
185 </label>
186 <br/>
187 <label>
188 <input type="checkbox" name="wpdadiehard_page" <?php
189 echo ( 'on' === $wpdadiehard_page ? 'checked="checked"' : '' );
190 ?>/>
191 Allow in pages
192 </label>
193 </td>
194 </tr>
195 <?php
196 ?>
197 <tr>
198 <th><?php
199 esc_html_e( 'Date format', 'wp-data-access' );
200 ?></th>
201 <td>
202 <span class="settings_label"><?php
203 esc_html_e( 'Output', 'wp-data-access' );
204 ?></span>
205 <input type="text" value="<?php
206 echo esc_attr( get_option( 'date_format' ) );
207 ?>" class="item_width"
208 readonly/>
209 <?php
210 esc_html_e( '(WordPress format)', 'wp-data-access' );
211 ?>
212 <br/>
213 <span class="settings_line">
214 <span class="settings_label"><?php
215 esc_html_e( 'Input', 'wp-data-access' );
216 ?></span>
217 <label class="item_label">
218 <input type="radio" name="radio_date_format" class="radio_date_format"
219 value="Y-m-d" <?php
220 echo ( 'Y-m-d' === $date_format ? 'checked="checked"' : '' );
221 ?>/>
222 <span class="item_label_text"><?php
223 echo esc_attr( ( new \DateTime() )->format( 'Y-m-d' ) );
224 ?></span>
225 <span class="item_label_align">
226 <input type="text" class="item_label_format" value="Y-m-d" readonly/>
227 </span>
228 </label>
229 </span>
230 <?php
231 esc_html_e( '(JavaScript format)', 'wp-data-access' );
232 ?>
233 <br/>
234 <span class="settings_line">
235 <span class="settings_label"></span>
236 <label class="item_label">
237 <input type="radio" name="radio_date_format" class="radio_date_format"
238 value="m/d/Y" <?php
239 echo ( 'm/d/Y' === $date_format ? 'checked="checked"' : '' );
240 ?>/>
241 <span class="item_label_text"><?php
242 echo esc_attr( ( new \DateTime() )->format( 'm/d/Y' ) );
243 ?></span>
244 <span class="item_label_align">
245 <input type="text" class="item_label_format" value="m/d/Y" readonly/>
246 </span>
247 </label>
248 </span>
249 <br/>
250 <span class="settings_line">
251 <span class="settings_label"></span>
252 <label class="item_label">
253 <input type="radio" name="radio_date_format" class="radio_date_format"
254 value="d/m/Y" <?php
255 echo ( 'd/m/Y' === $date_format ? 'checked="checked"' : '' );
256 ?>/>
257 <span class="item_label_text"><?php
258 echo esc_attr( ( new \DateTime() )->format( 'd/m/Y' ) );
259 ?></span>
260 <span class="item_label_align">
261 <input type="text" class="item_label_format" value="d/m/Y" readonly/>
262 </span>
263 </label>
264 </span>
265 <br/>
266 <span class="settings_line">
267 <span class="settings_label"></span>
268 <label class="item_label">
269 <input type="radio" name="radio_date_format" name="date_format"
270 value="custom" <?php
271 echo ( 'Y-m-d' !== $date_format && 'd/m/Y' !== $date_format && 'm/d/Y' !== $date_format ? 'checked="checked"' : '' );
272 ?>/>
273 <span class="item_label_text"><?php
274 esc_html_e( 'Custom:', 'wp-data-access' );
275 ?></span>
276 <span class="item_label_align">
277 <input class="item_label_format" type="text" name="date_format" id="date_format"
278 value="<?php
279 echo esc_attr( $date_format );
280 ?>" class="item_label_format"/>
281 </span>
282 </label>
283 </span>
284 <br/>
285 <span class="settings_label"><?php
286 esc_html_e( 'Placeholder', 'wp-data-access' );
287 ?></span>
288 <input type="text" name="date_placeholder" id="date_placeholder"
289 value="<?php
290 echo esc_attr( $date_placeholder );
291 ?>" class="item_width"/>
292 <?php
293 esc_html_e( '(user info)', 'wp-data-access' );
294 ?>
295 </td>
296 </tr>
297 <tr>
298 <th><?php
299 esc_html_e( 'Time format', 'wp-data-access' );
300 ?></th>
301 <td>
302 <span class="settings_label"><?php
303 esc_html_e( 'Output', 'wp-data-access' );
304 ?></span>
305 <input type="text" value="<?php
306 echo esc_attr( get_option( 'time_format' ) );
307 ?>" class="item_width"
308 readonly/>
309 <?php
310 esc_html_e( '(WordPress format)', 'wp-data-access' );
311 ?>
312 <br/>
313 <span class="settings_line">
314 <span class="settings_label"><?php
315 esc_html_e( 'Input', 'wp-data-access' );
316 ?></span>
317 <label class="item_label">
318 <input type="radio" name="radio_time_format" class="radio_time_format"
319 value="H:i" <?php
320 echo ( 'H:i' === $time_format ? 'checked="checked"' : '' );
321 ?>/>
322 <span class="item_label_text"><?php
323 echo esc_attr( ( new \DateTime() )->format( 'H:i' ) );
324 ?></span>
325 <span class="item_label_align">
326 <input type="text" class="item_label_format" value="H:i" readonly/>
327 </span>
328 </label>
329 </span>
330 <?php
331 esc_html_e( '(JavaScript format)', 'wp-data-access' );
332 ?>
333 <br/>
334 <span class="settings_line">
335 <span class="settings_label"></span>
336 <label class="item_label">
337 <input type="radio" name="radio_time_format" name="time_format"
338 value="custom" <?php
339 echo ( 'H:i' !== $time_format ? 'checked="checked"' : '' );
340 ?>/>
341 <span class="item_label_text"><?php
342 esc_html_e( 'Custom:', 'wp-data-access' );
343 ?></span>
344 <span class="item_label_align">
345 <input class="item_label_format" type="text" name="time_format" id="time_format"
346 value="<?php
347 echo esc_attr( $time_format );
348 ?>" class="item_label_format"/>
349 </span>
350 </label>
351 </span>
352 <br/>
353 <span class="settings_label"><?php
354 esc_html_e( 'Placeholder', 'wp-data-access' );
355 ?></span>
356 <input type="text" name="time_placeholder" id="time_placeholder"
357 value="<?php
358 echo esc_attr( $time_placeholder );
359 ?>" class="item_width"/>
360 </td>
361 </tr>
362 <tr>
363 <th><?php
364 esc_html_e( 'Date/time test', 'wp-data-access' );
365 ?></th>
366 <td>
367 <input type="button" id="init_datetime" value="Test DateTimePicker" class="button item_width"/>
368 <input type="text" class="item_width" id="test_datetime" style="display:none;" />
369 </td>
370 </tr>
371 <tr>
372 <th><?php
373 esc_html_e( 'Set format', 'wp-data-access' );
374 ?></th>
375 <td>
376 <span><?php
377 esc_html_e( 'Show columns of data type set in list table as', 'wp-data-access' );
378 ?></span>
379 <select name="set_format">
380 <option value="csv" <?php
381 echo ( 'csv' === $set_format ? 'selected' : '' );
382 ?>>Comma separated values</option>
383 <option value="ul" <?php
384 echo ( 'ul' === $set_format ? 'selected' : '' );
385 ?>>Unordered list</option>
386 <option value="ol" <?php
387 echo ( 'ol' === $set_format ? 'selected' : '' );
388 ?>>Ordered list</option>
389 </select>
390 </td>
391 </tr>
392 <tr>
393 <th><span class="dashicons dashicons-info" style="float:right;font-size:300%;"></span></th>
394 <td>
395 <span class="dashicons dashicons-yes"></span>
396 <?php
397 esc_html_e( 'The plugin uses your WordPress general settings to format your date and time output', 'wp-data-access' );
398 ?>
399 <br/>
400 <span class="dashicons dashicons-yes"></span>
401 <?php
402 esc_html_e( 'The plugin uses the jQuery DateTimePicker plugin for data entry validation', 'wp-data-access' );
403 ?>
404 <br/>
405 <span class="dashicons dashicons-yes"></span>
406 <a href="https://xdsoft.net/jqplugins/datetimepicker/" target="_blank">
407 <?php
408 esc_html_e( 'Input formats can be found on the XDSoft DateTimePicker page', 'wp-data-access' );
409 ?>
410 </a>
411 </td>
412 </tr>
413 </table>
414 <div class="wpda-table-settings-button">
415 <input type="hidden" name="action" value="save"/>
416 <button type="submit" class="button button-primary">
417 <i class="fas fa-check wpda_icon_on_button"></i>
418 <?php
419 esc_html_e( 'Save Plugin Settings', 'wp-data-access' );
420 ?>
421 </button>
422 <a href="javascript:void(0)"
423 onclick="if (confirm('<?php
424 esc_html_e( 'Reset to defaults?', 'wp-data-access' );
425 ?>')) {
426 jQuery('input[name=&quot;action&quot;]').val('setdefaults');
427 jQuery('#wpda_settings_plugin').trigger('submit')
428 }"
429 class="button">
430 <i class="fas fa-times-circle wpda_icon_on_button"></i>
431 <?php
432 esc_html_e( 'Reset Plugin Settings To Defaults', 'wp-data-access' );
433 ?>
434 </a>
435 </div>
436 <?php
437 wp_nonce_field( 'wpda-plugin-settings-' . WPDA::get_current_user_login(), '_wpnonce', false );
438 ?>
439 </form>
440 <?php
441 }
442
443 }
444