Plugin Directory

Changeset 3095307

Timestamp:
05/30/2024 06:05:30 PM (2 months ago)
Author:
room34
Message:

Version 11.2.1

Location:
ics-calendar
Files:
144 added
6 edited

Legend:

Unmodified
Added
Removed
  • ics-calendar/trunk/changelog.txt

    r3094839 r3095307  
    11=== ICS Calendar Changelog ===
     2
     3
     4
     5
     6
     7
     8
     9
    210
    311= 11.2.0 - 2024.05.29 =
  • ics-calendar/trunk/class-r34ics.php

    r3094834 r3095307  
    7070        'eventdesc' => false,
    7171        'eventdl' => false,
     72
    7273        'extendmultiday' => false,
    7374        'feedlabel' => '',
     
    616617                        if (!empty($exclude_event)) { continue; }
    617618                       
     619
     620
     621
     622
     623
     624
     625
     626
     627
    618628                        // Set start and end dates for event
    619                         $dtstart_date = wp_date('Ymd', $event->dtstart_array[2], $url_tz);
     629                        $dtstart_date = wp_date('Ymd', $event->dtstart_array[2], $_tz);
    620630                        // Conditional is for events that are missing DTEND altogether, which should never be the case but has been observed in customer support
    621                         $dtend_date = wp_date('Ymd', ($event->dtend_array[2] ?? $event->dtstart_array[2]), $url_tz);
     631                        $dtend_date = wp_date('Ymd', ($event->dtend_array[2] ?? $event->dtstart_array[2]), $_tz);
    622632
    623633                        // All-day events
     
    629639                        // Start/end times
    630640                        else {
    631                             $dtstart_time = wp_date('His', $event->dtstart_array[2], $url_tz);
     641                            $dtstart_time = wp_date('His', $event->dtstart_array[2], $_tz);
    632642                            // Conditional is for events that are missing DTEND altogether, which should never be the case but has been observed in customer support
    633                             $dtend_time = wp_date('His', ($event->dtend_array[2] ?? $event->dtstart_array[2]), $url_tz);
     643                            $dtend_time = wp_date('His', ($event->dtend_array[2] ?? $event->dtstart_array[2]), $_tz);
    634644                            $all_day = false;
    635645                        }
     
    688698                            'uid' => ($event->uid ?: ''),
    689699                            'url' => ($event->url ?? ($event->uri ?: '')),
     700
     701
    690702                        );
    691703                       
     
    698710                        if  (
    699711                                $dtend_date != $dtstart_date &&
    700                                 // Watch out for events that are NOT multiday, but end at midnight of the start date!
    701                                 !($dtend_date == r34ics_date('Ymd', $dtstart_date, $url_tz, '+1 day') && ($dtend_time == '000000' || empty($dtend_time)))
     712                                // Watch out for events that are NOT multiday, but
     713                                !($dtend_date == r34ics_date('Ymd', $dtstart_date, $))
    702714                            )
    703715                        {
     
    710722                                // Multi-day events may be given with end date/time as midnight of the NEXT day (unless $extendmultiday is set)
    711723                                $effective_end_date =   (!empty($all_day) && empty($dtend_time) && empty($extendmultiday))
    712                                                         ? r34ics_date('Ymd', $dtend_date, $url_tz, '-1 day')
     724                                                        ? r34ics_date('Ymd', $dtend_date, $_tz, '-1 day')
    713725                                                        : $dtend_date;
    714726                                if ($dtstart_date == $effective_end_date) {
     
    733745                                    $event_item['multiday']['position'] = 'middle';
    734746                                }
    735                                 $event_item['start'] = !empty($dtstart_time) ? r34ics_time_format($dtstart_time, $timeformat) : null;
    736                                 $event_item['end'] = !empty($dtend_time) ? r34ics_time_format($dtend_time, $timeformat) : null;
     747                                $event_item['start'] = !empty($dtstart_time) ? r34ics_time_format($dtstart_time, $timeformat) : null;
     748                                $event_item['end'] = !empty($dtend_time) ? r34ics_time_format($dtend_time, $timeformat) : null;
    737749                                $ics_data['events'][$loop_date]['all-day'][] = $event_item;
    738750                                // Increment loop date
    739                                 $loop_date = r34ics_date('Ymd', $loop_date, $url_tz, '+1 day');
     751                                $loop_date = r34ics_date('Ymd', $loop_date, $_tz, '+1 day');
    740752                            }
    741753                        }
     
    746758                        // Events with start/end times
    747759                        else {
    748                             $event_item['start'] = r34ics_time_format($dtstart_time, $timeformat);
    749                             $event_item['end'] = r34ics_time_format($dtend_time, $timeformat);
     760                            $event_item['start'] = r34ics_time_format($dtstart_time, $timeformat);
     761                            $event_item['end'] = r34ics_time_format($dtend_time, $timeformat);
    750762                            $ics_data['events'][$dtstart_date]['t'.$dtstart_time][] = $event_item;
    751763                        }
     
    15941606            // eventdl doesn't support feeds using basic auth
    15951607            'eventdl' => (r34ics_boolean_check($eventdl) && !r34ics_boolean_check($basicauth)),
     1608
    15961609            'extendmultiday' => r34ics_boolean_check($extendmultiday),
    15971610            'feedlabel' => $feedlabel,
     
    17271740        $args = apply_filters('r34ics_display_calendar_args', $args, $atts);
    17281741       
     1742
     1743
     1744
     1745
     1746
    17291747        // Allow custom actions prior to generating the calendar output
    17301748        do_action('r34ics_shortcode_before_display_calendar', $args);
  • ics-calendar/trunk/functions.php

    r3084757 r3095307  
    543543    $empty = true;
    544544    array_walk_recursive($array, function($leaf) use (&$empty) {
    545         if ($leaf === [] || trim($leaf ?? '') === '') { return; }
     545        if ($leaf === [] || ) { return; }
    546546        $empty = false;
    547547    });
     
    817817        : '';
    818818    if (!empty($event['multiday']['start_time'])) {
    819         $md_start .= ' <small class="time-inline">' . r34ics_time_format($event['multiday']['start_time'], $args['timeformat']) . '</small>';
     819        $md_start .= ' <small class="time-inline">' . r34ics_time_format($event['multiday']['start_time'], $args['timeformat']) . '</small>';
    820820    }
    821821    if (!empty($event['multiday']['end_time'])) {
    822         $md_end .= ' <small class="time-inline">' . r34ics_time_format($event['multiday']['end_time'], $args['timeformat']) . '</small>';
     822        $md_end .= ' <small class="time-inline">' . r34ics_time_format($event['multiday']['end_time'], $args['timeformat']) . '</small>';
    823823    }
    824824    return '<span class="multiday-start">' . $md_start . '</span><span class="multiday-sep"> &#8211; </span><span class="multiday-end">' . $md_end . '</span>';
     
    11341134 *
    11351135 */
    1136 function r34ics_time_format($time_string='', $time_format='') {
    1137     $time_string = (string)$time_string; // Avoid PHP 8.1 "Passing null to parameter" deprecation notice
    1138     $time_format = (string)$time_format; // Avoid PHP 8.1 "Passing null to parameter" deprecation notice
     1136function r34ics_time_format($time_string='', $time_format='', $tz='', $date=null) {
     1137    // Avoid PHP 8.1 "Passing null to parameter" deprecation notice
     1138    $time_string = (string)$time_string;
     1139    $time_format = (string)$time_format;
     1140
    11391141    $output = '';
     1142
    11401143    // Get time format from WP settings if not passed in
    11411144    if (empty($time_format)) { $time_format = get_option('time_format'); }
     1145
    11421146    // Strip unsupported format elements from string (a temporary workaround until these can be supported)
    1143     $time_format = trim(preg_replace('/[BsueOPTZ]/', '', $time_format));
     1147    $time_format = trim(preg_replace('/[BsueOPZ]/', '', $time_format));
     1148    $time_format_minus_t = trim(preg_replace('/[T]/', '', $time_format));
     1149
    11441150    // Get digits from time string
    11451151    $time_digits = preg_replace('/[^0-9]+/', '', $time_string);
     1152
    11461153    // Get am/pm from time string
    11471154    $time_ampm = preg_replace('/[^amp]+/', '', strtolower($time_string));
    11481155    if ($time_ampm != 'am' && $time_ampm != 'pm') { $time_ampm = null; }
     1156
    11491157    // Prepend zero to digits if length is odd
    11501158    if (strlen($time_digits) % 2 == 1) { $time_digits = '0' . $time_digits; }
     1159
    11511160    // Get hour, minutes and seconds from time digits
    11521161    $time_h = substr($time_digits, 0, 2);
    11531162    $time_m = substr($time_digits, 2, 2);
    11541163    $time_s = strlen($time_digits) == 6 ? substr($time_digits, 4, 2) : null;
     1164
    11551165    // Convert hour to correct 24-hour value if needed
    11561166    if ($time_ampm == 'pm') { $time_h = (int)$time_h + 12; }
    11571167    if ($time_ampm == 'am' && $time_h == '12') { $time_h = '00'; }
     1168
    11581169    // Determine am/pm if not passed in
    11591170    if (empty($time_ampm)) { $time_ampm = (int)$time_h >= 12 ? 'pm' : 'am'; }
     1171
    11601172    // Get 12-hour version of hour
    11611173    $time_h12 = (int)$time_h % 12;
    11621174    if ($time_h12 == 0) { $time_h12 = 12; }
    11631175    if ($time_h12 < 10) { $time_h12 = '0' . (string)$time_h12; }
     1176
    11641177    // Convert am/pm abbreviations for Greek (this is simpler than putting it in the i18n files)
    11651178    if (get_locale() == 'el') { $time_ampm = ($time_ampm == 'am') ? 'πμ' : 'μμ'; }
     1179
    11661180    // Format output
    1167     switch ($time_format) {
     1181    switch ($time_format_minus_t) {
     1182
    11681183        // 12-hour formats without seconds
    11691184        case 'g:i a': $output = intval($time_h12) . ':' . $time_m . '&nbsp;' . $time_ampm; break;
     
    11751190        case 'h:i A': $output = $time_h12 . ':' . $time_m . '&nbsp;' . strtoupper($time_ampm); break;
    11761191        case 'h:iA': $output = $time_h12 . ':' . $time_m . strtoupper($time_ampm); break;
     1192
    11771193        // 24-hour formats without seconds
    11781194        case 'G:i': $output = intval($time_h) . ':' . $time_m; break;
    11791195        case 'G.i': $output = intval($time_h) . '.' . $time_m; break;
    11801196        case 'Gi': $output = intval($time_h) . $time_m; break;
     1197
    11811198        // case 'H:i': is the default, below
    11821199        case 'Hi': $output = $time_h . $time_m; break;
     1200
    11831201        // 24-hour formats without seconds, using h and m or min
    11841202        case 'G \h i \m\i\n': $output = intval($time_h) . '&nbsp;h&nbsp;' . $time_m . '&nbsp;min'; break;
     
    11951213        case 'H\h i\m': $output = $time_h . 'h&nbsp;' . $time_m . 'm'; break;
    11961214        case 'H\hi\m': $output = $time_h . 'h' . $time_m . 'm'; break;
     1215
    11971216        // 12-hour formats with seconds
    11981217        case 'g:i:s a': $output = intval($time_h12) . ':' . $time_m . ':' . $time_s . '&nbsp;' . $time_ampm; break;
     
    12041223        case 'h:i:s A': $output = $time_h12 . ':' . $time_m . ':' . $time_s . '&nbsp;' . strtoupper($time_ampm); break;
    12051224        case 'h:i:sA': $output = $time_h12 . ':' . $time_m . ':' . $time_s . strtoupper($time_ampm); break;
     1225
    12061226        // 24-hour formats with seconds
    12071227        case 'G:i:s': $output = intval($time_h) . ':' . $time_m . ':' . $time_s; break;
    12081228        case 'H:i:s': $output = $time_h . ':' . $time_m . ':' . $time_s; break;
    12091229        case 'His': $output = $time_h . $time_m . $time_s; break;
     1230
    12101231        // Hour-only formats used for grid labels
    12111232        case 'H:00': $output = $time_h . ':00'; break;
     
    12141235        case 'g a': $output = intval($time_h12) . ' ' . $time_ampm; break;
    12151236        case 'g A': $output = intval($time_h12) . ' ' . strtoupper($time_ampm); break;
     1237
    12161238        // Default
    12171239        case 'H:i':
    12181240        default: $output = $time_h . ':' . $time_m; break;
    1219     }
     1241
     1242    }
     1243
     1244    // Append T (timezone) if applicable
     1245    // @todo Insert in the prescribed spot rather than just appending to end!
     1246    if (!empty($tz) && $time_format_minus_t != $time_format) {
     1247        if (is_string($tz)) {
     1248            $tz = (r34ics_is_valid_tz($tz) ? timezone_open($tz) : wp_timezone());
     1249        }
     1250        $output .= ' ' . wp_date('T', (!empty($date) ? r34ics_date('U', $date) : null), $tz);
     1251    }
     1252
    12201253    // Return output
    12211254    return $output;
  • ics-calendar/trunk/ics-calendar.php

    r3094834 r3095307  
    44Plugin URI: https://icscalendar.com
    55Description: Turn your Google Calendar, Microsoft Office 365 or Apple iCloud Calendar into a seamlessly integrated, auto-updating, zero-maintenance WordPress experience.
    6 Version: 11.2.0
     6Version: 11.2.
    77Requires at least: 4.9
    88Requires PHP: 7.0
  • ics-calendar/trunk/readme.txt

    r3094839 r3095307  
    66Tested up to: 6.5.3
    77Requires PHP: 7.0
    8 Stable tag: 11.2.0
     8Stable tag: 11.2.
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9999
    100100== Changelog ==
     101
     102
     103
     104
     105
     106
     107
     108
    101109
    102110= 11.2.0 - 2024.05.29 =
  • ics-calendar/trunk/templates/admin/admin-options.php

    r3091077 r3095307  
    1 <p class="r34ics-input">
    2     <label for="r34ics-admin-options-transients_expiration"><strong><?php _e('Transient (cache) expiration', 'r34ics'); ?>:</strong> <input type="number" name="transients_expiration" id="r34ics-admin-options-transients_expiration" value="<?php echo esc_attr(get_option('r34ics_transients_expiration') ? get_option('r34ics_transients_expiration') : 3600); ?>" min="0" max="86400" style="width: 100px;" /> <?php _e('seconds', 'r34ics'); ?></label>
    3     <span class="description"><small class="r34ics-help"><span class="help_content"><?php _e('Sets how long calendar feed data should be cached on the server (WordPress transients) before reloading. Default is 3600 (1 hour).', 'r34ics'); ?></span></small></span>
    4 </p>
    5 
    6 <p class="r34ics-input">
    7     <label for="r34ics_allowed_hosts"><strong><?php _e('Allow access to these hostnames that resolve to reserved IP addresses', 'r34ics'); ?>:</strong><br />
    8     <textarea name="allowed_hosts" id="r34ics_allowed_hosts" style="max-width: 400px; width: 100%; height: 4.5rem;" /><?php echo esc_attr(implode("\n", get_option('r34ics_allowed_hosts') ? get_option('r34ics_allowed_hosts') : array())); ?></textarea></label>
    9     <span class="description"><small class="r34ics-help"><span class="help_content"><?php printf(__('If your calendar server is hosted on the same physical server as your website, is part of the same local network, or otherwise uses a %1$sreserved IP address%2$s, enter its hostname here to allow access. For multiple calendar servers, enter one hostname per line. See %3$sthe %4$s documentation%5$s for more information.', 'r34ics'), '<a href="https://en.wikipedia.org/wiki/Internet_Protocol_version_4#Special-use_addresses" target="_blank">', '</a>', '<a href="https://icscalendar.com/developer/#http_request_host_is_external" target="_blank">', 'ICS Calendar', '</a>'); ?></span></small></span><br />
    10     <small><?php _e('Enter one hostname per line.', 'r34ics'); ?></small>
    11 </p>
    12 
    131<p class="r34ics-input">
    142    <label for="r34ics_ajax_by_default"><input type="checkbox" name="ajax_by_default" id="r34ics_ajax_by_default"<?php if (get_option('r34ics_ajax_by_default')) { echo ' checked="checked"'; } ?> /> <strong><?php _e('Always use AJAX to render calendars (recommended)', 'r34ics'); ?></strong></label>
     
    3119</p>
    3220
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
Note: See TracChangeset for help on using the changeset viewer.