@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use Carbon\Carbon; |
10 | 10 | use SimpleCalendar\Abstracts\Calendar; |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param Event $event |
55 | 55 | * @param Calendar $calendar |
56 | 56 | */ |
57 | - public function __construct( Event $event, Calendar $calendar ) { |
|
57 | + public function __construct(Event $event, Calendar $calendar) { |
|
58 | 58 | $this->event = $event; |
59 | 59 | $this->calendar = $calendar; |
60 | 60 | $this->tags = $this->get_content_tags(); |
@@ -74,84 +74,84 @@ discard block |
||
74 | 74 | * Content Tags * |
75 | 75 | * ============ */ |
76 | 76 | |
77 | - 'title', // The event title. |
|
78 | - 'event-title', // @deprecated An alias for 'title' tag. |
|
79 | - 'description', // The event description. |
|
80 | - |
|
81 | - 'when', // Date and time of the event. |
|
82 | - 'start-time', // Start time of the event. |
|
83 | - 'start-date', // Start date of the event. |
|
84 | - 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
85 | - 'start-human', // Start time in a human friendly format. |
|
86 | - 'end-time', // End time of the event. |
|
87 | - 'end-date', // End date of the event. |
|
88 | - 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
89 | - 'end-human', // End date-time in a human friendly format. |
|
90 | - |
|
91 | - 'duration', // How long the events lasts, in a human-readable format. |
|
92 | - 'length', // @deprecated An alias of 'duration' tag. |
|
93 | - |
|
94 | - 'location', // Alias of start-location. |
|
95 | - 'start-location', // Location name where the event starts. |
|
96 | - 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
97 | - 'start-location-link', // Link to Google Maps querying the event start location address. |
|
98 | - 'end-location', // Location name where the event ends. |
|
99 | - 'end-location-link', // Link to Google Maps querying the event end location address. |
|
100 | - |
|
101 | - 'link', // An HTML link to the event URL. |
|
102 | - 'url', // A string with the raw event link URL. |
|
103 | - |
|
104 | - 'calendar', // The title of the source calendar. |
|
105 | - 'feed-title', // @deprecated An alias of 'calendar'. |
|
106 | - |
|
107 | - 'id', // The event unique ID. |
|
108 | - 'uid', // An alias of ID. |
|
109 | - 'event-id', // @deprecated An alias for 'id' tag. |
|
110 | - 'calendar-id', // The calendar ID. |
|
111 | - 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
112 | - 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
77 | + 'title', // The event title. |
|
78 | + 'event-title', // @deprecated An alias for 'title' tag. |
|
79 | + 'description', // The event description. |
|
80 | + |
|
81 | + 'when', // Date and time of the event. |
|
82 | + 'start-time', // Start time of the event. |
|
83 | + 'start-date', // Start date of the event. |
|
84 | + 'start-custom', // @deprecated Start time in a user defined format (set by tag 'format' attribute). |
|
85 | + 'start-human', // Start time in a human friendly format. |
|
86 | + 'end-time', // End time of the event. |
|
87 | + 'end-date', // End date of the event. |
|
88 | + 'end-custom', // @deprecated End date-time in a user defined format (set by tag 'format' attribute). |
|
89 | + 'end-human', // End date-time in a human friendly format. |
|
90 | + |
|
91 | + 'duration', // How long the events lasts, in a human-readable format. |
|
92 | + 'length', // @deprecated An alias of 'duration' tag. |
|
93 | + |
|
94 | + 'location', // Alias of start-location. |
|
95 | + 'start-location', // Location name where the event starts. |
|
96 | + 'maps-link', // @deprecated An alias for 'start-location-link' tag. |
|
97 | + 'start-location-link', // Link to Google Maps querying the event start location address. |
|
98 | + 'end-location', // Location name where the event ends. |
|
99 | + 'end-location-link', // Link to Google Maps querying the event end location address. |
|
100 | + |
|
101 | + 'link', // An HTML link to the event URL. |
|
102 | + 'url', // A string with the raw event link URL. |
|
103 | + |
|
104 | + 'calendar', // The title of the source calendar. |
|
105 | + 'feed-title', // @deprecated An alias of 'calendar'. |
|
106 | + |
|
107 | + 'id', // The event unique ID. |
|
108 | + 'uid', // An alias of ID. |
|
109 | + 'event-id', // @deprecated An alias for 'id' tag. |
|
110 | + 'calendar-id', // The calendar ID. |
|
111 | + 'feed-id', // @deprecated An alias for 'calendar-id' tag. |
|
112 | + 'cal-id', // @deprecated An alias for 'calendar-id' tag. |
|
113 | 113 | |
114 | 114 | /* ========= * |
115 | 115 | * Meta Tags * |
116 | 116 | * ========= */ |
117 | 117 | |
118 | - 'attachments', // List of attachments. |
|
119 | - 'attendees', // List of attendees. |
|
120 | - 'organizer', // Creator info. |
|
118 | + 'attachments', // List of attachments. |
|
119 | + 'attendees', // List of attendees. |
|
120 | + 'organizer', // Creator info. |
|
121 | 121 | |
122 | 122 | /* ================ * |
123 | 123 | * Conditional Tags * |
124 | 124 | * ================ */ |
125 | 125 | |
126 | - 'if-title', // If the event has a title. |
|
127 | - 'if-description', // If the event has a description. |
|
128 | - |
|
129 | - 'if-now', // If the event is taking place now. |
|
130 | - 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
131 | - 'if-started', // If the event has started (and may as well as ended). |
|
132 | - 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
133 | - 'if-ended', // If the event has ended (event could be any time in the past). |
|
134 | - 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
135 | - |
|
136 | - 'if-whole-day', // If the event lasts the whole day. |
|
137 | - 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
138 | - 'if-not-whole-day', // If the event does NOT last the whole day. |
|
139 | - 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
140 | - 'if-end-time', // If the event has a set end time. |
|
141 | - 'if-no-end-time', // If the event has NOT a set end time. |
|
142 | - |
|
143 | - 'if-multi-day', // If the event spans multiple days. |
|
144 | - 'if-single-day', // If the event does not span multiple days. |
|
145 | - |
|
146 | - 'if-recurring', // If the event is a recurring event. |
|
147 | - 'if-not-recurring', // If the event is NOT a recurring event. |
|
148 | - |
|
149 | - 'if-location', // @deprecated Alias for 'if-start-location'. |
|
150 | - 'if-start-location', // Does the event has a start location? |
|
151 | - 'if-end-location', // Does the event has an end location? |
|
152 | - 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
126 | + 'if-title', // If the event has a title. |
|
127 | + 'if-description', // If the event has a description. |
|
128 | + |
|
129 | + 'if-now', // If the event is taking place now. |
|
130 | + 'if-not-now', // If the event is not taking place now (may have ended or just not started yet). |
|
131 | + 'if-started', // If the event has started (and may as well as ended). |
|
132 | + 'if-not-started', // If the event has NOT started yet (event could be any time in the future). |
|
133 | + 'if-ended', // If the event has ended (event could be any time in the past). |
|
134 | + 'if-not-ended', // If the event has NOT ended (may as well as not started yet). |
|
135 | + |
|
136 | + 'if-whole-day', // If the event lasts the whole day. |
|
137 | + 'if-all-day', // @deprecated Alias for 'if-whole-day'. |
|
138 | + 'if-not-whole-day', // If the event does NOT last the whole day. |
|
139 | + 'if-not-all-day', // @deprecated Alias for 'if-not-whole-day'. |
|
140 | + 'if-end-time', // If the event has a set end time. |
|
141 | + 'if-no-end-time', // If the event has NOT a set end time. |
|
142 | + |
|
143 | + 'if-multi-day', // If the event spans multiple days. |
|
144 | + 'if-single-day', // If the event does not span multiple days. |
|
145 | + |
|
146 | + 'if-recurring', // If the event is a recurring event. |
|
147 | + 'if-not-recurring', // If the event is NOT a recurring event. |
|
148 | + |
|
149 | + 'if-location', // @deprecated Alias for 'if-start-location'. |
|
150 | + 'if-start-location', // Does the event has a start location? |
|
151 | + 'if-end-location', // Does the event has an end location? |
|
152 | + 'if-not-location', // @deprecated Alias for 'if-not-start-location'. |
|
153 | 153 | 'if-not-start-location', // Does the event has NOT a start location? |
154 | - 'if-not-end-location', // Does the event has NOT an end location? |
|
154 | + 'if-not-end-location', // Does the event has NOT an end location? |
|
155 | 155 | |
156 | 156 | ); |
157 | 157 | } |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return string |
167 | 167 | */ |
168 | - public function parse_event_template_tags( $template_tags = '' ) { |
|
168 | + public function parse_event_template_tags($template_tags = '') { |
|
169 | 169 | |
170 | 170 | // Process tags. |
171 | 171 | $result = preg_replace_callback( |
172 | 172 | $this->get_regex(), |
173 | - array( $this, 'process_event_content' ), |
|
173 | + array($this, 'process_event_content'), |
|
174 | 174 | $template_tags |
175 | 175 | ); |
176 | 176 | |
177 | 177 | // Removes extra consecutive <br> tags. |
178 | - return preg_replace( '#(<br */?>\s*)+#i', '<br />', trim( $result ) ); |
|
178 | + return preg_replace('#(<br */?>\s*)+#i', '<br />', trim($result)); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string |
189 | 189 | */ |
190 | - public function process_event_content( $match ) { |
|
190 | + public function process_event_content($match) { |
|
191 | 191 | |
192 | - if ( $match[1] == '[' && $match[6] == ']' ) { |
|
193 | - return substr( $match[0], 1, - 1 ); |
|
192 | + if ($match[1] == '[' && $match[6] == ']') { |
|
193 | + return substr($match[0], 1, - 1); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | $tag = $match[2]; // Tag name without square brackets. |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | $calendar = $this->calendar; |
203 | 203 | $event = $this->event; |
204 | 204 | |
205 | - if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) { |
|
205 | + if (($calendar instanceof Calendar) && ($event instanceof Event)) { |
|
206 | 206 | |
207 | - switch ( $tag ) { |
|
207 | + switch ($tag) { |
|
208 | 208 | |
209 | 209 | /* ============ * |
210 | 210 | * Content Tags * |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | |
213 | 213 | case 'title' : |
214 | 214 | case 'event-title' : |
215 | - return $this->get_title( $event->title, $attr ); |
|
215 | + return $this->get_title($event->title, $attr); |
|
216 | 216 | |
217 | 217 | case 'description' : |
218 | - return $this->get_description( $event->description, $attr ); |
|
218 | + return $this->get_description($event->description, $attr); |
|
219 | 219 | |
220 | 220 | case 'when' : |
221 | - return $this->get_when( $event ); |
|
221 | + return $this->get_when($event); |
|
222 | 222 | |
223 | 223 | case 'end-date' : |
224 | 224 | case 'end-custom' : |
@@ -228,40 +228,40 @@ discard block |
||
228 | 228 | case 'start-date' : |
229 | 229 | case 'start-human' : |
230 | 230 | case 'start-time' : |
231 | - return $this->get_dt( $tag, $event, $attr ); |
|
231 | + return $this->get_dt($tag, $event, $attr); |
|
232 | 232 | |
233 | 233 | case 'length' : |
234 | 234 | case 'duration' : |
235 | - if ( false !== $event->end ) { |
|
235 | + if (false !== $event->end) { |
|
236 | 236 | $duration = $event->start - $event->end; |
237 | - $value = human_time_diff( $event->start, $event->end ); |
|
237 | + $value = human_time_diff($event->start, $event->end); |
|
238 | 238 | } else { |
239 | 239 | $duration = '-1'; |
240 | - $value = __( 'No end time', 'google-calendar-events' ); |
|
240 | + $value = __('No end time', 'google-calendar-events'); |
|
241 | 241 | } |
242 | - return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>'; |
|
242 | + return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>'; |
|
243 | 243 | |
244 | 244 | case 'location' : |
245 | 245 | case 'start-location' : |
246 | 246 | case 'end-location' : |
247 | 247 | $location = $tag == 'end-location' ? $event->end_location['address'] : $event->start_location['address']; |
248 | 248 | $location_class = $tag == 'end-location' ? 'end' : 'start'; |
249 | - return ' <span class="simcal-event-address simcal-event-' . $location_class . '-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . wp_strip_all_tags( $location ) . '</span>'; |
|
249 | + return ' <span class="simcal-event-address simcal-event-'.$location_class.'-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.wp_strip_all_tags($location).'</span>'; |
|
250 | 250 | |
251 | 251 | case 'start-location-link': |
252 | 252 | case 'end-location-link' : |
253 | 253 | case 'maps-link' : |
254 | 254 | $location = $tag == 'end-location-link' ? $event->end_location['address'] : $event->start_location['address']; |
255 | - if ( ! empty( $location ) ) { |
|
256 | - $url = '//maps.google.com?q=' . urlencode( $location ); |
|
257 | - return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr ); |
|
255 | + if ( ! empty($location)) { |
|
256 | + $url = '//maps.google.com?q='.urlencode($location); |
|
257 | + return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr); |
|
258 | 258 | } |
259 | 259 | break; |
260 | 260 | |
261 | 261 | case 'link' : |
262 | 262 | case 'url' : |
263 | - $content = 'link' == $tag ? $calendar->get_event_html( $event, $partial ) : ''; |
|
264 | - return $this->make_link( $tag, $event->link, $content , $attr ); |
|
263 | + $content = 'link' == $tag ? $calendar->get_event_html($event, $partial) : ''; |
|
264 | + return $this->make_link($tag, $event->link, $content, $attr); |
|
265 | 265 | |
266 | 266 | case 'calendar' : |
267 | 267 | case 'feed-title' : |
@@ -283,22 +283,22 @@ discard block |
||
283 | 283 | |
284 | 284 | case 'attachments' : |
285 | 285 | $attachments = $event->get_attachments(); |
286 | - if ( ! empty( $attachments ) ) { |
|
287 | - return $this->get_attachments( $attachments ); |
|
286 | + if ( ! empty($attachments)) { |
|
287 | + return $this->get_attachments($attachments); |
|
288 | 288 | } |
289 | 289 | break; |
290 | 290 | |
291 | 291 | case 'attendees' : |
292 | 292 | $attendees = $event->get_attendees(); |
293 | - if ( ! empty( $attendees ) ) { |
|
294 | - return $this->get_attendees( $attendees, $attr ); |
|
293 | + if ( ! empty($attendees)) { |
|
294 | + return $this->get_attendees($attendees, $attr); |
|
295 | 295 | } |
296 | 296 | break; |
297 | 297 | |
298 | 298 | case 'organizer' : |
299 | 299 | $organizer = $event->get_organizer(); |
300 | - if ( ! empty( $organizer ) ) { |
|
301 | - return $this->get_organizer( $organizer, $attr ); |
|
300 | + if ( ! empty($organizer)) { |
|
301 | + return $this->get_organizer($organizer, $attr); |
|
302 | 302 | } |
303 | 303 | break; |
304 | 304 | |
@@ -307,35 +307,35 @@ discard block |
||
307 | 307 | * ================ */ |
308 | 308 | |
309 | 309 | case 'if-title': |
310 | - if ( ! empty( $event->title ) ) { |
|
311 | - return $calendar->get_event_html( $event, $partial ); |
|
310 | + if ( ! empty($event->title)) { |
|
311 | + return $calendar->get_event_html($event, $partial); |
|
312 | 312 | } |
313 | 313 | break; |
314 | 314 | |
315 | 315 | case 'if-description': |
316 | - if ( ! empty( $event->description ) ) { |
|
317 | - return $calendar->get_event_html( $event, $partial ); |
|
316 | + if ( ! empty($event->description)) { |
|
317 | + return $calendar->get_event_html($event, $partial); |
|
318 | 318 | } |
319 | 319 | break; |
320 | 320 | |
321 | 321 | case 'if-now' : |
322 | 322 | case 'if-not-now' : |
323 | 323 | |
324 | - $start_dt = $event->start_dt->setTimezone( $calendar->timezone ); |
|
324 | + $start_dt = $event->start_dt->setTimezone($calendar->timezone); |
|
325 | 325 | $start = $start_dt->getTimestamp(); |
326 | 326 | |
327 | - if ( $event->end_dt instanceof Carbon ) { |
|
328 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
327 | + if ($event->end_dt instanceof Carbon) { |
|
328 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
329 | 329 | } else { |
330 | 330 | return ''; |
331 | 331 | } |
332 | 332 | |
333 | - $now = ( $start <= $calendar->now ) && ( $end >= $calendar->now ); |
|
333 | + $now = ($start <= $calendar->now) && ($end >= $calendar->now); |
|
334 | 334 | |
335 | - if ( ( 'if-now' == $tag ) && $now ) { |
|
336 | - return $calendar->get_event_html( $event, $partial ); |
|
337 | - } elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) { |
|
338 | - return $calendar->get_event_html( $event, $partial ); |
|
335 | + if (('if-now' == $tag) && $now) { |
|
336 | + return $calendar->get_event_html($event, $partial); |
|
337 | + } elseif (('if-not-now' == $tag) && (false == $now)) { |
|
338 | + return $calendar->get_event_html($event, $partial); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | break; |
@@ -343,15 +343,15 @@ discard block |
||
343 | 343 | case 'if-started' : |
344 | 344 | case 'if-not-started' : |
345 | 345 | |
346 | - $start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
346 | + $start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
347 | 347 | |
348 | - if ( 'if-started' == $tag ) { |
|
349 | - if ( $start < $calendar->now ) { |
|
350 | - return $calendar->get_event_html( $event, $partial ); |
|
348 | + if ('if-started' == $tag) { |
|
349 | + if ($start < $calendar->now) { |
|
350 | + return $calendar->get_event_html($event, $partial); |
|
351 | 351 | } |
352 | - } elseif ( 'if-not-started' == $tag ) { |
|
353 | - if ( $start > $calendar->now ) { |
|
354 | - return $calendar->get_event_html( $event, $partial ); |
|
352 | + } elseif ('if-not-started' == $tag) { |
|
353 | + if ($start > $calendar->now) { |
|
354 | + return $calendar->get_event_html($event, $partial); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -360,17 +360,17 @@ discard block |
||
360 | 360 | case 'if-ended' : |
361 | 361 | case 'if-not-ended' : |
362 | 362 | |
363 | - if ( false !== $event->end ) { |
|
363 | + if (false !== $event->end) { |
|
364 | 364 | |
365 | - $end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp(); |
|
365 | + $end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp(); |
|
366 | 366 | |
367 | - if ( 'if-ended' == $tag ) { |
|
368 | - if ( $end < $calendar->now ) { |
|
369 | - return $calendar->get_event_html( $event, $partial ); |
|
367 | + if ('if-ended' == $tag) { |
|
368 | + if ($end < $calendar->now) { |
|
369 | + return $calendar->get_event_html($event, $partial); |
|
370 | 370 | } |
371 | - } elseif ( 'if-not-ended' == $tag ) { |
|
372 | - if ( $end > $calendar->now ) { |
|
373 | - return $calendar->get_event_html( $event, $partial ); |
|
371 | + } elseif ('if-not-ended' == $tag) { |
|
372 | + if ($end > $calendar->now) { |
|
373 | + return $calendar->get_event_html($event, $partial); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -379,14 +379,14 @@ discard block |
||
379 | 379 | break; |
380 | 380 | |
381 | 381 | case 'if-end-time' : |
382 | - if ( false !== $event->end ) { |
|
383 | - return $calendar->get_event_html( $event, $partial ); |
|
382 | + if (false !== $event->end) { |
|
383 | + return $calendar->get_event_html($event, $partial); |
|
384 | 384 | } |
385 | 385 | break; |
386 | 386 | |
387 | 387 | case 'if-no-end-time' : |
388 | - if ( false === $event->end ) { |
|
389 | - return $calendar->get_event_html( $event, $partial ); |
|
388 | + if (false === $event->end) { |
|
389 | + return $calendar->get_event_html($event, $partial); |
|
390 | 390 | } |
391 | 391 | break; |
392 | 392 | |
@@ -394,59 +394,59 @@ discard block |
||
394 | 394 | case 'if-whole-day' : |
395 | 395 | case 'if-not-all-day' : |
396 | 396 | case 'if-not-whole-day' : |
397 | - $bool = strstr( $tag, 'not' ) ? false : true; |
|
398 | - if ( $bool === $event->whole_day ) { |
|
399 | - return $calendar->get_event_html( $event, $partial ); |
|
397 | + $bool = strstr($tag, 'not') ? false : true; |
|
398 | + if ($bool === $event->whole_day) { |
|
399 | + return $calendar->get_event_html($event, $partial); |
|
400 | 400 | } |
401 | 401 | break; |
402 | 402 | |
403 | 403 | case 'if-recurring' : |
404 | - if ( ! empty( $event->recurrence ) ) { |
|
405 | - return $calendar->get_event_html( $event, $partial ); |
|
404 | + if ( ! empty($event->recurrence)) { |
|
405 | + return $calendar->get_event_html($event, $partial); |
|
406 | 406 | } |
407 | 407 | break; |
408 | 408 | |
409 | 409 | case 'if-not-recurring' : |
410 | - if ( false === $event->recurrence ) { |
|
411 | - return $calendar->get_event_html( $event, $partial ); |
|
410 | + if (false === $event->recurrence) { |
|
411 | + return $calendar->get_event_html($event, $partial); |
|
412 | 412 | } |
413 | 413 | break; |
414 | 414 | |
415 | 415 | case 'if-multi-day' : |
416 | - if ( false !== $event->multiple_days ) { |
|
417 | - return $calendar->get_event_html( $event, $partial ); |
|
416 | + if (false !== $event->multiple_days) { |
|
417 | + return $calendar->get_event_html($event, $partial); |
|
418 | 418 | } |
419 | 419 | break; |
420 | 420 | |
421 | 421 | case 'if-single-day' : |
422 | - if ( false === $event->multiple_days ) { |
|
423 | - return $calendar->get_event_html( $event, $partial ); |
|
422 | + if (false === $event->multiple_days) { |
|
423 | + return $calendar->get_event_html($event, $partial); |
|
424 | 424 | } |
425 | 425 | break; |
426 | 426 | |
427 | 427 | case 'if-location' : |
428 | 428 | case 'if-start-location' : |
429 | - if ( ! empty( $event->start_location['address'] ) ) { |
|
430 | - return $calendar->get_event_html( $event, $partial ); |
|
429 | + if ( ! empty($event->start_location['address'])) { |
|
430 | + return $calendar->get_event_html($event, $partial); |
|
431 | 431 | } |
432 | 432 | return false; |
433 | 433 | |
434 | 434 | case 'if-not-location' : |
435 | 435 | case 'if-not-start-location' : |
436 | - if ( empty( $event->start_location['address'] ) ) { |
|
437 | - return $calendar->get_event_html( $event, $partial ); |
|
436 | + if (empty($event->start_location['address'])) { |
|
437 | + return $calendar->get_event_html($event, $partial); |
|
438 | 438 | } |
439 | 439 | return ''; |
440 | 440 | |
441 | 441 | case 'if-not-end-location' : |
442 | - if ( empty( $event->end_location['address'] ) ) { |
|
443 | - return $calendar->get_event_html( $event, $partial ); |
|
442 | + if (empty($event->end_location['address'])) { |
|
443 | + return $calendar->get_event_html($event, $partial); |
|
444 | 444 | } |
445 | 445 | return ''; |
446 | 446 | |
447 | 447 | case 'if-end-location' : |
448 | - if ( ! empty( $event->end_location['address'] ) ) { |
|
449 | - return $calendar->get_event_html( $event, $partial ); |
|
448 | + if ( ! empty($event->end_location['address'])) { |
|
449 | + return $calendar->get_event_html($event, $partial); |
|
450 | 450 | } |
451 | 451 | return ''; |
452 | 452 | |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | * ======= */ |
456 | 456 | |
457 | 457 | default : |
458 | - return wp_kses_post( $before . $partial . $after ); |
|
458 | + return wp_kses_post($before.$partial.$after); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -473,14 +473,14 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - private function limit_words( $text, $limit ) { |
|
476 | + private function limit_words($text, $limit) { |
|
477 | 477 | |
478 | - $limit = max( absint( $limit ), 0 ); |
|
478 | + $limit = max(absint($limit), 0); |
|
479 | 479 | |
480 | - if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) { |
|
481 | - $words = str_word_count( $text, 2 ); |
|
482 | - $pos = array_keys( $words ); |
|
483 | - $text = trim( substr( $text, 0, $pos[ $limit ] ) ) . '…'; |
|
480 | + if ($limit > 0 && (str_word_count($text, 0) > $limit)) { |
|
481 | + $words = str_word_count($text, 2); |
|
482 | + $pos = array_keys($words); |
|
483 | + $text = trim(substr($text, 0, $pos[$limit])).'…'; |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | return $text; |
@@ -497,26 +497,26 @@ discard block |
||
497 | 497 | * |
498 | 498 | * @return string |
499 | 499 | */ |
500 | - private function get_title( $title, $attr ) { |
|
500 | + private function get_title($title, $attr) { |
|
501 | 501 | |
502 | - if ( empty( $title ) ) { |
|
502 | + if (empty($title)) { |
|
503 | 503 | return ''; |
504 | 504 | } |
505 | 505 | |
506 | - $attr = array_merge( array( |
|
507 | - 'html' => '', // Parse HTML |
|
508 | - 'limit' => 0, // Trim length to amount of words |
|
509 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
506 | + $attr = array_merge(array( |
|
507 | + 'html' => '', // Parse HTML |
|
508 | + 'limit' => 0, // Trim length to amount of words |
|
509 | + ), (array) shortcode_parse_atts($attr)); |
|
510 | 510 | |
511 | - if ( ! empty( $attr['html'] ) ) { |
|
512 | - $title = wp_kses_post( $title ); |
|
511 | + if ( ! empty($attr['html'])) { |
|
512 | + $title = wp_kses_post($title); |
|
513 | 513 | $tag = 'div'; |
514 | 514 | } else { |
515 | - $title = $this->limit_words( $title, $attr['limit'] ); |
|
515 | + $title = $this->limit_words($title, $attr['limit']); |
|
516 | 516 | $tag = 'span'; |
517 | 517 | } |
518 | 518 | |
519 | - return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>'; |
|
519 | + return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>'; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -530,40 +530,40 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return string |
532 | 532 | */ |
533 | - private function get_description( $description, $attr ) { |
|
533 | + private function get_description($description, $attr) { |
|
534 | 534 | |
535 | - if ( empty( $description ) ) { |
|
535 | + if (empty($description)) { |
|
536 | 536 | return ''; |
537 | 537 | } |
538 | 538 | |
539 | - $attr = array_merge( array( |
|
540 | - 'limit' => 0, // Trim length to number of words |
|
541 | - 'html' => 'no', // Parse HTML content |
|
542 | - 'markdown' => 'no', // Parse Markdown content |
|
543 | - 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
544 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
539 | + $attr = array_merge(array( |
|
540 | + 'limit' => 0, // Trim length to number of words |
|
541 | + 'html' => 'no', // Parse HTML content |
|
542 | + 'markdown' => 'no', // Parse Markdown content |
|
543 | + 'autolink' => 'no', // Automatically convert plaintext URIs to anchors |
|
544 | + ), (array) shortcode_parse_atts($attr)); |
|
545 | 545 | |
546 | - $allow_html = 'no' != $attr['html'] ? true : false; |
|
546 | + $allow_html = 'no' != $attr['html'] ? true : false; |
|
547 | 547 | $allow_md = 'no' != $attr['markdown'] ? true : false; |
548 | 548 | |
549 | 549 | $html = '<div class="simcal-event-description" itemprop="description">'; |
550 | 550 | |
551 | 551 | // Markdown and HTML don't play well together, use one or the other in the same tag. |
552 | - if ( $allow_html || $allow_md ) { |
|
553 | - if ( $allow_html ) { |
|
554 | - $description = wp_kses_post( $description ); |
|
555 | - } elseif ( $allow_md ) { |
|
552 | + if ($allow_html || $allow_md) { |
|
553 | + if ($allow_html) { |
|
554 | + $description = wp_kses_post($description); |
|
555 | + } elseif ($allow_md) { |
|
556 | 556 | $markdown = new \Parsedown(); |
557 | - $description = $markdown->text( wp_strip_all_tags( $description ) ); |
|
557 | + $description = $markdown->text(wp_strip_all_tags($description)); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
561 | - $description = $this->limit_words( $description, $attr['limit'] ); |
|
561 | + $description = $this->limit_words($description, $attr['limit']); |
|
562 | 562 | |
563 | - $html .= $description . '</div>'; |
|
563 | + $html .= $description.'</div>'; |
|
564 | 564 | |
565 | - if ( 'no' != $attr['autolink'] ) { |
|
566 | - $html = ' ' . make_clickable( $html ); |
|
565 | + if ('no' != $attr['autolink']) { |
|
566 | + $html = ' '.make_clickable($html); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | return $html; |
@@ -579,74 +579,74 @@ discard block |
||
579 | 579 | * |
580 | 580 | * @return string |
581 | 581 | */ |
582 | - private function get_when( Event $event ) { |
|
582 | + private function get_when(Event $event) { |
|
583 | 583 | |
584 | - $start = $event->start_dt->setTimezone( $event->timezone ); |
|
585 | - $end = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null; |
|
584 | + $start = $event->start_dt->setTimezone($event->timezone); |
|
585 | + $end = ! is_null($event->end_dt) ? $event->end_dt->setTimezone($event->timezone) : null; |
|
586 | 586 | |
587 | 587 | $time_start = ''; |
588 | 588 | $time_end = ''; |
589 | 589 | |
590 | - if ( ! $event->whole_day ) { |
|
590 | + if ( ! $event->whole_day) { |
|
591 | 591 | |
592 | - $time_start = $this->calendar->datetime_separator . |
|
593 | - ' <span class="simcal-event-start simcal-event-start-time" ' . |
|
594 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
595 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
596 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
597 | - date_i18n( $this->calendar->time_format, $start->getTimestamp() ) . |
|
592 | + $time_start = $this->calendar->datetime_separator. |
|
593 | + ' <span class="simcal-event-start simcal-event-start-time" '. |
|
594 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
595 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
596 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
597 | + date_i18n($this->calendar->time_format, $start->getTimestamp()). |
|
598 | 598 | '</span> '; |
599 | 599 | |
600 | - if ( $end instanceof Carbon ) { |
|
600 | + if ($end instanceof Carbon) { |
|
601 | 601 | |
602 | - $time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . |
|
603 | - 'data-event-end="' . $end->getTimestamp() . '" ' . |
|
604 | - 'data-event-format="' . $this->calendar->time_format . '" ' . |
|
605 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
606 | - date_i18n( $this->calendar->time_format, $end->getTimestamp() ) . |
|
602 | + $time_end = ' <span class="simcal-event-end simcal-event-end-time" '. |
|
603 | + 'data-event-end="'.$end->getTimestamp().'" '. |
|
604 | + 'data-event-format="'.$this->calendar->time_format.'" '. |
|
605 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
606 | + date_i18n($this->calendar->time_format, $end->getTimestamp()). |
|
607 | 607 | '</span> '; |
608 | 608 | |
609 | 609 | } |
610 | 610 | |
611 | 611 | } |
612 | 612 | |
613 | - if ( $event->multiple_days ) { |
|
613 | + if ($event->multiple_days) { |
|
614 | 614 | |
615 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
616 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
617 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
618 | - 'itemprop="startDate" content="' . $start->toIso8601String() . '">' . |
|
619 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
620 | - '</span> ' . |
|
615 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
616 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
617 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
618 | + 'itemprop="startDate" content="'.$start->toIso8601String().'">'. |
|
619 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
620 | + '</span> '. |
|
621 | 621 | $time_start; |
622 | 622 | |
623 | - if ( $end instanceof Carbon ) { |
|
623 | + if ($end instanceof Carbon) { |
|
624 | 624 | |
625 | - $output .= '-' . |
|
626 | - ' <span class="simcal-event-start simcal-event-end-date" ' . |
|
627 | - 'data-event-start="' . $end->getTimestamp() . '" ' . |
|
628 | - 'data-event-format="' . $this->calendar->date_format . '" ' . |
|
629 | - 'itemprop="endDate" content="' . $end->toIso8601String() . '">' . |
|
630 | - date_i18n( $this->calendar->date_format, $end->getTimestamp() ) . |
|
631 | - '</span> ' . |
|
625 | + $output .= '-'. |
|
626 | + ' <span class="simcal-event-start simcal-event-end-date" '. |
|
627 | + 'data-event-start="'.$end->getTimestamp().'" '. |
|
628 | + 'data-event-format="'.$this->calendar->date_format.'" '. |
|
629 | + 'itemprop="endDate" content="'.$end->toIso8601String().'">'. |
|
630 | + date_i18n($this->calendar->date_format, $end->getTimestamp()). |
|
631 | + '</span> '. |
|
632 | 632 | $time_end; |
633 | 633 | } |
634 | 634 | |
635 | 635 | } else { |
636 | 636 | |
637 | - $time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : ''; |
|
637 | + $time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : ''; |
|
638 | 638 | |
639 | - $output = ' <span class="simcal-event-start simcal-event-start-date" ' . |
|
640 | - 'data-event-start="' . $start->getTimestamp() . '" ' . |
|
641 | - 'data-event-format="' . $this->calendar->date_format . '">' . |
|
642 | - date_i18n( $this->calendar->date_format, $start->getTimestamp() ) . |
|
643 | - '</span> ' . |
|
644 | - $time_start . |
|
639 | + $output = ' <span class="simcal-event-start simcal-event-start-date" '. |
|
640 | + 'data-event-start="'.$start->getTimestamp().'" '. |
|
641 | + 'data-event-format="'.$this->calendar->date_format.'">'. |
|
642 | + date_i18n($this->calendar->date_format, $start->getTimestamp()). |
|
643 | + '</span> '. |
|
644 | + $time_start. |
|
645 | 645 | $time_end; |
646 | 646 | |
647 | 647 | } |
648 | 648 | |
649 | - return trim( $output ); |
|
649 | + return trim($output); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | /** |
@@ -661,44 +661,44 @@ discard block |
||
661 | 661 | * |
662 | 662 | * @return string |
663 | 663 | */ |
664 | - private function get_dt( $tag, Event $event, $attr ) { |
|
664 | + private function get_dt($tag, Event $event, $attr) { |
|
665 | 665 | |
666 | - $bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start'; |
|
667 | - if ( ( 'end' == $bound ) && ( false === $event->end ) ) { |
|
666 | + $bound = 0 === strpos($tag, 'end') ? 'end' : 'start'; |
|
667 | + if (('end' == $bound) && (false === $event->end)) { |
|
668 | 668 | return ''; |
669 | 669 | } |
670 | 670 | |
671 | - $dt = $bound . '_dt'; |
|
672 | - if ( ! $event->$dt instanceof Carbon ) { |
|
671 | + $dt = $bound.'_dt'; |
|
672 | + if ( ! $event->$dt instanceof Carbon) { |
|
673 | 673 | return ''; |
674 | 674 | } |
675 | - $event_dt = $event->$dt->setTimezone( $event->timezone ); |
|
675 | + $event_dt = $event->$dt->setTimezone($event->timezone); |
|
676 | 676 | |
677 | - $attr = array_merge( array( |
|
677 | + $attr = array_merge(array( |
|
678 | 678 | 'format' => '', |
679 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
679 | + ), (array) shortcode_parse_atts($attr)); |
|
680 | 680 | |
681 | - $format = ltrim( strstr( $tag, '-' ), '-' ); |
|
681 | + $format = ltrim(strstr($tag, '-'), '-'); |
|
682 | 682 | $dt_format = ''; |
683 | - if ( ! empty( $attr['format'] ) ) { |
|
684 | - $dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) ); |
|
685 | - } elseif ( 'date' == $format ) { |
|
683 | + if ( ! empty($attr['format'])) { |
|
684 | + $dt_format = esc_attr(wp_strip_all_tags($attr['format'])); |
|
685 | + } elseif ('date' == $format) { |
|
686 | 686 | $dt_format = $this->calendar->date_format; |
687 | - } elseif ( 'time' == $format ) { |
|
687 | + } elseif ('time' == $format) { |
|
688 | 688 | $dt_format = $this->calendar->time_format; |
689 | 689 | } |
690 | 690 | |
691 | - if ( 'human' == $format ) { |
|
692 | - $value = human_time_diff( $event_dt->getTimestamp(), Carbon::now( $event->timezone )->getTimestamp() ); |
|
691 | + if ('human' == $format) { |
|
692 | + $value = human_time_diff($event_dt->getTimestamp(), Carbon::now($event->timezone)->getTimestamp()); |
|
693 | 693 | } else { |
694 | - $value = date_i18n( $dt_format, $event_dt->getTimestamp() ); |
|
694 | + $value = date_i18n($dt_format, $event_dt->getTimestamp()); |
|
695 | 695 | } |
696 | 696 | |
697 | - return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '"' . |
|
698 | - 'data-event-' . $bound . '="' . $event_dt->getTimestamp() . '"' . |
|
699 | - 'data-event-format="' . $dt_format . '"' . |
|
700 | - 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . |
|
701 | - $value . |
|
697 | + return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'"'. |
|
698 | + 'data-event-'.$bound.'="'.$event_dt->getTimestamp().'"'. |
|
699 | + 'data-event-format="'.$dt_format.'"'. |
|
700 | + 'itemprop="'.$bound.'Date" content="'.$event_dt->toIso8601String().'">'. |
|
701 | + $value. |
|
702 | 702 | '</span>'; |
703 | 703 | } |
704 | 704 | |
@@ -715,23 +715,23 @@ discard block |
||
715 | 715 | * |
716 | 716 | * @return string |
717 | 717 | */ |
718 | - private function make_link( $tag, $url, $content, $attr ) { |
|
718 | + private function make_link($tag, $url, $content, $attr) { |
|
719 | 719 | |
720 | - if ( empty( $url ) ) { |
|
720 | + if (empty($url)) { |
|
721 | 721 | return ''; |
722 | 722 | } |
723 | 723 | |
724 | - $text = empty( $content ) ? $url : $content; |
|
724 | + $text = empty($content) ? $url : $content; |
|
725 | 725 | |
726 | - $attr = array_merge( array( |
|
727 | - 'autolink' => false, // Convert url to link anchor |
|
728 | - 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
729 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
726 | + $attr = array_merge(array( |
|
727 | + 'autolink' => false, // Convert url to link anchor |
|
728 | + 'newwindow' => false, // If autolink attribute is true, open link in new window |
|
729 | + ), (array) shortcode_parse_atts($attr)); |
|
730 | 730 | |
731 | 731 | $anchor = $tag != 'url' ? 'yes' : $attr['autolink']; |
732 | 732 | $target = $attr['newwindow'] !== false ? 'target="_blank"' : ''; |
733 | 733 | |
734 | - return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text; |
|
734 | + return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text; |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -744,20 +744,20 @@ discard block |
||
744 | 744 | * |
745 | 745 | * @return string |
746 | 746 | */ |
747 | - private function get_attachments( $attachments ) { |
|
747 | + private function get_attachments($attachments) { |
|
748 | 748 | |
749 | - $html = '<ul class="simcal-attachments">' . "\n\t"; |
|
749 | + $html = '<ul class="simcal-attachments">'."\n\t"; |
|
750 | 750 | |
751 | - foreach ( $attachments as $attachment ) { |
|
751 | + foreach ($attachments as $attachment) { |
|
752 | 752 | $html .= '<li class="simcal-attachment">'; |
753 | - $html .= '<a href="' . $attachment['url'] . '" target="_blank">'; |
|
754 | - $html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : ''; |
|
755 | - $html .= '<span>' . $attachment['name'] . '</span>'; |
|
753 | + $html .= '<a href="'.$attachment['url'].'" target="_blank">'; |
|
754 | + $html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : ''; |
|
755 | + $html .= '<span>'.$attachment['name'].'</span>'; |
|
756 | 756 | $html .= '</a>'; |
757 | - $html .= '</li>' . "\n"; |
|
757 | + $html .= '</li>'."\n"; |
|
758 | 758 | } |
759 | 759 | |
760 | - $html .= '</ul>' . "\n"; |
|
760 | + $html .= '</ul>'."\n"; |
|
761 | 761 | |
762 | 762 | return $html; |
763 | 763 | } |
@@ -773,41 +773,41 @@ discard block |
||
773 | 773 | * |
774 | 774 | * @return string |
775 | 775 | */ |
776 | - private function get_attendees( $attendees, $attr ) { |
|
776 | + private function get_attendees($attendees, $attr) { |
|
777 | 777 | |
778 | - $attr = array_merge( array( |
|
779 | - 'photo' => 'show', // show/hide attendee photo |
|
780 | - 'email' => 'hide', // show/hide attendee email address |
|
781 | - 'rsvp' => 'hide', // show/hide rsvp response status |
|
782 | - 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
783 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
778 | + $attr = array_merge(array( |
|
779 | + 'photo' => 'show', // show/hide attendee photo |
|
780 | + 'email' => 'hide', // show/hide attendee email address |
|
781 | + 'rsvp' => 'hide', // show/hide rsvp response status |
|
782 | + 'response' => '', // filter attendees by rsvp response (yes/no/maybe) |
|
783 | + ), (array) shortcode_parse_atts($attr)); |
|
784 | 784 | |
785 | - $html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t"; |
|
785 | + $html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t"; |
|
786 | 786 | |
787 | 787 | $known = 0; |
788 | 788 | $unknown = 0; |
789 | 789 | |
790 | - foreach ( $attendees as $attendee ) { |
|
790 | + foreach ($attendees as $attendee) { |
|
791 | 791 | |
792 | - if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) { |
|
792 | + if ('yes' == $attr['response'] && 'yes' != $attendee['response']) { |
|
793 | 793 | continue; |
794 | - } elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) { |
|
794 | + } elseif ('no' == $attr['response'] && 'no' != $attendee['response']) { |
|
795 | 795 | continue; |
796 | - } elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) { |
|
796 | + } elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) { |
|
797 | 797 | continue; |
798 | 798 | } |
799 | 799 | |
800 | - if ( ! empty( $attendee['name'] ) ) { |
|
800 | + if ( ! empty($attendee['name'])) { |
|
801 | 801 | |
802 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : ''; |
|
803 | - $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : ''; |
|
804 | - $guest = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>'; |
|
802 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : ''; |
|
803 | + $response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : ''; |
|
804 | + $guest = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>'; |
|
805 | 805 | |
806 | - if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
807 | - $guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest ); |
|
806 | + if ( ! empty($attendee['email']) && ('show' == $attr['email'])) { |
|
807 | + $guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest); |
|
808 | 808 | } |
809 | 809 | |
810 | - $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n"; |
|
810 | + $html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n"; |
|
811 | 811 | |
812 | 812 | $known++; |
813 | 813 | |
@@ -818,21 +818,21 @@ discard block |
||
818 | 818 | } |
819 | 819 | } |
820 | 820 | |
821 | - if ( $unknown > 0 ) { |
|
822 | - if ( $known > 0 ) { |
|
821 | + if ($unknown > 0) { |
|
822 | + if ($known > 0) { |
|
823 | 823 | /* translators: One more person attending the event. */ |
824 | - $others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
824 | + $others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown); |
|
825 | 825 | } else { |
826 | 826 | /* translators: One or more persons attending the event whose name is unknown. */ |
827 | - $others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown ); |
|
827 | + $others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown); |
|
828 | 828 | } |
829 | - $photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : ''; |
|
830 | - $html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n"; |
|
831 | - } elseif ( $known === 0 ) { |
|
832 | - $html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n"; |
|
829 | + $photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : ''; |
|
830 | + $html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n"; |
|
831 | + } elseif ($known === 0) { |
|
832 | + $html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n"; |
|
833 | 833 | } |
834 | 834 | |
835 | - $html .= '</ul>' . "\n"; |
|
835 | + $html .= '</ul>'."\n"; |
|
836 | 836 | |
837 | 837 | return $html; |
838 | 838 | } |
@@ -846,23 +846,23 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return string |
848 | 848 | */ |
849 | - private function get_rsvp_response( $response ) { |
|
849 | + private function get_rsvp_response($response) { |
|
850 | 850 | |
851 | - if ( 'yes' == $response ) { |
|
851 | + if ('yes' == $response) { |
|
852 | 852 | /* translators: Someone replied with 'yes' to a rsvp request. */ |
853 | - $rsvp = __( 'Attending', 'google-calendar-events' ); |
|
854 | - } elseif ( 'no' == $response ) { |
|
853 | + $rsvp = __('Attending', 'google-calendar-events'); |
|
854 | + } elseif ('no' == $response) { |
|
855 | 855 | /* translators: Someone replied with 'no' to a rsvp request. */ |
856 | - $rsvp = __( 'Not attending', 'google-calendar-events' ); |
|
857 | - } elseif ( 'maybe' == $response ) { |
|
856 | + $rsvp = __('Not attending', 'google-calendar-events'); |
|
857 | + } elseif ('maybe' == $response) { |
|
858 | 858 | /* translators: Someone replied with 'maybe' to a rsvp request. */ |
859 | - $rsvp = __( 'Maybe attending', 'google-calendar-events' ); |
|
859 | + $rsvp = __('Maybe attending', 'google-calendar-events'); |
|
860 | 860 | } else { |
861 | 861 | /* translators: Someone did not send yet a rsvp confirmation to join an event. */ |
862 | - $rsvp = __( 'Response pending', 'google-calendar-events' ); |
|
862 | + $rsvp = __('Response pending', 'google-calendar-events'); |
|
863 | 863 | } |
864 | 864 | |
865 | - return ' <small>(' . $rsvp . ')</small>'; |
|
865 | + return ' <small>('.$rsvp.')</small>'; |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | /** |
@@ -876,21 +876,21 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return string |
878 | 878 | */ |
879 | - private function get_organizer( $organizer, $attr ) { |
|
879 | + private function get_organizer($organizer, $attr) { |
|
880 | 880 | |
881 | - $attr = array_merge( array( |
|
882 | - 'photo' => 'show', // show/hide attendee photo |
|
883 | - 'email' => 'hide', // show/hide attendee email address |
|
884 | - ), (array) shortcode_parse_atts( $attr ) ); |
|
881 | + $attr = array_merge(array( |
|
882 | + 'photo' => 'show', // show/hide attendee photo |
|
883 | + 'email' => 'hide', // show/hide attendee email address |
|
884 | + ), (array) shortcode_parse_atts($attr)); |
|
885 | 885 | |
886 | - $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image" />' : ''; |
|
887 | - $organizer_html = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>'; |
|
886 | + $photo = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image" />' : ''; |
|
887 | + $organizer_html = $photo.'<span itemprop="name">'.$organizer['name'].'</span>'; |
|
888 | 888 | |
889 | - if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) { |
|
890 | - $organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html ); |
|
889 | + if ( ! empty($organizer['email']) && ('show' == $attr['email'])) { |
|
890 | + $organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html); |
|
891 | 891 | } |
892 | 892 | |
893 | - return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>'; |
|
893 | + return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>'; |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | /** |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | // This is largely borrowed on get_shortcode_regex() from WordPress Core. |
916 | 916 | // @see /wp-includes/shortcodes.php (with some modification) |
917 | 917 | |
918 | - $tagregexp = implode( '|', array_values( $this->tags ) ); |
|
918 | + $tagregexp = implode('|', array_values($this->tags)); |
|
919 | 919 | |
920 | 920 | return '/' |
921 | 921 | . '\\[' // Opening bracket |