| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @description Action for Template Setup pages |
| 4 |
* @category Setup Action |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site http://oplugins.com/ |
| 8 |
* @email info@oplugins.com |
| 9 |
* |
| 10 |
* @modified 2024-10-12 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
// ------------------------------------------------------------------------------------------------------------- |
| 17 |
// == Date | Time Formats, Etc... == |
| 18 |
// ------------------------------------------------------------------------------------------------------------- |
| 19 |
/** |
| 20 |
* Template - Date | Time Formats ... - Step 02 |
| 21 |
* |
| 22 |
* Help Tips: |
| 23 |
* |
| 24 |
* <script type="text/html" id="tmpl-template_name_a"> |
| 25 |
* Escaped: {{data.test_key}} |
| 26 |
* HTML: {{{data.test_key}}} |
| 27 |
* JS: <# if (true) { alert( 1 ); } #> |
| 28 |
* </script> |
| 29 |
* |
| 30 |
* var template__var = wp.template( 'template_name_a' ); |
| 31 |
* |
| 32 |
* jQuery( '.content' ).html( template__var( { 'test_key' => '<strong>Data</strong>' } ) ); |
| 33 |
* |
| 34 |
* @return void |
| 35 |
*/ |
| 36 |
|
| 37 |
|
| 38 |
function wpbc_template__date_time_formats__action_validate_data( $post_data ){ |
| 39 |
|
| 40 |
$escaped_data = array( |
| 41 |
'wpbc_swp_date_format' => get_option( 'booking_date_format' ), |
| 42 |
'wpbc_swp_time_format' => get_option( 'date_format' ), |
| 43 |
'wpbc_swp_start_day_weeek' => 0, |
| 44 |
'wpbc_swp_date_view_type' => 'short' |
| 45 |
); |
| 46 |
|
| 47 |
$key = 'wpbc_swp_date_format'; |
| 48 |
if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) { |
| 49 |
$escaped_data[ $key ] = wpbc_clean_text_value( $post_data[ $key ] ); |
| 50 |
} |
| 51 |
$key = 'wpbc_swp_time_format'; |
| 52 |
if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) { |
| 53 |
$escaped_data[ $key ] = wpbc_clean_text_value( $post_data[ $key ] ); |
| 54 |
} |
| 55 |
$key = 'wpbc_swp_start_day_weeek'; |
| 56 |
if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) { |
| 57 |
$escaped_data[ $key ] = intval( $post_data[ $key ] ); |
| 58 |
} |
| 59 |
$key = 'wpbc_swp_date_view_type'; |
| 60 |
if ( ( isset( $post_data[ $key ] ) ) && ( ! empty( ( $post_data[ $key ] ) ) ) ) { |
| 61 |
$escaped_data[ $key ] = wpbc_clean_text_value( $post_data[ $key ] ); |
| 62 |
} |
| 63 |
|
| 64 |
return $escaped_data; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
/** |
| 70 |
* Update data |
| 71 |
* |
| 72 |
* @param $cleaned_data array() |
| 73 |
* |
| 74 |
* @return void |
| 75 |
*/ |
| 76 |
function wpbc_setup__update__date_time_formats( $cleaned_data ){ |
| 77 |
|
| 78 |
if ( ! empty( $cleaned_data['wpbc_swp_date_format'] ) ) { |
| 79 |
update_bk_option( 'booking_date_format', $cleaned_data['wpbc_swp_date_format'] ); |
| 80 |
} |
| 81 |
if ( ! empty( $cleaned_data['wpbc_swp_time_format'] ) ) { |
| 82 |
update_bk_option( 'booking_time_format', $cleaned_data['wpbc_swp_time_format'] ); |
| 83 |
} |
| 84 |
if ( ! empty( $cleaned_data['wpbc_swp_start_day_weeek'] ) ) { |
| 85 |
update_bk_option( 'booking_start_day_weeek', $cleaned_data['wpbc_swp_start_day_weeek'] ); |
| 86 |
} |
| 87 |
if ( ! empty( $cleaned_data['wpbc_swp_date_view_type'] ) ) { |
| 88 |
update_bk_option( 'booking_date_view_type', $cleaned_data['wpbc_swp_date_view_type'] ); |
| 89 |
} |
| 90 |
} |