dates_config(); ?>
';print_r($date_infos);echo ''; $format_array = ABPTB_Layout::array_date_format(); $date_format = $date_infos['date_format'] ?? 'D d M , yy'; $time_format = $date_infos['time_format'] ?? ABPTB_Time_Format; ?>

common_part($abptb_dates); ?>
';print_r($time_infos);echo ''; //echo '
';print_r($time_infos);echo '
'; ?>

🗓️

common_part($date_infos); ?>

⏰

*
time_item('operation_time[]', $times, 'required'); $time_exit++; } } } if ($time_exit == 0) { $this->time_item('operation_time[]', '', 'required'); } ?>
time_item('operation_time[]'); ?>
day_wise_time($day_times); ?> date_wise_time($date_times); ?>
';print_r($return_time_infos);echo ''; ?>
*
time_item('return_operation_time[]', $times, 'required'); $time_exit++; } } } if ($time_exit == 0) { $this->time_item('return_operation_time[]', '', 'required'); } ?>
time_item('return_operation_time[]'); ?>
day_wise_time($return_day_times, 'return_'); ?> date_wise_time($return_date_times, 'return_'); ?>
__('Invalid security token or Insufficient permissions.', 'abp-transport-booking'), 'type' => 'warn'], 403); } ob_start(); $this->common_part(ABPTB_Function::get_option('abptb_dates')); $html_content = ob_get_clean(); wp_send_json_success(['html' => $html_content, 'msg' => __('Global date configuration Imported Successfully ..... !! ', 'abp-transport-booking'), 'type' => 'success'], 200); } public function save_global_dates(): void { if (!check_ajax_referer('abptb_admin_ajax_nonce', 'nonce', false) || !current_user_can('manage_options')) { wp_send_json_error(['msg' => __('Invalid security token or Insufficient permissions.', 'abp-transport-booking'), 'type' => 'warn'], 403); } $post_val = fn($key, $default = '') => isset($_POST[$key]) ? sanitize_text_field(wp_unslash($_POST[$key])) : $default; $date_infos = $this->get_date_array(); $date_config['date_format'] = $post_val('date_format'); $date_config['time_format'] = $post_val('time_format'); $date_config['advance_date_number'] = $post_val('advance_date_number', '28'); $date_config['sale_close_before'] = $post_val('sale_close_before'); update_option('abptb_dates', $date_infos); update_option('abptb_date_config', $date_config); ob_start(); $this->dates_config(); $html = ob_get_clean(); wp_send_json_success([ 'html' => $html, 'msg' => __('Global Date Configuration Saved Successfully ..... !!', 'abp-transport-booking'), 'type' => 'success' ]); } public function get_date_array(array $date_infos = []): array { $has_post_nonce = false; if (isset($_POST['abptb_post_nonce'])) { $has_post_nonce = wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['abptb_post_nonce'])), 'abptb_post_nonce'); } $has_ajax_nonce = check_ajax_referer('abptb_admin_ajax_nonce', 'nonce', false); if (($has_post_nonce || $has_ajax_nonce) && current_user_can('manage_options')) { $post_val = fn($key, $default = '') => isset($_POST[$key]) ? sanitize_text_field(wp_unslash($_POST[$key])) : $default; $post_array = fn($key) => (isset($_POST[$key]) && is_array($_POST[$key])) ? array_map('sanitize_text_field', wp_unslash($_POST[$key])) : []; $format_date = fn($date) => $date ? gmdate('Y-m-d', strtotime($date)) : ''; $date_infos['date_type'] = $post_val('date_type', 'periodic_date'); $date_infos['periodic_start_date'] = $format_date($post_val('periodic_start_date')); $date_infos['periodic_end_date'] = $format_date($post_val('periodic_end_date')); $date_infos['periodic_after'] = $post_val('periodic_after', '1'); $date_rule = $post_val('date_rule'); $date_infos['date_rule'] = $post_val('date_rule'); $date_rule_array = $date_rule ? explode(',', $date_rule) : []; if (in_array('weekend', $date_rule_array)) { $date_infos['weekend'] = $post_val('weekend'); } if (in_array('specific_off_dates', $date_rule_array)) { $specific_off_dates = array_filter($post_array('specific_off_dates')); $date_infos['specific_off_dates'] = array_unique(array_map(fn($d) => gmdate('Y-m-d', strtotime($d)), $specific_off_dates)); } if (in_array('off_date_range', $date_rule_array)) { $off_schedules = []; $from_dates = $post_array('abptb_off_from'); $to_dates = $post_array('abptb_off_to'); foreach ($from_dates as $key => $from_date) { if ($from_date && !empty($to_dates[$key])) { $off_schedules[] = ['from' => $from_date, 'to' => $to_dates[$key]]; } } $date_infos['off_date_range'] = $off_schedules; } if (in_array('special_on_dates', $date_rule_array)) { $special_on_dates = $post_array('special_on_dates'); $on_start = $post_array('special_on_time_start'); $on_end = $post_array('special_on_time_end'); $specific_on = []; foreach ($special_on_dates as $key => $date) { if ($date) { $specific_on[$key] = ['date' => $format_date($date), 'start' => $on_start[$key] ?? '', 'end' => $on_end[$key] ?? '']; } } $date_infos['special_on_dates'] = $specific_on; } $off_schedules = []; $from_dates = $post_array('abptb_off_from'); $to_dates = $post_array('abptb_off_to'); foreach ($from_dates as $key => $from_date) { if ($from_date && !empty($to_dates[$key])) { $off_schedules[] = ['from' => $from_date, 'to' => $to_dates[$key]]; } } $date_infos['off_date_range'] = $off_schedules; /****************/ $specific_dates = $post_array('specific_dates'); $specific_dates = !empty($specific_dates) ? array_values(array_unique(array_filter($specific_dates))) : []; sort($specific_dates); $date_infos['specific_dates'] = $specific_dates; } return $date_infos; } public function common_part($date_infos): void { $date_type = ($date_infos['date_type'] ?? null) ?: 'periodic_date'; $specific_dates = $date_infos['specific_dates'] ?? []; //echo '
';print_r($date_rule_array);echo '
'; ?>
*
date_item('specific_dates[]', $specific_date); } } } ?>
date_item('specific_dates[]'); ?>
special_on_off_dates($date_infos); } public function special_on_off_dates($date_infos = []): void { $date_rule = $date_infos['date_rule'] ?? ''; $date_rule_array = $date_rule ? explode(',', $date_rule) : []; $date_type = ($date_infos['date_type'] ?? null) ?: 'periodic_date'; $weekend = $date_infos['weekend'] ?? ''; $weekend_array = $weekend ? explode(',', $weekend) : []; $days = ABPTB_Layout::week_day(); $date_rules = ABPTB_Layout::date_option_rules(); ?>
$rule) { ?>
$day) { ?>
date_item('specific_off_dates[]', $specific_date); } } } ?>
date_item('specific_off_dates[]'); ?>
date_item('special_on_dates[]', $specific_date); } } } ?>
date_item('special_on_dates[]'); ?>
0 && $specific_date['from'] && $specific_date['to']) { $this->off_day_range($specific_date['from'], $specific_date['to']); } } } ?>
off_day_range(); ?>
$day) { ?>
$day) { $operation_times = $day_times[$key] ?? []; ?>
time_item($prefix . $key . '_time[]', $times); } } } ?>
time_item($prefix . $key . '_time[]'); ?>
$date_time) { $this->date_wise_time_item($date_time, $key, $prefix); } } ?>
date_wise_time_item([], uniqid('abp_'), $prefix); ?>
time_item($prefix . 'date_wise_time[' . $key . '][]', $time); } } } ?>
time_item($prefix . 'date_wise_time[' . $key . '][]'); ?>