//TODO: delete it in version 9.9 or later, if no errors
/**
* Shortcode [wpbc_test_dates_functions] to test different dates functions on the server.
*
* @return void
*/
function wpbc_test_dates_functions() {
if ( wpbc_is_on_edit_page() ) {
return wpbc_get_preview_for_shortcode( 'wpbc_test_dates_functions', array() ); // FixIn: 9.9.0.39.
}
ob_start();
ob_clean();
$server_zone = date_default_timezone_get();
debuge( array( 'init' => 'Default Timezones', 'server' => date_default_timezone_get(), 'wordpress' => wp_timezone()->getName(), 'wordpress - gmt_offset' => get_option( 'gmt_offset' ) ) );
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
// date_default_timezone_set( 'Europe/Oslo' );
// date_default_timezone_set( 'Europe/Amsterdam' );
// date_default_timezone_set( 'UTC' );
debuge( array( 'init' => 'After WPBC changed timezone to UTC', 'server' => date_default_timezone_get(), 'wordpress' => wp_timezone()->getName(), 'wordpress - gmt_offset' => get_option( 'gmt_offset' ) ) );
echo '
';
echo 'Test dates functions:
';
echo '
';
for ( $i = 0; $i < 366; $i ++ ) {
$ts = gmdate( 'Y-m-d 16:00:01', strtotime( '+' . $i . ' days' ) );
$ts_arr = explode(' ',$ts);
$date_arr = array();
$date_arr['str'] = '+' . $i . ' days for ' . $ts_arr[0] . ' ' .$ts_arr[1] ;
$date_arr['server'] = date_default_timezone_get();
$date_arr['wordpress'] = wp_timezone()->getName();
$date_arr['loc_DT'] = wpbc_datetime_localized( $ts );
$date_arr['loc_D'] = wpbc_date_localized( $ts );
$date_arr['loc_T'] = wpbc_time_localized( $ts );
$date_arr['loc_D_param_D'] = wpbc_date_localized( $ts_arr[0] );
$date_arr['loc_T_param_T'] = wpbc_time_localized( $ts_arr[1] );
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_var_export
echo '' . var_export( $date_arr, 1 ) . '
';
}
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
date_default_timezone_set( $server_zone );
debuge( array( 'end' => 'Back to default previos timezone', 'server' => date_default_timezone_get(), 'wordpress' => wp_timezone_string() ) );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
add_shortcode( 'wpbc_test_dates_functions', 'wpbc_test_dates_functions' );
//
//TODO: it's only for Debug: Comment it. // FixIn: 9.9.0.17.
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
// date_default_timezone_set( 'America/Chicago' ); // For Debug in Booking Calendar - booking form, for shortcode [wpbc_test_dates_functions] this line can be commented
// ---------------------------------------------------------------------------------------------------------------------
// Get available / unavailable intervals based from Today date (current time).
// ---------------------------------------------------------------------------------------------------------------------
/**
* Get unavailable from today array values and hints
*
* @return array - [
* booking_unavailable_days_num_from_today = "540m"
* booking_unavailable_days_num_from_today__hint = ": 2025-01-25 15:19 - 2025-01-26 00:18:42"
* booking_available_days_num_from_today = "0"
* booking_available_days_num_from_today__hint = ": 26 Jan, 2025 - ..."
* ]
*/
function wpbc_get_unavailable_from_today_hints_arr() {
$data_arr = array();
// -----------------------------------------------------------------------------------------------------
// == UNAVAILABLE Today days ==
// -----------------------------------------------------------------------------------------------------
// FixIn: 10.8.1.4.
$last_unavailable_date = '';
if ( 'm' === substr( get_bk_option( 'booking_unavailable_days_num_from_today' ), - 1 ) ) {
// -------------------------------------------------------------------------------------------------
// == Minutes ==
// -------------------------------------------------------------------------------------------------
$data_arr['booking_unavailable_days_num_from_today'] = intval( get_bk_option( 'booking_unavailable_days_num_from_today' ) );
// Hints.
$data_arr['booking_unavailable_days_num_from_today__hint'] = ':