Changeset 3418960
- Timestamp:
- 12/13/2025 03:01:52 PM (3 months ago)
- Location:
- reventor-calendar-appointment-booking/trunk
- Files:
-
- 7 edited
-
assets/css/admin.css (modified) (2 diffs)
-
includes/class-admin.php (modified) (6 diffs)
-
includes/class-frontend.php (modified) (5 diffs)
-
includes/functions.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
reventor-calendar-appointment-booking.php (modified) (2 diffs)
-
templates/admin-page.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
reventor-calendar-appointment-booking/trunk/assets/css/admin.css
r3407895 r3418960 265 265 } 266 266 267 /* Working Hours Layout */ 268 .reventorcab-working-hours-container { 269 display: flex; 270 flex-direction: column; 271 gap: 20px; 272 } 273 274 .reventorcab-time-row { 275 display: flex; 276 gap: 20px; 277 align-items: flex-start; 278 } 279 280 .reventorcab-time-field { 281 flex: 1; 282 margin-bottom: 0; 283 min-width: 0; 284 } 285 286 .reventorcab-time-field label { 287 display: block; 288 font-weight: 600; 289 color: #1d2327; 290 margin-bottom: 8px; 291 font-size: 14px; 292 } 293 294 .reventorcab-time-field input[type="time"] { 295 width: 100%; 296 max-width: none; 297 padding: 12px 16px; 298 border: 1px solid #dcdcde; 299 border-radius: 6px; 300 font-size: 14px; 301 background: #fff; 302 transition: all 0.2s ease; 303 display: block; 304 vertical-align: middle; 305 } 306 307 .reventorcab-time-field input[type="time"]:focus { 308 outline: none; 309 border-color: #007cba; 310 box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1); 311 } 312 313 .reventorcab-time-field .description { 314 color: #646970; 315 font-size: 13px; 316 margin-top: 8px; 317 line-height: 1.4; 318 } 319 267 320 .reventorcab-field-group .description { 268 321 color: #646970; … … 753 806 flex-direction: column; 754 807 gap: 15px; 808 } 809 810 /* Working Hours Responsive */ 811 .reventorcab-time-row { 812 flex-direction: column; 813 gap: 15px; 814 } 815 816 .reventorcab-time-field { 817 width: 100%; 755 818 } 756 819 } -
reventor-calendar-appointment-booking/trunk/includes/class-admin.php
r3352327 r3418960 49 49 register_setting('reventorcab_settings', 'reventorcab_working_hours_start', ['sanitize_callback' => 'sanitize_text_field']); 50 50 register_setting('reventorcab_settings', 'reventorcab_working_hours_end', ['sanitize_callback' => 'sanitize_text_field']); 51 register_setting('reventorcab_settings', 'reventorcab_break_start', ['sanitize_callback' => 'sanitize_text_field']); 52 register_setting('reventorcab_settings', 'reventorcab_break_end', ['sanitize_callback' => 'sanitize_text_field']); 51 53 register_setting('reventorcab_settings', 'reventorcab_working_days', ['sanitize_callback' => [$this, 'sanitize_working_days']]); 52 54 register_setting('reventorcab_settings', 'reventorcab_timeslot_granularity', ['sanitize_callback' => 'intval']); … … 178 180 $working_hours_start = get_option('reventorcab_working_hours_start', '09:00'); 179 181 $working_hours_end = get_option('reventorcab_working_hours_end', '17:00'); 182 $break_start = get_option('reventorcab_break_start', '12:00'); 183 $break_end = get_option('reventorcab_break_end', '13:00'); 180 184 $working_days = get_option('reventorcab_working_days', array('monday', 'tuesday', 'wednesday', 'thursday', 'friday')); 181 185 $timezone = get_option('reventorcab_timezone', 'UTC'); … … 250 254 $working_hours_start = isset($_POST['working_hours_start']) ? sanitize_text_field(wp_unslash($_POST['working_hours_start'])) : '09:00'; 251 255 $working_hours_end = isset($_POST['working_hours_end']) ? sanitize_text_field(wp_unslash($_POST['working_hours_end'])) : '17:00'; 256 $break_start = isset($_POST['break_start']) ? sanitize_text_field(wp_unslash($_POST['break_start'])) : '12:00'; 257 $break_end = isset($_POST['break_end']) ? sanitize_text_field(wp_unslash($_POST['break_end'])) : '13:00'; 252 258 $working_days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday'); 253 259 if (isset($_POST['working_days']) && is_array($_POST['working_days'])) { … … 260 266 update_option('reventorcab_working_hours_start', $working_hours_start); 261 267 update_option('reventorcab_working_hours_end', $working_hours_end); 268 update_option('reventorcab_break_start', $break_start); 269 update_option('reventorcab_break_end', $break_end); 262 270 update_option('reventorcab_working_days', $working_days); 263 271 … … 512 520 'reventorcab_working_hours_start' => get_option('reventorcab_working_hours_start', '09:00'), 513 521 'reventorcab_working_hours_end' => get_option('reventorcab_working_hours_end', '23:00'), 522 'reventorcab_break_start' => get_option('reventorcab_break_start', '12:00'), 523 'reventorcab_break_end' => get_option('reventorcab_break_end', '13:00'), 514 524 'reventorcab_working_days' => get_option('reventorcab_working_days', array('monday', 'tuesday', 'wednesday', 'thursday', 'friday')), 515 525 … … 574 584 'reventorcab_working_hours_start', 575 585 'reventorcab_working_hours_end', 586 'reventorcab_break_start', 587 'reventorcab_break_end', 576 588 'reventorcab_working_days', 577 589 -
reventor-calendar-appointment-booking/trunk/includes/class-frontend.php
r3408023 r3418960 603 603 $working_hours_start = get_option('reventorcab_working_hours_start', '09:00'); 604 604 $working_hours_end = get_option('reventorcab_working_hours_end', '17:00'); 605 605 $break_start = get_option('reventorcab_break_start', '12:00'); 606 $break_end = get_option('reventorcab_break_end', '13:00'); 607 606 608 // Get plugin's configured timezone for working hours calculation 607 609 try { … … 644 646 $slot_datetime = new DateTime('@' . $time); 645 647 $slot_datetime->setTimezone($plugin_timezone); 646 $slots[] = $slot_datetime->format('H:i'); 648 $slot_time = $slot_datetime->format('H:i'); 649 650 // Skip slots that fall within break time 651 if ($this->is_time_in_break($slot_time, $break_start, $break_end)) { 652 $this->debug_log("Slot {$slot_time} filtered out (break time)"); 653 continue; 654 } 655 656 $slots[] = $slot_time; 647 657 } 648 658 } else { … … 683 693 $this->debug_log("Min advance setting: " . get_option('reventorcab_min_booking_advance', '2h')); 684 694 $this->debug_log("Working hours: {$working_hours_start} - {$working_hours_end}"); 685 695 $this->debug_log("Break time: {$break_start} - {$break_end}"); 696 686 697 // Use granularity setting instead of appointment duration for slot generation 687 698 $granularity = get_option('reventorcab_timeslot_granularity', 15); … … 703 714 $this->debug_log("Time >= min advance: " . ($time >= $min_advance_time ? 'true' : 'false')); 704 715 705 // Skip slots that are in the past or don't meet minimum advance time (use plugin time for calculations)716 // Skip slots that are in the past, don't meet minimum advance time, or fall within break time 706 717 if ($time > $current_time && $time >= $min_advance_time) { 718 // Check if slot falls within break time 719 if ($this->is_time_in_break($slot_time_display, $break_start, $break_end)) { 720 $this->debug_log("Slot {$slot_time_display} filtered out (break time)"); 721 continue; 722 } 723 707 724 $slots[] = $slot_time_display; // Store display time for frontend 708 725 $this->debug_log("Slot {$slot_time_display} added to available slots"); … … 1066 1083 reventorcab_log($message); 1067 1084 } 1085 1086 /** 1087 * Check if a given time falls within the break time 1088 */ 1089 private function is_time_in_break(string $time, string $break_start, string $break_end): bool { 1090 // Convert time strings to comparable format (minutes since midnight) 1091 $time_minutes = $this->time_to_minutes($time); 1092 $break_start_minutes = $this->time_to_minutes($break_start); 1093 $break_end_minutes = $this->time_to_minutes($break_end); 1094 1095 // Check if time falls within break period 1096 return $time_minutes >= $break_start_minutes && $time_minutes < $break_end_minutes; 1097 } 1098 1099 /** 1100 * Convert time string (HH:MM) to minutes since midnight 1101 */ 1102 private function time_to_minutes(string $time): int { 1103 $parts = explode(':', $time); 1104 if (count($parts) !== 2) { 1105 return 0; 1106 } 1107 return (intval($parts[0]) * 60) + intval($parts[1]); 1108 } 1068 1109 1069 1110 /** -
reventor-calendar-appointment-booking/trunk/includes/functions.php
r3408023 r3418960 340 340 341 341 /** 342 * Check if a given time falls within the break time 343 */ 344 function reventorcab_is_time_in_break(string $time, string $break_start, string $break_end): bool { 345 // Convert time strings to comparable format (minutes since midnight) 346 $time_minutes = reventorcab_time_to_minutes($time); 347 $break_start_minutes = reventorcab_time_to_minutes($break_start); 348 $break_end_minutes = reventorcab_time_to_minutes($break_end); 349 350 // Check if time falls within break period 351 return $time_minutes >= $break_start_minutes && $time_minutes < $break_end_minutes; 352 } 353 354 /** 355 * Convert time string (HH:MM) to minutes since midnight 356 */ 357 function reventorcab_time_to_minutes(string $time): int { 358 $parts = explode(':', $time); 359 if (count($parts) !== 2) { 360 return 0; 361 } 362 return (intval($parts[0]) * 60) + intval($parts[1]); 363 } 364 365 /** 342 366 * Get timezone string - SIMPLIFIED VERSION 343 367 * Forces use of reventorcab_timezone only to ensure consistency across servers … … 480 504 $working_hours_start = get_option('reventorcab_working_hours_start', '09:00'); 481 505 $working_hours_end = get_option('reventorcab_working_hours_end', '17:00'); 482 506 $break_start = get_option('reventorcab_break_start', '12:00'); 507 $break_end = get_option('reventorcab_break_end', '13:00'); 508 483 509 // Create timezone-aware datetime objects for working hours 484 510 $start_datetime = new DateTime($date . ' ' . $working_hours_start . ':00', $timezone); … … 501 527 $slot_time = $slot_datetime->format('H:i'); 502 528 503 // Skip slots that are in the past or don't meet minimum advancetime529 // Skip slots that are in the past, don't meet minimum advance time, or fall within break time 504 530 if ($time > $current_time && $time >= $min_advance_time) { 531 // Check if slot falls within break time 532 if (reventorcab_is_time_in_break($slot_time, $break_start, $break_end)) { 533 continue; 534 } 505 535 $available_slots[] = $slot_time; 506 536 } -
reventor-calendar-appointment-booking/trunk/readme.txt
r3408156 r3418960 4 4 Requires at least: 6.3 5 5 Tested up to: 6.9 6 Stable tag: 1.1. 27 Requires PHP: 8. 16 Stable tag: 1.1.3 7 Requires PHP: 8.3 8 8 License: GPL v2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 42 42 == Changelog == 43 43 44 = 1.1.3 = 45 * Added Break times feature 46 44 47 = 1.1.2 = 45 48 * Added automated scrolling to the form to make it easier to see the form fields in all 3 steps -
reventor-calendar-appointment-booking/trunk/reventor-calendar-appointment-booking.php
r3408156 r3418960 4 4 * Description: A REVENTOR calendar appointment booking system with CalDAV integration for seamless scheduling and calendar synchronization. 5 5 * Plugin URI: https://wordpress.org/plugins/reventor-calendar-appointment-booking/ 6 * Version: 1.1. 26 * Version: 1.1.3 7 7 * Author: REVENTOR 8 8 * Author URI: https://reventor.eu … … 40 40 define('REVENTORCAB_PLUGIN_URL', plugin_dir_url(__FILE__)); 41 41 define('REVENTORCAB_PLUGIN_PATH', plugin_dir_path(__FILE__)); 42 define('REVENTORCAB_VERSION', '1.1. 2');42 define('REVENTORCAB_VERSION', '1.1.3'); 43 43 44 44 // Main plugin class -
reventor-calendar-appointment-booking/trunk/templates/admin-page.php
r3407895 r3418960 188 188 <h3><?php esc_html_e('Working Hours', 'reventor-calendar-appointment-booking'); ?></h3> 189 189 190 <div class="reventorcab-field-group"> 191 <label for="working_hours_start"><?php esc_html_e('Start Time', 'reventor-calendar-appointment-booking'); ?></label> 192 <input type="time" id="working_hours_start" name="working_hours_start" value="<?php echo esc_attr($working_hours_start); ?>" /> 193 <p class="description"><?php esc_html_e('Daily working hours start time.', 'reventor-calendar-appointment-booking'); ?></p> 194 </div> 195 196 <div class="reventorcab-field-group"> 197 <label for="working_hours_end"><?php esc_html_e('End Time', 'reventor-calendar-appointment-booking'); ?></label> 198 <input type="time" id="working_hours_end" name="working_hours_end" value="<?php echo esc_attr($working_hours_end); ?>" /> 199 <p class="description"><?php esc_html_e('Daily working hours end time.', 'reventor-calendar-appointment-booking'); ?></p> 200 </div> 201 202 <div class="reventorcab-field-group"> 203 <label><?php esc_html_e('Working Days', 'reventor-calendar-appointment-booking'); ?></label> 204 <div class="reventorcab-working-days"> 205 <?php 206 $days = array( 207 'monday' => __('Monday', 'reventor-calendar-appointment-booking'), 208 'tuesday' => __('Tuesday', 'reventor-calendar-appointment-booking'), 209 'wednesday' => __('Wednesday', 'reventor-calendar-appointment-booking'), 210 'thursday' => __('Thursday', 'reventor-calendar-appointment-booking'), 211 'friday' => __('Friday', 'reventor-calendar-appointment-booking'), 212 'saturday' => __('Saturday', 'reventor-calendar-appointment-booking'), 213 'sunday' => __('Sunday', 'reventor-calendar-appointment-booking') 214 ); 215 foreach ($days as $day_key => $day_label): 216 ?> 217 <label class="reventorcab-checkbox-label"> 218 <input type="checkbox" name="working_days[]" value="<?php echo esc_attr($day_key); ?>" <?php checked(in_array($day_key, $working_days)); ?> /> 219 <?php echo esc_html($day_label); ?> 220 </label> 221 <?php endforeach; ?> 222 </div> 223 <p class="description"><?php esc_html_e('Select the days when appointments can be booked.', 'reventor-calendar-appointment-booking'); ?></p> 190 <div class="reventorcab-working-hours-container"> 191 <!-- Working Hours Row --> 192 <div class="reventorcab-time-row"> 193 <div class="reventorcab-field-group reventorcab-time-field"> 194 <label for="working_hours_start"><?php esc_html_e('Start Time', 'reventor-calendar-appointment-booking'); ?></label> 195 <input type="time" id="working_hours_start" name="working_hours_start" value="<?php echo esc_attr($working_hours_start); ?>" /> 196 <p class="description"><?php esc_html_e('Daily working hours start time.', 'reventor-calendar-appointment-booking'); ?></p> 197 </div> 198 199 <div class="reventorcab-field-group reventorcab-time-field"> 200 <label for="working_hours_end"><?php esc_html_e('End Time', 'reventor-calendar-appointment-booking'); ?></label> 201 <input type="time" id="working_hours_end" name="working_hours_end" value="<?php echo esc_attr($working_hours_end); ?>" /> 202 <p class="description"><?php esc_html_e('Daily working hours end time.', 'reventor-calendar-appointment-booking'); ?></p> 203 </div> 204 </div> 205 206 <!-- Break Hours Row --> 207 <div class="reventorcab-time-row"> 208 <div class="reventorcab-field-group reventorcab-time-field"> 209 <label for="break_start"><?php esc_html_e('Break Start', 'reventor-calendar-appointment-booking'); ?></label> 210 <input type="time" id="break_start" name="break_start" value="<?php echo esc_attr($break_start ?? '12:00'); ?>" /> 211 <p class="description"><?php esc_html_e('Daily break start time. Appointments cannot be booked during this time.', 'reventor-calendar-appointment-booking'); ?></p> 212 </div> 213 214 <div class="reventorcab-field-group reventorcab-time-field"> 215 <label for="break_end"><?php esc_html_e('Break End', 'reventor-calendar-appointment-booking'); ?></label> 216 <input type="time" id="break_end" name="break_end" value="<?php echo esc_attr($break_end ?? '13:00'); ?>" /> 217 <p class="description"><?php esc_html_e('Daily break end time. Appointments cannot be booked during this time.', 'reventor-calendar-appointment-booking'); ?></p> 218 </div> 219 </div> 220 221 <!-- Working Days --> 222 <div class="reventorcab-field-group"> 223 <label><?php esc_html_e('Working Days', 'reventor-calendar-appointment-booking'); ?></label> 224 <div class="reventorcab-working-days"> 225 <?php 226 $days = array( 227 'monday' => __('Monday', 'reventor-calendar-appointment-booking'), 228 'tuesday' => __('Tuesday', 'reventor-calendar-appointment-booking'), 229 'wednesday' => __('Wednesday', 'reventor-calendar-appointment-booking'), 230 'thursday' => __('Thursday', 'reventor-calendar-appointment-booking'), 231 'friday' => __('Friday', 'reventor-calendar-appointment-booking'), 232 'saturday' => __('Saturday', 'reventor-calendar-appointment-booking'), 233 'sunday' => __('Sunday', 'reventor-calendar-appointment-booking') 234 ); 235 foreach ($days as $day_key => $day_label): 236 ?> 237 <label class="reventorcab-checkbox-label"> 238 <input type="checkbox" name="working_days[]" value="<?php echo esc_attr($day_key); ?>" <?php checked(in_array($day_key, $working_days)); ?> /> 239 <?php echo esc_html($day_label); ?> 240 </label> 241 <?php endforeach; ?> 242 </div> 243 <p class="description"><?php esc_html_e('Select the days when appointments can be booked.', 'reventor-calendar-appointment-booking'); ?></p> 244 </div> 224 245 </div> 225 246
Note: See TracChangeset
for help on using the changeset viewer.