Plugin Directory

Changeset 3382840


Ignore:
Timestamp:
10/22/2025 05:42:04 PM (5 months ago)
Author:
stankovski
Message:

Version 1.0.3

Location:
muslim-prayer-times/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • muslim-prayer-times/trunk/includes/helpers.php

    r3303241 r3382840  
    169169
    170170// Helper function to calculate Fajr Iqama times for a collection of days
    171 function muslprti_calculate_fajr_iqama($days_data, $fajr_rule, $fajr_minutes_after, $fajr_minutes_before_shuruq, $is_weekly, $fajr_rounding) {
     171function muslprti_calculate_fajr_iqama($days_data, $fajr_rule, $fajr_minutes_after, $fajr_minutes_before_shuruq, $is_weekly, $fajr_rounding, $fajr_min_time = '00:00', $fajr_max_time = '23:59') {
    172172    $results = [];
    173173   
     
    231231        }
    232232       
    233         // Denormalize the result to account for DST before storing
     233        // Denormalize the result to account for DST before applying constraints
    234234        // Use the original date for denormalization to maintain correct DST information
    235235        $day_fajr_iqama = muslprti_denormalize_time_for_dst($day_fajr_iqama);
     236       
     237        // Create min_fajr_time and max_fajr_time as DateTime objects
     238        $min_fajr_time = clone $day_date;
     239        list($hours, $minutes) = explode(':', $fajr_min_time);
     240        $min_fajr_time->setTime((int)$hours, (int)$minutes);
     241       
     242        $max_fajr_time = clone $day_date;
     243        list($hours, $minutes) = explode(':', $fajr_max_time);
     244        $max_fajr_time->setTime((int)$hours, (int)$minutes);
     245       
     246        // Apply minimum constraint: use the greater of calculated time or min_fajr_time
     247        if (muslprti_time_to_minutes($day_fajr_iqama) < muslprti_time_to_minutes($min_fajr_time)) {
     248            $day_fajr_iqama = $min_fajr_time;
     249        }
     250       
     251        // Apply maximum constraint: use the lesser of result or max_fajr_time
     252        if (muslprti_time_to_minutes($day_fajr_iqama) > muslprti_time_to_minutes($max_fajr_time)) {
     253            $day_fajr_iqama = $max_fajr_time;
     254        }
    236255       
    237256        $results[$day_index] = $day_fajr_iqama;
  • muslim-prayer-times/trunk/readme.txt

    r3307273 r3382840  
    33Tags: prayer times, muslim, islamic, mosque, salah
    44Requires at least: 5.0
    5 Tested up to: 6.8
     5Tested up to: 6.8.3
    66Stable tag: 1.0.2
    77Requires PHP: 7.0
     
    151151Initial release of Muslim Prayer Times plugin.
    152152
    153 = 1.0.2 =
    154 * Added support for custom date format
    155 * Minor bug fixed
     153= 1.0.3 =
     154Bug fixes.
  • muslim-prayer-times/trunk/settings-ajax.php

    r3307273 r3382840  
    150150        $fajr_daily_change = isset($opts['fajr_daily_change']) ? $opts['fajr_daily_change'] : 0;
    151151        $fajr_rounding = isset($opts['fajr_rounding']) ? $opts['fajr_rounding'] : 1;
     152        $fajr_min_time = isset($opts['fajr_min_time']) ? $opts['fajr_min_time'] : '05:00';
     153        $fajr_max_time = isset($opts['fajr_max_time']) ? $opts['fajr_max_time'] : '07:00';
    152154       
    153155        $dhuhr_rule = isset($opts['dhuhr_rule']) ? $opts['dhuhr_rule'] : 'after_athan';
     
    223225            // Store this day's data
    224226            $day_index = $processed_days;
     227            $date_prefix = $current_date->format('Y-m-d') . ' ';
    225228            $week_days_data[$day_index] = [
    226229                'date' => clone $current_date,
    227230                'formatted_date' => $current_date->format('Y-m-d'),
    228231                'athan' => [
    229                     'fajr' => new DateTime($times['Fajr'], $dtz),
    230                     'sunrise' => new DateTime($times['Sunrise'], $dtz),
    231                     'dhuhr' => new DateTime($times['Dhuhr'], $dtz),
    232                     'asr' => new DateTime($times['Asr'], $dtz),
    233                     'maghrib' => new DateTime($times['Maghrib'], $dtz),
    234                     'isha' => new DateTime($times['Isha'], $dtz)
     232                    'fajr' => new DateTime($date_prefix . $times['Fajr'], $dtz),
     233                    'sunrise' => new DateTime($date_prefix . $times['Sunrise'], $dtz),
     234                    'dhuhr' => new DateTime($date_prefix . $times['Dhuhr'], $dtz),
     235                    'asr' => new DateTime($date_prefix . $times['Asr'], $dtz),
     236                    'maghrib' => new DateTime($date_prefix . $times['Maghrib'], $dtz),
     237                    'isha' => new DateTime($date_prefix . $times['Isha'], $dtz)
    235238                ]
    236239            ];
     
    248251                    $fajr_rule,
    249252                    $fajr_minutes_after,
    250                     $fajr_minutes_before_shuruq, 
     253                    $fajr_minutes_before_shuruq,
    251254                    $is_weekly && !$fajr_daily_change,
    252                     $fajr_rounding
     255                    $fajr_rounding,
     256                    $fajr_min_time,
     257                    $fajr_max_time
    253258                );
    254259               
  • muslim-prayer-times/trunk/settings.php

    r3307273 r3382840  
    378378        $opts['fajr_daily_change'] = isset($_POST['muslprti_fajr_daily_change']) ? 1 : 0;
    379379        $opts['fajr_rounding'] = isset($_POST['muslprti_fajr_rounding']) ? intval(wp_unslash($_POST['muslprti_fajr_rounding'])) : 1;
     380        $opts['fajr_min_time'] = isset($_POST['muslprti_fajr_min_time']) ? sanitize_text_field(wp_unslash($_POST['muslprti_fajr_min_time'])) : '05:00';
     381        $opts['fajr_max_time'] = isset($_POST['muslprti_fajr_max_time']) ? sanitize_text_field(wp_unslash($_POST['muslprti_fajr_max_time'])) : '07:00';
    380382       
    381383        // Dhuhr rules
     
    472474    $fajr_daily_change = isset($opts['fajr_daily_change']) ? $opts['fajr_daily_change'] : 0;
    473475    $fajr_rounding = isset($opts['fajr_rounding']) ? $opts['fajr_rounding'] : 1;
     476    $fajr_min_time = isset($opts['fajr_min_time']) ? $opts['fajr_min_time'] : '05:00';
     477    $fajr_max_time = isset($opts['fajr_max_time']) ? $opts['fajr_max_time'] : '07:00';
    474478   
    475479    // Dhuhr defaults
     
    739743                                <p class="description">Note: For safety, this will never be less than 15 minutes before sunrise.</p>
    740744                            </div>
     745                        </div>
     746                       
     747                        <div class="iqama-rule-option">
     748                            <p><strong>Time constraints (applies to all rules):</strong></p>
     749                            <p>
     750                                <label>Minimum Fajr time: <input type="time" name="muslprti_fajr_min_time" value="<?php echo esc_attr($fajr_min_time); ?>"></label><br>
     751                                <label>Maximum Fajr time: <input type="time" name="muslprti_fajr_max_time" value="<?php echo esc_attr($fajr_max_time); ?>"></label>
     752                            </p>
     753                            <p class="description">These settings ensure Fajr Iqama is never before the minimum time or after the maximum time. For "before Shuruq" rule, the maximum is automatically limited to the calculated time before sunrise.</p>
    741754                        </div>
    742755                    </div>
Note: See TracChangeset for help on using the changeset viewer.