Plugin Directory

Changeset 3418960


Ignore:
Timestamp:
12/13/2025 03:01:52 PM (3 months ago)
Author:
reventor
Message:

Version 1.1.3 – Breaks Added in Update

Location:
reventor-calendar-appointment-booking/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • reventor-calendar-appointment-booking/trunk/assets/css/admin.css

    r3407895 r3418960  
    265265}
    266266
     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
    267320.reventorcab-field-group .description {
    268321    color: #646970;
     
    753806        flex-direction: column;
    754807        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%;
    755818    }
    756819}
  • reventor-calendar-appointment-booking/trunk/includes/class-admin.php

    r3352327 r3418960  
    4949        register_setting('reventorcab_settings', 'reventorcab_working_hours_start', ['sanitize_callback' => 'sanitize_text_field']);
    5050        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']);
    5153        register_setting('reventorcab_settings', 'reventorcab_working_days', ['sanitize_callback' => [$this, 'sanitize_working_days']]);
    5254        register_setting('reventorcab_settings', 'reventorcab_timeslot_granularity', ['sanitize_callback' => 'intval']);
     
    178180        $working_hours_start = get_option('reventorcab_working_hours_start', '09:00');
    179181        $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');
    180184        $working_days = get_option('reventorcab_working_days', array('monday', 'tuesday', 'wednesday', 'thursday', 'friday'));
    181185        $timezone = get_option('reventorcab_timezone', 'UTC');
     
    250254        $working_hours_start = isset($_POST['working_hours_start']) ? sanitize_text_field(wp_unslash($_POST['working_hours_start'])) : '09:00';
    251255        $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';
    252258        $working_days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday');
    253259        if (isset($_POST['working_days']) && is_array($_POST['working_days'])) {
     
    260266        update_option('reventorcab_working_hours_start', $working_hours_start);
    261267        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);
    262270        update_option('reventorcab_working_days', $working_days);
    263271       
     
    512520            'reventorcab_working_hours_start' => get_option('reventorcab_working_hours_start', '09:00'),
    513521            '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'),
    514524            'reventorcab_working_days' => get_option('reventorcab_working_days', array('monday', 'tuesday', 'wednesday', 'thursday', 'friday')),
    515525
     
    574584            'reventorcab_working_hours_start',
    575585            'reventorcab_working_hours_end',
     586            'reventorcab_break_start',
     587            'reventorcab_break_end',
    576588            'reventorcab_working_days',
    577589
  • reventor-calendar-appointment-booking/trunk/includes/class-frontend.php

    r3408023 r3418960  
    603603        $working_hours_start = get_option('reventorcab_working_hours_start', '09:00');
    604604        $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
    606608        // Get plugin's configured timezone for working hours calculation
    607609        try {
     
    644646                $slot_datetime = new DateTime('@' . $time);
    645647                $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;
    647657            }
    648658        } else {
     
    683693            $this->debug_log("Min advance setting: " . get_option('reventorcab_min_booking_advance', '2h'));
    684694            $this->debug_log("Working hours: {$working_hours_start} - {$working_hours_end}");
    685            
     695            $this->debug_log("Break time: {$break_start} - {$break_end}");
     696
    686697            // Use granularity setting instead of appointment duration for slot generation
    687698            $granularity = get_option('reventorcab_timeslot_granularity', 15);
     
    703714                $this->debug_log("Time >= min advance: " . ($time >= $min_advance_time ? 'true' : 'false'));
    704715               
    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
    706717                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                   
    707724                    $slots[] = $slot_time_display; // Store display time for frontend
    708725                    $this->debug_log("Slot {$slot_time_display} added to available slots");
     
    10661083        reventorcab_log($message);
    10671084    }
     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    }
    10681109   
    10691110    /**
  • reventor-calendar-appointment-booking/trunk/includes/functions.php

    r3408023 r3418960  
    340340
    341341/**
     342 * Check if a given time falls within the break time
     343 */
     344function 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 */
     357function 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/**
    342366 * Get timezone string - SIMPLIFIED VERSION
    343367 * Forces use of reventorcab_timezone only to ensure consistency across servers
     
    480504    $working_hours_start = get_option('reventorcab_working_hours_start', '09:00');
    481505    $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
    483509    // Create timezone-aware datetime objects for working hours
    484510    $start_datetime = new DateTime($date . ' ' . $working_hours_start . ':00', $timezone);
     
    501527        $slot_time = $slot_datetime->format('H:i');
    502528       
    503         // Skip slots that are in the past or don't meet minimum advance time
     529    // Skip slots that are in the past, don't meet minimum advance time, or fall within break time
    504530        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            }
    505535            $available_slots[] = $slot_time;
    506536        }
  • reventor-calendar-appointment-booking/trunk/readme.txt

    r3408156 r3418960  
    44Requires at least: 6.3
    55Tested up to: 6.9
    6 Stable tag: 1.1.2
    7 Requires PHP: 8.1
     6Stable tag: 1.1.3
     7Requires PHP: 8.3
    88License: GPL v2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4242== Changelog ==
    4343
     44= 1.1.3 =
     45* Added Break times feature
     46
    4447= 1.1.2 =
    4548* 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  
    44 * Description: A REVENTOR calendar appointment booking system with CalDAV integration for seamless scheduling and calendar synchronization.
    55 * Plugin URI: https://wordpress.org/plugins/reventor-calendar-appointment-booking/
    6  * Version: 1.1.2
     6 * Version: 1.1.3
    77 * Author: REVENTOR
    88 * Author URI: https://reventor.eu
     
    4040define('REVENTORCAB_PLUGIN_URL', plugin_dir_url(__FILE__));
    4141define('REVENTORCAB_PLUGIN_PATH', plugin_dir_path(__FILE__));
    42 define('REVENTORCAB_VERSION', '1.1.2');
     42define('REVENTORCAB_VERSION', '1.1.3');
    4343
    4444// Main plugin class
  • reventor-calendar-appointment-booking/trunk/templates/admin-page.php

    r3407895 r3418960  
    188188                    <h3><?php esc_html_e('Working Hours', 'reventor-calendar-appointment-booking'); ?></h3>
    189189                   
    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>
    224245                    </div>
    225246                   
Note: See TracChangeset for help on using the changeset viewer.