Changeset 3095307
- Timestamp:
- 05/30/2024 06:05:30 PM (2 months ago)
- Location:
- ics-calendar
- Files:
-
- 144 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
ics-calendar/trunk/changelog.txt
r3094839 r3095307 1 1 === ICS Calendar Changelog === 2 3 4 5 6 7 8 9 2 10 3 11 = 11.2.0 - 2024.05.29 = -
ics-calendar/trunk/class-r34ics.php
r3094834 r3095307 70 70 'eventdesc' => false, 71 71 'eventdl' => false, 72 72 73 'extendmultiday' => false, 73 74 'feedlabel' => '', … … 616 617 if (!empty($exclude_event)) { continue; } 617 618 619 620 621 622 623 624 625 626 627 618 628 // 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); 620 630 // 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); 622 632 623 633 // All-day events … … 629 639 // Start/end times 630 640 else { 631 $dtstart_time = wp_date('His', $event->dtstart_array[2], $ url_tz);641 $dtstart_time = wp_date('His', $event->dtstart_array[2], $_tz); 632 642 // 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); 634 644 $all_day = false; 635 645 } … … 688 698 'uid' => ($event->uid ?: ''), 689 699 'url' => ($event->url ?? ($event->uri ?: '')), 700 701 690 702 ); 691 703 … … 698 710 if ( 699 711 $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, $)) 702 714 ) 703 715 { … … 710 722 // Multi-day events may be given with end date/time as midnight of the NEXT day (unless $extendmultiday is set) 711 723 $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') 713 725 : $dtend_date; 714 726 if ($dtstart_date == $effective_end_date) { … … 733 745 $event_item['multiday']['position'] = 'middle'; 734 746 } 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; 737 749 $ics_data['events'][$loop_date]['all-day'][] = $event_item; 738 750 // 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'); 740 752 } 741 753 } … … 746 758 // Events with start/end times 747 759 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); 750 762 $ics_data['events'][$dtstart_date]['t'.$dtstart_time][] = $event_item; 751 763 } … … 1594 1606 // eventdl doesn't support feeds using basic auth 1595 1607 'eventdl' => (r34ics_boolean_check($eventdl) && !r34ics_boolean_check($basicauth)), 1608 1596 1609 'extendmultiday' => r34ics_boolean_check($extendmultiday), 1597 1610 'feedlabel' => $feedlabel, … … 1727 1740 $args = apply_filters('r34ics_display_calendar_args', $args, $atts); 1728 1741 1742 1743 1744 1745 1746 1729 1747 // Allow custom actions prior to generating the calendar output 1730 1748 do_action('r34ics_shortcode_before_display_calendar', $args); -
ics-calendar/trunk/functions.php
r3084757 r3095307 543 543 $empty = true; 544 544 array_walk_recursive($array, function($leaf) use (&$empty) { 545 if ($leaf === [] || trim($leaf ?? '') === '') { return; }545 if ($leaf === [] || ) { return; } 546 546 $empty = false; 547 547 }); … … 817 817 : ''; 818 818 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>'; 820 820 } 821 821 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>'; 823 823 } 824 824 return '<span class="multiday-start">' . $md_start . '</span><span class="multiday-sep"> – </span><span class="multiday-end">' . $md_end . '</span>'; … … 1134 1134 * 1135 1135 */ 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 1136 function 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 1139 1141 $output = ''; 1142 1140 1143 // Get time format from WP settings if not passed in 1141 1144 if (empty($time_format)) { $time_format = get_option('time_format'); } 1145 1142 1146 // 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 1144 1150 // Get digits from time string 1145 1151 $time_digits = preg_replace('/[^0-9]+/', '', $time_string); 1152 1146 1153 // Get am/pm from time string 1147 1154 $time_ampm = preg_replace('/[^amp]+/', '', strtolower($time_string)); 1148 1155 if ($time_ampm != 'am' && $time_ampm != 'pm') { $time_ampm = null; } 1156 1149 1157 // Prepend zero to digits if length is odd 1150 1158 if (strlen($time_digits) % 2 == 1) { $time_digits = '0' . $time_digits; } 1159 1151 1160 // Get hour, minutes and seconds from time digits 1152 1161 $time_h = substr($time_digits, 0, 2); 1153 1162 $time_m = substr($time_digits, 2, 2); 1154 1163 $time_s = strlen($time_digits) == 6 ? substr($time_digits, 4, 2) : null; 1164 1155 1165 // Convert hour to correct 24-hour value if needed 1156 1166 if ($time_ampm == 'pm') { $time_h = (int)$time_h + 12; } 1157 1167 if ($time_ampm == 'am' && $time_h == '12') { $time_h = '00'; } 1168 1158 1169 // Determine am/pm if not passed in 1159 1170 if (empty($time_ampm)) { $time_ampm = (int)$time_h >= 12 ? 'pm' : 'am'; } 1171 1160 1172 // Get 12-hour version of hour 1161 1173 $time_h12 = (int)$time_h % 12; 1162 1174 if ($time_h12 == 0) { $time_h12 = 12; } 1163 1175 if ($time_h12 < 10) { $time_h12 = '0' . (string)$time_h12; } 1176 1164 1177 // Convert am/pm abbreviations for Greek (this is simpler than putting it in the i18n files) 1165 1178 if (get_locale() == 'el') { $time_ampm = ($time_ampm == 'am') ? 'πμ' : 'μμ'; } 1179 1166 1180 // Format output 1167 switch ($time_format) { 1181 switch ($time_format_minus_t) { 1182 1168 1183 // 12-hour formats without seconds 1169 1184 case 'g:i a': $output = intval($time_h12) . ':' . $time_m . ' ' . $time_ampm; break; … … 1175 1190 case 'h:i A': $output = $time_h12 . ':' . $time_m . ' ' . strtoupper($time_ampm); break; 1176 1191 case 'h:iA': $output = $time_h12 . ':' . $time_m . strtoupper($time_ampm); break; 1192 1177 1193 // 24-hour formats without seconds 1178 1194 case 'G:i': $output = intval($time_h) . ':' . $time_m; break; 1179 1195 case 'G.i': $output = intval($time_h) . '.' . $time_m; break; 1180 1196 case 'Gi': $output = intval($time_h) . $time_m; break; 1197 1181 1198 // case 'H:i': is the default, below 1182 1199 case 'Hi': $output = $time_h . $time_m; break; 1200 1183 1201 // 24-hour formats without seconds, using h and m or min 1184 1202 case 'G \h i \m\i\n': $output = intval($time_h) . ' h ' . $time_m . ' min'; break; … … 1195 1213 case 'H\h i\m': $output = $time_h . 'h ' . $time_m . 'm'; break; 1196 1214 case 'H\hi\m': $output = $time_h . 'h' . $time_m . 'm'; break; 1215 1197 1216 // 12-hour formats with seconds 1198 1217 case 'g:i:s a': $output = intval($time_h12) . ':' . $time_m . ':' . $time_s . ' ' . $time_ampm; break; … … 1204 1223 case 'h:i:s A': $output = $time_h12 . ':' . $time_m . ':' . $time_s . ' ' . strtoupper($time_ampm); break; 1205 1224 case 'h:i:sA': $output = $time_h12 . ':' . $time_m . ':' . $time_s . strtoupper($time_ampm); break; 1225 1206 1226 // 24-hour formats with seconds 1207 1227 case 'G:i:s': $output = intval($time_h) . ':' . $time_m . ':' . $time_s; break; 1208 1228 case 'H:i:s': $output = $time_h . ':' . $time_m . ':' . $time_s; break; 1209 1229 case 'His': $output = $time_h . $time_m . $time_s; break; 1230 1210 1231 // Hour-only formats used for grid labels 1211 1232 case 'H:00': $output = $time_h . ':00'; break; … … 1214 1235 case 'g a': $output = intval($time_h12) . ' ' . $time_ampm; break; 1215 1236 case 'g A': $output = intval($time_h12) . ' ' . strtoupper($time_ampm); break; 1237 1216 1238 // Default 1217 1239 case 'H:i': 1218 1240 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 1220 1253 // Return output 1221 1254 return $output; -
ics-calendar/trunk/ics-calendar.php
r3094834 r3095307 4 4 Plugin URI: https://icscalendar.com 5 5 Description: 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. 06 Version: 11.2. 7 7 Requires at least: 4.9 8 8 Requires PHP: 7.0 -
ics-calendar/trunk/readme.txt
r3094839 r3095307 6 6 Tested up to: 6.5.3 7 7 Requires PHP: 7.0 8 Stable tag: 11.2. 08 Stable tag: 11.2. 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 99 99 100 100 == Changelog == 101 102 103 104 105 106 107 108 101 109 102 110 = 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 13 1 <p class="r34ics-input"> 14 2 <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> … … 31 19 </p> 32 20 21 22 23 24 25 26 27 28 29 30 31
Note: See TracChangeset
for help on using the changeset viewer.