Completed
Push — master ( 492b47...187862 )
by
unknown
02:47
created
includes/events/event-builder.php 3 patches
Doc Comments   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 	 * @since  3.0.0
585 585
 	 * @access private
586 586
 	 *
587
-	 * @param  $title
588
-	 * @param  $attr
587
+	 * @param  string $title
588
+	 * @param  string $attr
589 589
 	 *
590 590
 	 * @return string
591 591
 	 */
@@ -1023,6 +1023,13 @@  discard block
 block discarded – undo
1023 1023
 	}
1024 1024
 
1025 1025
 	//allow other plugins to replace own (registered) event tags with their value
1026
+
1027
+	/**
1028
+	 * @param string $tag
1029
+	 * @param string $partial
1030
+	 * @param string $attr
1031
+	 * @param Event $event
1032
+	 */
1026 1033
 	private function do_custom_event_tag( $tag, $partial, $attr, $event ) {
1027 1034
 		$returnvalue = apply_filters( 'simcal_event_tags_do_custom', "", $tag, $partial, $attr, $event );
1028 1035
 
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -996,23 +996,23 @@
 block discarded – undo
996 996
 		$tagregexp = implode( '|', array_values( $this->tags ) );
997 997
 
998 998
 		return '/' . '\\['                              // Opening bracket
999
-		       . '(\\[?)'                           // 1: Optional second opening bracket for escaping tags: [[tag]]
1000
-		       . "($tagregexp)"                     // 2: Tag name
1001
-		       . '(?![\\w-])'                       // Not followed by word character or hyphen
1002
-		       . '('                                // 3: Unroll the loop: Inside the opening tag
1003
-		       . '[^\\]\\/]*'                   // Not a closing bracket or forward slash
1004
-		       . '(?:' . '\\/(?!\\])'               // A forward slash not followed by a closing bracket
1005
-		       . '[^\\]\\/]*'               // Not a closing bracket or forward slash
1006
-		       . ')*?' . ')' . '(?:' . '(\\/)'                        // 4: Self closing tag ...
1007
-		       . '\\]'                          // ... and closing bracket
1008
-		       . '|' . '\\]'                          // Closing bracket
1009
-		       . '(?:' . '('                        // 5: Unroll the loop: Optionally, anything between the opening and closing tags
1010
-		       . '[^\\[]*+'             // Not an opening bracket
1011
-		       . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag
1012
-		       . '[^\\[]*+'         // Not an opening bracket
1013
-		       . ')*+' . ')' . '\\[\\/\\2\\]'             // Closing tag
1014
-		       . ')?' . ')' . '(\\]?)'                           // 6: Optional second closing bracket for escaping tags: [[tag]]
1015
-		       . '/s';
999
+			   . '(\\[?)'                           // 1: Optional second opening bracket for escaping tags: [[tag]]
1000
+			   . "($tagregexp)"                     // 2: Tag name
1001
+			   . '(?![\\w-])'                       // Not followed by word character or hyphen
1002
+			   . '('                                // 3: Unroll the loop: Inside the opening tag
1003
+			   . '[^\\]\\/]*'                   // Not a closing bracket or forward slash
1004
+			   . '(?:' . '\\/(?!\\])'               // A forward slash not followed by a closing bracket
1005
+			   . '[^\\]\\/]*'               // Not a closing bracket or forward slash
1006
+			   . ')*?' . ')' . '(?:' . '(\\/)'                        // 4: Self closing tag ...
1007
+			   . '\\]'                          // ... and closing bracket
1008
+			   . '|' . '\\]'                          // Closing bracket
1009
+			   . '(?:' . '('                        // 5: Unroll the loop: Optionally, anything between the opening and closing tags
1010
+			   . '[^\\[]*+'             // Not an opening bracket
1011
+			   . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag
1012
+			   . '[^\\[]*+'         // Not an opening bracket
1013
+			   . ')*+' . ')' . '\\[\\/\\2\\]'             // Closing tag
1014
+			   . ')?' . ')' . '(\\]?)'                           // 6: Optional second closing bracket for escaping tags: [[tag]]
1015
+			   . '/s';
1016 1016
 	}
1017 1017
 
1018 1018
 	//allow other plugins to register own event tags
Please login to merge, or discard this patch.
Spacing   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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();
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return array
69 69
 	 */
70 70
 	public function get_content_tags() {
71
-		return array_merge( array(
71
+		return array_merge(array(
72 72
 
73 73
 			/* ============ *
74 74
 			 * Content Tags *
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 			'if-not-end-location',
215 215
 			// Does the event has NOT an end location?
216 216
 
217
-		), (array) $this->add_custom_event_tags() );
217
+		), (array) $this->add_custom_event_tags());
218 218
 	}
219 219
 
220 220
 	/**
@@ -226,16 +226,16 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @return string
228 228
 	 */
229
-	public function parse_event_template_tags( $template_tags = '' ) {
229
+	public function parse_event_template_tags($template_tags = '') {
230 230
 
231 231
 		// Process tags.
232
-		$result = preg_replace_callback( $this->get_regex(), array( $this, 'process_event_content' ), $template_tags );
232
+		$result = preg_replace_callback($this->get_regex(), array($this, 'process_event_content'), $template_tags);
233 233
 
234 234
 		// Removes extra consecutive <br> tags.
235 235
 		// TODO: Doesn't seem to work but going to remove it to allow multiple <br> tags in the editor
236 236
 		/*return preg_replace( '#(<br *//*?>\s*)+#i', '<br />', trim( $result ) );*/
237 237
 
238
-		return do_shortcode( trim( $result ) );
238
+		return do_shortcode(trim($result));
239 239
 	}
240 240
 
241 241
 	/**
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return string
249 249
 	 */
250
-	public function process_event_content( $match ) {
250
+	public function process_event_content($match) {
251 251
 
252
-		if ( $match[1] == '[' && $match[6] == ']' ) {
253
-			return substr( $match[0], 1, -1 );
252
+		if ($match[1] == '[' && $match[6] == ']') {
253
+			return substr($match[0], 1, -1);
254 254
 		}
255 255
 
256 256
 		$tag     = $match[2]; // Tag name without square brackets.
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 		$calendar = $this->calendar;
263 263
 		$event    = $this->event;
264 264
 
265
-		if ( ( $calendar instanceof Calendar ) && ( $event instanceof Event ) ) {
265
+		if (($calendar instanceof Calendar) && ($event instanceof Event)) {
266 266
 
267
-			switch ( $tag ) {
267
+			switch ($tag) {
268 268
 
269 269
 				/* ============ *
270 270
 				 * Content Tags *
@@ -272,13 +272,13 @@  discard block
 block discarded – undo
272 272
 
273 273
 				case 'title' :
274 274
 				case 'event-title' :
275
-					return $this->get_title( $event->title, $attr );
275
+					return $this->get_title($event->title, $attr);
276 276
 
277 277
 				case 'description' :
278
-					return $this->get_description( $event->description, $attr );
278
+					return $this->get_description($event->description, $attr);
279 279
 
280 280
 				case 'when' :
281
-					return $this->get_when( $event );
281
+					return $this->get_when($event);
282 282
 
283 283
 				case 'end-date' :
284 284
 				case 'end-custom' :
@@ -288,58 +288,58 @@  discard block
 block discarded – undo
288 288
 				case 'start-date' :
289 289
 				case 'start-human' :
290 290
 				case 'start-time' :
291
-					return $this->get_dt( $tag, $event, $attr );
291
+					return $this->get_dt($tag, $event, $attr);
292 292
 
293 293
 				case 'length' :
294 294
 				case 'duration' :
295
-					if ( false !== $event->end ) {
295
+					if (false !== $event->end) {
296 296
 						$duration = $event->start - $event->end;
297
-						$value    = human_time_diff( $event->start, $event->end );
297
+						$value    = human_time_diff($event->start, $event->end);
298 298
 					} else {
299 299
 						$duration = '-1';
300
-						$value    = __( 'No end time', 'google-calendar-events' );
300
+						$value    = __('No end time', 'google-calendar-events');
301 301
 					}
302 302
 
303
-					return ' <span class="simcal-event-duration" data-event-duration="' . $duration . '">' . $value . '</span>';
303
+					return ' <span class="simcal-event-duration" data-event-duration="'.$duration.'">'.$value.'</span>';
304 304
 
305 305
 				case 'location' :
306 306
 				case 'start-location' :
307 307
 				case 'end-location' :
308
-					$location       = ( 'end-location' == $tag ) ? $event->end_location['address'] : $event->start_location['address'];
309
-					$location_class = ( 'end-location' == $tag ) ? 'end' : 'start';
308
+					$location       = ('end-location' == $tag) ? $event->end_location['address'] : $event->start_location['address'];
309
+					$location_class = ('end-location' == $tag) ? 'end' : 'start';
310 310
 
311 311
 					// location, location.name, location.address (type PostalAddress) all required for schema data.
312 312
 					// Need to use event name where location data doesn't exist.
313 313
 					// Since we have 1 location field, use it as the name and address.
314 314
 					// If the location is blank, use the event title as the name and address.
315 315
 					// Wrap with wp_strip_all_tags().
316
-					$meta_location_name_and_address = empty( $location ) ? wp_strip_all_tags( $event->title ) : wp_strip_all_tags( $location );
316
+					$meta_location_name_and_address = empty($location) ? wp_strip_all_tags($event->title) : wp_strip_all_tags($location);
317 317
 
318
-					return ' <span class="simcal-event-address simcal-event-' . $location_class . '-location" itemprop="location" itemscope itemtype="http://schema.org/Place">' . '<meta itemprop="name" content="' . $meta_location_name_and_address . '" />' . '<meta itemprop="address" content="' . $meta_location_name_and_address . '" />' . wp_strip_all_tags( $location ) . '</span>';
318
+					return ' <span class="simcal-event-address simcal-event-'.$location_class.'-location" itemprop="location" itemscope itemtype="http://schema.org/Place">'.'<meta itemprop="name" content="'.$meta_location_name_and_address.'" />'.'<meta itemprop="address" content="'.$meta_location_name_and_address.'" />'.wp_strip_all_tags($location).'</span>';
319 319
 
320 320
 				case 'start-location-link':
321 321
 				case 'end-location-link' :
322 322
 				case 'maps-link' :
323
-					$location = ( 'end-location-link' == $tag ) ? $event->end_location['address'] : $event->start_location['address'];
324
-					if ( ! empty( $location ) ) {
325
-						$url = '//maps.google.com?q=' . urlencode( $location );
323
+					$location = ('end-location-link' == $tag) ? $event->end_location['address'] : $event->start_location['address'];
324
+					if ( ! empty($location)) {
325
+						$url = '//maps.google.com?q='.urlencode($location);
326 326
 
327
-						return $this->make_link( $tag, $url, $calendar->get_event_html( $event, $partial ), $attr );
327
+						return $this->make_link($tag, $url, $calendar->get_event_html($event, $partial), $attr);
328 328
 					}
329 329
 					break;
330 330
 
331 331
 				case 'link' :
332 332
 				case 'url' :
333
-					$content = ( 'link' == $tag ) ? $calendar->get_event_html( $event, $partial ) : '';
333
+					$content = ('link' == $tag) ? $calendar->get_event_html($event, $partial) : '';
334 334
 
335
-					return $this->make_link( $tag, $event->link, $content, $attr );
335
+					return $this->make_link($tag, $event->link, $content, $attr);
336 336
 
337 337
 				case 'add-to-gcal-link';
338
-					$content = ( 'add-to-gcal-link' == $tag ) ? $calendar->get_event_html( $event, $partial ) : '';
339
-					if ( ! empty( $content ) ) {
340
-						$url = $calendar->get_add_to_gcal_url( $event );
338
+					$content = ('add-to-gcal-link' == $tag) ? $calendar->get_event_html($event, $partial) : '';
339
+					if ( ! empty($content)) {
340
+						$url = $calendar->get_add_to_gcal_url($event);
341 341
 
342
-						return $this->make_link( $tag, $url, $content, $attr );
342
+						return $this->make_link($tag, $url, $content, $attr);
343 343
 					}
344 344
 					break;
345 345
 
@@ -366,22 +366,22 @@  discard block
 block discarded – undo
366 366
 
367 367
 				case 'attachments' :
368 368
 					$attachments = $event->get_attachments();
369
-					if ( ! empty( $attachments ) ) {
370
-						return $this->get_attachments( $attachments );
369
+					if ( ! empty($attachments)) {
370
+						return $this->get_attachments($attachments);
371 371
 					}
372 372
 					break;
373 373
 
374 374
 				case 'attendees' :
375 375
 					$attendees = $event->get_attendees();
376
-					if ( ! empty( $attendees ) ) {
377
-						return $this->get_attendees( $attendees, $attr );
376
+					if ( ! empty($attendees)) {
377
+						return $this->get_attendees($attendees, $attr);
378 378
 					}
379 379
 					break;
380 380
 
381 381
 				case 'organizer' :
382 382
 					$organizer = $event->get_organizer();
383
-					if ( ! empty( $organizer ) ) {
384
-						return $this->get_organizer( $organizer, $attr );
383
+					if ( ! empty($organizer)) {
384
+						return $this->get_organizer($organizer, $attr);
385 385
 					}
386 386
 					break;
387 387
 
@@ -390,35 +390,35 @@  discard block
 block discarded – undo
390 390
 				 * ================ */
391 391
 
392 392
 				case 'if-title':
393
-					if ( ! empty( $event->title ) ) {
394
-						return $calendar->get_event_html( $event, $partial );
393
+					if ( ! empty($event->title)) {
394
+						return $calendar->get_event_html($event, $partial);
395 395
 					}
396 396
 					break;
397 397
 
398 398
 				case 'if-description':
399
-					if ( ! empty( $event->description ) ) {
400
-						return $calendar->get_event_html( $event, $partial );
399
+					if ( ! empty($event->description)) {
400
+						return $calendar->get_event_html($event, $partial);
401 401
 					}
402 402
 					break;
403 403
 
404 404
 				case 'if-now' :
405 405
 				case 'if-not-now' :
406 406
 
407
-					$start_dt = $event->start_dt->setTimezone( $calendar->timezone );
407
+					$start_dt = $event->start_dt->setTimezone($calendar->timezone);
408 408
 					$start    = $start_dt->getTimestamp();
409 409
 
410
-					if ( $event->end_dt instanceof Carbon ) {
411
-						$end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp();
410
+					if ($event->end_dt instanceof Carbon) {
411
+						$end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp();
412 412
 					} else {
413 413
 						return '';
414 414
 					}
415 415
 
416
-					$now = ( $start <= $calendar->now ) && ( $end >= $calendar->now );
416
+					$now = ($start <= $calendar->now) && ($end >= $calendar->now);
417 417
 
418
-					if ( ( 'if-now' == $tag ) && $now ) {
419
-						return $calendar->get_event_html( $event, $partial );
420
-					} elseif ( ( 'if-not-now' == $tag ) && ( false == $now ) ) {
421
-						return $calendar->get_event_html( $event, $partial );
418
+					if (('if-now' == $tag) && $now) {
419
+						return $calendar->get_event_html($event, $partial);
420
+					} elseif (('if-not-now' == $tag) && (false == $now)) {
421
+						return $calendar->get_event_html($event, $partial);
422 422
 					}
423 423
 
424 424
 					break;
@@ -426,15 +426,15 @@  discard block
 block discarded – undo
426 426
 				case 'if-started' :
427 427
 				case 'if-not-started' :
428 428
 
429
-					$start = $event->start_dt->setTimezone( $calendar->timezone )->getTimestamp();
429
+					$start = $event->start_dt->setTimezone($calendar->timezone)->getTimestamp();
430 430
 
431
-					if ( 'if-started' == $tag ) {
432
-						if ( $start < $calendar->now ) {
433
-							return $calendar->get_event_html( $event, $partial );
431
+					if ('if-started' == $tag) {
432
+						if ($start < $calendar->now) {
433
+							return $calendar->get_event_html($event, $partial);
434 434
 						}
435
-					} elseif ( 'if-not-started' == $tag ) {
436
-						if ( $start > $calendar->now ) {
437
-							return $calendar->get_event_html( $event, $partial );
435
+					} elseif ('if-not-started' == $tag) {
436
+						if ($start > $calendar->now) {
437
+							return $calendar->get_event_html($event, $partial);
438 438
 						}
439 439
 					}
440 440
 
@@ -443,17 +443,17 @@  discard block
 block discarded – undo
443 443
 				case 'if-ended' :
444 444
 				case 'if-not-ended' :
445 445
 
446
-					if ( false !== $event->end ) {
446
+					if (false !== $event->end) {
447 447
 
448
-						$end = $event->end_dt->setTimezone( $calendar->timezone )->getTimestamp();
448
+						$end = $event->end_dt->setTimezone($calendar->timezone)->getTimestamp();
449 449
 
450
-						if ( 'if-ended' == $tag ) {
451
-							if ( $end < $calendar->now ) {
452
-								return $calendar->get_event_html( $event, $partial );
450
+						if ('if-ended' == $tag) {
451
+							if ($end < $calendar->now) {
452
+								return $calendar->get_event_html($event, $partial);
453 453
 							}
454
-						} elseif ( 'if-not-ended' == $tag ) {
455
-							if ( $end > $calendar->now ) {
456
-								return $calendar->get_event_html( $event, $partial );
454
+						} elseif ('if-not-ended' == $tag) {
455
+							if ($end > $calendar->now) {
456
+								return $calendar->get_event_html($event, $partial);
457 457
 							}
458 458
 						}
459 459
 
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
 					break;
463 463
 
464 464
 				case 'if-end-time' :
465
-					if ( false !== $event->end ) {
466
-						return $calendar->get_event_html( $event, $partial );
465
+					if (false !== $event->end) {
466
+						return $calendar->get_event_html($event, $partial);
467 467
 					}
468 468
 					break;
469 469
 
470 470
 				case 'if-no-end-time' :
471
-					if ( false === $event->end ) {
472
-						return $calendar->get_event_html( $event, $partial );
471
+					if (false === $event->end) {
472
+						return $calendar->get_event_html($event, $partial);
473 473
 					}
474 474
 					break;
475 475
 
@@ -477,62 +477,62 @@  discard block
 block discarded – undo
477 477
 				case 'if-whole-day' :
478 478
 				case 'if-not-all-day' :
479 479
 				case 'if-not-whole-day' :
480
-					$bool = strstr( $tag, 'not' ) ? false : true;
481
-					if ( $bool === $event->whole_day ) {
482
-						return $calendar->get_event_html( $event, $partial );
480
+					$bool = strstr($tag, 'not') ? false : true;
481
+					if ($bool === $event->whole_day) {
482
+						return $calendar->get_event_html($event, $partial);
483 483
 					}
484 484
 					break;
485 485
 
486 486
 				case 'if-recurring' :
487
-					if ( ! empty( $event->recurrence ) ) {
488
-						return $calendar->get_event_html( $event, $partial );
487
+					if ( ! empty($event->recurrence)) {
488
+						return $calendar->get_event_html($event, $partial);
489 489
 					}
490 490
 					break;
491 491
 
492 492
 				case 'if-not-recurring' :
493
-					if ( false === $event->recurrence ) {
494
-						return $calendar->get_event_html( $event, $partial );
493
+					if (false === $event->recurrence) {
494
+						return $calendar->get_event_html($event, $partial);
495 495
 					}
496 496
 					break;
497 497
 
498 498
 				case 'if-multi-day' :
499
-					if ( false !== $event->multiple_days ) {
500
-						return $calendar->get_event_html( $event, $partial );
499
+					if (false !== $event->multiple_days) {
500
+						return $calendar->get_event_html($event, $partial);
501 501
 					}
502 502
 					break;
503 503
 
504 504
 				case 'if-single-day' :
505
-					if ( false === $event->multiple_days ) {
506
-						return $calendar->get_event_html( $event, $partial );
505
+					if (false === $event->multiple_days) {
506
+						return $calendar->get_event_html($event, $partial);
507 507
 					}
508 508
 					break;
509 509
 
510 510
 				case 'if-location' :
511 511
 				case 'if-start-location' :
512
-					if ( ! empty( $event->start_location['address'] ) ) {
513
-						return $calendar->get_event_html( $event, $partial );
512
+					if ( ! empty($event->start_location['address'])) {
513
+						return $calendar->get_event_html($event, $partial);
514 514
 					}
515 515
 
516 516
 					return false;
517 517
 
518 518
 				case 'if-not-location' :
519 519
 				case 'if-not-start-location' :
520
-					if ( empty( $event->start_location['address'] ) ) {
521
-						return $calendar->get_event_html( $event, $partial );
520
+					if (empty($event->start_location['address'])) {
521
+						return $calendar->get_event_html($event, $partial);
522 522
 					}
523 523
 
524 524
 					return '';
525 525
 
526 526
 				case 'if-not-end-location' :
527
-					if ( empty( $event->end_location['address'] ) ) {
528
-						return $calendar->get_event_html( $event, $partial );
527
+					if (empty($event->end_location['address'])) {
528
+						return $calendar->get_event_html($event, $partial);
529 529
 					}
530 530
 
531 531
 					return '';
532 532
 
533 533
 				case 'if-end-location' :
534
-					if ( ! empty( $event->end_location['address'] ) ) {
535
-						return $calendar->get_event_html( $event, $partial );
534
+					if ( ! empty($event->end_location['address'])) {
535
+						return $calendar->get_event_html($event, $partial);
536 536
 					}
537 537
 
538 538
 					return '';
@@ -542,12 +542,12 @@  discard block
 block discarded – undo
542 542
 				 * ======= */
543 543
 
544 544
 				default :
545
-					$resultCustom = $this->do_custom_event_tag( $tag, $partial, $attr, $event );
546
-					if ( $resultCustom != "" ) {
545
+					$resultCustom = $this->do_custom_event_tag($tag, $partial, $attr, $event);
546
+					if ($resultCustom != "") {
547 547
 						return $resultCustom;
548 548
 					}
549 549
 
550
-					return wp_kses_post( $before . $partial . $after );
550
+					return wp_kses_post($before.$partial.$after);
551 551
 			}
552 552
 		}
553 553
 
@@ -565,14 +565,14 @@  discard block
 block discarded – undo
565 565
 	 *
566 566
 	 * @return string
567 567
 	 */
568
-	private function limit_words( $text, $limit ) {
568
+	private function limit_words($text, $limit) {
569 569
 
570
-		$limit = max( absint( $limit ), 0 );
570
+		$limit = max(absint($limit), 0);
571 571
 
572
-		if ( $limit > 0 && ( str_word_count( $text, 0 ) > $limit ) ) {
573
-			$words = str_word_count( $text, 2 );
574
-			$pos   = array_keys( $words );
575
-			$text  = trim( substr( $text, 0, $pos[ $limit ] ) ) . '&hellip;';
572
+		if ($limit > 0 && (str_word_count($text, 0) > $limit)) {
573
+			$words = str_word_count($text, 2);
574
+			$pos   = array_keys($words);
575
+			$text  = trim(substr($text, 0, $pos[$limit])).'&hellip;';
576 576
 		}
577 577
 
578 578
 		return $text;
@@ -589,26 +589,26 @@  discard block
 block discarded – undo
589 589
 	 *
590 590
 	 * @return string
591 591
 	 */
592
-	private function get_title( $title, $attr ) {
592
+	private function get_title($title, $attr) {
593 593
 
594
-		if ( empty( $title ) ) {
594
+		if (empty($title)) {
595 595
 			return '';
596 596
 		}
597 597
 
598
-		$attr = array_merge( array(
599
-			'html'  => '',  // Parse HTML
600
-			'limit' => 0,   // Trim length to amount of words
601
-		), (array) shortcode_parse_atts( $attr ) );
598
+		$attr = array_merge(array(
599
+			'html'  => '', // Parse HTML
600
+			'limit' => 0, // Trim length to amount of words
601
+		), (array) shortcode_parse_atts($attr));
602 602
 
603
-		if ( ! empty( $attr['html'] ) ) {
604
-			$title = wp_kses_post( $title );
603
+		if ( ! empty($attr['html'])) {
604
+			$title = wp_kses_post($title);
605 605
 			$tag   = 'div';
606 606
 		} else {
607
-			$title = $this->limit_words( $title, $attr['limit'] );
607
+			$title = $this->limit_words($title, $attr['limit']);
608 608
 			$tag   = 'span';
609 609
 		}
610 610
 
611
-		return '<' . $tag . ' class="simcal-event-title" itemprop="name">' . $title . '</' . $tag . '>';
611
+		return '<'.$tag.' class="simcal-event-title" itemprop="name">'.$title.'</'.$tag.'>';
612 612
 	}
613 613
 
614 614
 	/**
@@ -622,18 +622,18 @@  discard block
 block discarded – undo
622 622
 	 *
623 623
 	 * @return string
624 624
 	 */
625
-	private function get_description( $description, $attr ) {
625
+	private function get_description($description, $attr) {
626 626
 
627
-		if ( empty( $description ) ) {
627
+		if (empty($description)) {
628 628
 			return '';
629 629
 		}
630 630
 
631
-		$attr = array_merge( array(
632
-			'limit'    => 0,       // Trim length to number of words
633
-			'html'     => 'no',    // Parse HTML content
634
-			'markdown' => 'no',    // Parse Markdown content
635
-			'autolink' => 'no',    // Automatically convert plaintext URIs to anchors
636
-		), (array) shortcode_parse_atts( $attr ) );
631
+		$attr = array_merge(array(
632
+			'limit'    => 0, // Trim length to number of words
633
+			'html'     => 'no', // Parse HTML content
634
+			'markdown' => 'no', // Parse Markdown content
635
+			'autolink' => 'no', // Automatically convert plaintext URIs to anchors
636
+		), (array) shortcode_parse_atts($attr));
637 637
 
638 638
 		$allow_html = 'no' != $attr['html'] ? true : false;
639 639
 		$allow_md   = 'no' != $attr['markdown'] ? true : false;
@@ -641,23 +641,23 @@  discard block
 block discarded – undo
641 641
 		$html = '<div class="simcal-event-description" itemprop="description">';
642 642
 
643 643
 		// Markdown and HTML don't play well together, use one or the other in the same tag.
644
-		if ( $allow_html || $allow_md ) {
645
-			if ( $allow_html ) {
646
-				$description = wp_kses_post( $description );
647
-			} elseif ( $allow_md ) {
644
+		if ($allow_html || $allow_md) {
645
+			if ($allow_html) {
646
+				$description = wp_kses_post($description);
647
+			} elseif ($allow_md) {
648 648
 				$markdown    = new \Parsedown();
649
-				$description = $markdown->text( wp_strip_all_tags( $description ) );
649
+				$description = $markdown->text(wp_strip_all_tags($description));
650 650
 			}
651 651
 		} else {
652
-			$description = wpautop( $description );
652
+			$description = wpautop($description);
653 653
 		}
654 654
 
655
-		$description = $this->limit_words( $description, $attr['limit'] );
655
+		$description = $this->limit_words($description, $attr['limit']);
656 656
 
657
-		$html .= $description . '</div>';
657
+		$html .= $description.'</div>';
658 658
 
659
-		if ( 'no' != $attr['autolink'] ) {
660
-			$html = ' ' . make_clickable( $html );
659
+		if ('no' != $attr['autolink']) {
660
+			$html = ' '.make_clickable($html);
661 661
 		}
662 662
 
663 663
 		return $html;
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return string
675 675
 	 */
676
-	private function get_when( Event $event ) {
676
+	private function get_when(Event $event) {
677 677
 
678 678
 		//$start = $event->start_dt->setTimezone( $event->timezone );
679 679
 		//$end   = ! is_null( $event->end_dt ) ? $event->end_dt->setTimezone( $event->timezone ) : null;
@@ -687,37 +687,37 @@  discard block
 block discarded – undo
687 687
 		$start_iso  = $start->toIso8601String();
688 688
 		$end_iso    = $end->toIso8601String();
689 689
 
690
-		if ( ! $event->whole_day ) {
690
+		if ( ! $event->whole_day) {
691 691
 
692
-			$time_start = $this->calendar->datetime_separator . ' <span class="simcal-event-start simcal-event-start-time" ' . 'data-event-start="' . $start_ts . '" ' . 'data-event-format="' . $this->calendar->time_format . '" ' . 'itemprop="startDate" content="' . $start_iso . '">' . $start->format( $this->calendar->time_format ) . '</span> ';
692
+			$time_start = $this->calendar->datetime_separator.' <span class="simcal-event-start simcal-event-start-time" '.'data-event-start="'.$start_ts.'" '.'data-event-format="'.$this->calendar->time_format.'" '.'itemprop="startDate" content="'.$start_iso.'">'.$start->format($this->calendar->time_format).'</span> ';
693 693
 
694
-			if ( $end instanceof Carbon ) {
694
+			if ($end instanceof Carbon) {
695 695
 
696
-				$time_end = ' <span class="simcal-event-end simcal-event-end-time" ' . 'data-event-end="' . $end_ts . '" ' . 'data-event-format="' . $this->calendar->time_format . '" ' . 'itemprop="endDate" content="' . $end_iso . '">' . $end->format( $this->calendar->time_format ) . '</span> ';
696
+				$time_end = ' <span class="simcal-event-end simcal-event-end-time" '.'data-event-end="'.$end_ts.'" '.'data-event-format="'.$this->calendar->time_format.'" '.'itemprop="endDate" content="'.$end_iso.'">'.$end->format($this->calendar->time_format).'</span> ';
697 697
 
698 698
 			}
699 699
 
700 700
 		}
701 701
 
702
-		if ( $event->multiple_days ) {
702
+		if ($event->multiple_days) {
703 703
 
704
-			$output = ' <span class="simcal-event-start simcal-event-start-date" ' . 'data-event-start="' . $start_ts . '" ' . 'data-event-format="' . $this->calendar->date_format . '" ' . 'itemprop="startDate" content="' . $start_iso . '">' . $start->format( $this->calendar->date_format ) . '</span> ' . $time_start;
704
+			$output = ' <span class="simcal-event-start simcal-event-start-date" '.'data-event-start="'.$start_ts.'" '.'data-event-format="'.$this->calendar->date_format.'" '.'itemprop="startDate" content="'.$start_iso.'">'.$start->format($this->calendar->date_format).'</span> '.$time_start;
705 705
 
706
-			if ( $end instanceof Carbon ) {
706
+			if ($end instanceof Carbon) {
707 707
 
708
-				$output .= '-' . ' <span class="simcal-event-start simcal-event-end-date" ' . 'data-event-start="' . $end_ts . '" ' . 'data-event-format="' . $this->calendar->date_format . '" ' . 'itemprop="endDate" content="' . $end_iso . '">' . $end->format( $this->calendar->date_format ) . '</span> ' . $time_end;
708
+				$output .= '-'.' <span class="simcal-event-start simcal-event-end-date" '.'data-event-start="'.$end_ts.'" '.'data-event-format="'.$this->calendar->date_format.'" '.'itemprop="endDate" content="'.$end_iso.'">'.$end->format($this->calendar->date_format).'</span> '.$time_end;
709 709
 			}
710 710
 
711 711
 		} else {
712 712
 
713
-			$time_end = ! empty( $time_start ) && ! empty( $time_end ) ? ' - ' . $time_end : '';
713
+			$time_end = ! empty($time_start) && ! empty($time_end) ? ' - '.$time_end : '';
714 714
 
715 715
 			// All-day events also need startDate for schema data.
716
-			$output = ' <span class="simcal-event-start simcal-event-start-date" ' . 'data-event-start="' . $start_ts . '" ' . 'data-event-format="' . $this->calendar->date_format . '" ' . 'itemprop="startDate" content="' . $start_iso . '">' . $start->format( $this->calendar->date_format ) . '</span> ' . $time_start . $time_end;
716
+			$output = ' <span class="simcal-event-start simcal-event-start-date" '.'data-event-start="'.$start_ts.'" '.'data-event-format="'.$this->calendar->date_format.'" '.'itemprop="startDate" content="'.$start_iso.'">'.$start->format($this->calendar->date_format).'</span> '.$time_start.$time_end;
717 717
 
718 718
 		}
719 719
 
720
-		return trim( $output );
720
+		return trim($output);
721 721
 	}
722 722
 
723 723
 	/**
@@ -732,52 +732,52 @@  discard block
 block discarded – undo
732 732
 	 *
733 733
 	 * @return string
734 734
 	 */
735
-	private function get_dt( $tag, Event $event, $attr ) {
735
+	private function get_dt($tag, Event $event, $attr) {
736 736
 
737
-		$bound = 0 === strpos( $tag, 'end' ) ? 'end' : 'start';
737
+		$bound = 0 === strpos($tag, 'end') ? 'end' : 'start';
738 738
 
739
-		if ( ( 'end' == $bound ) && ( false === $event->end ) ) {
739
+		if (('end' == $bound) && (false === $event->end)) {
740 740
 			return '';
741 741
 		}
742 742
 
743
-		$dt = $bound . '_dt';
743
+		$dt = $bound.'_dt';
744 744
 
745
-		if ( ! $event->$dt instanceof Carbon ) {
745
+		if ( ! $event->$dt instanceof Carbon) {
746 746
 			return '';
747 747
 		}
748 748
 
749 749
 		$event_dt = $event->$dt;
750 750
 
751
-		$attr = array_merge( array(
751
+		$attr = array_merge(array(
752 752
 			'format' => '',
753
-		), (array) shortcode_parse_atts( $attr ) );
753
+		), (array) shortcode_parse_atts($attr));
754 754
 
755
-		$format    = ltrim( strstr( $tag, '-' ), '-' );
755
+		$format    = ltrim(strstr($tag, '-'), '-');
756 756
 		$dt_format = '';
757 757
 
758
-		if ( ! empty( $attr['format'] ) ) {
759
-			$dt_format = esc_attr( wp_strip_all_tags( $attr['format'] ) );
760
-		} elseif ( 'date' == $format ) {
758
+		if ( ! empty($attr['format'])) {
759
+			$dt_format = esc_attr(wp_strip_all_tags($attr['format']));
760
+		} elseif ('date' == $format) {
761 761
 			$dt_format = $this->calendar->date_format;
762
-		} elseif ( 'time' == $format ) {
762
+		} elseif ('time' == $format) {
763 763
 			$dt_format = $this->calendar->time_format;
764 764
 		}
765 765
 
766 766
 		$dt_ts = $event_dt->timestamp;
767 767
 
768
-		if ( 'human' == $format ) {
769
-			$value = human_time_diff( $dt_ts, Carbon::now( $event->timezone )->getTimestamp() );
768
+		if ('human' == $format) {
769
+			$value = human_time_diff($dt_ts, Carbon::now($event->timezone)->getTimestamp());
770 770
 
771
-			if ( $dt_ts < Carbon::now( $event->timezone )->getTimestamp() ) {
772
-				$value .= ' ' . _x( 'ago', 'human date event builder code modifier', 'google-calendar-events' );
771
+			if ($dt_ts < Carbon::now($event->timezone)->getTimestamp()) {
772
+				$value .= ' '._x('ago', 'human date event builder code modifier', 'google-calendar-events');
773 773
 			} else {
774
-				$value .= ' ' . _x( 'from now', 'human date event builder code modifier', 'google-calendar-events' );
774
+				$value .= ' '._x('from now', 'human date event builder code modifier', 'google-calendar-events');
775 775
 			}
776 776
 		} else {
777
-			$value = $event->$dt->format( $dt_format );
777
+			$value = $event->$dt->format($dt_format);
778 778
 		}
779 779
 
780
-		return '<span class="simcal-event-' . $bound . ' ' . 'simcal-event-' . $bound . '-' . $format . '" ' . 'data-event-' . $bound . '="' . $dt_ts . '" ' . 'data-event-format="' . $dt_format . '" ' . 'itemprop="' . $bound . 'Date" content="' . $event_dt->toIso8601String() . '">' . $value . '</span>';
780
+		return '<span class="simcal-event-'.$bound.' '.'simcal-event-'.$bound.'-'.$format.'" '.'data-event-'.$bound.'="'.$dt_ts.'" '.'data-event-format="'.$dt_format.'" '.'itemprop="'.$bound.'Date" content="'.$event_dt->toIso8601String().'">'.$value.'</span>';
781 781
 	}
782 782
 
783 783
 	/**
@@ -793,23 +793,23 @@  discard block
 block discarded – undo
793 793
 	 *
794 794
 	 * @return string
795 795
 	 */
796
-	private function make_link( $tag, $url, $content, $attr ) {
796
+	private function make_link($tag, $url, $content, $attr) {
797 797
 
798
-		if ( empty( $url ) ) {
798
+		if (empty($url)) {
799 799
 			return '';
800 800
 		}
801 801
 
802
-		$text = empty( $content ) ? $url : $content;
802
+		$text = empty($content) ? $url : $content;
803 803
 
804
-		$attr = array_merge( array(
805
-			'autolink'  => false,   // Convert url to link anchor
806
-			'newwindow' => false,   // If autolink attribute is true, open link in new window
807
-		), (array) shortcode_parse_atts( $attr ) );
804
+		$attr = array_merge(array(
805
+			'autolink'  => false, // Convert url to link anchor
806
+			'newwindow' => false, // If autolink attribute is true, open link in new window
807
+		), (array) shortcode_parse_atts($attr));
808 808
 
809 809
 		$anchor = $tag != 'url' ? 'yes' : $attr['autolink'];
810 810
 		$target = $attr['newwindow'] !== false ? 'target="_blank"' : '';
811 811
 
812
-		return $anchor !== false ? ' <a href="' . esc_url( $url ) . '" ' . $target . '>' . $text . '</a>' : ' ' . $text;
812
+		return $anchor !== false ? ' <a href="'.esc_url($url).'" '.$target.'>'.$text.'</a>' : ' '.$text;
813 813
 	}
814 814
 
815 815
 	/**
@@ -822,20 +822,20 @@  discard block
 block discarded – undo
822 822
 	 *
823 823
 	 * @return string
824 824
 	 */
825
-	private function get_attachments( $attachments ) {
825
+	private function get_attachments($attachments) {
826 826
 
827
-		$html = '<ul class="simcal-attachments">' . "\n\t";
827
+		$html = '<ul class="simcal-attachments">'."\n\t";
828 828
 
829
-		foreach ( $attachments as $attachment ) {
829
+		foreach ($attachments as $attachment) {
830 830
 			$html .= '<li class="simcal-attachment">';
831
-			$html .= '<a href="' . $attachment['url'] . '" target="_blank">';
832
-			$html .= ! empty( $attachment['icon'] ) ? '<img src="' . $attachment['icon'] . '" />' : '';
833
-			$html .= '<span>' . $attachment['name'] . '</span>';
831
+			$html .= '<a href="'.$attachment['url'].'" target="_blank">';
832
+			$html .= ! empty($attachment['icon']) ? '<img src="'.$attachment['icon'].'" />' : '';
833
+			$html .= '<span>'.$attachment['name'].'</span>';
834 834
 			$html .= '</a>';
835
-			$html .= '</li>' . "\n";
835
+			$html .= '</li>'."\n";
836 836
 		}
837 837
 
838
-		$html .= '</ul>' . "\n";
838
+		$html .= '</ul>'."\n";
839 839
 
840 840
 		return $html;
841 841
 	}
@@ -851,41 +851,41 @@  discard block
 block discarded – undo
851 851
 	 *
852 852
 	 * @return string
853 853
 	 */
854
-	private function get_attendees( $attendees, $attr ) {
854
+	private function get_attendees($attendees, $attr) {
855 855
 
856
-		$attr = array_merge( array(
857
-			'photo'    => 'show',  // show/hide attendee photo
858
-			'email'    => 'hide',  // show/hide attendee email address
859
-			'rsvp'     => 'hide',  // show/hide rsvp response status
860
-			'response' => '',      // filter attendees by rsvp response (yes/no/maybe)
861
-		), (array) shortcode_parse_atts( $attr ) );
856
+		$attr = array_merge(array(
857
+			'photo'    => 'show', // show/hide attendee photo
858
+			'email'    => 'hide', // show/hide attendee email address
859
+			'rsvp'     => 'hide', // show/hide rsvp response status
860
+			'response' => '', // filter attendees by rsvp response (yes/no/maybe)
861
+		), (array) shortcode_parse_atts($attr));
862 862
 
863
-		$html = '<ul class="simcal-attendees" itemprop="attendees">' . "\n\t";
863
+		$html = '<ul class="simcal-attendees" itemprop="attendees">'."\n\t";
864 864
 
865 865
 		$known   = 0;
866 866
 		$unknown = 0;
867 867
 
868
-		foreach ( $attendees as $attendee ) {
868
+		foreach ($attendees as $attendee) {
869 869
 
870
-			if ( 'yes' == $attr['response'] && 'yes' != $attendee['response'] ) {
870
+			if ('yes' == $attr['response'] && 'yes' != $attendee['response']) {
871 871
 				continue;
872
-			} elseif ( 'no' == $attr['response'] && 'no' != $attendee['response'] ) {
872
+			} elseif ('no' == $attr['response'] && 'no' != $attendee['response']) {
873 873
 				continue;
874
-			} elseif ( 'maybe' == $attr['response'] && ! in_array( $attendee['response'], array( 'yes', 'maybe' ) ) ) {
874
+			} elseif ('maybe' == $attr['response'] && ! in_array($attendee['response'], array('yes', 'maybe'))) {
875 875
 				continue;
876 876
 			}
877 877
 
878
-			if ( ! empty( $attendee['name'] ) ) {
878
+			if ( ! empty($attendee['name'])) {
879 879
 
880
-				$photo    = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $attendee['photo'] . '" itemprop="image" />' : '';
881
-				$response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response( $attendee['response'] ) : '';
882
-				$guest    = $photo . '<span itemprop="name">' . $attendee['name'] . $response . '</span>';
880
+				$photo    = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$attendee['photo'].'" itemprop="image" />' : '';
881
+				$response = 'hide' != $attr['rsvp'] ? $this->get_rsvp_response($attendee['response']) : '';
882
+				$guest    = $photo.'<span itemprop="name">'.$attendee['name'].$response.'</span>';
883 883
 
884
-				if ( ! empty( $attendee['email'] ) && ( 'show' == $attr['email'] ) ) {
885
-					$guest = sprintf( '<a href="mailto:' . $attendee['email'] . '" itemprop="email">%s</a>', $guest );
884
+				if ( ! empty($attendee['email']) && ('show' == $attr['email'])) {
885
+					$guest = sprintf('<a href="mailto:'.$attendee['email'].'" itemprop="email">%s</a>', $guest);
886 886
 				}
887 887
 
888
-				$html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">' . $guest . '</li>' . "\n";
888
+				$html .= '<li class="simcal-attendee" itemprop="attendee" itemscope itemtype="http://schema.org/Person">'.$guest.'</li>'."\n";
889 889
 
890 890
 				$known++;
891 891
 
@@ -896,21 +896,21 @@  discard block
 block discarded – undo
896 896
 			}
897 897
 		}
898 898
 
899
-		if ( $unknown > 0 ) {
900
-			if ( $known > 0 ) {
899
+		if ($unknown > 0) {
900
+			if ($known > 0) {
901 901
 				/* translators: One more person attending the event. */
902
-				$others = sprintf( _n( '1 more attendee', '%s more attendees', $unknown, 'google-calendar-events' ), $unknown );
902
+				$others = sprintf(_n('1 more attendee', '%s more attendees', $unknown, 'google-calendar-events'), $unknown);
903 903
 			} else {
904 904
 				/* translators: One or more persons attending the event whose name is unknown. */
905
-				$others = sprintf( _n( '1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events' ), $unknown );
905
+				$others = sprintf(_n('1 anonymous attendee', '%s anonymous attendees', $unknown, 'google-calendar-events'), $unknown);
906 906
 			}
907
-			$photo = $attr['photo'] !== 'hide' ? get_avatar( '', 128 ) : '';
908
-			$html .= '<li class="simcal-attendee simcal-attendee-anonymous">' . $photo . '<span>' . $others . '</span></li>' . "\n";
909
-		} elseif ( $known === 0 ) {
910
-			$html .= '<li class="simcal-attendee">' . _x( 'No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events' ) . '</li>' . "\n";
907
+			$photo = $attr['photo'] !== 'hide' ? get_avatar('', 128) : '';
908
+			$html .= '<li class="simcal-attendee simcal-attendee-anonymous">'.$photo.'<span>'.$others.'</span></li>'."\n";
909
+		} elseif ($known === 0) {
910
+			$html .= '<li class="simcal-attendee">'._x('No one yet', 'No one yet rsvp to attend the event.', 'google-calendar-events').'</li>'."\n";
911 911
 		}
912 912
 
913
-		$html .= '</ul>' . "\n";
913
+		$html .= '</ul>'."\n";
914 914
 
915 915
 		return $html;
916 916
 	}
@@ -924,23 +924,23 @@  discard block
 block discarded – undo
924 924
 	 *
925 925
 	 * @return string
926 926
 	 */
927
-	private function get_rsvp_response( $response ) {
927
+	private function get_rsvp_response($response) {
928 928
 
929
-		if ( 'yes' == $response ) {
929
+		if ('yes' == $response) {
930 930
 			/* translators: Someone replied with 'yes' to a rsvp request. */
931
-			$rsvp = __( 'Attending', 'google-calendar-events' );
932
-		} elseif ( 'no' == $response ) {
931
+			$rsvp = __('Attending', 'google-calendar-events');
932
+		} elseif ('no' == $response) {
933 933
 			/* translators: Someone replied with 'no' to a rsvp request. */
934
-			$rsvp = __( 'Not attending', 'google-calendar-events' );
935
-		} elseif ( 'maybe' == $response ) {
934
+			$rsvp = __('Not attending', 'google-calendar-events');
935
+		} elseif ('maybe' == $response) {
936 936
 			/* translators: Someone replied with 'maybe' to a rsvp request. */
937
-			$rsvp = __( 'Maybe attending', 'google-calendar-events' );
937
+			$rsvp = __('Maybe attending', 'google-calendar-events');
938 938
 		} else {
939 939
 			/* translators: Someone did not send yet a rsvp confirmation to join an event. */
940
-			$rsvp = __( 'Response pending', 'google-calendar-events' );
940
+			$rsvp = __('Response pending', 'google-calendar-events');
941 941
 		}
942 942
 
943
-		return ' <small>(' . $rsvp . ')</small>';
943
+		return ' <small>('.$rsvp.')</small>';
944 944
 	}
945 945
 
946 946
 	/**
@@ -954,21 +954,21 @@  discard block
 block discarded – undo
954 954
 	 *
955 955
 	 * @return string
956 956
 	 */
957
-	private function get_organizer( $organizer, $attr ) {
957
+	private function get_organizer($organizer, $attr) {
958 958
 
959
-		$attr = array_merge( array(
960
-			'photo' => 'show',  // show/hide attendee photo
961
-			'email' => 'hide',  // show/hide attendee email address
962
-		), (array) shortcode_parse_atts( $attr ) );
959
+		$attr = array_merge(array(
960
+			'photo' => 'show', // show/hide attendee photo
961
+			'email' => 'hide', // show/hide attendee email address
962
+		), (array) shortcode_parse_atts($attr));
963 963
 
964
-		$photo          = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="' . $organizer['photo'] . '" itemprop="image"  />' : '';
965
-		$organizer_html = $photo . '<span itemprop="name">' . $organizer['name'] . '</span>';
964
+		$photo          = 'hide' != $attr['photo'] ? '<img class="avatar avatar-128 photo" src="'.$organizer['photo'].'" itemprop="image"  />' : '';
965
+		$organizer_html = $photo.'<span itemprop="name">'.$organizer['name'].'</span>';
966 966
 
967
-		if ( ! empty( $organizer['email'] ) && ( 'show' == $attr['email'] ) ) {
968
-			$organizer_html = sprintf( '<a href="mailto:' . $organizer['email'] . '" itemprop="email">%s</a>', $organizer_html );
967
+		if ( ! empty($organizer['email']) && ('show' == $attr['email'])) {
968
+			$organizer_html = sprintf('<a href="mailto:'.$organizer['email'].'" itemprop="email">%s</a>', $organizer_html);
969 969
 		}
970 970
 
971
-		return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">' . $organizer_html . '</div>';
971
+		return '<div class="simcal-organizer" itemprop="organizer" itemscope itemtype="https://schema.org/Person">'.$organizer_html.'</div>';
972 972
 	}
973 973
 
974 974
 	/**
@@ -993,38 +993,38 @@  discard block
 block discarded – undo
993 993
 		// This is largely borrowed on get_shortcode_regex() from WordPress Core.
994 994
 		// @see /wp-includes/shortcodes.php (with some modification)
995 995
 
996
-		$tagregexp = implode( '|', array_values( $this->tags ) );
996
+		$tagregexp = implode('|', array_values($this->tags));
997 997
 
998
-		return '/' . '\\['                              // Opening bracket
998
+		return '/'.'\\['                              // Opening bracket
999 999
 		       . '(\\[?)'                           // 1: Optional second opening bracket for escaping tags: [[tag]]
1000 1000
 		       . "($tagregexp)"                     // 2: Tag name
1001 1001
 		       . '(?![\\w-])'                       // Not followed by word character or hyphen
1002 1002
 		       . '('                                // 3: Unroll the loop: Inside the opening tag
1003 1003
 		       . '[^\\]\\/]*'                   // Not a closing bracket or forward slash
1004
-		       . '(?:' . '\\/(?!\\])'               // A forward slash not followed by a closing bracket
1004
+		       . '(?:'.'\\/(?!\\])'               // A forward slash not followed by a closing bracket
1005 1005
 		       . '[^\\]\\/]*'               // Not a closing bracket or forward slash
1006
-		       . ')*?' . ')' . '(?:' . '(\\/)'                        // 4: Self closing tag ...
1006
+		       . ')*?'.')'.'(?:'.'(\\/)'                        // 4: Self closing tag ...
1007 1007
 		       . '\\]'                          // ... and closing bracket
1008
-		       . '|' . '\\]'                          // Closing bracket
1009
-		       . '(?:' . '('                        // 5: Unroll the loop: Optionally, anything between the opening and closing tags
1008
+		       . '|'.'\\]'                          // Closing bracket
1009
+		       . '(?:'.'('                        // 5: Unroll the loop: Optionally, anything between the opening and closing tags
1010 1010
 		       . '[^\\[]*+'             // Not an opening bracket
1011
-		       . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag
1011
+		       . '(?:'.'\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing tag
1012 1012
 		       . '[^\\[]*+'         // Not an opening bracket
1013
-		       . ')*+' . ')' . '\\[\\/\\2\\]'             // Closing tag
1014
-		       . ')?' . ')' . '(\\]?)'                           // 6: Optional second closing bracket for escaping tags: [[tag]]
1013
+		       . ')*+'.')'.'\\[\\/\\2\\]'             // Closing tag
1014
+		       . ')?'.')'.'(\\]?)'                           // 6: Optional second closing bracket for escaping tags: [[tag]]
1015 1015
 		       . '/s';
1016 1016
 	}
1017 1017
 
1018 1018
 	//allow other plugins to register own event tags
1019 1019
 	private function add_custom_event_tags() {
1020
-		$array = apply_filters( 'simcal_event_tags_add_custom', array() );
1020
+		$array = apply_filters('simcal_event_tags_add_custom', array());
1021 1021
 
1022 1022
 		return $array;
1023 1023
 	}
1024 1024
 
1025 1025
 	//allow other plugins to replace own (registered) event tags with their value
1026
-	private function do_custom_event_tag( $tag, $partial, $attr, $event ) {
1027
-		$returnvalue = apply_filters( 'simcal_event_tags_do_custom', "", $tag, $partial, $attr, $event );
1026
+	private function do_custom_event_tag($tag, $partial, $attr, $event) {
1027
+		$returnvalue = apply_filters('simcal_event_tags_do_custom', "", $tag, $partial, $attr, $event);
1028 1028
 
1029 1029
 		return $returnvalue;
1030 1030
 	}
Please login to merge, or discard this patch.
includes/calendars/views/default-calendar-list.php 1 patch
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Calendars\Default_Calendar;
14 14
 use SimpleCalendar\Events\Event;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @param string|Calendar $calendar
77 77
 	 */
78
-	public function __construct( $calendar = '' ) {
78
+	public function __construct($calendar = '') {
79 79
 		$this->calendar = $calendar;
80 80
 	}
81 81
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return string
110 110
 	 */
111 111
 	public function get_name() {
112
-		return __( 'List', 'google-calendar-events' );
112
+		return __('List', 'google-calendar-events');
113 113
 	}
114 114
 
115 115
 	/**
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	 * @since 3.0.0
119 119
 	 */
120 120
 	public function add_ajax_actions() {
121
-		add_action( 'wp_ajax_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) );
122
-		add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_list', array( $this, 'draw_list_ajax' ) );
121
+		add_action('wp_ajax_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax'));
122
+		add_action('wp_ajax_nopriv_simcal_default_calendar_draw_list', array($this, 'draw_list_ajax'));
123 123
 	}
124 124
 
125 125
 	/**
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return array
135 135
 	 */
136
-	public function scripts( $min = '' ) {
136
+	public function scripts($min = '') {
137 137
 		return array(
138 138
 			'simcal-qtip' => array(
139
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/vendor/qtip' . $min . '.js',
140
-				'deps'      => array( 'jquery' ),
139
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/vendor/qtip'.$min.'.js',
140
+				'deps'      => array('jquery'),
141 141
 				'in_footer' => true,
142 142
 			),
143 143
 			'simcal-default-calendar' => array(
144
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js',
144
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js',
145 145
 				'deps'      => array(
146 146
 					'jquery',
147 147
 					'simcal-qtip',
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @return array
167 167
 	 */
168
-	public function styles( $min = '' ) {
168
+	public function styles($min = '') {
169 169
 		return array(
170 170
 			'simcal-default-calendar-list' => array(
171
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css',
171
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css',
172 172
 				'media' => 'all',
173 173
 			),
174 174
 		);
@@ -183,49 +183,49 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$calendar = $this->calendar;
185 185
 
186
-		if ( $calendar instanceof Default_Calendar ) {
186
+		if ($calendar instanceof Default_Calendar) {
187 187
 
188
-			$disabled = $calendar->static === true || empty( $calendar->events ) ? ' disabled="disabled"' : '';
188
+			$disabled = $calendar->static === true || empty($calendar->events) ? ' disabled="disabled"' : '';
189 189
 
190 190
 
191
-			$hide_header = get_post_meta( $this->calendar->id, '_default_calendar_list_header', true ) == 'yes' ? true : false;
192
-			$static_calendar = get_post_meta( $this->calendar->id, '_calendar_is_static', true ) == 'yes' ? true : false;
191
+			$hide_header = get_post_meta($this->calendar->id, '_default_calendar_list_header', true) == 'yes' ? true : false;
192
+			$static_calendar = get_post_meta($this->calendar->id, '_calendar_is_static', true) == 'yes' ? true : false;
193 193
 
194 194
 			$header_class = '';
195 195
 			$compact_list_class = $calendar->compact_list ? 'simcal-calendar-list-compact' : '';
196 196
 
197
-			edit_post_link( __( 'Edit Calendar', 'google-calendar-events' ), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id );
197
+			edit_post_link(__('Edit Calendar', 'google-calendar-events'), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id);
198 198
 
199
-			echo '<div class="simcal-calendar-list ' . $compact_list_class . '">';
199
+			echo '<div class="simcal-calendar-list '.$compact_list_class.'">';
200 200
 
201
-			if ( ! $hide_header && ! $static_calendar ) {
202
-				echo '<nav class="simcal-calendar-head">' . "\n";
201
+			if ( ! $hide_header && ! $static_calendar) {
202
+				echo '<nav class="simcal-calendar-head">'."\n";
203 203
 
204
-				echo "\t" . '<div class="simcal-nav">' . "\n";
205
-				echo "\t\t" . '<button class="simcal-nav-button simcal-prev" title="' . __('Previous', 'google-calendar-events') . '"' . $disabled . '>' . "\n";
206
-				echo "\t\t\t" . '<i class="simcal-icon-left"></i>' . "\n";
207
-				echo "\t\t" . '</button>' . "\n";
208
-				echo "\t" . '</div>' . "\n";
204
+				echo "\t".'<div class="simcal-nav">'."\n";
205
+				echo "\t\t".'<button class="simcal-nav-button simcal-prev" title="'.__('Previous', 'google-calendar-events').'"'.$disabled.'>'."\n";
206
+				echo "\t\t\t".'<i class="simcal-icon-left"></i>'."\n";
207
+				echo "\t\t".'</button>'."\n";
208
+				echo "\t".'</div>'."\n";
209 209
 
210
-				if ( $hide_header ) {
210
+				if ($hide_header) {
211 211
 					$header_class = 'simcal-hide-header';
212 212
 				}
213 213
 
214 214
 
215
-				echo "\t" . '<div class="simcal-nav simcal-current ' . $header_class . '" data-calendar-current="' . $calendar->start . '">' . "\n";
216
-				echo "\t\t" . '<h3 class="simcal-current-label"> </h3>' . "\n";
217
-				echo "\t" . '</div>' . "\n";
215
+				echo "\t".'<div class="simcal-nav simcal-current '.$header_class.'" data-calendar-current="'.$calendar->start.'">'."\n";
216
+				echo "\t\t".'<h3 class="simcal-current-label"> </h3>'."\n";
217
+				echo "\t".'</div>'."\n";
218 218
 
219
-				echo "\t" . '<div class="simcal-nav">';
220
-				echo "\t\t" . '<button class="simcal-nav-button simcal-next" title="' . __('Next', 'google-calendar-events') . '"' . $disabled . '>';
221
-				echo "\t\t\t" . '<i class="simcal-icon-right"></i>' . "\n";
222
-				echo "\t\t" . '</button>' . "\n";
223
-				echo "\t" . '</div>' . "\n";
219
+				echo "\t".'<div class="simcal-nav">';
220
+				echo "\t\t".'<button class="simcal-nav-button simcal-next" title="'.__('Next', 'google-calendar-events').'"'.$disabled.'>';
221
+				echo "\t\t\t".'<i class="simcal-icon-right"></i>'."\n";
222
+				echo "\t\t".'</button>'."\n";
223
+				echo "\t".'</div>'."\n";
224 224
 
225
-				echo '</nav>' . "\n";
225
+				echo '</nav>'."\n";
226 226
 			}
227 227
 
228
-			echo $this->draw_list( $calendar->start );
228
+			echo $this->draw_list($calendar->start);
229 229
 
230 230
 			echo '<div class="simcal-ajax-loader simcal-spinner-top" style="display: none;"><i class="simcal-icon-spinner simcal-icon-spin"></i></div>';
231 231
 
@@ -245,99 +245,99 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @return array
247 247
 	 */
248
-	private function get_events( $timestamp ) {
248
+	private function get_events($timestamp) {
249 249
 
250 250
 		$calendar = $this->calendar;
251 251
 		$timezone = $calendar->timezone;
252 252
 
253
-		if ( ! $calendar->group_type || ! $calendar->group_span ) {
253
+		if ( ! $calendar->group_type || ! $calendar->group_span) {
254 254
 			return array();
255 255
 		}
256 256
 
257
-		$current = Carbon::createFromTimestamp( $timestamp, $timezone );
257
+		$current = Carbon::createFromTimestamp($timestamp, $timezone);
258 258
 		$prev = clone $current;
259 259
 		$next = clone $current;
260 260
 
261 261
 		$this->start = $current->getTimestamp();
262 262
 
263
-		$interval = $span = max( absint( $calendar->group_span ), 1 );
264
-
265
-		if ( 'monthly' == $calendar->group_type ) {
266
-			$this->prev = $prev->subMonths( $span )->getTimestamp();
267
-			$this->next = $next->addMonths( $span )->getTimestamp();
268
-		} elseif ( 'weekly' == $calendar->group_type ) {
269
-			$week = new Carbon( $calendar->timezone );
270
-			$week->setTimestamp( $timestamp );
271
-			$week->setWeekStartsAt( $calendar->week_starts );
272
-			$this->prev = $prev->subWeeks( $span )->getTimestamp();
273
-			$this->next = $next->addWeeks( $span )->getTimestamp();
274
-		} elseif ( 'daily' == $calendar->group_type ) {
275
-			$this->prev = $prev->subDays( $span )->getTimestamp();
276
-			$this->next = $next->addDays( $span )->getTimestamp();
263
+		$interval = $span = max(absint($calendar->group_span), 1);
264
+
265
+		if ('monthly' == $calendar->group_type) {
266
+			$this->prev = $prev->subMonths($span)->getTimestamp();
267
+			$this->next = $next->addMonths($span)->getTimestamp();
268
+		} elseif ('weekly' == $calendar->group_type) {
269
+			$week = new Carbon($calendar->timezone);
270
+			$week->setTimestamp($timestamp);
271
+			$week->setWeekStartsAt($calendar->week_starts);
272
+			$this->prev = $prev->subWeeks($span)->getTimestamp();
273
+			$this->next = $next->addWeeks($span)->getTimestamp();
274
+		} elseif ('daily' == $calendar->group_type) {
275
+			$this->prev = $prev->subDays($span)->getTimestamp();
276
+			$this->next = $next->addDays($span)->getTimestamp();
277 277
 		}
278 278
 
279 279
 		$events = $calendar->events;
280 280
 		$daily_events = $paged_events = $flattened_events = array();
281 281
 
282
-		if ( 'events' != $calendar->group_type ) {
282
+		if ('events' != $calendar->group_type) {
283 283
 
284
-			$this->end   = $this->next - 1;
284
+			$this->end = $this->next - 1;
285 285
 
286
-			$timestamps   = array_keys( $events );
287
-			$lower_bound  = array_filter( $timestamps,  array( $this, 'filter_events_before' ) );
288
-			$higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after'  ) );
286
+			$timestamps   = array_keys($events);
287
+			$lower_bound  = array_filter($timestamps, array($this, 'filter_events_before'));
288
+			$higher_bound = array_filter($lower_bound, array($this, 'filter_events_after'));
289 289
 
290
-			if ( is_array( $higher_bound ) && !empty( $higher_bound ) ) {
291
-				$filtered = array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) );
292
-				foreach ( $filtered as $timestamp => $events ) {
293
-					$paged_events[ intval( $timestamp ) ] = $events;
290
+			if (is_array($higher_bound) && ! empty($higher_bound)) {
291
+				$filtered = array_intersect_key($events, array_combine($higher_bound, $higher_bound));
292
+				foreach ($filtered as $timestamp => $events) {
293
+					$paged_events[intval($timestamp)] = $events;
294 294
 				}
295 295
 			}
296 296
 
297 297
 		} else {
298 298
 
299
-			foreach ( $events as $timestamp => $e ) {
299
+			foreach ($events as $timestamp => $e) {
300 300
 				$second = 0;
301
-				foreach ( $e as $event ) {
302
-					$flattened_events[ intval( $timestamp + $second ) ][] = $event;
301
+				foreach ($e as $event) {
302
+					$flattened_events[intval($timestamp + $second)][] = $event;
303 303
 					$second++;
304 304
 				}
305 305
 			}
306
-			ksort( $flattened_events, SORT_NUMERIC );
306
+			ksort($flattened_events, SORT_NUMERIC);
307 307
 
308
-			$keys  = array_keys( $flattened_events );
308
+			$keys = array_keys($flattened_events);
309 309
 			$current = 0;
310
-			foreach ( $keys as $timestamp ) {
311
-				if ( $timestamp < $this->start ) {
310
+			foreach ($keys as $timestamp) {
311
+				if ($timestamp < $this->start) {
312 312
 					$current++;
313 313
 				}
314 314
 			}
315 315
 
316
-			$paged_events = array_slice( $flattened_events, $current, $interval, true );
316
+			$paged_events = array_slice($flattened_events, $current, $interval, true);
317 317
 
318
-			$events_end = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $calendar->end;
318
+			$events_end = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $calendar->end;
319 319
 			$this->end  = $events_end > $calendar->end ? $calendar->end : $events_end;
320 320
 
321
-			$this->prev = isset( $keys[ $current - $interval ] ) ? $keys[ $current - $interval ] : $calendar->earliest_event;
322
-			$this->next = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $this->end;
321
+			$this->prev = isset($keys[$current - $interval]) ? $keys[$current - $interval] : $calendar->earliest_event;
322
+			$this->next = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $this->end;
323 323
 
324 324
 		}
325 325
 
326 326
 		// Put resulting events in an associative array, with Ymd date as key for easy retrieval in calendar days loop.
327
-		foreach ( $paged_events as $timestamp => $events ) {
328
-			if ( $timestamp <= $this->end ) {
329
-				$date = Carbon::createFromTimestamp( $timestamp, $calendar->timezone )->endOfDay()->format( 'Ymd' );
330
-				$daily_events[ intval( $date ) ][] = $events;
327
+		foreach ($paged_events as $timestamp => $events) {
328
+			if ($timestamp <= $this->end) {
329
+				$date = Carbon::createFromTimestamp($timestamp, $calendar->timezone)->endOfDay()->format('Ymd');
330
+				$daily_events[intval($date)][] = $events;
331 331
 			}
332 332
 		}
333
-		ksort( $daily_events, SORT_NUMERIC );
333
+		ksort($daily_events, SORT_NUMERIC);
334 334
 
335
-		if ( ! empty( $paged_events ) ) {
336
-			$first_event       = array_slice( $paged_events, 0, 1, true );
337
-			$first_event       = array_pop( $first_event );
335
+		if ( ! empty($paged_events)) {
336
+			$first_event       = array_slice($paged_events, 0, 1, true);
337
+			$first_event       = array_pop($first_event);
338 338
 			$this->first_event = $first_event[0]->start;
339 339
 
340
-			$last_event       = array_pop( $paged_events );
340
+			$last_event       = array_pop($paged_events);
341 341
 			$this->last_event = $last_event[0]->start;
342 342
 		}
343 343
 
@@ -357,84 +357,84 @@  discard block
 block discarded – undo
357 357
 	private function get_heading() {
358 358
 
359 359
 		$calendar = $this->calendar;
360
-		$start = Carbon::createFromTimestamp( $calendar->start, $calendar->timezone );
361
-		$end = Carbon::createFromTimestamp( $this->end, $calendar->timezone );
360
+		$start = Carbon::createFromTimestamp($calendar->start, $calendar->timezone);
361
+		$end = Carbon::createFromTimestamp($this->end, $calendar->timezone);
362 362
 		$date_format = $this->calendar->date_format;
363
-		$date_order  = simcal_get_date_format_order( $date_format );
363
+		$date_order  = simcal_get_date_format_order($date_format);
364 364
 
365 365
 		$st = $this->start;
366 366
 		$et = $this->end;
367 367
 
368
-		if ( $this->first_event !== 0 ) {
369
-			$start = Carbon::createFromTimestamp( $this->first_event, $calendar->timezone );
368
+		if ($this->first_event !== 0) {
369
+			$start = Carbon::createFromTimestamp($this->first_event, $calendar->timezone);
370 370
 			$st = $this->first_event;
371 371
 		}
372 372
 
373
-		if ( $this->last_event !== 0 ) {
374
-			$end = Carbon::createFromTimestamp( $this->last_event, $calendar->timezone );
373
+		if ($this->last_event !== 0) {
374
+			$end = Carbon::createFromTimestamp($this->last_event, $calendar->timezone);
375 375
 			$et = $this->last_event;
376 376
 		}
377 377
 
378
-		if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) {
378
+		if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) {
379 379
 			// Start and end on the same day.
380 380
 			// e.g. 1 February 2020
381
-			$large = $small = date_i18n( $calendar->date_format , $st );
382
-			if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) {
383
-				if ( $date_order['m'] > $date_order['d'] ) {
384
-					if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) {
385
-						$small = date_i18n( 'Y, d M', $st );
381
+			$large = $small = date_i18n($calendar->date_format, $st);
382
+			if (($date_order['d'] !== false) && ($date_order['m'] !== false)) {
383
+				if ($date_order['m'] > $date_order['d']) {
384
+					if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) {
385
+						$small = date_i18n('Y, d M', $st);
386 386
 					} else {
387
-						$small = date_i18n( 'd M Y', $st );
387
+						$small = date_i18n('d M Y', $st);
388 388
 					}
389 389
 				} else {
390
-					if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) {
391
-						$small = date_i18n( 'Y, M d', $st );
390
+					if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) {
391
+						$small = date_i18n('Y, M d', $st);
392 392
 					} else {
393
-						$small = date_i18n( 'M d Y', $st );
393
+						$small = date_i18n('M d Y', $st);
394 394
 					}
395 395
 				}
396 396
 			}
397
-		} elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) {
397
+		} elseif (($start->month == $end->month) && ($start->year == $end->year)) {
398 398
 			// Start and end days on the same month.
399 399
 			// e.g. August 2020
400
-			if ( $date_order['y'] === false ) {
400
+			if ($date_order['y'] === false) {
401 401
 				// August.
402
-				$large = $small = date_i18n( 'F', $st );
402
+				$large = $small = date_i18n('F', $st);
403 403
 			} else {
404
-				if ( $date_order['y'] < $date_order['m'] ) {
404
+				if ($date_order['y'] < $date_order['m']) {
405 405
 					// 2020 August.
406
-					$large = date_i18n( 'Y F', $st );
407
-					$small = date_i18n( 'Y M', $st );
406
+					$large = date_i18n('Y F', $st);
407
+					$small = date_i18n('Y M', $st);
408 408
 				} else {
409 409
 					// August 2020.
410
-					$large = date_i18n( 'F Y', $st );
411
-					$small = date_i18n( 'M Y', $st );
410
+					$large = date_i18n('F Y', $st);
411
+					$small = date_i18n('M Y', $st);
412 412
 				}
413 413
 			}
414
-		} elseif ( $start->year == $end->year ) {
414
+		} elseif ($start->year == $end->year) {
415 415
 			// Start and end days on months of the same year.
416 416
 			// e.g. August - September 2020
417
-			if ( $date_order['y'] === false ) {
417
+			if ($date_order['y'] === false) {
418 418
 				// August - September.
419
-				$large = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et );
420
-				$small = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et );
419
+				$large = date_i18n('F', $st).' - '.date_i18n('F', $et);
420
+				$small = date_i18n('M', $st).' - '.date_i18n('M', $et);
421 421
 			} else {
422
-				if ( $date_order['y'] < $date_order['m'] ) {
422
+				if ($date_order['y'] < $date_order['m']) {
423 423
 					// 2020, August - September.
424
-					$large  = $small = date( 'Y', $st ) . ', ';
425
-					$large .= date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et );
426
-					$small .= date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et );
424
+					$large  = $small = date('Y', $st).', ';
425
+					$large .= date_i18n('F', $st).' - '.date_i18n('F', $et);
426
+					$small .= date_i18n('M', $st).' - '.date_i18n('M', $et);
427 427
 				} else {
428 428
 					// August - September, 2020.
429
-					$large  = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ) . ', ';
430
-					$small  = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ) . ' ';
431
-					$year   = date( 'Y', $st );
429
+					$large  = date_i18n('F', $st).' - '.date_i18n('F', $et).', ';
430
+					$small  = date_i18n('M', $st).' - '.date_i18n('M', $et).' ';
431
+					$year   = date('Y', $st);
432 432
 					$large .= $year;
433 433
 					$small .= $year;
434 434
 				}
435 435
 			}
436 436
 		} else {
437
-			$large = $small = date( 'Y', $st ) . ' - ' . date( 'Y', $et );
437
+			$large = $small = date('Y', $st).' - '.date('Y', $et);
438 438
 		}
439 439
 
440 440
 		return array(
@@ -456,65 +456,65 @@  discard block
 block discarded – undo
456 456
 	 *
457 457
 	 * @return string
458 458
 	 */
459
-	private function draw_list( $timestamp, $id = 0 ) {
459
+	private function draw_list($timestamp, $id = 0) {
460 460
 
461 461
 		$calendar = $this->calendar;
462 462
 
463
-		if ( empty( $calendar ) ) {
464
-			$calendar = $this->calendar = simcal_get_calendar( intval( $id ) );
465
-			if ( ! $calendar instanceof Default_Calendar ) {
463
+		if (empty($calendar)) {
464
+			$calendar = $this->calendar = simcal_get_calendar(intval($id));
465
+			if ( ! $calendar instanceof Default_Calendar) {
466 466
 				return '';
467 467
 			}
468 468
 		}
469 469
 
470
-		$feed          = simcal_get_feed( $calendar );
470
+		$feed          = simcal_get_feed($calendar);
471 471
 
472 472
 		// TODO Need $feed_timezone?
473
-		$feed_timezone = get_post_meta( $feed->post_id, '_feed_timezone', true );
473
+		$feed_timezone = get_post_meta($feed->post_id, '_feed_timezone', true);
474 474
 
475 475
 		$now = $calendar->now;
476
-		$current_events = $this->get_events( $timestamp );
476
+		$current_events = $this->get_events($timestamp);
477 477
 		$format = $calendar->date_format;
478 478
 
479 479
 		ob_start();
480 480
 
481 481
 		// Draw the events.
482 482
 
483
-		$block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl';
483
+		$block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl';
484 484
 
485 485
 		$data_heading = '';
486 486
 		$heading = $this->get_heading();
487
-		foreach ( $heading as $k => $v ) {
488
-			$data_heading .= ' data-heading-' . $k . '="' . $v . '"';
487
+		foreach ($heading as $k => $v) {
488
+			$data_heading .= ' data-heading-'.$k.'="'.$v.'"';
489 489
 		}
490 490
 
491
-		echo '<' . $block_tag . ' class="simcal-events-list-container"' .
492
-			' data-prev="' . $this->prev . '"' .
493
-			' data-next="' . $this->next . '"' .
494
-			$data_heading . '>';
491
+		echo '<'.$block_tag.' class="simcal-events-list-container"'.
492
+			' data-prev="'.$this->prev.'"'.
493
+			' data-next="'.$this->next.'"'.
494
+			$data_heading.'>';
495 495
 
496
-		if ( ! empty( $current_events ) && is_array( $current_events ) ) :
496
+		if ( ! empty($current_events) && is_array($current_events)) :
497 497
 
498 498
 			$last_event = null;
499 499
 
500
-			foreach ( $current_events as $ymd => $events ) :
500
+			foreach ($current_events as $ymd => $events) :
501 501
 
502 502
 				// This is where we can find out if an event is a multi-day event and if it needs to be shown.
503 503
 				// Since this is for list view we are showing the event on the day viewed if it is part of that day even when
504 504
 				// expand multi-day events are turned off.
505
-				if ( isset( $events[0][0]->multiple_days ) && $events[0][0]->multiple_days > 0 ) {
506
-					if ( 'current_day_only' == get_post_meta( $calendar->id, '_default_calendar_expand_multi_day_events', true ) ) {
505
+				if (isset($events[0][0]->multiple_days) && $events[0][0]->multiple_days > 0) {
506
+					if ('current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true)) {
507 507
 
508
-						$year  = substr( $ymd, 0, 4 );
509
-						$month = substr( $ymd, 4, 2 );
510
-						$day   = substr( $ymd, 6, 2 );
508
+						$year  = substr($ymd, 0, 4);
509
+						$month = substr($ymd, 4, 2);
510
+						$day   = substr($ymd, 6, 2);
511 511
 
512
-						$temp_date = Carbon::createFromDate( $year, $month, $day );
512
+						$temp_date = Carbon::createFromDate($year, $month, $day);
513 513
 
514
-						if ( ! ( $temp_date < Carbon::now()->endOfDay() ) ) {
514
+						if ( ! ($temp_date < Carbon::now()->endOfDay())) {
515 515
 
516 516
 							// Break here only if event already shown once.
517
-							if ( $last_event == $events[0][0] ) {
517
+							if ($last_event == $events[0][0]) {
518 518
 								continue;
519 519
 							} else {
520 520
 								// Save event as "last" for next time through, then break.
@@ -525,139 +525,139 @@  discard block
 block discarded – undo
525 525
 				}
526 526
 
527 527
 				// Calculate timestamp offset for list view day headings.
528
-				$day_date = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone );
529
-				$day_ts_offset = $day_date->addSeconds( $day_date->offset )->timestamp;
528
+				$day_date = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone);
529
+				$day_ts_offset = $day_date->addSeconds($day_date->offset)->timestamp;
530 530
 
531
-				if ( ! $calendar->compact_list ) :
531
+				if ( ! $calendar->compact_list) :
532 532
 
533
-					$date = new Carbon( 'now', $calendar->timezone );
534
-					$date->setLocale( substr( get_locale(), 0, 2 ) );
535
-					$date->setTimestamp( $day_ts_offset );
533
+					$date = new Carbon('now', $calendar->timezone);
534
+					$date->setLocale(substr(get_locale(), 0, 2));
535
+					$date->setTimestamp($day_ts_offset);
536 536
 
537
-					if ( $date->isToday() ) {
538
-						$the_color = new Color( $calendar->today_color );
537
+					if ($date->isToday()) {
538
+						$the_color = new Color($calendar->today_color);
539 539
 					} else {
540
-						$the_color = new Color( $calendar->days_events_color );
540
+						$the_color = new Color($calendar->days_events_color);
541 541
 					}
542 542
 
543
-					$bg_color = '#' . $the_color->getHex();
543
+					$bg_color = '#'.$the_color->getHex();
544 544
 					$color = $the_color->isDark() ? '#ffffff' : '#000000';
545
-					$border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" ';
546
-					$bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"';
545
+					$border_style = ' style="border-bottom: 1px solid '.$bg_color.';" ';
546
+					$bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"';
547 547
 
548
-					echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>';
549
-					echo '<span' . $bg_style .'>';
550
-					echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_ts_offset ) . '</span> ' : ' ';
548
+					echo "\t".'<dt class="simcal-day-label"'.$border_style.'>';
549
+					echo '<span'.$bg_style.'>';
550
+					echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_ts_offset).'</span> ' : ' ';
551 551
 					echo '</span>';
552
-					echo '</dt>' . "\n";
552
+					echo '</dt>'."\n";
553 553
 
554 554
 				endif;
555 555
 
556
-				$list_events = '<ul class="simcal-events">' . "\n";
556
+				$list_events = '<ul class="simcal-events">'."\n";
557 557
 
558 558
 				$calendar_classes = array();
559
-				$day_classes = 'simcal-weekday-' . date( 'w', $day_ts_offset );
559
+				$day_classes = 'simcal-weekday-'.date('w', $day_ts_offset);
560 560
 
561 561
 				// Is this the present, the past or the future, Doc?
562
-				if ( $timestamp <= $now && $timestamp >= $now ) {
562
+				if ($timestamp <= $now && $timestamp >= $now) {
563 563
 					$day_classes .= ' simcal-today simcal-present simcal-day';
564
-				} elseif ( $timestamp < $now ) {
564
+				} elseif ($timestamp < $now) {
565 565
 					$day_classes .= ' simcal-past simcal-day';
566
-				} elseif ( $this->end > $now ) {
566
+				} elseif ($this->end > $now) {
567 567
 					$day_classes .= ' simcal-future simcal-day';
568 568
 				}
569 569
 
570 570
 				$count = 0;
571 571
 
572
-				foreach ( $events as $day_events ) :
573
-					foreach ( $day_events as $event ) :
572
+				foreach ($events as $day_events) :
573
+					foreach ($day_events as $event) :
574 574
 
575
-						if ( $event instanceof Event ) :
575
+						if ($event instanceof Event) :
576 576
 
577 577
 							$event_classes = $event_visibility = '';
578 578
 
579
-							$calendar_class     = 'simcal-events-calendar-' . strval( $event->calendar );
579
+							$calendar_class     = 'simcal-events-calendar-'.strval($event->calendar);
580 580
 							$calendar_classes[] = $calendar_class;
581 581
 
582 582
 							$recurring     = $event->recurrence ? 'simcal-event-recurring ' : '';
583 583
 							$has_location  = $event->venue ? 'simcal-event-has-location ' : '';
584 584
 
585
-							$event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class;
585
+							$event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class;
586 586
 
587 587
 							// Toggle some events visibility if more than optional limit.
588
-							if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) :
588
+							if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) :
589 589
 								$event_classes .= ' simcal-event-toggled';
590 590
 								$event_visibility = ' style="display: none"';
591 591
 							endif;
592 592
 
593 593
 							$event_color = $event->get_color();
594
-							if ( ! empty( $event_color ) ) {
594
+							if ( ! empty($event_color)) {
595 595
 								$side = is_rtl() ? 'right' : 'left';
596
-								$event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"';
596
+								$event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"';
597 597
 							}
598 598
 
599
-							$list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemscope itemtype="http://schema.org/Event" data-start="' . esc_attr( $event->start ) . '">' . "\n";
600
-							$list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n";
601
-							$list_events .= "\t" . '</li>' . "\n";
599
+							$list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemscope itemtype="http://schema.org/Event" data-start="'.esc_attr($event->start).'">'."\n";
600
+							$list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n";
601
+							$list_events .= "\t".'</li>'."\n";
602 602
 
603
-							$count ++;
603
+							$count++;
604 604
 
605 605
 							// Event falls within today.
606
-							if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) :
606
+							if (($this->end <= $now) && ($this->start >= $now)) :
607 607
 								$day_classes .= ' simcal-today-has-events';
608 608
 							endif;
609
-							$day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events';
609
+							$day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events';
610 610
 
611
-							if ( $calendar_classes ) :
612
-								$day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) );
611
+							if ($calendar_classes) :
612
+								$day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes)));
613 613
 							endif;
614 614
 
615 615
 						endif;
616 616
 					endforeach;
617 617
 				endforeach;
618 618
 
619
-				$list_events .= '</ul>' . "\n";
619
+				$list_events .= '</ul>'."\n";
620 620
 
621 621
 				// If events visibility is limited, print the button toggle.
622
-				if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) :
622
+				if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) :
623 623
 					$list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>';
624 624
 				endif;
625 625
 
626 626
 				// Print final list of events for the current day.
627 627
 				$tag = $calendar->compact_list ? 'div' : 'dd';
628
-				echo '<'  . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n";
629
-				echo "\t" . $list_events . "\n";
630
-				echo '</' . $tag . '>' . "\n";
628
+				echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n";
629
+				echo "\t".$list_events."\n";
630
+				echo '</'.$tag.'>'."\n";
631 631
 
632 632
 			endforeach;
633 633
 
634 634
 		else :
635 635
 
636
-			echo "\t" . '<p>';
636
+			echo "\t".'<p>';
637 637
 
638
-			$message = get_post_meta( $calendar->id, '_no_events_message', true );
638
+			$message = get_post_meta($calendar->id, '_no_events_message', true);
639 639
 
640
-			if ( 'events' == $calendar->group_type ) {
641
-				echo ! empty( $message ) ? $message : __( 'There are no upcoming events.', 'google-calendar-events' );
640
+			if ('events' == $calendar->group_type) {
641
+				echo ! empty($message) ? $message : __('There are no upcoming events.', 'google-calendar-events');
642 642
 			} else {
643
-				if ( ! empty( $message ) ) {
643
+				if ( ! empty($message)) {
644 644
 					echo $message;
645 645
 				} else {
646
-					$from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp();
647
-					$to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp();
648
-					echo apply_filters( 'simcal_no_events_message', sprintf(
649
-						__( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ),
650
-						date_i18n( $calendar->date_format, $from ),
651
-						date_i18n( $calendar->date_format, $to )
652
-					), $calendar->id, $from, $to );
646
+					$from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp();
647
+					$to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp();
648
+					echo apply_filters('simcal_no_events_message', sprintf(
649
+						__('Nothing from %1$s to %2$s.', 'google-calendar-events'),
650
+						date_i18n($calendar->date_format, $from),
651
+						date_i18n($calendar->date_format, $to)
652
+					), $calendar->id, $from, $to);
653 653
 				}
654 654
 			}
655 655
 
656
-			echo "\t" . '</p>' . "\n";
656
+			echo "\t".'</p>'."\n";
657 657
 
658 658
 		endif;
659 659
 
660
-		echo '</' . $block_tag . '>';
660
+		echo '</'.$block_tag.'>';
661 661
 
662 662
 		return ob_get_clean();
663 663
 	}
@@ -669,16 +669,16 @@  discard block
 block discarded – undo
669 669
 	 */
670 670
 	public function draw_list_ajax() {
671 671
 
672
-		if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) {
672
+		if (isset($_POST['ts']) && isset($_POST['id'])) {
673 673
 
674
-			$ts = absint( $_POST['ts'] );
675
-			$id = absint( $_POST['id'] );
674
+			$ts = absint($_POST['ts']);
675
+			$id = absint($_POST['id']);
676 676
 
677
-			wp_send_json_success( $this->draw_list( $ts, $id ) );
677
+			wp_send_json_success($this->draw_list($ts, $id));
678 678
 
679 679
 		} else {
680 680
 
681
-			wp_send_json_error( 'Missing arguments in default calendar list ajax request.' );
681
+			wp_send_json_error('Missing arguments in default calendar list ajax request.');
682 682
 
683 683
 		}
684 684
 	}
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 	 *
694 694
 	 * @return bool
695 695
 	 */
696
-	private function filter_events_before( $event ) {
697
-		return intval( $event ) >= intval( $this->start );
696
+	private function filter_events_before($event) {
697
+		return intval($event) >= intval($this->start);
698 698
 	}
699 699
 
700 700
 	/**
@@ -707,8 +707,8 @@  discard block
 block discarded – undo
707 707
 	 *
708 708
 	 * @return bool
709 709
 	 */
710
-	private function filter_events_after( $event ) {
711
-		return intval( $event ) < intval( $this->end );
710
+	private function filter_events_after($event) {
711
+		return intval($event) < intval($this->end);
712 712
 	}
713 713
 
714 714
 }
Please login to merge, or discard this patch.
includes/calendars/views/default-calendar-grid.php 1 patch
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use SimpleCalendar\Events\Event;
14 14
 use SimpleCalendar\Calendars\Default_Calendar;
15 15
 
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param string|Calendar $calendar
57 57
 	 */
58
-	public function __construct( $calendar = '' ) {
58
+	public function __construct($calendar = '') {
59 59
 		$this->calendar = $calendar;
60 60
 	}
61 61
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return string
90 90
 	 */
91 91
 	public function get_name() {
92
-		return __( 'Grid', 'google-calendar-events' );
92
+		return __('Grid', 'google-calendar-events');
93 93
 	}
94 94
 
95 95
 	/**
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 * @since 3.0.0
99 99
 	 */
100 100
 	public function add_ajax_actions() {
101
-		add_action( 'wp_ajax_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) );
102
-		add_action( 'wp_ajax_nopriv_simcal_default_calendar_draw_grid', array( $this, 'draw_grid_ajax' ) );
101
+		add_action('wp_ajax_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax'));
102
+		add_action('wp_ajax_nopriv_simcal_default_calendar_draw_grid', array($this, 'draw_grid_ajax'));
103 103
 	}
104 104
 
105 105
 	/**
@@ -113,25 +113,25 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return array
115 115
 	 */
116
-	public function scripts( $min = '' ) {
116
+	public function scripts($min = '') {
117 117
 		return array(
118 118
 			'simcal-qtip' => array(
119
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/vendor/jquery.qtip' . $min . '.js',
120
-				'deps'      => array( 'jquery' ),
119
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/vendor/jquery.qtip'.$min.'.js',
120
+				'deps'      => array('jquery'),
121 121
 				'in_footer' => true,
122 122
 			),
123 123
 			'simcal-fullcal-moment' => array(
124
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/vendor/moment' . $min . '.js',
125
-				'deps'      => array( 'jquery' ),
124
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/vendor/moment'.$min.'.js',
125
+				'deps'      => array('jquery'),
126 126
 				'in_footer' => true,
127 127
 			),
128 128
 			'simcal-moment-timezone' => array(
129
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/vendor/moment-timezone-with-data' . $min . '.js',
130
-				'deps'      => array( 'jquery' ),
129
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/vendor/moment-timezone-with-data'.$min.'.js',
130
+				'deps'      => array('jquery'),
131 131
 				'in_footer' => true,
132 132
 			),
133 133
 			'simcal-default-calendar' => array(
134
-				'src'       => SIMPLE_CALENDAR_ASSETS . 'js/default-calendar' . $min . '.js',
134
+				'src'       => SIMPLE_CALENDAR_ASSETS.'js/default-calendar'.$min.'.js',
135 135
 				'deps'      => array(
136 136
 					'jquery',
137 137
 					'simcal-qtip',
@@ -157,21 +157,21 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @return array
159 159
 	 */
160
-	public function styles( $min = '' ) {
160
+	public function styles($min = '') {
161 161
 		return array(
162 162
 			'simcal-qtip' => array(
163
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/vendor/jquery.qtip' . $min . '.css',
163
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/vendor/jquery.qtip'.$min.'.css',
164 164
 				'media' => 'all',
165 165
 			),
166 166
 			'simcal-default-calendar-grid' => array(
167
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-grid' . $min . '.css',
167
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-grid'.$min.'.css',
168 168
 				'deps'  => array(
169 169
 					'simcal-qtip',
170 170
 				),
171 171
 				'media' => 'all',
172 172
 			),
173 173
 			'simcal-default-calendar-list' => array(
174
-				'src'   => SIMPLE_CALENDAR_ASSETS . 'css/default-calendar-list' . $min . '.css',
174
+				'src'   => SIMPLE_CALENDAR_ASSETS.'css/default-calendar-list'.$min.'.css',
175 175
 				'deps'  => array(
176 176
 					'simcal-qtip',
177 177
 				),
@@ -189,22 +189,22 @@  discard block
 block discarded – undo
189 189
 
190 190
 		$calendar = $this->calendar;
191 191
 
192
-		if ( $calendar instanceof Default_Calendar ) {
192
+		if ($calendar instanceof Default_Calendar) {
193 193
 
194 194
 			?>
195 195
 
196
-			<?php edit_post_link( __( 'Edit Calendar', 'google-calendar-events' ), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id ); ?>
196
+			<?php edit_post_link(__('Edit Calendar', 'google-calendar-events'), '<p class="simcal-align-right"><small>', '</small></p>', $calendar->id); ?>
197 197
 
198 198
 			<table class="simcal-calendar-grid"
199 199
 			       data-event-bubble-trigger="<?php echo $calendar->event_bubble_trigger; ?>">
200 200
 				<thead class="simcal-calendar-head">
201 201
 					<tr>
202
-						<?php if ( ! $calendar->static ) { ?>
203
-							<th class="simcal-nav simcal-prev-wrapper" colspan="<?php echo apply_filters( 'simcal_prev_cols', '1' ); ?>">
204
-								<button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e( 'Previous Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-left"></i></button>
202
+						<?php if ( ! $calendar->static) { ?>
203
+							<th class="simcal-nav simcal-prev-wrapper" colspan="<?php echo apply_filters('simcal_prev_cols', '1'); ?>">
204
+								<button class="simcal-nav-button simcal-month-nav simcal-prev" title="<?php _e('Previous Month', 'google-calendar-events'); ?>"><i class="simcal-icon-left"></i></button>
205 205
 							</th>
206 206
 						<?php } ?>
207
-						<th colspan="<?php echo apply_filters( 'simcal_current_cols', $calendar->static ? '7' : '5' ); ?>"
207
+						<th colspan="<?php echo apply_filters('simcal_current_cols', $calendar->static ? '7' : '5'); ?>"
208 208
 						    class="simcal-nav simcal-current"
209 209
 						    data-calendar-current="<?php echo $calendar->start; ?>">
210 210
 							<?php
@@ -213,26 +213,26 @@  discard block
 block discarded – undo
213 213
 
214 214
 							// Display month and year according to user date format preference.
215 215
 
216
-							$year_pos  = strcspn( $calendar->date_format, 'Y y' );
217
-							$month_pos = strcspn( $calendar->date_format, 'F M m n' );
216
+							$year_pos  = strcspn($calendar->date_format, 'Y y');
217
+							$month_pos = strcspn($calendar->date_format, 'F M m n');
218 218
 
219
-							$current = array( 'month' => 'F', 'year' => 'Y' );
219
+							$current = array('month' => 'F', 'year' => 'Y');
220 220
 
221
-							if ( $year_pos < $month_pos ) {
222
-								$current = array_reverse( $current );
221
+							if ($year_pos < $month_pos) {
222
+								$current = array_reverse($current);
223 223
 							}
224 224
 
225
-							foreach ( $current as $k => $v ) {
226
-								echo ' <span class="simcal-current-' . $k , '">' . date_i18n( $v, $calendar->start ) . '</span> ';
225
+							foreach ($current as $k => $v) {
226
+								echo ' <span class="simcal-current-'.$k, '">'.date_i18n($v, $calendar->start).'</span> ';
227 227
 							}
228 228
 
229 229
 							echo '</h3>';
230 230
 
231 231
 							?>
232 232
 						</th>
233
-						<?php if ( ! $calendar->static ) { ?>
234
-							<th class="simcal-nav simcal-next-wrapper" colspan="<?php echo apply_filters( 'simcal_next_cols', '1' ); ?>">
235
-								<button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e( 'Next Month', 'google-calendar-events' ); ?>"><i class="simcal-icon-right"></i></button>
233
+						<?php if ( ! $calendar->static) { ?>
234
+							<th class="simcal-nav simcal-next-wrapper" colspan="<?php echo apply_filters('simcal_next_cols', '1'); ?>">
235
+								<button class="simcal-nav-button simcal-month-nav simcal-next" title="<?php _e('Next Month', 'google-calendar-events'); ?>"><i class="simcal-icon-right"></i></button>
236 236
 							</th>
237 237
 						<?php } ?>
238 238
 					</tr>
@@ -242,28 +242,28 @@  discard block
 block discarded – undo
242 242
 						// Print day names in short or long form for different viewport sizes.
243 243
 
244 244
 						$week_starts     = $calendar->week_starts;
245
-						$week_days_short = simcal_get_calendar_names_i18n( 'day', 'short' );
246
-						$week_days_full  = simcal_get_calendar_names_i18n( 'day', 'full' );
245
+						$week_days_short = simcal_get_calendar_names_i18n('day', 'short');
246
+						$week_days_full  = simcal_get_calendar_names_i18n('day', 'full');
247 247
 
248
-						for ( $i = $week_starts; $i <= 6; $i ++ ) :
248
+						for ($i = $week_starts; $i <= 6; $i++) :
249 249
 
250 250
 							?>
251 251
 							<th class="simcal-week-day simcal-week-day-<?php echo $i ?>"
252
-								data-screen-small="<?php echo mb_substr( $week_days_short[ $i ], 0, 1, 'UTF-8' ); ?>"
253
-							    data-screen-medium="<?php echo $week_days_short[ $i ]; ?>"
254
-							    data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th>
252
+								data-screen-small="<?php echo mb_substr($week_days_short[$i], 0, 1, 'UTF-8'); ?>"
253
+							    data-screen-medium="<?php echo $week_days_short[$i]; ?>"
254
+							    data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th>
255 255
 							<?php
256 256
 
257 257
 						endfor;
258 258
 
259
-						if ( $week_starts !== 0 ) :
260
-							for ( $i = 0; $i < $week_starts; $i ++ ) :
259
+						if ($week_starts !== 0) :
260
+							for ($i = 0; $i < $week_starts; $i++) :
261 261
 
262 262
 								?>
263 263
 								<th class="simcal-week-day simcal-week-day-<?php echo $i ?>"
264
-								    data-screen-small="<?php echo mb_substr( $week_days_short[ $i ], 0, 1, 'UTF-8' ); ?>"
265
-								    data-screen-medium="<?php echo $week_days_short[ $i ]; ?>"
266
-								    data-screen-large="<?php echo $week_days_full[ $i ]; ?>"><?php echo $week_days_short[ $i ]; ?></th>
264
+								    data-screen-small="<?php echo mb_substr($week_days_short[$i], 0, 1, 'UTF-8'); ?>"
265
+								    data-screen-medium="<?php echo $week_days_short[$i]; ?>"
266
+								    data-screen-large="<?php echo $week_days_full[$i]; ?>"><?php echo $week_days_short[$i]; ?></th>
267 267
 								<?php
268 268
 
269 269
 							endfor;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 					</tr>
274 274
 				</thead>
275 275
 
276
-				<?php echo $this->draw_month( date( 'n', $calendar->start ), date( 'Y', $calendar->start ) ); ?>
276
+				<?php echo $this->draw_month(date('n', $calendar->start), date('Y', $calendar->start)); ?>
277 277
 
278 278
 			</table>
279 279
 
@@ -299,85 +299,85 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return string
301 301
 	 */
302
-	private function draw_month( $month, $year, $id = 0 ) {
302
+	private function draw_month($month, $year, $id = 0) {
303 303
 
304 304
 		$calendar = $this->calendar;
305
-		if ( empty( $calendar ) ) {
306
-			$calendar = simcal_get_calendar( intval( $id ) );
307
-			if ( ! $calendar ) {
305
+		if (empty($calendar)) {
306
+			$calendar = simcal_get_calendar(intval($id));
307
+			if ( ! $calendar) {
308 308
 				return '';
309 309
 			}
310 310
 		}
311 311
 
312 312
 		$events = $calendar->events;
313 313
 
314
-		$feed          = simcal_get_feed( $calendar );
315
-		$feed_timezone = get_post_meta( $feed->post_id, '_feed_timezone', true );
314
+		$feed          = simcal_get_feed($calendar);
315
+		$feed_timezone = get_post_meta($feed->post_id, '_feed_timezone', true);
316 316
 
317 317
 		// Variables to cycle days in current month and find today in calendar.
318 318
 		$now         = $calendar->now;
319
-		$current     = Carbon::create( $year, $month, 1, 0, 0, 0, $calendar->timezone );
319
+		$current     = Carbon::create($year, $month, 1, 0, 0, 0, $calendar->timezone);
320 320
 		$current_min = $current->getTimestamp();
321 321
 		$current_max = $current->endOfDay()->getTimestamp();
322 322
 
323 323
 		// Calendar grid variables.
324 324
 		$week_starts   = $calendar->week_starts;
325
-		$week_of_year  = $current->weekOfYear;   // Relative count of the week number of the year.
326
-		$month_starts  = $current->dayOfWeek;    // Day upon which the month starts.
327
-		$days_in_month = $current->daysInMonth;  // Number of days in the given month.
325
+		$week_of_year  = $current->weekOfYear; // Relative count of the week number of the year.
326
+		$month_starts  = $current->dayOfWeek; // Day upon which the month starts.
327
+		$days_in_month = $current->daysInMonth; // Number of days in the given month.
328 328
 
329 329
 		// Set current month events timestamp boundaries.
330 330
 		$this->start = $current_min;
331 331
 		$this->end   = $current->endOfMonth()->timestamp;
332 332
 
333 333
 		// Get daily events for this month.
334
-		if ( $events && is_array( $events ) ) {
334
+		if ($events && is_array($events)) {
335 335
 
336 336
 			// Filter events within the boundaries previously set above.
337
-			$timestamps   = array_keys( $events );
338
-			$lower_bound  = array_filter( $timestamps, array( $this, 'filter_events_before' ) );
339
-			$higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) );
340
-			$filtered     = ( is_array( $events ) && is_array( $higher_bound) ) && ! empty( $events ) && ! empty( $higher_bound ) ? array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ) : array();
337
+			$timestamps   = array_keys($events);
338
+			$lower_bound  = array_filter($timestamps, array($this, 'filter_events_before'));
339
+			$higher_bound = array_filter($lower_bound, array($this, 'filter_events_after'));
340
+			$filtered     = (is_array($events) && is_array($higher_bound)) && ! empty($events) && ! empty($higher_bound) ? array_intersect_key($events, array_combine($higher_bound, $higher_bound)) : array();
341 341
 
342 342
 			// Put resulting events in an associative array, with day of the month as key for easy retrieval in calendar days loop.
343 343
 			$day_events = array();
344
-			foreach ( $filtered as $timestamp => $events_in_day ) {
345
-				foreach ( $events_in_day as $event ) {
346
-					if ( $event instanceof Event ){
347
-						$day = intval( Carbon::createFromTimestamp( $timestamp, $event->timezone )->endOfDay()->day );
348
-						$day_events[ $day ][] = $event;
344
+			foreach ($filtered as $timestamp => $events_in_day) {
345
+				foreach ($events_in_day as $event) {
346
+					if ($event instanceof Event) {
347
+						$day = intval(Carbon::createFromTimestamp($timestamp, $event->timezone)->endOfDay()->day);
348
+						$day_events[$day][] = $event;
349 349
 					}
350 350
 				}
351 351
 			}
352 352
 
353
-			ksort( $day_events, SORT_NUMERIC );
353
+			ksort($day_events, SORT_NUMERIC);
354 354
 		}
355 355
 
356 356
 		ob_start();
357 357
 
358
-		echo '<tbody class="simcal-month simcal-month-' . $month . '">' . "\n";
359
-		echo "\t" . '<tr class="simcal-week simcal-week-' . $week_of_year . '">';
358
+		echo '<tbody class="simcal-month simcal-month-'.$month.'">'."\n";
359
+		echo "\t".'<tr class="simcal-week simcal-week-'.$week_of_year.'">';
360 360
 
361 361
 		$days_in_row = 0;
362 362
 		// Week may start on an arbitrary day (sun, 0 - sat, 6).
363 363
 		$week_day = $week_starts;
364 364
 
365 365
 		// This fixes a possible bug when a month starts by Sunday (0).
366
-		if ( 0 !== $week_starts ) {
366
+		if (0 !== $week_starts) {
367 367
 			$b = $month_starts === 0 ? 7 : $month_starts;
368 368
 		} else {
369 369
 			$b = $month_starts;
370 370
 		}
371 371
 
372 372
 		// Void days in first week.
373
-		for ( $a = $week_starts; $a < $b; $a++ ) :
373
+		for ($a = $week_starts; $a < $b; $a++) :
374 374
 
375
-			$last_void_day_class = ( $a === ( $b - 1 ) ) ? 'simcal-day-void-last' : '';
375
+			$last_void_day_class = ($a === ($b - 1)) ? 'simcal-day-void-last' : '';
376 376
 
377
-			echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n";
377
+			echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n";
378 378
 
379 379
 			// Reset day of the week count (sun, 0 - sat, 6).
380
-			if ( $week_day === 6 ) {
380
+			if ($week_day === 6) {
381 381
 				$week_day = -1;
382 382
 			}
383 383
 			$week_day++;
@@ -387,97 +387,97 @@  discard block
 block discarded – undo
387 387
 		endfor;
388 388
 
389 389
 		// Actual days of the month.
390
-		for ( $day = 1; $day <= $days_in_month; $day++ ) :
390
+		for ($day = 1; $day <= $days_in_month; $day++) :
391 391
 
392 392
 			$count = 0;
393 393
 			$calendar_classes = array();
394
-			$day_classes = 'simcal-day-' . $day . ' simcal-weekday-' . $week_day;
394
+			$day_classes = 'simcal-day-'.$day.' simcal-weekday-'.$week_day;
395 395
 
396 396
 			$border_style = $bg_color = $color = '';
397 397
 
398 398
 			// Is this the present, the past or the future, Doc?
399
-			if ( $current_min <= $now && $current_max >= $now ) {
399
+			if ($current_min <= $now && $current_max >= $now) {
400 400
 				$day_classes .= ' simcal-today simcal-present simcal-day';
401
-				$the_color = new Color( $calendar->today_color );
402
-				$bg_color = '#' . $the_color->getHex();
401
+				$the_color = new Color($calendar->today_color);
402
+				$bg_color = '#'.$the_color->getHex();
403 403
 				$color = $the_color->isDark() ? '#ffffff' : '#000000';
404
-				$border_style = ' style="border: 1px solid ' . $bg_color . ';"';
405
-			} elseif ( $current_max < $now ) {
404
+				$border_style = ' style="border: 1px solid '.$bg_color.';"';
405
+			} elseif ($current_max < $now) {
406 406
 				$day_classes .= ' simcal-past simcal-day';
407
-			} elseif ( $current_min > $now ) {
407
+			} elseif ($current_min > $now) {
408 408
 				$day_classes .= ' simcal-future simcal-day';
409 409
 			}
410 410
 
411 411
 			// Print events for the current day in loop, if found any.
412
-			if ( isset( $day_events[ $day ] ) ) :
412
+			if (isset($day_events[$day])) :
413 413
 
414 414
 				$bullet_colors = array();
415 415
 
416 416
 				$list_events = '<ul class="simcal-events">';
417 417
 
418
-				foreach ( $day_events[ $day ] as $event ) :
418
+				foreach ($day_events[$day] as $event) :
419 419
 
420 420
 					$event_classes = $event_visibility = '';
421 421
 
422
-					if ( $event instanceof Event ) :
422
+					if ($event instanceof Event) :
423 423
 
424 424
 						// Store the calendar id where the event belongs (useful in grouped calendar feeds)
425
-						$calendar_class  = 'simcal-events-calendar-' . strval( $event->calendar );
426
-						$calendar_classes[] = $calendar_class ;
425
+						$calendar_class = 'simcal-events-calendar-'.strval($event->calendar);
426
+						$calendar_classes[] = $calendar_class;
427 427
 
428 428
 						$recurring     = $event->recurrence ? 'simcal-event-recurring ' : '';
429 429
 						$has_location  = $event->venue ? 'simcal-event-has-location ' : '';
430 430
 
431
-						$event_classes  .= 'simcal-event ' . $recurring . $has_location . $calendar_class . ' simcal-tooltip';
431
+						$event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class.' simcal-tooltip';
432 432
 
433 433
 						// Toggle some events visibility if more than optional limit.
434
-						if ( ( $calendar->events_limit > -1 )  && ( $count >= $calendar->events_limit ) ) :
434
+						if (($calendar->events_limit > -1) && ($count >= $calendar->events_limit)) :
435 435
 							$event_classes    .= ' simcal-event-toggled';
436 436
 							$event_visibility  = ' style="display: none"';
437 437
 						endif;
438 438
 
439 439
 						// Event title in list.
440
-						$title = ! empty( $event->title ) ? trim( $event->title ) : __( 'Event', 'google-calendar-events' );
441
-						if ( $calendar->trim_titles >= 1 ) {
442
-							$title = strlen( $title ) > $calendar->trim_titles ? mb_substr( $title, 0, $calendar->trim_titles ) . '&hellip;' : $title;
440
+						$title = ! empty($event->title) ? trim($event->title) : __('Event', 'google-calendar-events');
441
+						if ($calendar->trim_titles >= 1) {
442
+							$title = strlen($title) > $calendar->trim_titles ? mb_substr($title, 0, $calendar->trim_titles).'&hellip;' : $title;
443 443
 						}
444 444
 
445 445
 						// Event color.
446 446
 						$bullet = '';
447 447
 						//$bullet_color = '#000';
448 448
 						$event_color = $event->get_color();
449
-						if ( ! empty( $event_color ) ) {
450
-							$bullet = '<span style="color: ' . $event_color . ';">&#9632;</span> ';
449
+						if ( ! empty($event_color)) {
450
+							$bullet = '<span style="color: '.$event_color.';">&#9632;</span> ';
451 451
 							$bullet_colors[] = $event_color;
452 452
 						} else {
453 453
 							$bullet_colors[] = '#000';
454 454
 						}
455 455
 
456 456
 						// Event contents.
457
-						$list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . ' itemscope itemtype="http://schema.org/Event">' . "\n";
458
-						$list_events .= "\t\t" . '<span class="simcal-event-title">' . $bullet . $title . '</span>' . "\n";
459
-						$list_events .= "\t\t" . '<div class="simcal-event-details simcal-tooltip-content" style="display: none;">' . $calendar->get_event_html( $event ) . '</div>' . "\n";
460
-						$list_events .= "\t" . '</li>' . "\n";
457
+						$list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.' itemscope itemtype="http://schema.org/Event">'."\n";
458
+						$list_events .= "\t\t".'<span class="simcal-event-title">'.$bullet.$title.'</span>'."\n";
459
+						$list_events .= "\t\t".'<div class="simcal-event-details simcal-tooltip-content" style="display: none;">'.$calendar->get_event_html($event).'</div>'."\n";
460
+						$list_events .= "\t".'</li>'."\n";
461 461
 
462
-						$count ++;
462
+						$count++;
463 463
 
464 464
 					endif;
465 465
 
466 466
 				endforeach;
467 467
 
468
-				if ( ( $current_min <= $now ) && ( $current_max >= $now ) ) {
468
+				if (($current_min <= $now) && ($current_max >= $now)) {
469 469
 					$day_classes .= ' simcal-today-has-events';
470 470
 				}
471
-				$day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events';
471
+				$day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events';
472 472
 
473
-				if ( $calendar_classes ) {
474
-					$day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) );
473
+				if ($calendar_classes) {
474
+					$day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes)));
475 475
 				}
476 476
 
477
-				$list_events .= '</ul>' . "\n";
477
+				$list_events .= '</ul>'."\n";
478 478
 
479 479
 				// Optional button to toggle hidden events in list.
480
-				if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) :
480
+				if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) :
481 481
 					$list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>';
482 482
 				endif;
483 483
 
@@ -489,49 +489,49 @@  discard block
 block discarded – undo
489 489
 			endif;
490 490
 
491 491
 			// The actual days with numbers and events in each row cell.
492
-			echo '<td class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n";
493
-
494
-			if ( $color ) {
495
-				$day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"';
496
-			} elseif ( $count > 0 ) {
497
-				$the_color = new Color( $calendar->days_events_color );
498
-				$color = ! $color ? ( $the_color->isDark() ? '#ffffff' : '#000000' ) : $color;
499
-				$bg_color = ! $bg_color ? '#' . $the_color->getHex() : $bg_color;
500
-				$day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"';
492
+			echo '<td class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n";
493
+
494
+			if ($color) {
495
+				$day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"';
496
+			} elseif ($count > 0) {
497
+				$the_color = new Color($calendar->days_events_color);
498
+				$color = ! $color ? ($the_color->isDark() ? '#ffffff' : '#000000') : $color;
499
+				$bg_color = ! $bg_color ? '#'.$the_color->getHex() : $bg_color;
500
+				$day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"';
501 501
 			} else {
502 502
 				$day_style = '';
503 503
 			}
504 504
 
505
-			echo "\t" . '<div' . $border_style . '>' . "\n";
506
-			echo "\t\t" . '<span class="simcal-day-label simcal-day-number"' . $day_style . '>' . $day . '</span>' . "\n";
507
-			echo "\t\t" . $list_events . "\n";
505
+			echo "\t".'<div'.$border_style.'>'."\n";
506
+			echo "\t\t".'<span class="simcal-day-label simcal-day-number"'.$day_style.'>'.$day.'</span>'."\n";
507
+			echo "\t\t".$list_events."\n";
508 508
 			echo "\t\t";
509 509
 			echo '<span class="simcal-events-dots" style="display: none;">';
510 510
 
511 511
 			// Event bullets for calendar mobile mode.
512
-			for( $i = 0; $i < $count; $i++ ) {
513
-				echo '<b style="color: ' . $bullet_colors[ $i ] . ';"> &bull; </b>';
512
+			for ($i = 0; $i < $count; $i++) {
513
+				echo '<b style="color: '.$bullet_colors[$i].';"> &bull; </b>';
514 514
 			}
515 515
 
516
-			echo '</span>' . "\n";
517
-			echo "\t" . '</div>' . "\n";
518
-			echo '</td>' . "\n";
516
+			echo '</span>'."\n";
517
+			echo "\t".'</div>'."\n";
518
+			echo '</td>'."\n";
519 519
 
520 520
 			// Reset day of the week count (sun, 0 - sat, 6).
521
-			if ( $week_day === 6 ) {
521
+			if ($week_day === 6) {
522 522
 				$week_day = - 1;
523 523
 			}
524 524
 			$week_day++;
525 525
 
526 526
 			// Reset count of days for this row (0-6).
527
-			if ( $days_in_row === 6 ) :
527
+			if ($days_in_row === 6) :
528 528
 
529 529
 				// Close the week row.
530 530
 				echo '</tr>';
531 531
 
532 532
 				// Open a new week row.
533
-				if ( $day < $days_in_month ) {
534
-					echo '<tr class="simcal-week simcal-week-' . $week_of_year++ . '">' . "\n";
533
+				if ($day < $days_in_month) {
534
+					echo '<tr class="simcal-week simcal-week-'.$week_of_year++.'">'."\n";
535 535
 				}
536 536
 
537 537
 				$days_in_row = -1;
@@ -540,25 +540,25 @@  discard block
 block discarded – undo
540 540
 
541 541
 			$days_in_row++;
542 542
 
543
-			$current_min = Carbon::createFromTimestamp( $current_min, $calendar->timezone )->addDay()->getTimestamp();
544
-			$current_max = Carbon::createFromTimestamp( $current_max, $calendar->timezone )->addDay()->getTimestamp();
543
+			$current_min = Carbon::createFromTimestamp($current_min, $calendar->timezone)->addDay()->getTimestamp();
544
+			$current_max = Carbon::createFromTimestamp($current_max, $calendar->timezone)->addDay()->getTimestamp();
545 545
 
546 546
 		endfor;
547 547
 
548 548
 		// Void days at the end of the month.
549
-		$remainder_days = ( 6 - $days_in_row );
549
+		$remainder_days = (6 - $days_in_row);
550 550
 
551
-		for ( $i = 0; $i <= $remainder_days; $i ++ ) {
551
+		for ($i = 0; $i <= $remainder_days; $i++) {
552 552
 
553
-			$last_void_day_class = ( $i == $remainder_days ) ? 'simcal-day-void-last' : '';
553
+			$last_void_day_class = ($i == $remainder_days) ? 'simcal-day-void-last' : '';
554 554
 
555
-			echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n";
555
+			echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n";
556 556
 
557 557
 			$week_day++;
558 558
 		}
559 559
 
560
-		echo "\t" . '</tr>' . "\n";
561
-		echo '</tbody>' . "\n";
560
+		echo "\t".'</tr>'."\n";
561
+		echo '</tbody>'."\n";
562 562
 
563 563
 		return ob_get_clean();
564 564
 	}
@@ -570,17 +570,17 @@  discard block
 block discarded – undo
570 570
 	 */
571 571
 	public function draw_grid_ajax() {
572 572
 
573
-		if ( isset( $_POST['month'] ) && isset( $_POST['year'] ) && isset( $_POST['id'] ) ) {
573
+		if (isset($_POST['month']) && isset($_POST['year']) && isset($_POST['id'])) {
574 574
 
575
-			$month = absint( $_POST['month'] );
576
-			$year  = absint( $_POST['year'] );
577
-			$id    = absint( $_POST['id'] );
575
+			$month = absint($_POST['month']);
576
+			$year  = absint($_POST['year']);
577
+			$id    = absint($_POST['id']);
578 578
 
579
-			wp_send_json_success( $this->draw_month( $month, $year, $id ) );
579
+			wp_send_json_success($this->draw_month($month, $year, $id));
580 580
 
581 581
 		} else {
582 582
 
583
-			wp_send_json_error( 'Missing arguments in default calendar grid ajax request.' );
583
+			wp_send_json_error('Missing arguments in default calendar grid ajax request.');
584 584
 
585 585
 		}
586 586
 
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
 	 *
597 597
 	 * @return bool
598 598
 	 */
599
-	private function filter_events_before( $event ) {
600
-		return intval( $event ) >= intval( $this->start );
599
+	private function filter_events_before($event) {
600
+		return intval($event) >= intval($this->start);
601 601
 	}
602 602
 
603 603
 	/**
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
 	 *
611 611
 	 * @return bool
612 612
 	 */
613
-	private function filter_events_after( $event ) {
614
-		return intval( $event ) < intval( $this->end );
613
+	private function filter_events_after($event) {
614
+		return intval($event) < intval($this->end);
615 615
 	}
616 616
 
617 617
 }
Please login to merge, or discard this patch.
includes/admin/metaboxes/settings.php 1 patch
Spacing   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use SimpleCalendar\Abstracts\Feed;
12 12
 use SimpleCalendar\Abstracts\Field;
13 13
 
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -31,40 +31,40 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param \WP_Post $post
33 33
 	 */
34
-	public static function html( $post ) {
34
+	public static function html($post) {
35 35
 
36 36
 		// @see Meta_Boxes::save_meta_boxes()
37
-		wp_nonce_field( 'simcal_save_data', 'simcal_meta_nonce' );
37
+		wp_nonce_field('simcal_save_data', 'simcal_meta_nonce');
38 38
 
39 39
 		?>
40 40
 		<div class="simcal-panels-wrap">
41 41
 
42 42
 			<span class="simcal-box-handle">
43
-				<?php self::settings_handle( $post ); ?>
43
+				<?php self::settings_handle($post); ?>
44 44
 			</span>
45 45
 
46 46
 			<ul class="simcal-tabs">
47
-				<?php self::settings_tabs( $post ); ?>
48
-				<?php do_action( 'simcal_settings_meta_tabs' ); ?>
47
+				<?php self::settings_tabs($post); ?>
48
+				<?php do_action('simcal_settings_meta_tabs'); ?>
49 49
 			</ul>
50 50
 
51 51
 			<div class="simcal-panels">
52 52
 				<div id="events-settings-panel" class="simcal-panel">
53
-					<?php self::events_settings_panel( $post ); ?>
54
-					<?php do_action( 'simcal_settings_meta_events_panel', $post->ID ); ?>
53
+					<?php self::events_settings_panel($post); ?>
54
+					<?php do_action('simcal_settings_meta_events_panel', $post->ID); ?>
55 55
 				</div>
56 56
 				<div id="calendar-settings-panel" class="simcal-panel">
57
-					<?php do_action( 'simcal_settings_meta_calendar_panel', $post->ID ); ?>
58
-					<?php self::calendar_settings_panel( $post ); ?>
57
+					<?php do_action('simcal_settings_meta_calendar_panel', $post->ID); ?>
58
+					<?php self::calendar_settings_panel($post); ?>
59 59
 				</div>
60 60
 				<?php
61 61
 				// Hook for additional settings panels.
62
-				do_action( 'simcal_settings_meta_panels', $post->ID );
62
+				do_action('simcal_settings_meta_panels', $post->ID);
63 63
 				// Thus advanced panel is always the last one:
64 64
 				?>
65 65
 				<div id="advanced-settings-panel" class="simcal-panel">
66
-					<?php self::advanced_settings_panel( $post ) ?>
67
-					<?php do_action( 'simcal_settings_meta_advanced_panel', $post->ID ); ?>
66
+					<?php self::advanced_settings_panel($post) ?>
67
+					<?php do_action('simcal_settings_meta_advanced_panel', $post->ID); ?>
68 68
 				</div>
69 69
 			</div>
70 70
 
@@ -84,45 +84,45 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param \WP_Post $post
86 86
 	 */
87
-	private static function settings_handle( $post ) {
87
+	private static function settings_handle($post) {
88 88
 
89 89
 		$feed_options = $calendar_options = $calendar_views = array();
90 90
 
91 91
 		$feed_types = simcal_get_feed_types();
92
-		foreach ( $feed_types as $feed_type ) {
92
+		foreach ($feed_types as $feed_type) {
93 93
 
94
-			$feed = simcal_get_feed( $feed_type );
94
+			$feed = simcal_get_feed($feed_type);
95 95
 
96
-			if ( $feed instanceof Feed ) {
97
-				$feed_options[ $feed_type ] = $feed->name;
96
+			if ($feed instanceof Feed) {
97
+				$feed_options[$feed_type] = $feed->name;
98 98
 			}
99 99
 		}
100 100
 
101 101
 		$calendar_types = simcal_get_calendar_types();
102
-		foreach ( $calendar_types as $calendar_type => $views ) {
102
+		foreach ($calendar_types as $calendar_type => $views) {
103 103
 
104
-			$calendar = simcal_get_calendar( $calendar_type );
104
+			$calendar = simcal_get_calendar($calendar_type);
105 105
 
106
-			if ( $calendar instanceof Calendar ) {
107
-				$calendar_options[ $calendar_type ] = $calendar->name;
108
-				$calendar_views[ $calendar_type ]   = $calendar->views;
106
+			if ($calendar instanceof Calendar) {
107
+				$calendar_options[$calendar_type] = $calendar->name;
108
+				$calendar_views[$calendar_type]   = $calendar->views;
109 109
 			}
110 110
 		}
111 111
 
112
-		if ( $feed_options ) {
112
+		if ($feed_options) {
113 113
 
114
-			if ( $feed_types = wp_get_object_terms( $post->ID, 'calendar_feed' ) ) {
115
-				$feed_type = sanitize_title( current( $feed_types )->name );
114
+			if ($feed_types = wp_get_object_terms($post->ID, 'calendar_feed')) {
115
+				$feed_type = sanitize_title(current($feed_types)->name);
116 116
 			} else {
117
-				$feed_type = apply_filters( 'simcal_default_feed_type', 'google' );
117
+				$feed_type = apply_filters('simcal_default_feed_type', 'google');
118 118
 			}
119 119
 
120 120
 			?>
121
-			<label for="_feed_type"><span><?php _e( 'Event Source', 'google-calendar-events' ); ?></span>
121
+			<label for="_feed_type"><span><?php _e('Event Source', 'google-calendar-events'); ?></span>
122 122
 				<select name="_feed_type" id="_feed_type">
123
-					<optgroup label="<?php _ex( 'Get events from', 'From which calendar source to load events from', 'google-calendar-events' ) ?>">
124
-						<?php foreach ( $feed_options as $feed => $name ) { ?>
125
-							<option value="<?php echo $feed; ?>" <?php selected( $feed, $feed_type, true ); ?>><?php echo $name; ?></option>
123
+					<optgroup label="<?php _ex('Get events from', 'From which calendar source to load events from', 'google-calendar-events') ?>">
124
+						<?php foreach ($feed_options as $feed => $name) { ?>
125
+							<option value="<?php echo $feed; ?>" <?php selected($feed, $feed_type, true); ?>><?php echo $name; ?></option>
126 126
 						<?php } ?>
127 127
 					</optgroup>
128 128
 				</select>
@@ -131,40 +131,40 @@  discard block
 block discarded – undo
131 131
 
132 132
 		}
133 133
 
134
-		if ( $calendar_options ) {
134
+		if ($calendar_options) {
135 135
 
136
-			if ( $calendar_types = wp_get_object_terms( $post->ID, 'calendar_type' ) ) {
137
-				$calendar_type = sanitize_title( current( $calendar_types )->name );
136
+			if ($calendar_types = wp_get_object_terms($post->ID, 'calendar_type')) {
137
+				$calendar_type = sanitize_title(current($calendar_types)->name);
138 138
 			} else {
139
-				$calendar_type = apply_filters( 'simcal_default_calendar_type', 'default-calendar' );
139
+				$calendar_type = apply_filters('simcal_default_calendar_type', 'default-calendar');
140 140
 			}
141 141
 
142 142
 			?>
143
-			<label for="_calendar_type"><span><?php _e( 'Calendar Type', 'google-calendar-events' ); ?></span>
143
+			<label for="_calendar_type"><span><?php _e('Calendar Type', 'google-calendar-events'); ?></span>
144 144
 				<select name="_calendar_type" id="_calendar_type">
145
-					<optgroup label="<?php _e( 'Calendar to use', 'google-calendar-events' ); ?>">
146
-						<?php foreach ( $calendar_options as $calendar => $name ) { ?>
147
-							<option value="<?php echo $calendar; ?>" <?php selected( $calendar, $calendar_type, true ); ?>><?php echo $name; ?></option>
145
+					<optgroup label="<?php _e('Calendar to use', 'google-calendar-events'); ?>">
146
+						<?php foreach ($calendar_options as $calendar => $name) { ?>
147
+							<option value="<?php echo $calendar; ?>" <?php selected($calendar, $calendar_type, true); ?>><?php echo $name; ?></option>
148 148
 						<?php } ?>
149 149
 					</optgroup>
150 150
 				</select>
151 151
 			</label>
152 152
 			<?php
153 153
 
154
-			if ( $calendar_views ) {
154
+			if ($calendar_views) {
155 155
 
156
-				$calendar_view = get_post_meta( $post->ID, '_calendar_view', true );
156
+				$calendar_view = get_post_meta($post->ID, '_calendar_view', true);
157 157
 
158
-				foreach ( $calendar_views as $calendar => $views ) {
158
+				foreach ($calendar_views as $calendar => $views) {
159 159
 
160
-					$calendar_type_view = isset( $calendar_view[ $calendar ] ) ? $calendar_view[ $calendar ] : '';
160
+					$calendar_type_view = isset($calendar_view[$calendar]) ? $calendar_view[$calendar] : '';
161 161
 
162 162
 					?>
163
-					<label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e( 'View', 'google-calendar-events' ); ?></span>
163
+					<label for="_calendar_view_<?php echo $calendar; ?>"><span><?php _e('View', 'google-calendar-events'); ?></span>
164 164
 						<select name="_calendar_view[<?php echo $calendar; ?>]" id="_calendar_view_<?php echo $calendar; ?>">
165
-							<optgroup label="<?php _e( 'View to display', 'google-calendar-events' ); ?>">
166
-								<?php foreach ( $views as $view => $name ) { ?>
167
-									<option value="<?php echo $view; ?>" <?php selected( $view, $calendar_type_view, true ); ?>><?php echo $name; ?></option>
165
+							<optgroup label="<?php _e('View to display', 'google-calendar-events'); ?>">
166
+								<?php foreach ($views as $view => $name) { ?>
167
+									<option value="<?php echo $view; ?>" <?php selected($view, $calendar_type_view, true); ?>><?php echo $name; ?></option>
168 168
 								<?php } ?>
169 169
 							</optgroup>
170 170
 						</select>
@@ -184,42 +184,42 @@  discard block
 block discarded – undo
184 184
 	 *
185 185
 	 * @param  \WP_Post $post
186 186
 	 */
187
-	private static function settings_tabs( $post ) {
187
+	private static function settings_tabs($post) {
188 188
 
189 189
 		// Hook to add more tabs.
190
-		$tabs = apply_filters( 'simcal_settings_meta_tabs_li', array(
190
+		$tabs = apply_filters('simcal_settings_meta_tabs_li', array(
191 191
 			'events' => array(
192
-				'label'   => __( 'Events', 'google-calendar-events' ),
192
+				'label'   => __('Events', 'google-calendar-events'),
193 193
 				'target'  => 'events-settings-panel',
194
-				'class'   => array( 'active' ),
194
+				'class'   => array('active'),
195 195
 				'icon'    => 'simcal-icon-event',
196 196
 			),
197 197
 			'calendar' => array(
198
-				'label'  => __( 'Appearance', 'google-calendar-events' ),
198
+				'label'  => __('Appearance', 'google-calendar-events'),
199 199
 				'target' => 'calendar-settings-panel',
200 200
 				'class'  => array(),
201 201
 				'icon'   => 'simcal-icon-calendar',
202 202
 			),
203
-		), $post->ID );
203
+		), $post->ID);
204 204
 
205 205
 		// Always keep advanced tab as the last one.
206 206
 		$tabs['advanced'] = array(
207
-			'label'   => __( 'Advanced', 'google-calendar-events' ),
207
+			'label'   => __('Advanced', 'google-calendar-events'),
208 208
 			'target'  => 'advanced-settings-panel',
209 209
 			'class'   => array(),
210 210
 			'icon'    => 'simcal-icon-settings',
211 211
 		);
212 212
 
213 213
 		// Output the tabs as list items.
214
-		foreach ( $tabs as $key => $tab ) {
214
+		foreach ($tabs as $key => $tab) {
215 215
 
216
-			if ( isset( $tab['target'] ) && isset( $tab['label'] ) ) {
216
+			if (isset($tab['target']) && isset($tab['label'])) {
217 217
 
218 218
 				$icon  = $tab['icon'] ? $tab['icon'] : 'simcal-icon-panel';
219 219
 				$class = $tab['class'] ? $tab['class'] : array();
220 220
 
221
-				echo '<li class="' . $key . '-settings ' . $key . '-tab ' . implode( ' ', $class ) . '" data-tab="' . $key . '">';
222
-				echo    '<a href="#' . $tab['target'] . '"><i class="' . $icon . '" ></i> <span>' . esc_html( $tab['label'] ) . '</span></a>';
221
+				echo '<li class="'.$key.'-settings '.$key.'-tab '.implode(' ', $class).'" data-tab="'.$key.'">';
222
+				echo    '<a href="#'.$tab['target'].'"><i class="'.$icon.'" ></i> <span>'.esc_html($tab['label']).'</span></a>';
223 223
 				echo '</li>';
224 224
 			}
225 225
 		}
@@ -233,22 +233,22 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @param  \WP_Post $post
235 235
 	 */
236
-	private static function events_settings_panel( $post ) {
236
+	private static function events_settings_panel($post) {
237 237
 
238 238
 		?>
239 239
 		<table>
240 240
 			<thead>
241
-			<tr><th colspan="2"><?php _e( 'Event Settings', 'google-calendar-events' ); ?></th></tr>
241
+			<tr><th colspan="2"><?php _e('Event Settings', 'google-calendar-events'); ?></th></tr>
242 242
 			</thead>
243 243
 			<tbody class="simcal-panel-section simcal-panel-section-events-range">
244 244
 			<tr class="simcal-panel-field">
245
-				<th><label for="_calendar_begins"><?php _e( 'Calendar Start', 'google-calendar-events' ); ?></label></th>
245
+				<th><label for="_calendar_begins"><?php _e('Calendar Start', 'google-calendar-events'); ?></label></th>
246 246
 				<td>
247 247
 					<?php
248 248
 
249
-					$calendar_begins = esc_attr( get_post_meta( $post->ID, '_calendar_begins', true ) );
250
-					$calendar_begins_nth = max( absint( get_post_meta( $post->ID, '_calendar_begins_nth', true ) ), 1 );
251
-					$calendar_begins_nth_show = in_array( $calendar_begins, array(
249
+					$calendar_begins = esc_attr(get_post_meta($post->ID, '_calendar_begins', true));
250
+					$calendar_begins_nth = max(absint(get_post_meta($post->ID, '_calendar_begins_nth', true)), 1);
251
+					$calendar_begins_nth_show = in_array($calendar_begins, array(
252 252
 						'days_before',
253 253
 						'days_after',
254 254
 						'weeks_before',
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
 						'months_after',
258 258
 						'years_before',
259 259
 						'years_after',
260
-					) );
260
+					));
261 261
 
262
-					simcal_print_field( array(
262
+					simcal_print_field(array(
263 263
 						'type'       => 'standard',
264 264
 						'subtype'    => 'number',
265 265
 						'name'       => '_calendar_begins_nth',
266 266
 						'id'         => '_calendar_begins_nth',
267
-						'value'      => strval( $calendar_begins_nth ),
267
+						'value'      => strval($calendar_begins_nth),
268 268
 						'attributes' => array(
269 269
 							'min' => '1',
270 270
 						),
@@ -272,97 +272,97 @@  discard block
 block discarded – undo
272 272
 							'simcal-field-inline',
273 273
 							'simcal-field-tiny',
274 274
 						),
275
-						'style'      => ! $calendar_begins_nth_show ? array( 'display' => 'none' ) : '',
276
-					) );
275
+						'style'      => ! $calendar_begins_nth_show ? array('display' => 'none') : '',
276
+					));
277 277
 
278 278
 					?>
279 279
 					<select name="_calendar_begins"
280 280
 							id="_calendar_begins"
281 281
 							class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other">
282
-						<optgroup label="<?php _e( 'Days', 'google-calendar-events' ); ?>">
282
+						<optgroup label="<?php _e('Days', 'google-calendar-events'); ?>">
283 283
 							<option value="today"
284 284
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
285
-								<?php selected( 'today', $calendar_begins, true ); ?>><?php _e( 'Today', 'google-calendar-events' ); ?></option>
285
+								<?php selected('today', $calendar_begins, true); ?>><?php _e('Today', 'google-calendar-events'); ?></option>
286 286
 							<option value="now"
287 287
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
288
-								<?php selected( 'now', $calendar_begins, true ); ?>><?php _e( 'Now', 'google-calendar-events' ); ?></option>
288
+								<?php selected('now', $calendar_begins, true); ?>><?php _e('Now', 'google-calendar-events'); ?></option>
289 289
 							<option value="days_before"
290 290
 									data-hide-field="_calendar_begins_custom_date"
291
-									data-show-field="_calendar_begins_nth" <?php selected( 'days_before', $calendar_begins, true ); ?>><?php _e( 'Day(s) before today', 'google-calendar-events' ); ?></option>
291
+									data-show-field="_calendar_begins_nth" <?php selected('days_before', $calendar_begins, true); ?>><?php _e('Day(s) before today', 'google-calendar-events'); ?></option>
292 292
 							<option value="days_after"
293 293
 									data-hide-field="_calendar_begins_custom_date"
294
-									data-show-field="_calendar_begins_nth" <?php selected( 'days_after', $calendar_begins, true ); ?>><?php _e( 'Day(s) after today', 'google-calendar-events' ); ?></option>
294
+									data-show-field="_calendar_begins_nth" <?php selected('days_after', $calendar_begins, true); ?>><?php _e('Day(s) after today', 'google-calendar-events'); ?></option>
295 295
 						</optgroup>
296
-						<optgroup label="<?php _e( 'Weeks', 'google-calendar-events' ); ?>">
296
+						<optgroup label="<?php _e('Weeks', 'google-calendar-events'); ?>">
297 297
 							<option value="this_week"
298 298
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
299
-								<?php selected( 'this_week', $calendar_begins, true ); ?>><?php _e( 'This week', 'google-calendar-events' ); ?></option>
299
+								<?php selected('this_week', $calendar_begins, true); ?>><?php _e('This week', 'google-calendar-events'); ?></option>
300 300
 							<option value="weeks_before"
301 301
 									data-hide-field="_calendar_begins_custom_date"
302
-									data-show-field="_calendar_begins_nth" <?php selected( 'weeks_before', $calendar_begins, true ); ?>><?php _e( 'Week(s) before current', 'google-calendar-events' ); ?></option>
302
+									data-show-field="_calendar_begins_nth" <?php selected('weeks_before', $calendar_begins, true); ?>><?php _e('Week(s) before current', 'google-calendar-events'); ?></option>
303 303
 							<option value="weeks_after"
304 304
 									data-hide-field="_calendar_begins_custom_date"
305
-									data-show-field="_calendar_begins_nth" <?php selected( 'weeks_after', $calendar_begins, true ); ?>><?php _e( 'Week(s) after current', 'google-calendar-events' ); ?></option>
305
+									data-show-field="_calendar_begins_nth" <?php selected('weeks_after', $calendar_begins, true); ?>><?php _e('Week(s) after current', 'google-calendar-events'); ?></option>
306 306
 						</optgroup>
307
-						<optgroup label="<?php _e( 'Months', 'google-calendar-events' ); ?>">
307
+						<optgroup label="<?php _e('Months', 'google-calendar-events'); ?>">
308 308
 							<option value="this_month"
309 309
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
310
-								<?php selected( 'this_month', $calendar_begins, true ); ?>><?php _e( 'This month', 'google-calendar-events' ); ?></option>
310
+								<?php selected('this_month', $calendar_begins, true); ?>><?php _e('This month', 'google-calendar-events'); ?></option>
311 311
 							<option value="months_before"
312 312
 									data-hide-field="_calendar_begins_custom_date"
313
-									data-show-field="_calendar_begins_nth" <?php selected( 'months_before', $calendar_begins, true ); ?>><?php _e( 'Month(s) before current', 'google-calendar-events' ); ?></option>
313
+									data-show-field="_calendar_begins_nth" <?php selected('months_before', $calendar_begins, true); ?>><?php _e('Month(s) before current', 'google-calendar-events'); ?></option>
314 314
 							<option value="months_after"
315 315
 									data-hide-field="_calendar_begins_custom_date"
316
-									data-show-field="_calendar_begins_nth" <?php selected( 'months_after', $calendar_begins, true ); ?>><?php _e( 'Month(s) after current', 'google-calendar-events' ); ?></option>
316
+									data-show-field="_calendar_begins_nth" <?php selected('months_after', $calendar_begins, true); ?>><?php _e('Month(s) after current', 'google-calendar-events'); ?></option>
317 317
 						</optgroup>
318
-						<optgroup label="<?php _e( 'Years', 'google-calendar-events' ); ?>">
318
+						<optgroup label="<?php _e('Years', 'google-calendar-events'); ?>">
319 319
 							<option value="this_year"
320 320
 									data-hide-fields="_calendar_begins_custom_date,_calendar_begins_nth"
321
-								<?php selected( 'this_year', $calendar_begins, true ); ?>><?php _e( 'This year', 'google-calendar-events' ); ?></option>
321
+								<?php selected('this_year', $calendar_begins, true); ?>><?php _e('This year', 'google-calendar-events'); ?></option>
322 322
 							<option value="years_before"
323
-									data-show-field="_calendar_begins_nth" <?php selected( 'years_before', $calendar_begins, true ); ?>><?php _e( 'Year(s) before current', 'google-calendar-events' ); ?></option>
323
+									data-show-field="_calendar_begins_nth" <?php selected('years_before', $calendar_begins, true); ?>><?php _e('Year(s) before current', 'google-calendar-events'); ?></option>
324 324
 							<option value="years_after"
325 325
 									data-hide-field="_calendar_begins_custom_date"
326
-									data-show-field="_calendar_begins_nth" <?php selected( 'years_after', $calendar_begins, true ); ?>><?php _e( 'Year(s) after current', 'google-calendar-events' ); ?></option>
326
+									data-show-field="_calendar_begins_nth" <?php selected('years_after', $calendar_begins, true); ?>><?php _e('Year(s) after current', 'google-calendar-events'); ?></option>
327 327
 						</optgroup>
328
-						<optgroup label="<?php _e( 'Other', 'google-calendar-events' ); ?>">
328
+						<optgroup label="<?php _e('Other', 'google-calendar-events'); ?>">
329 329
 							<option value="custom_date"
330 330
 									data-hide-field="_calendar_begins_nth"
331
-									data-show-field="_calendar_begins_custom_date" <?php selected( 'custom_date', $calendar_begins, true ); ?>><?php _e( 'Specific date', 'google-calendar-events' ); ?></option>
331
+									data-show-field="_calendar_begins_custom_date" <?php selected('custom_date', $calendar_begins, true); ?>><?php _e('Specific date', 'google-calendar-events'); ?></option>
332 332
 						</optgroup>
333 333
 					</select>
334 334
 					<?php
335 335
 
336
-					simcal_print_field( array(
336
+					simcal_print_field(array(
337 337
 						'type'    => 'date-picker',
338 338
 						'name'    => '_calendar_begins_custom_date',
339 339
 						'id'      => '_calendar_begins_custom_date',
340
-						'value'   => get_post_meta( $post->ID, '_calendar_begins_custom_date', true ),
340
+						'value'   => get_post_meta($post->ID, '_calendar_begins_custom_date', true),
341 341
 						'class' => array(
342 342
 							'simcal-field-inline',
343 343
 						),
344
-						'style'   => 'custom_date' != $calendar_begins ? array( 'display' => 'none' ) : '',
345
-					) );
344
+						'style'   => 'custom_date' != $calendar_begins ? array('display' => 'none') : '',
345
+					));
346 346
 
347 347
 					?>
348 348
 					<i class="simcal-icon-help simcal-help-tip"
349
-					   data-tip="<?php _e( 'The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events' ); ?>"></i>
349
+					   data-tip="<?php _e('The calendar default opening date. It will automatically adapt based on the chosen calendar type.', 'google-calendar-events'); ?>"></i>
350 350
 				</td>
351 351
 			</tr>
352 352
 			<tr class="simcal-panel-field">
353
-				<th><label for="_feed_earliest_event_date"><?php _e( 'Earliest Event', 'google-calendar-events' ); ?></label></th>
353
+				<th><label for="_feed_earliest_event_date"><?php _e('Earliest Event', 'google-calendar-events'); ?></label></th>
354 354
 				<td>
355 355
 					<?php
356 356
 
357
-					$earliest_event_saved = get_post_meta( $post->ID, '_feed_earliest_event_date', true );
358
-					$earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr( $earliest_event_saved );
357
+					$earliest_event_saved = get_post_meta($post->ID, '_feed_earliest_event_date', true);
358
+					$earliest_event = false == $earliest_event_saved ? 'months_before' : esc_attr($earliest_event_saved);
359 359
 
360
-					simcal_print_field( array(
360
+					simcal_print_field(array(
361 361
 						'type'       => 'standard',
362 362
 						'subtype'    => 'number',
363 363
 						'name'       => '_feed_earliest_event_date_range',
364 364
 						'id'         => '_feed_earliest_event_date_range',
365
-						'value'      => strval( max( absint( get_post_meta( $post->ID, '_feed_earliest_event_date_range', true ) ), 1 ) ),
365
+						'value'      => strval(max(absint(get_post_meta($post->ID, '_feed_earliest_event_date_range', true)), 1)),
366 366
 						'attributes' => array(
367 367
 							'min' => '1',
368 368
 						),
@@ -370,37 +370,37 @@  discard block
 block discarded – undo
370 370
 							'simcal-field-inline',
371 371
 							'simcal-field-tiny',
372 372
 						),
373
-						'style'      => ( 'now' != $earliest_event ) && ( 'today' != $earliest_event ) ? array( 'display' => 'none' ) : '',
374
-					) );
373
+						'style'      => ('now' != $earliest_event) && ('today' != $earliest_event) ? array('display' => 'none') : '',
374
+					));
375 375
 
376 376
 					?>
377 377
 					<select name="_feed_earliest_event_date"
378 378
 							id="_feed_earliest_event_date"
379 379
 							class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other">
380
-						<option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Same as start date', 'google-calendar-events' ); ?></option>
381
-						<option value="days_before"    data-show-field="_feed_earliest_event_date_range" <?php selected( 'days_before', $earliest_event, true ); ?>><?php _e( 'Day(s) before start date', 'google-calendar-events' ); ?></option>
382
-						<option value="weeks_before"   data-show-field="_feed_earliest_event_date_range" <?php selected( 'weeks_before', $earliest_event, true ); ?>><?php _e( 'Week(s) before start date', 'google-calendar-events' ); ?></option>
383
-						<option value="months_before"  data-show-field="_feed_earliest_event_date_range" <?php selected( 'months_before', $earliest_event, true ); ?>><?php _e( 'Month(s) before start date', 'google-calendar-events' ); ?></option>
384
-						<option value="years_before"   data-show-field="_feed_earliest_event_date_range" <?php selected( 'years_before', $earliest_event, true ); ?>><?php _e( 'Year(s) before start date', 'google-calendar-events' ); ?></option>
380
+						<option value="calendar_start" data-hide-field="_feed_earliest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Same as start date', 'google-calendar-events'); ?></option>
381
+						<option value="days_before"    data-show-field="_feed_earliest_event_date_range" <?php selected('days_before', $earliest_event, true); ?>><?php _e('Day(s) before start date', 'google-calendar-events'); ?></option>
382
+						<option value="weeks_before"   data-show-field="_feed_earliest_event_date_range" <?php selected('weeks_before', $earliest_event, true); ?>><?php _e('Week(s) before start date', 'google-calendar-events'); ?></option>
383
+						<option value="months_before"  data-show-field="_feed_earliest_event_date_range" <?php selected('months_before', $earliest_event, true); ?>><?php _e('Month(s) before start date', 'google-calendar-events'); ?></option>
384
+						<option value="years_before"   data-show-field="_feed_earliest_event_date_range" <?php selected('years_before', $earliest_event, true); ?>><?php _e('Year(s) before start date', 'google-calendar-events'); ?></option>
385 385
 					</select>
386 386
 					<i class="simcal-icon-help simcal-help-tip"
387
-					   data-tip="<?php _e( 'Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events' ); ?>"></i>
387
+					   data-tip="<?php _e('Set the date for the earliest possible event to show in calendar. There will not be events before this date.', 'google-calendar-events'); ?>"></i>
388 388
 				</td>
389 389
 			</tr>
390 390
 			<tr class="simcal-panel-field">
391
-				<th><label for="_feed_latest_event_date"><?php _e( 'Latest Event', 'google-calendar-events' ); ?></label></th>
391
+				<th><label for="_feed_latest_event_date"><?php _e('Latest Event', 'google-calendar-events'); ?></label></th>
392 392
 				<td>
393 393
 					<?php
394 394
 
395
-					$latest_event_saved = get_post_meta( $post->ID, '_feed_latest_event_date', true );
396
-					$latest_event = false == $latest_event_saved ? 'years_after' : esc_attr( $latest_event_saved );
395
+					$latest_event_saved = get_post_meta($post->ID, '_feed_latest_event_date', true);
396
+					$latest_event = false == $latest_event_saved ? 'years_after' : esc_attr($latest_event_saved);
397 397
 
398
-					simcal_print_field( array(
398
+					simcal_print_field(array(
399 399
 						'type'       => 'standard',
400 400
 						'subtype'    => 'number',
401 401
 						'name'       => '_feed_latest_event_date_range',
402 402
 						'id'         => '_feed_latest_event_date_range',
403
-						'value'      => strval( max( absint( get_post_meta( $post->ID, '_feed_latest_event_date_range', true ) ), 1 ) ),
403
+						'value'      => strval(max(absint(get_post_meta($post->ID, '_feed_latest_event_date_range', true)), 1)),
404 404
 						'attributes' => array(
405 405
 							'min' => '1',
406 406
 						),
@@ -408,21 +408,21 @@  discard block
 block discarded – undo
408 408
 							'simcal-field-inline',
409 409
 							'simcal-field-tiny',
410 410
 						),
411
-						'style'      => 'indefinite' != $latest_event ? array( 'display' => 'none' ) : '',
412
-					) );
411
+						'style'      => 'indefinite' != $latest_event ? array('display' => 'none') : '',
412
+					));
413 413
 
414 414
 					?>
415 415
 					<select name="_feed_latest_event_date"
416 416
 							id="_feed_latest_event_date"
417 417
 							class="simcal-field simcal-field-select simcal-field-inline simcal-field-switch-other">
418
-						<option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected( 'calendar_start', $earliest_event, true ); ?>><?php _e( 'Day end of start date', 'google-calendar-events' ); ?></option>
419
-						<option value="days_after"     data-show-field="_feed_latest_event_date_range" <?php selected( 'days_after', $latest_event, true ); ?>><?php _e( 'Day(s) after start date', 'google-calendar-events' ); ?></option>
420
-						<option value="weeks_after"    data-show-field="_feed_latest_event_date_range" <?php selected( 'weeks_after', $latest_event, true ); ?>><?php _e( 'Weeks(s) after start date', 'google-calendar-events' ); ?></option>
421
-						<option value="months_after"   data-show-field="_feed_latest_event_date_range" <?php selected( 'months_after', $latest_event, true ); ?>><?php _e( 'Month(s) after start date', 'google-calendar-events' ); ?></option>
422
-						<option value="years_after"    data-show-field="_feed_latest_event_date_range" <?php selected( 'years_after', $latest_event, true ); ?>><?php _e( 'Year(s) after start date', 'google-calendar-events' ); ?></option>
418
+						<option value="calendar_start" data-hide-field="_feed_latest_event_date_range" <?php selected('calendar_start', $earliest_event, true); ?>><?php _e('Day end of start date', 'google-calendar-events'); ?></option>
419
+						<option value="days_after"     data-show-field="_feed_latest_event_date_range" <?php selected('days_after', $latest_event, true); ?>><?php _e('Day(s) after start date', 'google-calendar-events'); ?></option>
420
+						<option value="weeks_after"    data-show-field="_feed_latest_event_date_range" <?php selected('weeks_after', $latest_event, true); ?>><?php _e('Weeks(s) after start date', 'google-calendar-events'); ?></option>
421
+						<option value="months_after"   data-show-field="_feed_latest_event_date_range" <?php selected('months_after', $latest_event, true); ?>><?php _e('Month(s) after start date', 'google-calendar-events'); ?></option>
422
+						<option value="years_after"    data-show-field="_feed_latest_event_date_range" <?php selected('years_after', $latest_event, true); ?>><?php _e('Year(s) after start date', 'google-calendar-events'); ?></option>
423 423
 					</select>
424 424
 					<i class="simcal-icon-help simcal-help-tip"
425
-					   data-tip="<?php _e( 'Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events' ); ?>"></i>
425
+					   data-tip="<?php _e('Set the date for the latest possible event to show on calendar. There will not be events after this date.', 'google-calendar-events'); ?>"></i>
426 426
 				</td>
427 427
 			</tr>
428 428
 			</tbody>
@@ -439,88 +439,88 @@  discard block
 block discarded – undo
439 439
 	 *
440 440
 	 * @param  \WP_Post $post
441 441
 	 */
442
-	private static function calendar_settings_panel( $post ) {
442
+	private static function calendar_settings_panel($post) {
443 443
 
444 444
 		?>
445 445
 		<table>
446 446
 			<thead>
447
-			<tr><th colspan="2"><?php _e( 'Miscellaneous', 'google-calendar-events' ); ?></th></tr>
447
+			<tr><th colspan="2"><?php _e('Miscellaneous', 'google-calendar-events'); ?></th></tr>
448 448
 			</thead>
449 449
 			<tbody class="simcal-panel-section">
450 450
 			<tr class="simcal-panel-field">
451
-				<th><label for="_calendar_is_static"><?php _e( 'Static Calendar', 'google-calendar-events' ); ?></label></th>
451
+				<th><label for="_calendar_is_static"><?php _e('Static Calendar', 'google-calendar-events'); ?></label></th>
452 452
 				<td>
453 453
 					<?php
454 454
 
455
-					$fixed = get_post_meta( $post->ID, '_calendar_is_static', true );
455
+					$fixed = get_post_meta($post->ID, '_calendar_is_static', true);
456 456
 
457
-					simcal_print_field( array(
457
+					simcal_print_field(array(
458 458
 						'type'    => 'checkbox',
459 459
 						'name'    => '_calendar_is_static',
460 460
 						'id'      => '_calendar_is_static',
461
-						'tooltip' => __( 'Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events' ),
461
+						'tooltip' => __('Remove the navigation arrows and fix the calendar view to its initial state.', 'google-calendar-events'),
462 462
 						'value'   => 'yes' == $fixed ? 'yes' : 'no',
463
-						'text'    => __( 'Yes (hide navigation arrows)', 'google-calendar-events' ),
464
-					) );
463
+						'text'    => __('Yes (hide navigation arrows)', 'google-calendar-events'),
464
+					));
465 465
 
466 466
 					?>
467 467
 				</td>
468 468
 			</tr>
469 469
 			<tr class="simcal-panel-field">
470
-				<th><label for="_no_events_message"><?php _e( 'No Events Message', 'google-calendar-events' ); ?></label></th>
470
+				<th><label for="_no_events_message"><?php _e('No Events Message', 'google-calendar-events'); ?></label></th>
471 471
 				<td>
472 472
 					<?php
473 473
 
474
-					simcal_print_field( array(
474
+					simcal_print_field(array(
475 475
 						'type'    => 'textarea',
476 476
 						'name'    => '_no_events_message',
477 477
 						'id'      => '_no_events_message',
478
-						'tooltip' => __( 'Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events' ),
479
-						'value'   => get_post_meta( $post->ID, '_no_events_message', true ),
480
-						'placeholder' => __( 'There are no upcoming events.', 'google-calendar-events' ),
481
-					) );
478
+						'tooltip' => __('Some calendars may display a message when no events are found. You can change the default message here.', 'google-calendar-events'),
479
+						'value'   => get_post_meta($post->ID, '_no_events_message', true),
480
+						'placeholder' => __('There are no upcoming events.', 'google-calendar-events'),
481
+					));
482 482
 
483 483
 					?>
484 484
 				</td>
485 485
 			</tr>
486 486
 			<tr class="simcal-panel-field">
487
-				<th><label for="_event_formatting"><?php _e( 'Event Formatting', 'google-calendar-events' ); ?></label></th>
487
+				<th><label for="_event_formatting"><?php _e('Event Formatting', 'google-calendar-events'); ?></label></th>
488 488
 				<td>
489 489
 					<?php
490 490
 
491
-					$event_formatting = get_post_meta( $post->ID, '_event_formatting', true );
491
+					$event_formatting = get_post_meta($post->ID, '_event_formatting', true);
492 492
 
493
-					simcal_print_field( array(
493
+					simcal_print_field(array(
494 494
 						'type'    => 'select',
495 495
 						'name'    => '_event_formatting',
496 496
 						'id'      => '_event_formatting',
497
-						'tooltip' => __( 'How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events' ),
497
+						'tooltip' => __('How to preserve line breaks and paragraphs in the event template builder.', 'google-calendar-events'),
498 498
 						'value'   => $event_formatting,
499 499
 						'default' => 'preserve_linebreaks',
500 500
 						'options' => array(
501
-							'preserve_linebreaks' => __( 'Preserve line breaks, auto paragraphs (default)', 'google-calendar-events' ),
502
-							'no_linebreaks'       => __( 'No line breaks, auto paragraphs', 'google-calendar-events' ),
503
-							'none'                => __( 'No line breaks, no auto paragraphs', 'google-calendar-events' ),
501
+							'preserve_linebreaks' => __('Preserve line breaks, auto paragraphs (default)', 'google-calendar-events'),
502
+							'no_linebreaks'       => __('No line breaks, auto paragraphs', 'google-calendar-events'),
503
+							'none'                => __('No line breaks, no auto paragraphs', 'google-calendar-events'),
504 504
 						),
505
-					) );
505
+					));
506 506
 
507 507
 					?>
508 508
 				</td>
509 509
 			</tr>
510 510
 			<tr class="simcal-panel-field">
511
-				<th><label for="_poweredby"><?php _e( 'Powered By', 'google-calendar-events' ); ?></label></th>
511
+				<th><label for="_poweredby"><?php _e('Powered By', 'google-calendar-events'); ?></label></th>
512 512
 				<td>
513 513
 					<?php
514 514
 
515
-					$poweredby = get_post_meta( $post->ID, '_poweredby', true );
515
+					$poweredby = get_post_meta($post->ID, '_poweredby', true);
516 516
 
517
-					simcal_print_field( array(
517
+					simcal_print_field(array(
518 518
 						'type'    => 'checkbox',
519 519
 						'name'    => '_poweredby',
520 520
 						'id'      => '_poweredby',
521 521
 						'value'   => 'yes' == $poweredby ? 'yes' : 'no',
522
-						'text'    => __( 'Yes, Simple Calendar rocks! Show some love with a little link below this calendar.', 'google-calendar-events' ),
523
-					) );
522
+						'text'    => __('Yes, Simple Calendar rocks! Show some love with a little link below this calendar.', 'google-calendar-events'),
523
+					));
524 524
 
525 525
 					?>
526 526
 				</td>
@@ -539,28 +539,28 @@  discard block
 block discarded – undo
539 539
 	 *
540 540
 	 * @param  \WP_Post $post
541 541
 	 */
542
-	private static function advanced_settings_panel( $post ) {
542
+	private static function advanced_settings_panel($post) {
543 543
 
544 544
 		?>
545 545
 		<table>
546 546
 			<thead>
547
-			<tr><th colspan="2"><?php _e( 'Date and Time', 'google-calendar-events' ); ?></th></tr>
547
+			<tr><th colspan="2"><?php _e('Date and Time', 'google-calendar-events'); ?></th></tr>
548 548
 			</thead>
549 549
 			<tbody class="simcal-panel-section simcal-panel-datetime-formatting">
550 550
 			<tr class="simcal-panel-field">
551
-				<th><label for="_calendar_timezone_setting"><?php _e( 'Timezone', 'google-calendar-events' ); ?></label></th>
551
+				<th><label for="_calendar_timezone_setting"><?php _e('Timezone', 'google-calendar-events'); ?></label></th>
552 552
 				<td>
553 553
 					<?php
554 554
 
555 555
 					$timezone_wordpress = simcal_get_wp_timezone();
556 556
 					$timezone_default   = $timezone_wordpress ? $timezone_wordpress : 'UTC';
557
-					$timezone_setting   = esc_attr( get_post_meta( $post->ID, '_feed_timezone_setting', true ) );
558
-					$timezone           = esc_attr( get_post_meta( $post->ID, '_feed_timezone', true ) );
557
+					$timezone_setting   = esc_attr(get_post_meta($post->ID, '_feed_timezone_setting', true));
558
+					$timezone           = esc_attr(get_post_meta($post->ID, '_feed_timezone', true));
559 559
 					$timezone           = $timezone ? $timezone : $timezone_default;
560
-					$show_use_calendar  = isset( simcal_get_feed( $post )->type );
560
+					$show_use_calendar  = isset(simcal_get_feed($post)->type);
561 561
 
562
-					if ( $show_use_calendar ) {
563
-						$show_use_calendar = ( simcal_get_feed( $post )->type !== 'grouped-calendars' ? 1 : 0 );
562
+					if ($show_use_calendar) {
563
+						$show_use_calendar = (simcal_get_feed($post)->type !== 'grouped-calendars' ? 1 : 0);
564 564
 					} else {
565 565
 						$show_use_calendar = true;
566 566
 					}
@@ -570,58 +570,58 @@  discard block
 block discarded – undo
570 570
 							id="_feed_timezone_setting"
571 571
 							class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other"
572 572
 							data-show-field-on-choice="true">
573
-						<option value="use_site" <?php selected( 'use_site', $timezone_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', $timezone_default ); ?></option>
574
-						<?php if ( $show_use_calendar ) { ?>
575
-							<option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected( 'use_calendar', $timezone_setting, true ); ?>><?php _ex( 'Event source default', 'Use the calendar default setting', 'google-calendar-events' ); ?></option>
573
+						<option value="use_site" <?php selected('use_site', $timezone_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', $timezone_default); ?></option>
574
+						<?php if ($show_use_calendar) { ?>
575
+							<option id="use_calendar" value="use_calendar" data-show-field="_use_calendar_warning" <?php selected('use_calendar', $timezone_setting, true); ?>><?php _ex('Event source default', 'Use the calendar default setting', 'google-calendar-events'); ?></option>
576 576
 						<?php } ?>
577
-						<option value="use_custom" data-show-field="_feed_timezone" <?php selected( 'use_custom', $timezone_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option>
577
+						<option value="use_custom" data-show-field="_feed_timezone" <?php selected('use_custom', $timezone_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option>
578 578
 					</select>
579 579
 					<select name="_feed_timezone"
580 580
 							id="_feed_timezone"
581 581
 							class="simcal-field simcal-field-select simcal-field-inline"
582 582
 						<?php echo 'use_custom' != $timezone_setting ? 'style="display: none;"' : ''; ?>>
583
-						<?php echo wp_timezone_choice( $timezone ); ?>
583
+						<?php echo wp_timezone_choice($timezone); ?>
584 584
 					</select>
585
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Using a different timezone may alter the date and time display of your calendar events. We recommended using the site default timezone.', 'google-calendar-events' ); ?>"></i>
585
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Using a different timezone may alter the date and time display of your calendar events. We recommended using the site default timezone.', 'google-calendar-events'); ?>"></i>
586 586
 					<p id="_use_calendar_warning" style="display: none;" class="simcal-field">
587
-						<span class="attention"><?php _e( 'Warning', 'google-calendar-events' ); ?>:</span>
588
-						<?php _e( 'Setting this to <code>Event source default</code> can at times cause unexpected results. Please test thoroughly.', 'google-calendar-events' ); ?>
589
-						<a href="http://docs.simplecalendar.io/timezone-settings/" target="_blank"><?php _e( 'See details.', 'google-calendar-events' ); ?></a>
587
+						<span class="attention"><?php _e('Warning', 'google-calendar-events'); ?>:</span>
588
+						<?php _e('Setting this to <code>Event source default</code> can at times cause unexpected results. Please test thoroughly.', 'google-calendar-events'); ?>
589
+						<a href="http://docs.simplecalendar.io/timezone-settings/" target="_blank"><?php _e('See details.', 'google-calendar-events'); ?></a>
590 590
 					</p>
591 591
 				</td>
592 592
 			</tr>
593 593
 			<tr class="simcal-panel-field">
594
-				<th><label for="_calendar_date_format_setting"><?php _e( 'Date Format', 'google-calendar-events' ); ?></label></th>
594
+				<th><label for="_calendar_date_format_setting"><?php _e('Date Format', 'google-calendar-events'); ?></label></th>
595 595
 				<td>
596 596
 					<?php
597 597
 
598
-					$date_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_setting', true ) );
599
-					$date_format_default = esc_attr( get_option( 'date_format' ) );
600
-					$date_format = esc_attr( get_post_meta( $post->ID, '_calendar_date_format', true ) );
601
-					$date_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_date_format_php', true ) );
598
+					$date_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_date_format_setting', true));
599
+					$date_format_default = esc_attr(get_option('date_format'));
600
+					$date_format = esc_attr(get_post_meta($post->ID, '_calendar_date_format', true));
601
+					$date_format_php = esc_attr(get_post_meta($post->ID, '_calendar_date_format_php', true));
602 602
 					$date_format_php = $date_format_php ? $date_format_php : $date_format_default;
603 603
 
604 604
 					?>
605 605
 					<select name="_calendar_date_format_setting"
606 606
 							id="_calendar_date_format_setting"
607 607
 							class="simcal-field simcal-field-select simcal-field-show-other">
608
-						<option value="use_site" data-show-field="_calendar_date_format_default" <?php selected( 'use_site', $date_format_setting, true ); ?>><?php  _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option>
609
-						<option value="use_custom" data-show-field="_calendar_date_format" <?php selected( 'use_custom', $date_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option>
610
-						<option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected( 'use_custom_php', $date_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option>
608
+						<option value="use_site" data-show-field="_calendar_date_format_default" <?php selected('use_site', $date_format_setting, true); ?>><?php  _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option>
609
+						<option value="use_custom" data-show-field="_calendar_date_format" <?php selected('use_custom', $date_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option>
610
+						<option value="use_custom_php" data-show-field="_calendar_date_format_php_field" <?php selected('use_custom_php', $date_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option>
611 611
 					</select>
612
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i>
612
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event dates. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i>
613 613
 					<p id="_calendar_date_format_default" style="<?php echo $date_format_setting != 'use_site' ? 'display: none;' : ''; ?>">
614
-						<em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em>&nbsp;&nbsp;
615
-						<code><?php echo date_i18n( $date_format_default, time() ); ?></code>
614
+						<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
615
+						<code><?php echo date_i18n($date_format_default, time()); ?></code>
616 616
 					</p>
617
-					<?php simcal_print_field( array(
617
+					<?php simcal_print_field(array(
618 618
 						'type'    => 'datetime-format',
619 619
 						'subtype' => 'date',
620 620
 						'name'    => '_calendar_date_format',
621 621
 						'id'      => '_calendar_date_format',
622 622
 						'value'   => $date_format,
623
-						'style'   => $date_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '',
624
-					) ); ?>
623
+						'style'   => $date_format_setting != 'use_custom' ? array('display' => 'none') : '',
624
+					)); ?>
625 625
 					<div class="simcal-field-datetime-format-php" id="_calendar_date_format_php_field" style="<?php echo $date_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>">
626 626
 						<br>
627 627
 						<label for="_calendar_date_format_php">
@@ -630,70 +630,70 @@  discard block
 block discarded – undo
630 630
 								   id="_calendar_date_format_php"
631 631
 								   class="simcal-field simcal-field-text simcal-field-small"
632 632
 								   value="<?php echo $date_format_php; ?>" />
633
-							<?php printf( __( 'Enter a date format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?>
633
+							<?php printf(__('Enter a date format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?>
634 634
 						</label>
635 635
 						<p>
636
-							<em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em>&nbsp;&nbsp;
637
-							<code><?php echo date_i18n( $date_format_php, time() ); ?></code>
636
+							<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
637
+							<code><?php echo date_i18n($date_format_php, time()); ?></code>
638 638
 						</p>
639 639
 					</div>
640 640
 				</td>
641 641
 			</tr>
642 642
 			<tr class="simcal-panel-field">
643
-				<th><label for="_calendar_datetime_separator"><?php _e( 'Separator', 'google-calendar-events' ); ?></label></th>
643
+				<th><label for="_calendar_datetime_separator"><?php _e('Separator', 'google-calendar-events'); ?></label></th>
644 644
 				<td>
645 645
 					<?php
646 646
 
647
-					$separator = get_post_meta( $post->ID, '_calendar_datetime_separator', true );
647
+					$separator = get_post_meta($post->ID, '_calendar_datetime_separator', true);
648 648
 					$separator = false == $separator ? '@' : $separator;
649 649
 
650
-					simcal_print_field( array(
650
+					simcal_print_field(array(
651 651
 						'type'    => 'standard',
652 652
 						'subtype' => 'text',
653 653
 						'name'    => '_calendar_datetime_separator',
654 654
 						'id'      => '_calendar_datetime_separator',
655 655
 						'value'   => $separator,
656
-						'tooltip' => __( 'Used to divide date and time when both are shown.', 'google-calendar-events' ),
656
+						'tooltip' => __('Used to divide date and time when both are shown.', 'google-calendar-events'),
657 657
 						'class'   => array(
658 658
 							'simcal-field-tiny',
659 659
 						),
660
-					) );
660
+					));
661 661
 
662 662
 					?>
663 663
 				</td>
664 664
 			</tr>
665 665
 			<tr class="simcal-panel-field">
666
-				<th><label for="_calendar_time_format_setting"><?php _e( 'Time Format', 'google-calendar-events' ); ?></label></th>
666
+				<th><label for="_calendar_time_format_setting"><?php _e('Time Format', 'google-calendar-events'); ?></label></th>
667 667
 				<td>
668 668
 					<?php
669 669
 
670
-					$time_format_setting = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_setting', true ) );
671
-					$time_format_default = esc_attr( get_option( 'time_format' ) );
672
-					$time_format = esc_attr( get_post_meta( $post->ID, '_calendar_time_format', true ) );
673
-					$time_format_php = esc_attr( get_post_meta( $post->ID, '_calendar_time_format_php', true ) );
670
+					$time_format_setting = esc_attr(get_post_meta($post->ID, '_calendar_time_format_setting', true));
671
+					$time_format_default = esc_attr(get_option('time_format'));
672
+					$time_format = esc_attr(get_post_meta($post->ID, '_calendar_time_format', true));
673
+					$time_format_php = esc_attr(get_post_meta($post->ID, '_calendar_time_format_php', true));
674 674
 					$time_format_php = $time_format_php ? $time_format_php : $time_format_default;
675 675
 
676 676
 					?>
677 677
 					<select name="_calendar_time_format_setting"
678 678
 							id="_calendar_time_format_setting"
679 679
 							class="simcal-field simcal-field-select simcal-field-show-other">
680
-						<option value="use_site" data-show-field="_calendar_time_format_default" <?php selected( 'use_site', $time_format_setting, true ); ?>><?php _ex( 'Site default', 'Use this site default setting', 'google-calendar-events' ); ?></option>
681
-						<option value="use_custom" data-show-field="_calendar_time_format" <?php selected( 'use_custom', $time_format_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option>
682
-						<option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected( 'use_custom_php', $time_format_setting, true ); ?>><?php _e( 'Custom (PHP format)', 'google-calendar-events' ); ?></option>
680
+						<option value="use_site" data-show-field="_calendar_time_format_default" <?php selected('use_site', $time_format_setting, true); ?>><?php _ex('Site default', 'Use this site default setting', 'google-calendar-events'); ?></option>
681
+						<option value="use_custom" data-show-field="_calendar_time_format" <?php selected('use_custom', $time_format_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option>
682
+						<option value="use_custom_php" data-show-field="_calendar_time_format_php_field" <?php selected('use_custom_php', $time_format_setting, true); ?>><?php _e('Custom (PHP format)', 'google-calendar-events'); ?></option>
683 683
 					</select>
684
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events' ); ?>"></i>
684
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('This option sets how calendars display event times. It is recommended to keep your site default setting.', 'google-calendar-events'); ?>"></i>
685 685
 					<p id="_calendar_time_format_default" style="<?php echo $time_format_setting != 'use_site' ? 'display: none;' : ''; ?>">
686
-						<em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em>&nbsp;&nbsp;
687
-						<code><?php echo date_i18n( $time_format_default, time() ); ?></code>
686
+						<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
687
+						<code><?php echo date_i18n($time_format_default, time()); ?></code>
688 688
 					</p>
689
-					<?php simcal_print_field( array(
689
+					<?php simcal_print_field(array(
690 690
 						'type'    => 'datetime-format',
691 691
 						'subtype' => 'time',
692 692
 						'name'    => '_calendar_time_format',
693 693
 						'id'      => '_calendar_time_format',
694 694
 						'value'   => $time_format,
695
-						'style'   => $time_format_setting != 'use_custom' ? array( 'display' => 'none' ) : '',
696
-					) ); ?>
695
+						'style'   => $time_format_setting != 'use_custom' ? array('display' => 'none') : '',
696
+					)); ?>
697 697
 					<div class="simcal-field-datetime-format-php" id="_calendar_time_format_php_field" style="<?php echo $time_format_setting != 'use_custom_php' ? 'display: none;' : ''; ?>">
698 698
 						<br>
699 699
 						<label for="_calendar_date_format_php">
@@ -702,24 +702,24 @@  discard block
 block discarded – undo
702 702
 								   id="_calendar_time_format_php"
703 703
 								   class="simcal-field simcal-field-text simcal-field-small"
704 704
 								   value="<?php echo $time_format_php; ?>"/>
705
-							<?php printf( __( 'Enter a time format using %s values.', 'google-calendar-events' ), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>' ); ?>
705
+							<?php printf(__('Enter a time format using %s values.', 'google-calendar-events'), '<a href="//php.net/manual/en/function.date.php" target="_blank">PHP</a>'); ?>
706 706
 						</label>
707 707
 						<p>
708
-							<em><?php _e( 'Preview', 'google-calendar-events' ) ?>:</em>&nbsp;&nbsp;
709
-							<code><?php echo date_i18n( $time_format_php, time() ); ?></code>
708
+							<em><?php _e('Preview', 'google-calendar-events') ?>:</em>&nbsp;&nbsp;
709
+							<code><?php echo date_i18n($time_format_php, time()); ?></code>
710 710
 						</p>
711 711
 					</div>
712 712
 				</td>
713 713
 			</tr>
714 714
 			<tr class="simcal-panel-field">
715
-				<th><label for="_calendar_week_starts_on_setting"><?php _e( 'Week Starts On', 'google-calendar-events' ); ?></label></th>
715
+				<th><label for="_calendar_week_starts_on_setting"><?php _e('Week Starts On', 'google-calendar-events'); ?></label></th>
716 716
 				<td>
717 717
 					<?php
718 718
 
719
-					$week_starts_setting = esc_attr( get_post_meta( $post->ID, '_calendar_week_starts_on_setting', true ) );
720
-					$week_starts_default = esc_attr( get_option( 'start_of_week' ) );
721
-					$week_starts = intval( get_post_meta( $post->ID, '_calendar_week_starts_on', true ) );
722
-					$week_starts = is_numeric( $week_starts ) ? strval( $week_starts ) : $week_starts_default;
719
+					$week_starts_setting = esc_attr(get_post_meta($post->ID, '_calendar_week_starts_on_setting', true));
720
+					$week_starts_default = esc_attr(get_option('start_of_week'));
721
+					$week_starts = intval(get_post_meta($post->ID, '_calendar_week_starts_on', true));
722
+					$week_starts = is_numeric($week_starts) ? strval($week_starts) : $week_starts_default;
723 723
 
724 724
 					?>
725 725
 					<select
@@ -727,40 +727,40 @@  discard block
 block discarded – undo
727 727
 						id="_calendar_week_starts_on_setting"
728 728
 						class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-next"
729 729
 						data-show-next-if-value="use_custom">
730
-						<option value="use_site" <?php selected( 'use_site', $week_starts_setting, true ); ?>><?php printf( _x( 'Site default', 'Use this site default setting', 'google-calendar-events' ) . ' (%s)', date_i18n( 'l', strtotime( "Sunday + $week_starts_default Days" ) ) ); ?></option>
731
-						<option value="use_custom" <?php selected( 'use_custom', $week_starts_setting, true ); ?>><?php _ex( 'Custom', 'Use a custom setting', 'google-calendar-events' ); ?></option>
730
+						<option value="use_site" <?php selected('use_site', $week_starts_setting, true); ?>><?php printf(_x('Site default', 'Use this site default setting', 'google-calendar-events').' (%s)', date_i18n('l', strtotime("Sunday + $week_starts_default Days"))); ?></option>
731
+						<option value="use_custom" <?php selected('use_custom', $week_starts_setting, true); ?>><?php _ex('Custom', 'Use a custom setting', 'google-calendar-events'); ?></option>
732 732
 					</select>
733 733
 					<select
734 734
 						name="_calendar_week_starts_on"
735 735
 						id="_calendar_week_starts_on"
736 736
 						class="simcal-field simcal-field-select simcal-field-inline"
737 737
 						<?php echo 'use_custom' != $week_starts_setting ? 'style="display: none;"' : ''; ?>>
738
-						<?php $day_names = simcal_get_calendar_names_i18n( 'day', 'full' ); ?>
739
-						<?php for ( $i = 0; $i <= 6; $i++ ) : ?>
740
-							<option value="<?php echo $i; ?>" <?php selected( $i, $week_starts, true ); ?>><?php echo $day_names[ $i ]; ?></option>
738
+						<?php $day_names = simcal_get_calendar_names_i18n('day', 'full'); ?>
739
+						<?php for ($i = 0; $i <= 6; $i++) : ?>
740
+							<option value="<?php echo $i; ?>" <?php selected($i, $week_starts, true); ?>><?php echo $day_names[$i]; ?></option>
741 741
 						<?php endfor; ?>
742 742
 					</select>
743
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events' ); ?>"></i>
743
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Some calendars may use this setting to display the start of the week. It is recommended to keep the site default setting.', 'google-calendar-events'); ?>"></i>
744 744
 				</td>
745 745
 			</tr>
746 746
 			</tbody>
747 747
 		</table>
748 748
 		<table>
749 749
 			<thead>
750
-			<tr><th colspan="2"><?php _e( 'Cache', 'google-calendar-events' ); ?></th></tr>
750
+			<tr><th colspan="2"><?php _e('Cache', 'google-calendar-events'); ?></th></tr>
751 751
 			</thead>
752 752
 			<tbody class="simcal-panel-section simcal-panel-section-cache">
753 753
 			<?php
754 754
 
755
-			$cache_freq = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_amount', true ) );
756
-			$cache_unit = esc_attr( get_post_meta( $post->ID, '_feed_cache_user_unit', true ) );
755
+			$cache_freq = esc_attr(get_post_meta($post->ID, '_feed_cache_user_amount', true));
756
+			$cache_unit = esc_attr(get_post_meta($post->ID, '_feed_cache_user_unit', true));
757 757
 
758
-			$cache_freq = intval( $cache_freq ) && $cache_freq >= 0 ? $cache_freq : 2;
758
+			$cache_freq = intval($cache_freq) && $cache_freq >= 0 ? $cache_freq : 2;
759 759
 			$cache_unit = $cache_unit ? $cache_unit : '3600';
760 760
 
761 761
 			?>
762 762
 			<tr class="simcal-panel-field">
763
-				<th><label for="_feed_cache_user_amount"><?php _ex( 'Refresh Interval', 'Cache maximum interval', 'google-calendar-events' ); ?></label></th>
763
+				<th><label for="_feed_cache_user_amount"><?php _ex('Refresh Interval', 'Cache maximum interval', 'google-calendar-events'); ?></label></th>
764 764
 				<td>
765 765
 					<input type="number"
766 766
 						   name="_feed_cache_user_amount"
@@ -771,12 +771,12 @@  discard block
 block discarded – undo
771 771
 					<select name="_feed_cache_user_unit"
772 772
 							id="_feed_cache_user_unit"
773 773
 							class="simcal-field simcalfield-select simcal-field-inline">
774
-						<option value="60" <?php selected( '60', $cache_unit, true ); ?>><?php _e( 'Minute(s)', 'google-calendar-events' ); ?></option>
775
-						<option value="3600" <?php selected( '3600', $cache_unit, true ); ?>><?php _e( 'Hour(s)', 'google-calendar-events' ); ?></option>
776
-						<option value="86400" <?php selected( '86400', $cache_unit, true ); ?>><?php _e( 'Day(s)', 'google-calendar-events' ); ?></option>
777
-						<option value="604800" <?php selected( '604800', $cache_unit, true ); ?>><?php _e( 'Week(s)', 'google-calendar-events' ); ?></option>
774
+						<option value="60" <?php selected('60', $cache_unit, true); ?>><?php _e('Minute(s)', 'google-calendar-events'); ?></option>
775
+						<option value="3600" <?php selected('3600', $cache_unit, true); ?>><?php _e('Hour(s)', 'google-calendar-events'); ?></option>
776
+						<option value="86400" <?php selected('86400', $cache_unit, true); ?>><?php _e('Day(s)', 'google-calendar-events'); ?></option>
777
+						<option value="604800" <?php selected('604800', $cache_unit, true); ?>><?php _e('Week(s)', 'google-calendar-events'); ?></option>
778 778
 					</select>
779
-					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events' ); ?>"></i>
779
+					<i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('If you add, edit or remove events in your calendar very often, you can set a lower interval to refresh the events displayed. Set a higher interval for best performance.', 'google-calendar-events'); ?>"></i>
780 780
 				</td>
781 781
 			</tr>
782 782
 			</tbody>
@@ -795,21 +795,21 @@  discard block
 block discarded – undo
795 795
 	 *
796 796
 	 * @return void
797 797
 	 */
798
-	public static function print_panel_fields( $array, $post_id ) {
798
+	public static function print_panel_fields($array, $post_id) {
799 799
 
800
-		foreach ( $array as $section => $fields ) :
800
+		foreach ($array as $section => $fields) :
801 801
 
802
-			if ( $fields && is_array( $fields ) ) :
802
+			if ($fields && is_array($fields)) :
803 803
 
804 804
 				?>
805
-				<tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr( $section ); ?>">
806
-				<?php foreach ( $fields as $key => $field ) :
805
+				<tbody class="simcal-panel-section simcal-panel-section-<?php echo esc_attr($section); ?>">
806
+				<?php foreach ($fields as $key => $field) :
807 807
 
808
-					$value            = get_post_meta( $post_id, $key, true );
809
-					$field['value']   = $value ? $value : ( isset( $field['default'] ) ? $field['default'] : '' );
810
-					$the_field = simcal_get_field( $field ); ?>
808
+					$value            = get_post_meta($post_id, $key, true);
809
+					$field['value']   = $value ? $value : (isset($field['default']) ? $field['default'] : '');
810
+					$the_field = simcal_get_field($field); ?>
811 811
 
812
-					<?php if ( $the_field instanceof Field ) : ?>
812
+					<?php if ($the_field instanceof Field) : ?>
813 813
 					<tr class="simcal-panel-field">
814 814
 						<th><label for="<?php echo $the_field->id ?>"><?php echo $the_field->title; ?></label></th>
815 815
 						<td><?php $the_field->html(); ?></td>
@@ -836,30 +836,30 @@  discard block
 block discarded – undo
836 836
 	 *
837 837
 	 * @return void
838 838
 	 */
839
-	public static function save( $post_id, $post ) {
839
+	public static function save($post_id, $post) {
840 840
 
841 841
 		/* ====================== *
842 842
 		 * Calendar type and view *
843 843
 		 * ====================== */
844 844
 
845 845
 		// Unlink existing terms for feed type and calendar type.
846
-		wp_delete_object_term_relationships( $post_id, array(
846
+		wp_delete_object_term_relationships($post_id, array(
847 847
 			'calendar_feed',
848 848
 			'calendar_type',
849
-		) );
849
+		));
850 850
 
851 851
 		// Set the feed type as term.
852
-		$feed_type = isset( $_POST['_feed_type'] ) ? sanitize_title( stripslashes( $_POST['_feed_type'] ) ) : apply_filters( 'simcal_default_feed_type', 'google' );
853
-		wp_set_object_terms( $post_id, $feed_type, 'calendar_feed' );
852
+		$feed_type = isset($_POST['_feed_type']) ? sanitize_title(stripslashes($_POST['_feed_type'])) : apply_filters('simcal_default_feed_type', 'google');
853
+		wp_set_object_terms($post_id, $feed_type, 'calendar_feed');
854 854
 
855 855
 		// Set the calendar type as a term.
856
-		$calendar_type = isset( $_POST['_calendar_type'] ) ? sanitize_title( stripslashes( $_POST['_calendar_type'] ) ) : apply_filters( 'simcal_default_calendar_type', 'default-calendar' );
857
-		wp_set_object_terms( $post_id, $calendar_type, 'calendar_type' );
856
+		$calendar_type = isset($_POST['_calendar_type']) ? sanitize_title(stripslashes($_POST['_calendar_type'])) : apply_filters('simcal_default_calendar_type', 'default-calendar');
857
+		wp_set_object_terms($post_id, $calendar_type, 'calendar_type');
858 858
 		// Set the calendar type view as post meta.
859
-		$calendar_view = isset( $_POST['_calendar_view'] ) ? $_POST['_calendar_view'] : '';
860
-		if ( $calendar_view && is_array( $calendar_view ) ) {
861
-			$views = array_map( 'sanitize_title', $calendar_view );
862
-			update_post_meta( $post_id, '_calendar_view', $views );
859
+		$calendar_view = isset($_POST['_calendar_view']) ? $_POST['_calendar_view'] : '';
860
+		if ($calendar_view && is_array($calendar_view)) {
861
+			$views = array_map('sanitize_title', $calendar_view);
862
+			update_post_meta($post_id, '_calendar_view', $views);
863 863
 		}
864 864
 
865 865
 		/* ===================== *
@@ -867,106 +867,106 @@  discard block
 block discarded – undo
867 867
 		 * ===================== */
868 868
 
869 869
 		// Calendar opening.
870
-		$calendar_begins = isset( $_POST['_calendar_begins'] ) ? sanitize_key( $_POST['_calendar_begins'] ) : 'this_month';
871
-		update_post_meta( $post_id, '_calendar_begins', $calendar_begins );
872
-		$calendar_begins_nth = isset( $_POST['_calendar_begins_nth'] ) ? absint( $_POST['_calendar_begins_nth'] ) : 2;
873
-		update_post_meta( $post_id, '_calendar_begins_nth', $calendar_begins_nth );
874
-		$calendar_begins_custom_date = isset( $_POST['_calendar_begins_custom_date'] ) ? sanitize_title( $_POST['_calendar_begins_custom_date'] ) : '';
875
-		update_post_meta( $post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date );
870
+		$calendar_begins = isset($_POST['_calendar_begins']) ? sanitize_key($_POST['_calendar_begins']) : 'this_month';
871
+		update_post_meta($post_id, '_calendar_begins', $calendar_begins);
872
+		$calendar_begins_nth = isset($_POST['_calendar_begins_nth']) ? absint($_POST['_calendar_begins_nth']) : 2;
873
+		update_post_meta($post_id, '_calendar_begins_nth', $calendar_begins_nth);
874
+		$calendar_begins_custom_date = isset($_POST['_calendar_begins_custom_date']) ? sanitize_title($_POST['_calendar_begins_custom_date']) : '';
875
+		update_post_meta($post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date);
876 876
 
877 877
 		// Feed earliest events date.
878
-		$earliest_events = isset( $_POST['_feed_earliest_event_date'] ) ? sanitize_key( $_POST['_feed_earliest_event_date'] ) : '';
879
-		update_post_meta( $post_id, '_feed_earliest_event_date', $earliest_events );
880
-		$earliest_events_range = isset( $_POST['_feed_earliest_event_date_range'] ) ? max( absint( $_POST['_feed_earliest_event_date_range'] ), 1 ) : 1;
881
-		update_post_meta( $post_id, '_feed_earliest_event_date_range', $earliest_events_range );
878
+		$earliest_events = isset($_POST['_feed_earliest_event_date']) ? sanitize_key($_POST['_feed_earliest_event_date']) : '';
879
+		update_post_meta($post_id, '_feed_earliest_event_date', $earliest_events);
880
+		$earliest_events_range = isset($_POST['_feed_earliest_event_date_range']) ? max(absint($_POST['_feed_earliest_event_date_range']), 1) : 1;
881
+		update_post_meta($post_id, '_feed_earliest_event_date_range', $earliest_events_range);
882 882
 
883 883
 		// Feed latest events date.
884
-		$latest_events = isset( $_POST['_feed_latest_event_date'] ) ? sanitize_key( $_POST['_feed_latest_event_date'] ) : '';
885
-		update_post_meta( $post_id, '_feed_latest_event_date', $latest_events );
886
-		$latest_events_range = isset( $_POST['_feed_latest_event_date_range'] ) ? max( absint( $_POST['_feed_latest_event_date_range'] ), 1 ) : 1;
887
-		update_post_meta( $post_id, '_feed_latest_event_date_range', $latest_events_range );
884
+		$latest_events = isset($_POST['_feed_latest_event_date']) ? sanitize_key($_POST['_feed_latest_event_date']) : '';
885
+		update_post_meta($post_id, '_feed_latest_event_date', $latest_events);
886
+		$latest_events_range = isset($_POST['_feed_latest_event_date_range']) ? max(absint($_POST['_feed_latest_event_date_range']), 1) : 1;
887
+		update_post_meta($post_id, '_feed_latest_event_date_range', $latest_events_range);
888 888
 
889 889
 		/* ======================= *
890 890
 		 * Calendar settings panel *
891 891
 		 * ======================= */
892 892
 
893 893
 		// Static calendar.
894
-		$static = isset( $_POST['_calendar_is_static'] ) ? 'yes' : 'no';
895
-		update_post_meta( $post_id, '_calendar_is_static', $static );
894
+		$static = isset($_POST['_calendar_is_static']) ? 'yes' : 'no';
895
+		update_post_meta($post_id, '_calendar_is_static', $static);
896 896
 
897 897
 		// No events message.
898
-		$message = isset( $_POST['_no_events_message'] ) ? wp_kses_post( $_POST['_no_events_message'] ) : '';
899
-		update_post_meta( $post_id, '_no_events_message', $message );
898
+		$message = isset($_POST['_no_events_message']) ? wp_kses_post($_POST['_no_events_message']) : '';
899
+		update_post_meta($post_id, '_no_events_message', $message);
900 900
 
901 901
 		// _event_formatting
902
-		$event_formatting = isset( $_POST['_event_formatting'] ) ? sanitize_key( $_POST['_event_formatting'] ) : 'preserve_linebreaks';
903
-		update_post_meta( $post_id, '_event_formatting', $event_formatting );
902
+		$event_formatting = isset($_POST['_event_formatting']) ? sanitize_key($_POST['_event_formatting']) : 'preserve_linebreaks';
903
+		update_post_meta($post_id, '_event_formatting', $event_formatting);
904 904
 
905 905
 		// Powered by option
906
-		$poweredby = isset( $_POST['_poweredby'] ) ? 'yes' : 'no';
907
-		update_post_meta( $post_id, '_poweredby', $poweredby );
906
+		$poweredby = isset($_POST['_poweredby']) ? 'yes' : 'no';
907
+		update_post_meta($post_id, '_poweredby', $poweredby);
908 908
 
909 909
 		/* ======================= *
910 910
 		 * Advanced settings panel *
911 911
 		 * ======================= */
912 912
 
913 913
 		// Timezone.
914
-		$feed_timezone_setting = isset( $_POST['_feed_timezone_setting'] ) ? sanitize_key( $_POST['_feed_timezone_setting'] ) : 'use_calendar';
915
-		update_post_meta( $post_id, '_feed_timezone_setting', $feed_timezone_setting );
914
+		$feed_timezone_setting = isset($_POST['_feed_timezone_setting']) ? sanitize_key($_POST['_feed_timezone_setting']) : 'use_calendar';
915
+		update_post_meta($post_id, '_feed_timezone_setting', $feed_timezone_setting);
916 916
 		$default_timezone = simcal_get_wp_timezone();
917 917
 		$feed_timezone = $default_timezone ? $default_timezone : 'UTC';
918
-		$feed_timezone = isset( $_POST['_feed_timezone'] ) ? sanitize_text_field( $_POST['_feed_timezone'] ) : $feed_timezone;
919
-		update_post_meta( $post_id, '_feed_timezone', $feed_timezone );
918
+		$feed_timezone = isset($_POST['_feed_timezone']) ? sanitize_text_field($_POST['_feed_timezone']) : $feed_timezone;
919
+		update_post_meta($post_id, '_feed_timezone', $feed_timezone);
920 920
 
921 921
 		// Date format.
922
-		$date_format_setting = isset( $_POST['_calendar_date_format_setting'] ) ? sanitize_key( $_POST['_calendar_date_format_setting'] ) : 'use_site';
923
-		update_post_meta( $post_id, '_calendar_date_format_setting', $date_format_setting );
924
-		$date_format = isset( $_POST['_calendar_date_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format'] ) ) : get_option( 'date_format' );
925
-		update_post_meta( $post_id, '_calendar_date_format', $date_format );
926
-		$date_format_php = isset( $_POST['_calendar_date_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_date_format_php'] ) ) : get_option( 'date_format' );
927
-		update_post_meta( $post_id, '_calendar_date_format_php', $date_format_php );
922
+		$date_format_setting = isset($_POST['_calendar_date_format_setting']) ? sanitize_key($_POST['_calendar_date_format_setting']) : 'use_site';
923
+		update_post_meta($post_id, '_calendar_date_format_setting', $date_format_setting);
924
+		$date_format = isset($_POST['_calendar_date_format']) ? sanitize_text_field(trim($_POST['_calendar_date_format'])) : get_option('date_format');
925
+		update_post_meta($post_id, '_calendar_date_format', $date_format);
926
+		$date_format_php = isset($_POST['_calendar_date_format_php']) ? sanitize_text_field(trim($_POST['_calendar_date_format_php'])) : get_option('date_format');
927
+		update_post_meta($post_id, '_calendar_date_format_php', $date_format_php);
928 928
 
929 929
 		// Time format.
930
-		$time_format_setting = isset( $_POST['_calendar_time_format_setting'] ) ? sanitize_key( $_POST['_calendar_time_format_setting'] ) : 'use_site';
931
-		update_post_meta( $post_id, '_calendar_time_format_setting', $time_format_setting );
932
-		$time_format = isset( $_POST['_calendar_time_format'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format'] ) ) : get_option( 'time_format' );
933
-		update_post_meta( $post_id, '_calendar_time_format', $time_format );
934
-		$time_format_php = isset( $_POST['_calendar_time_format_php'] ) ? sanitize_text_field( trim( $_POST['_calendar_time_format_php'] ) ) : get_option( 'time_format' );
935
-		update_post_meta( $post_id, '_calendar_time_format_php', $time_format_php );
930
+		$time_format_setting = isset($_POST['_calendar_time_format_setting']) ? sanitize_key($_POST['_calendar_time_format_setting']) : 'use_site';
931
+		update_post_meta($post_id, '_calendar_time_format_setting', $time_format_setting);
932
+		$time_format = isset($_POST['_calendar_time_format']) ? sanitize_text_field(trim($_POST['_calendar_time_format'])) : get_option('time_format');
933
+		update_post_meta($post_id, '_calendar_time_format', $time_format);
934
+		$time_format_php = isset($_POST['_calendar_time_format_php']) ? sanitize_text_field(trim($_POST['_calendar_time_format_php'])) : get_option('time_format');
935
+		update_post_meta($post_id, '_calendar_time_format_php', $time_format_php);
936 936
 
937 937
 		// Date-time separator.
938
-		$datetime_separator = isset( $_POST['_calendar_datetime_separator'] ) ? sanitize_text_field( $_POST['_calendar_datetime_separator'] ) : ' ';
939
-		update_post_meta( $post_id, '_calendar_datetime_separator', $datetime_separator );
938
+		$datetime_separator = isset($_POST['_calendar_datetime_separator']) ? sanitize_text_field($_POST['_calendar_datetime_separator']) : ' ';
939
+		update_post_meta($post_id, '_calendar_datetime_separator', $datetime_separator);
940 940
 
941 941
 		// Week start.
942
-		$week_start_setting = isset( $_POST['_calendar_week_starts_on_setting'] ) ? sanitize_key( $_POST['_calendar_week_starts_on_setting'] ) : 'use_site';
943
-		update_post_meta( $post_id, '_calendar_week_starts_on_setting', $week_start_setting );
944
-		$week_start = isset( $_POST['_calendar_week_starts_on'] ) ? intval( $_POST['_calendar_week_starts_on'] ) : get_option( 'start_of_week' );
945
-		update_post_meta( $post_id, '_calendar_week_starts_on', $week_start );
942
+		$week_start_setting = isset($_POST['_calendar_week_starts_on_setting']) ? sanitize_key($_POST['_calendar_week_starts_on_setting']) : 'use_site';
943
+		update_post_meta($post_id, '_calendar_week_starts_on_setting', $week_start_setting);
944
+		$week_start = isset($_POST['_calendar_week_starts_on']) ? intval($_POST['_calendar_week_starts_on']) : get_option('start_of_week');
945
+		update_post_meta($post_id, '_calendar_week_starts_on', $week_start);
946 946
 
947 947
 		// Cache interval.
948 948
 		$cache = 7200;
949
-		if ( isset( $_POST['_feed_cache_user_amount'] ) && isset( $_POST['_feed_cache_user_unit'] ) ) {
950
-			$amount = is_numeric( $_POST['_feed_cache_user_amount'] ) || $_POST['_feed_cache_user_amount'] == 0 ? absint( $_POST['_feed_cache_user_amount'] ) : 1;
951
-			$unit   = is_numeric( $_POST['_feed_cache_user_unit'] ) ? absint( $_POST['_feed_cache_user_unit'] ) : 3600;
952
-			update_post_meta( $post_id, '_feed_cache_user_amount', $amount );
953
-			update_post_meta( $post_id, '_feed_cache_user_unit', $unit );
954
-			$cache  = ( ( $amount * $unit ) > 0 ) ? $amount * $unit : 1;
949
+		if (isset($_POST['_feed_cache_user_amount']) && isset($_POST['_feed_cache_user_unit'])) {
950
+			$amount = is_numeric($_POST['_feed_cache_user_amount']) || $_POST['_feed_cache_user_amount'] == 0 ? absint($_POST['_feed_cache_user_amount']) : 1;
951
+			$unit   = is_numeric($_POST['_feed_cache_user_unit']) ? absint($_POST['_feed_cache_user_unit']) : 3600;
952
+			update_post_meta($post_id, '_feed_cache_user_amount', $amount);
953
+			update_post_meta($post_id, '_feed_cache_user_unit', $unit);
954
+			$cache  = (($amount * $unit) > 0) ? $amount * $unit : 1;
955 955
 		}
956
-		update_post_meta( $post_id, '_feed_cache', $cache );
956
+		update_post_meta($post_id, '_feed_cache', $cache);
957 957
 
958 958
 		/* ============= *
959 959
 		 * Miscellaneous *
960 960
 		 * ============= */
961 961
 
962 962
 		// Update version.
963
-		update_post_meta( $post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION );
963
+		update_post_meta($post_id, '_calendar_version', SIMPLE_CALENDAR_VERSION);
964 964
 
965 965
 		// Action hook.
966
-		do_action( 'simcal_process_settings_meta', $post_id );
966
+		do_action('simcal_process_settings_meta', $post_id);
967 967
 
968 968
 		// Clear cache.
969
-		simcal_delete_feed_transients( $post_id );
969
+		simcal_delete_feed_transients($post_id);
970 970
 	}
971 971
 
972 972
 }
Please login to merge, or discard this patch.
includes/abstracts/calendar.php 1 patch
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use SimpleCalendar\Events\Event_Builder;
12 12
 use SimpleCalendar\Events\Events;
13 13
 
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 	 * @param int|object|\WP_Post|Calendar $calendar
235 235
 	 * @param string $view
236 236
 	 */
237
-	public function __construct( $calendar, $view = '' ) {
237
+	public function __construct($calendar, $view = '') {
238 238
 
239 239
 		// Set the post object.
240
-		$this->set_post_object( $calendar );
240
+		$this->set_post_object($calendar);
241 241
 
242
-		if ( ! is_null( $this->post ) ) {
242
+		if ( ! is_null($this->post)) {
243 243
 
244 244
 			// Set calendar type and events source.
245 245
 			$this->set_taxonomies();
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
 			$this->set_events_template();
257 257
 
258 258
 			// Get events source data.
259
-			$feed = simcal_get_feed( $this );
260
-			if ( $feed instanceof Feed ) {
261
-				if ( ! empty( $feed->events ) ) {
262
-					if ( is_array( $feed->events ) ) {
263
-						$this->set_events( $feed->events );
264
-						if ( 'use_calendar' == get_post_meta( $this->id, '_feed_timezone_setting', true ) ) {
259
+			$feed = simcal_get_feed($this);
260
+			if ($feed instanceof Feed) {
261
+				if ( ! empty($feed->events)) {
262
+					if (is_array($feed->events)) {
263
+						$this->set_events($feed->events);
264
+						if ('use_calendar' == get_post_meta($this->id, '_feed_timezone_setting', true)) {
265 265
 							$this->timezone = $feed->timezone;
266 266
 							$this->set_start();
267 267
 						}
268
-					} elseif ( is_string( $feed->events ) ) {
268
+					} elseif (is_string($feed->events)) {
269 269
 						$this->errors[] = $feed->events;
270 270
 					}
271 271
 				}
272 272
 			}
273 273
 
274 274
 			// Set general purpose timestamps.
275
-			$now = Carbon::now( $this->timezone );
275
+			$now = Carbon::now($this->timezone);
276 276
 			$this->now    = $now->getTimestamp();
277 277
 			$this->today  = $now->startOfDay()->getTimestamp();
278 278
 			$this->offset = $now->getOffset();
@@ -283,26 +283,26 @@  discard block
 block discarded – undo
283 283
 			$this->set_datetime_separator();
284 284
 
285 285
 			// Set earliest and latest event timestamps.
286
-			if ( $this->events && is_array( $this->events ) ) {
287
-				$this->earliest_event = intval( current( array_keys( $this->events ) ) );
288
-				$this->latest_event   = intval( key( array_slice( $this->events, -1, 1, true ) ) );
286
+			if ($this->events && is_array($this->events)) {
287
+				$this->earliest_event = intval(current(array_keys($this->events)));
288
+				$this->latest_event   = intval(key(array_slice($this->events, -1, 1, true)));
289 289
 			}
290 290
 
291 291
 			// Set calendar end.
292 292
 			$this->set_end();
293 293
 
294 294
 			// Set view.
295
-			if ( ! $view ) {
295
+			if ( ! $view) {
296 296
 
297
-				$calendar_view = get_post_meta( $this->id, '_calendar_view', true );
298
-				$calendar_view = isset( $calendar_view[ $this->type ] ) ? $calendar_view[ $this->type ] : '';
297
+				$calendar_view = get_post_meta($this->id, '_calendar_view', true);
298
+				$calendar_view = isset($calendar_view[$this->type]) ? $calendar_view[$this->type] : '';
299 299
 
300
-				$view = esc_attr( $calendar_view );
300
+				$view = esc_attr($calendar_view);
301 301
 			}
302 302
 		}
303 303
 
304 304
 		// Get view.
305
-		$this->view = $this->get_view( $view );
305
+		$this->view = $this->get_view($view);
306 306
 	}
307 307
 
308 308
 	/**
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @return bool
316 316
 	 */
317
-	public function __isset( $key ) {
318
-		return metadata_exists( 'post', $this->id, '_' . $key );
317
+	public function __isset($key) {
318
+		return metadata_exists('post', $this->id, '_'.$key);
319 319
 	}
320 320
 
321 321
 	/**
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 	 *
328 328
 	 * @return mixed
329 329
 	 */
330
-	public function __get( $key ) {
331
-		$value = get_post_meta( $this->id, '_' . $key, true );
332
-		if ( ! empty( $value ) ) {
330
+	public function __get($key) {
331
+		$value = get_post_meta($this->id, '_'.$key, true);
332
+		if ( ! empty($value)) {
333 333
 			$this->$key = $value;
334 334
 		}
335 335
 		return $value;
@@ -342,17 +342,17 @@  discard block
 block discarded – undo
342 342
 	 *
343 343
 	 * @param int|object|\WP_Post|Calendar $calendar
344 344
 	 */
345
-	public function set_post_object( $calendar ) {
346
-		if ( is_numeric( $calendar ) ) {
347
-			$this->id   = absint( $calendar );
348
-			$this->post = get_post( $this->id );
349
-		} elseif ( $calendar instanceof Calendar ) {
350
-			$this->id   = absint( $calendar->id );
345
+	public function set_post_object($calendar) {
346
+		if (is_numeric($calendar)) {
347
+			$this->id   = absint($calendar);
348
+			$this->post = get_post($this->id);
349
+		} elseif ($calendar instanceof Calendar) {
350
+			$this->id   = absint($calendar->id);
351 351
 			$this->post = $calendar->post;
352
-		} elseif ( $calendar instanceof \WP_Post ) {
353
-			$this->id   = absint( $calendar->ID );
352
+		} elseif ($calendar instanceof \WP_Post) {
353
+			$this->id   = absint($calendar->ID);
354 354
 			$this->post = $calendar;
355
-		} elseif ( isset( $calendar->id ) && isset( $calendar->post ) ) {
355
+		} elseif (isset($calendar->id) && isset($calendar->post)) {
356 356
 			$this->id   = $calendar->id;
357 357
 			$this->post = $calendar->post;
358 358
 		}
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 	 * @return string
367 367
 	 */
368 368
 	public function get_title() {
369
-		$title = isset( $this->post->post_title ) ? $this->post->post_title : '';
370
-		return apply_filters( 'simcal_calendar_title', $title );
369
+		$title = isset($this->post->post_title) ? $this->post->post_title : '';
370
+		return apply_filters('simcal_calendar_title', $title);
371 371
 	}
372 372
 
373 373
 	/**
@@ -389,16 +389,16 @@  discard block
 block discarded – undo
389 389
 	 */
390 390
 	protected function set_taxonomies() {
391 391
 		// Set calendar type.
392
-		if ( $type = wp_get_object_terms( $this->id, 'calendar_type' ) ) {
393
-			$this->type = sanitize_title( current( $type )->name );
392
+		if ($type = wp_get_object_terms($this->id, 'calendar_type')) {
393
+			$this->type = sanitize_title(current($type)->name);
394 394
 		} else {
395
-			$this->type = apply_filters( 'simcal_calendar_default_type', 'default-calendar' );
395
+			$this->type = apply_filters('simcal_calendar_default_type', 'default-calendar');
396 396
 		}
397 397
 		// Set feed type.
398
-		if ( $feed_type = wp_get_object_terms( $this->id, 'calendar_feed' ) ) {
399
-			$this->feed = sanitize_title( current( $feed_type )->name );
398
+		if ($feed_type = wp_get_object_terms($this->id, 'calendar_feed')) {
399
+			$this->feed = sanitize_title(current($feed_type)->name);
400 400
 		} else {
401
-			$this->feed = apply_filters( 'simcal_calendar_default_feed', 'google' );
401
+			$this->feed = apply_filters('simcal_calendar_default_feed', 'google');
402 402
 		}
403 403
 	}
404 404
 
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 * @return Events
411 411
 	 */
412 412
 	public function get_events() {
413
-		return new Events( $this->events, $this->timezone );
413
+		return new Events($this->events, $this->timezone);
414 414
 	}
415 415
 
416 416
 	/**
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
 	 *
421 421
 	 * @param array $array
422 422
 	 */
423
-	public function set_events( array $array ) {
423
+	public function set_events(array $array) {
424 424
 
425 425
 		$events = array();
426 426
 
427
-		if ( ! empty( $array ) ) {
428
-			foreach ( $array as $tz => $e ) {
429
-				foreach ( $e as $event ) {
430
-					$events[ $tz ][] = $event instanceof Event ? $event : new Event( $event );
427
+		if ( ! empty($array)) {
428
+			foreach ($array as $tz => $e) {
429
+				foreach ($e as $event) {
430
+					$events[$tz][] = $event instanceof Event ? $event : new Event($event);
431 431
 				}
432 432
 			}
433 433
 		}
@@ -444,24 +444,24 @@  discard block
 block discarded – undo
444 444
 	 *
445 445
 	 * @return string
446 446
 	 */
447
-	public function set_events_template( $template = '' ) {
448
-		if ( empty( $template ) ) {
449
-			$template = isset( $this->post->post_content ) ? $this->post->post_content : '';
447
+	public function set_events_template($template = '') {
448
+		if (empty($template)) {
449
+			$template = isset($this->post->post_content) ? $this->post->post_content : '';
450 450
 		}
451 451
 
452 452
 		// TODO: Removed wpautop() call.
453 453
 
454
-		$event_formatting = get_post_meta( $this->id, '_event_formatting', true );
454
+		$event_formatting = get_post_meta($this->id, '_event_formatting', true);
455 455
 
456
-		switch( $event_formatting ) {
456
+		switch ($event_formatting) {
457 457
 			case 'none':
458
-				$this->events_template =  wp_kses_post( trim( $template ) );
458
+				$this->events_template = wp_kses_post(trim($template));
459 459
 				break;
460 460
 			case 'no_linebreaks':
461
-				$this->events_template =  wpautop( wp_kses_post( trim( $template ) ), false );
461
+				$this->events_template = wpautop(wp_kses_post(trim($template)), false);
462 462
 				break;
463 463
 			default:
464
-				$this->events_template =  wpautop( wp_kses_post( trim( $template ) ), true );
464
+				$this->events_template = wpautop(wp_kses_post(trim($template)), true);
465 465
 		}
466 466
 
467 467
 		//$this->events_template =  wpautop( wp_kses_post( trim( $template ) ), true );
@@ -474,37 +474,37 @@  discard block
 block discarded – undo
474 474
 	 *
475 475
 	 * @param string $tz Timezone.
476 476
 	 */
477
-	public function set_timezone( $tz = '' ) {
477
+	public function set_timezone($tz = '') {
478 478
 
479
-		$site_tz = esc_attr( simcal_get_wp_timezone() );
479
+		$site_tz = esc_attr(simcal_get_wp_timezone());
480 480
 
481
-		if ( $this->feed === 'grouped-calendars' ) {
481
+		if ($this->feed === 'grouped-calendars') {
482 482
 			$this->timezone = $site_tz;
483 483
 			return;
484 484
 		}
485 485
 
486
-		if ( empty( $tz ) ) {
486
+		if (empty($tz)) {
487 487
 
488
-			$timezone_setting = get_post_meta( $this->id, '_feed_timezone_setting', true );
488
+			$timezone_setting = get_post_meta($this->id, '_feed_timezone_setting', true);
489 489
 
490
-			if ( 'use_site' == $timezone_setting ) {
490
+			if ('use_site' == $timezone_setting) {
491 491
 				$tz = $site_tz;
492
-			} elseif ( 'use_custom' == $timezone_setting ) {
493
-				$custom_timezone = esc_attr( get_post_meta( $this->id, '_feed_timezone', true ) );
492
+			} elseif ('use_custom' == $timezone_setting) {
493
+				$custom_timezone = esc_attr(get_post_meta($this->id, '_feed_timezone', true));
494 494
 				// One may be using a non standard timezone in GMT (UTC) offset format.
495
-				if ( ( strpos( $custom_timezone, 'UTC+' ) === 0 ) || ( strpos( $custom_timezone, 'UTC-' ) === 0 ) ) {
496
-					$tz = simcal_get_timezone_from_gmt_offset( substr( $custom_timezone, 3 ) );
495
+				if ((strpos($custom_timezone, 'UTC+') === 0) || (strpos($custom_timezone, 'UTC-') === 0)) {
496
+					$tz = simcal_get_timezone_from_gmt_offset(substr($custom_timezone, 3));
497 497
 				} else {
498
-					$tz = ! empty( $custom_timezone ) ? $custom_timezone : 'UTC';
498
+					$tz = ! empty($custom_timezone) ? $custom_timezone : 'UTC';
499 499
 				}
500 500
 			}
501 501
 
502
-			$this->timezone = empty( $tz ) ? 'UTC' : $tz;
502
+			$this->timezone = empty($tz) ? 'UTC' : $tz;
503 503
 			return;
504 504
 		}
505 505
 
506 506
 		$this->site_timezone = $site_tz;
507
-		$this->timezone = simcal_esc_timezone( $tz, $this->timezone );
507
+		$this->timezone = simcal_esc_timezone($tz, $this->timezone);
508 508
 	}
509 509
 
510 510
 	/**
@@ -514,20 +514,20 @@  discard block
 block discarded – undo
514 514
 	 *
515 515
 	 * @param string $format PHP datetime format.
516 516
 	 */
517
-	public function set_date_format( $format = '' ) {
517
+	public function set_date_format($format = '') {
518 518
 
519 519
 		$date_format_custom = $date_format_default = $format;
520 520
 
521
-		if ( empty( $date_format_custom ) ) {
521
+		if (empty($date_format_custom)) {
522 522
 
523
-			$date_format_option  = esc_attr( get_post_meta( $this->id, '_calendar_date_format_setting', true ) );
524
-			$date_format_default = esc_attr( get_option( 'date_format' ) );
523
+			$date_format_option  = esc_attr(get_post_meta($this->id, '_calendar_date_format_setting', true));
524
+			$date_format_default = esc_attr(get_option('date_format'));
525 525
 			$date_format_custom  = '';
526 526
 
527
-			if ( 'use_custom' == $date_format_option ) {
528
-				$date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format', true ) );
529
-			} elseif ( 'use_custom_php' == $date_format_option ) {
530
-				$date_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_date_format_php', true ) );
527
+			if ('use_custom' == $date_format_option) {
528
+				$date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format', true));
529
+			} elseif ('use_custom_php' == $date_format_option) {
530
+				$date_format_custom = esc_attr(get_post_meta($this->id, '_calendar_date_format_php', true));
531 531
 			}
532 532
 		}
533 533
 
@@ -541,20 +541,20 @@  discard block
 block discarded – undo
541 541
 	 *
542 542
 	 * @param string $format PHP datetime format.
543 543
 	 */
544
-	public function set_time_format( $format = '' ) {
544
+	public function set_time_format($format = '') {
545 545
 
546 546
 		$time_format_custom = $time_format_default = $format;
547 547
 
548
-		if ( empty( $time_format_custom ) ) {
548
+		if (empty($time_format_custom)) {
549 549
 
550
-			$time_format_option  = esc_attr( get_post_meta( $this->id, '_calendar_time_format_setting', true ) );
551
-			$time_format_default = esc_attr( get_option( 'time_format' ) );
550
+			$time_format_option  = esc_attr(get_post_meta($this->id, '_calendar_time_format_setting', true));
551
+			$time_format_default = esc_attr(get_option('time_format'));
552 552
 			$time_format_custom  = '';
553 553
 
554
-			if ( 'use_custom' == $time_format_option ) {
555
-				$time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format', true ) );
556
-			} elseif ( 'use_custom_php' == $time_format_option ) {
557
-				$time_format_custom = esc_attr( get_post_meta( $this->id, '_calendar_time_format_php', true ) );
554
+			if ('use_custom' == $time_format_option) {
555
+				$time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format', true));
556
+			} elseif ('use_custom_php' == $time_format_option) {
557
+				$time_format_custom = esc_attr(get_post_meta($this->id, '_calendar_time_format_php', true));
558 558
 			}
559 559
 		}
560 560
 
@@ -568,13 +568,13 @@  discard block
 block discarded – undo
568 568
 	 *
569 569
 	 * @param string $separator A UTF8 character used as separator.
570 570
 	 */
571
-	public function set_datetime_separator( $separator = '' ) {
571
+	public function set_datetime_separator($separator = '') {
572 572
 
573
-		if ( empty( $separator ) ) {
574
-			$separator = get_post_meta( $this->id, '_calendar_datetime_separator', true );
573
+		if (empty($separator)) {
574
+			$separator = get_post_meta($this->id, '_calendar_datetime_separator', true);
575 575
 		}
576 576
 
577
-		$this->datetime_separator = esc_attr( $separator );
577
+		$this->datetime_separator = esc_attr($separator);
578 578
 	}
579 579
 
580 580
 	/**
@@ -584,18 +584,18 @@  discard block
 block discarded – undo
584 584
 	 *
585 585
 	 * @param int $weekday From 0 (Sunday) to 6 (Friday).
586 586
 	 */
587
-	public function set_start_of_week( $weekday = -1 ) {
587
+	public function set_start_of_week($weekday = -1) {
588 588
 
589
-		$week_starts = is_int( $weekday ) ? $weekday : -1;
589
+		$week_starts = is_int($weekday) ? $weekday : -1;
590 590
 
591
-		if ( $week_starts < 0 || $week_starts > 6 ) {
591
+		if ($week_starts < 0 || $week_starts > 6) {
592 592
 
593
-			$week_starts_setting = get_post_meta( $this->id, '_calendar_week_starts_on_setting', true );
594
-			$week_starts         = intval( get_option( 'start_of_week' ) );
593
+			$week_starts_setting = get_post_meta($this->id, '_calendar_week_starts_on_setting', true);
594
+			$week_starts         = intval(get_option('start_of_week'));
595 595
 
596
-			if ( 'use_custom' == $week_starts_setting ) {
597
-				$week_starts_on = get_post_meta( $this->id, '_calendar_week_starts_on', true );
598
-				$week_starts    = is_numeric( $week_starts_on ) ? intval( $week_starts_on ) : $week_starts;
596
+			if ('use_custom' == $week_starts_setting) {
597
+				$week_starts_on = get_post_meta($this->id, '_calendar_week_starts_on', true);
598
+				$week_starts    = is_numeric($week_starts_on) ? intval($week_starts_on) : $week_starts;
599 599
 			}
600 600
 		}
601 601
 
@@ -609,51 +609,51 @@  discard block
 block discarded – undo
609 609
 	 *
610 610
 	 * @param int $timestamp
611 611
 	 */
612
-	public function set_start( $timestamp = 0 ) {
612
+	public function set_start($timestamp = 0) {
613 613
 
614
-		if ( is_int( $timestamp ) && $timestamp !== 0 ) {
614
+		if (is_int($timestamp) && $timestamp !== 0) {
615 615
 			$this->start = $timestamp;
616 616
 			return;
617 617
 		}
618 618
 
619
-		$this->start = Carbon::now( $this->timezone )->getTimestamp();
619
+		$this->start = Carbon::now($this->timezone)->getTimestamp();
620 620
 
621
-		$calendar_begins = esc_attr( get_post_meta( $this->id, '_calendar_begins', true ) );
622
-		$nth = max( absint( get_post_meta( $this->id, '_calendar_begins_nth', true ) ), 1 );
621
+		$calendar_begins = esc_attr(get_post_meta($this->id, '_calendar_begins', true));
622
+		$nth = max(absint(get_post_meta($this->id, '_calendar_begins_nth', true)), 1);
623 623
 
624
-		if ( 'today' == $calendar_begins ) {
625
-			$this->start = Carbon::today( $this->timezone )->getTimestamp();
626
-		} elseif ( 'days_before' == $calendar_begins ) {
627
-			$this->start = Carbon::today( $this->timezone )->subDays( $nth )->getTimestamp();
628
-		} elseif ( 'days_after' == $calendar_begins ) {
629
-			$this->start = Carbon::today( $this->timezone )->addDays( $nth )->getTimestamp();
630
-		} elseif ( 'this_week' == $calendar_begins ) {
631
-			$week = new Carbon( 'now', $this->timezone );
632
-			$week->setWeekStartsAt( $this->week_starts );
624
+		if ('today' == $calendar_begins) {
625
+			$this->start = Carbon::today($this->timezone)->getTimestamp();
626
+		} elseif ('days_before' == $calendar_begins) {
627
+			$this->start = Carbon::today($this->timezone)->subDays($nth)->getTimestamp();
628
+		} elseif ('days_after' == $calendar_begins) {
629
+			$this->start = Carbon::today($this->timezone)->addDays($nth)->getTimestamp();
630
+		} elseif ('this_week' == $calendar_begins) {
631
+			$week = new Carbon('now', $this->timezone);
632
+			$week->setWeekStartsAt($this->week_starts);
633 633
 			$this->start = $week->startOfWeek()->getTimestamp();
634
-		} elseif ( 'weeks_before' == $calendar_begins ) {
635
-			$week = new Carbon( 'now', $this->timezone );
636
-			$week->setWeekStartsAt( $this->week_starts );
637
-			$this->start = $week->startOfWeek()->subWeeks( $nth )->getTimestamp();
638
-		} elseif ( 'weeks_after' == $calendar_begins ) {
639
-			$week = new Carbon( 'now', $this->timezone );
640
-			$week->setWeekStartsAt( $this->week_starts );
641
-			$this->start = $week->startOfWeek()->addWeeks( $nth )->getTimestamp();
642
-		} elseif ( 'this_month' == $calendar_begins ) {
643
-			$this->start = Carbon::today( $this->timezone )->startOfMonth()->getTimeStamp();
644
-		} elseif ( 'months_before' == $calendar_begins ) {
645
-			$this->start = Carbon::today( $this->timezone )->subMonths( $nth )->startOfMonth()->getTimeStamp();
646
-		} elseif ( 'months_after' == $calendar_begins ) {
647
-			$this->start = Carbon::today( $this->timezone )->addMonths( $nth )->startOfMonth()->getTimeStamp();
648
-		} elseif ( 'this_year' == $calendar_begins ) {
649
-			$this->start = Carbon::today( $this->timezone )->startOfYear()->getTimestamp();
650
-		} elseif ( 'years_before' == $calendar_begins ) {
651
-			$this->start = Carbon::today( $this->timezone )->subYears( $nth )->startOfYear()->getTimeStamp();
652
-		} elseif ( 'years_after' == $calendar_begins ) {
653
-			$this->start = Carbon::today( $this->timezone )->addYears( $nth )->startOfYear()->getTimeStamp();
654
-		} elseif ( 'custom_date' == $calendar_begins ) {
655
-			if ( $date = get_post_meta( $this->id, '_calendar_begins_custom_date', true ) ) {
656
-				$this->start = Carbon::createFromFormat( 'Y-m-d', esc_attr( $date ), $this->timezone )->setTimezone( $this->timezone )->startOfDay()->getTimestamp();
634
+		} elseif ('weeks_before' == $calendar_begins) {
635
+			$week = new Carbon('now', $this->timezone);
636
+			$week->setWeekStartsAt($this->week_starts);
637
+			$this->start = $week->startOfWeek()->subWeeks($nth)->getTimestamp();
638
+		} elseif ('weeks_after' == $calendar_begins) {
639
+			$week = new Carbon('now', $this->timezone);
640
+			$week->setWeekStartsAt($this->week_starts);
641
+			$this->start = $week->startOfWeek()->addWeeks($nth)->getTimestamp();
642
+		} elseif ('this_month' == $calendar_begins) {
643
+			$this->start = Carbon::today($this->timezone)->startOfMonth()->getTimeStamp();
644
+		} elseif ('months_before' == $calendar_begins) {
645
+			$this->start = Carbon::today($this->timezone)->subMonths($nth)->startOfMonth()->getTimeStamp();
646
+		} elseif ('months_after' == $calendar_begins) {
647
+			$this->start = Carbon::today($this->timezone)->addMonths($nth)->startOfMonth()->getTimeStamp();
648
+		} elseif ('this_year' == $calendar_begins) {
649
+			$this->start = Carbon::today($this->timezone)->startOfYear()->getTimestamp();
650
+		} elseif ('years_before' == $calendar_begins) {
651
+			$this->start = Carbon::today($this->timezone)->subYears($nth)->startOfYear()->getTimeStamp();
652
+		} elseif ('years_after' == $calendar_begins) {
653
+			$this->start = Carbon::today($this->timezone)->addYears($nth)->startOfYear()->getTimeStamp();
654
+		} elseif ('custom_date' == $calendar_begins) {
655
+			if ($date = get_post_meta($this->id, '_calendar_begins_custom_date', true)) {
656
+				$this->start = Carbon::createFromFormat('Y-m-d', esc_attr($date), $this->timezone)->setTimezone($this->timezone)->startOfDay()->getTimestamp();
657 657
 			}
658 658
 		}
659 659
 	}
@@ -665,8 +665,8 @@  discard block
 block discarded – undo
665 665
 	 *
666 666
 	 * @param int $timestamp
667 667
 	 */
668
-	public function set_end( $timestamp = 0 ) {
669
-		$latest = is_int( $timestamp ) && $timestamp !== 0 ? $timestamp : $this->latest_event;
668
+	public function set_end($timestamp = 0) {
669
+		$latest = is_int($timestamp) && $timestamp !== 0 ? $timestamp : $this->latest_event;
670 670
 		$this->end = $latest > $this->start ? $latest : $this->start;
671 671
 	}
672 672
 
@@ -677,14 +677,14 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @param string|bool $static
679 679
 	 */
680
-	public function set_static( $static = '' ) {
680
+	public function set_static($static = '') {
681 681
 
682
-		if ( ! empty( $static ) && is_bool( $static ) ) {
682
+		if ( ! empty($static) && is_bool($static)) {
683 683
 			$this->static = $static;
684 684
 			return;
685 685
 		}
686 686
 
687
-		if ( 'yes' == get_post_meta( $this->id, '_calendar_is_static', true ) ) {
687
+		if ('yes' == get_post_meta($this->id, '_calendar_is_static', true)) {
688 688
 			$this->static = true;
689 689
 			return;
690 690
 		}
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 	 *
713 713
 	 * @return Calendar_View
714 714
 	 */
715
-	abstract public function get_view( $view = '' );
715
+	abstract public function get_view($view = '');
716 716
 
717 717
 	/**
718 718
 	 * Get event HTML parsed by template.
@@ -724,11 +724,11 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @return string
726 726
 	 */
727
-	public function get_event_html( Event $event, $template = '' ) {
728
-		$event_builder = new Event_Builder( $event, $this );
727
+	public function get_event_html(Event $event, $template = '') {
728
+		$event_builder = new Event_Builder($event, $this);
729 729
 		// Use the event template to parse tags; if empty, fallback to calendar post content.
730
-		$template = empty( $template ) ? ( empty( $event->template ) ? $this->events_template : $event->template ) : $template;
731
-		return $event_builder->parse_event_template_tags( $template );
730
+		$template = empty($template) ? (empty($event->template) ? $this->events_template : $event->template) : $template;
731
+		return $event_builder->parse_event_template_tags($template);
732 732
 	}
733 733
 
734 734
 	/**
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 	 *
741 741
 	 * @return string
742 742
 	 */
743
-	public function get_add_to_gcal_url( Event $event ) {
743
+	public function get_add_to_gcal_url(Event $event) {
744 744
 		$base_url = 'https://calendar.google.com/calendar/render';
745 745
 		// Was https://www.google.com/calendar/render
746 746
 
@@ -748,30 +748,30 @@  discard block
 block discarded – undo
748 748
 		// &dates=20160504T110000/20160504T170000
749 749
 		// No "Z"s tacked on to preserve source timezone.
750 750
 		// All day events remove time component, but need to add a full day to show up correctly.
751
-		$is_all_day     = ( true == $event->whole_day );
751
+		$is_all_day     = (true == $event->whole_day);
752 752
 		$gcal_dt_format = $is_all_day ? 'Ymd' : 'Ymd\THi00';
753
-		$gcal_begin_dt  = $event->start_dt->format( $gcal_dt_format );
753
+		$gcal_begin_dt  = $event->start_dt->format($gcal_dt_format);
754 754
 		$end_dt_raw     = $is_all_day ? $event->end_dt->addDay() : $event->end_dt;
755
-		$gcal_end_dt    = $end_dt_raw->format( $gcal_dt_format );
756
-		$gcal_dt_string = $gcal_begin_dt . '/' . $gcal_end_dt;
755
+		$gcal_end_dt    = $end_dt_raw->format($gcal_dt_format);
756
+		$gcal_dt_string = $gcal_begin_dt.'/'.$gcal_end_dt;
757 757
 
758 758
 		// "details" (description) should work even when blank.
759 759
 		// "location" (address) should work with an address, just a name or blank.
760 760
 		$params = array(
761 761
 			'action'   => 'TEMPLATE',
762
-			'text'     => urlencode( strip_tags( $event->title ) ),
762
+			'text'     => urlencode(strip_tags($event->title)),
763 763
 			'dates'    => $gcal_dt_string,
764
-			'details'  => urlencode( $event->description ),
765
-			'location' => urlencode( $event->start_location['address'] ),
764
+			'details'  => urlencode($event->description),
765
+			'location' => urlencode($event->start_location['address']),
766 766
 			'trp'      => 'false',
767 767
 		);
768 768
 
769 769
 		// "ctz" (timezone) arg should be included unless all-day OR 'UTC'.
770
-		if ( ! $is_all_day && ( 'UTC' !== $event->timezone ) ) {
771
-			$params['ctz'] = urlencode( $event->timezone );
770
+		if ( ! $is_all_day && ('UTC' !== $event->timezone)) {
771
+			$params['ctz'] = urlencode($event->timezone);
772 772
 		}
773 773
 
774
-		$url = add_query_arg( $params, $base_url );
774
+		$url = add_query_arg($params, $base_url);
775 775
 
776 776
 		return $url;
777 777
 	}
@@ -783,56 +783,56 @@  discard block
 block discarded – undo
783 783
 	 *
784 784
 	 * @param string $view The calendar view to display.
785 785
 	 */
786
-	public function html( $view = '' ) {
786
+	public function html($view = '') {
787 787
 
788
-		$view = empty( $view ) ? $this->view : $this->get_view( $view );
788
+		$view = empty($view) ? $this->view : $this->get_view($view);
789 789
 
790
-		if ( $view instanceof Calendar_View ) {
790
+		if ($view instanceof Calendar_View) {
791 791
 
792
-			if ( ! empty( $this->errors ) ) {
792
+			if ( ! empty($this->errors)) {
793 793
 
794
-				if ( current_user_can( 'manage_options' )  ) {
794
+				if (current_user_can('manage_options')) {
795 795
 					echo '<pre><code>';
796
-					foreach ( $this->errors as $error ) { echo $error; }
796
+					foreach ($this->errors as $error) { echo $error; }
797 797
 					echo '</code></pre>';
798 798
 				}
799 799
 
800 800
 			} else {
801 801
 
802 802
 				// Get a CSS class from the class name of the calendar view (minus namespace part).
803
-				$view_name  = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( get_class( $view ) ) ) ) );
804
-				$view_class = substr( $view_name, strrpos( $view_name, '\\' ) + 1 );
803
+				$view_name  = implode('-', array_map('lcfirst', explode('_', strtolower(get_class($view)))));
804
+				$view_class = substr($view_name, strrpos($view_name, '\\') + 1);
805 805
 
806
-				$calendar_class = trim( implode( ' simcal-', apply_filters( 'simcal_calendar_class', array(
806
+				$calendar_class = trim(implode(' simcal-', apply_filters('simcal_calendar_class', array(
807 807
 					'simcal-calendar',
808 808
 					$this->type,
809 809
 					$view_class,
810
-				), $this->id ) ) );
811
-
812
-				echo '<div class="' . $calendar_class . '" '
813
-									. 'data-calendar-id="'    . $this->id . '" '
814
-									. 'data-timezone="'       . $this->timezone . '" '
815
-									. 'data-offset="'         . $this->offset . '" '
816
-									. 'data-week-start="'     . $this->week_starts . '" '
817
-									. 'data-calendar-start="' . $this->start .'" '
818
-									. 'data-calendar-end="'   . $this->end . '" '
819
-									. 'data-events-first="'   . $this->earliest_event .'" '
820
-									. 'data-events-last="'    . $this->latest_event . '"'
810
+				), $this->id)));
811
+
812
+				echo '<div class="'.$calendar_class.'" '
813
+									. 'data-calendar-id="'.$this->id.'" '
814
+									. 'data-timezone="'.$this->timezone.'" '
815
+									. 'data-offset="'.$this->offset.'" '
816
+									. 'data-week-start="'.$this->week_starts.'" '
817
+									. 'data-calendar-start="'.$this->start.'" '
818
+									. 'data-calendar-end="'.$this->end.'" '
819
+									. 'data-events-first="'.$this->earliest_event.'" '
820
+									. 'data-events-last="'.$this->latest_event.'"'
821 821
 									. '>';
822 822
 
823
-				do_action( 'simcal_calendar_html_before', $this->id );
823
+				do_action('simcal_calendar_html_before', $this->id);
824 824
 
825 825
 				$view->html();
826 826
 
827
-				do_action( 'simcal_calendar_html_after', $this->id );
827
+				do_action('simcal_calendar_html_after', $this->id);
828 828
 
829 829
 				//$settings = get_option( 'simple-calendar_settings_calendars' );
830
-				$poweredby = get_post_meta( $this->id, '_poweredby', true );
830
+				$poweredby = get_post_meta($this->id, '_poweredby', true);
831 831
 
832
-				if ( 'yes' == $poweredby ) {
832
+				if ('yes' == $poweredby) {
833 833
 					$align = is_rtl() ? 'left' : 'right';
834
-					echo '<small class="simcal-powered simcal-align-' . $align .'">' .
835
-					     sprintf( __( 'Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events' ), simcal_get_url( 'home' ) ) .
834
+					echo '<small class="simcal-powered simcal-align-'.$align.'">'.
835
+					     sprintf(__('Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events'), simcal_get_url('home')).
836 836
 					     '</small>';
837 837
 				}
838 838
 
Please login to merge, or discard this patch.
includes/events/event.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 use Carbon\Carbon;
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -239,35 +239,35 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @param array $event
241 241
 	 */
242
-	public function __construct( array $event ) {
242
+	public function __construct(array $event) {
243 243
 
244 244
 		/* ================= *
245 245
 		 * Event Identifiers *
246 246
 		 * ================= */
247 247
 
248 248
 		// Event unique id.
249
-		if ( ! empty( $event['uid'] ) ) {
250
-			$this->uid = esc_attr( $event['uid'] );
249
+		if ( ! empty($event['uid'])) {
250
+			$this->uid = esc_attr($event['uid']);
251 251
 		}
252 252
 
253 253
 		// iCal ID
254
-		if ( ! empty( $event['ical_id'] ) ) {
255
-			$this->ical_id = esc_attr( $event['ical_id'] );
254
+		if ( ! empty($event['ical_id'])) {
255
+			$this->ical_id = esc_attr($event['ical_id']);
256 256
 		}
257 257
 
258 258
 		// Event source.
259
-		if ( ! empty( $event['source'] ) ) {
260
-			$this->source = esc_attr( $event['source'] );
259
+		if ( ! empty($event['source'])) {
260
+			$this->source = esc_attr($event['source']);
261 261
 		}
262 262
 
263 263
 		// Event parent calendar id.
264
-		if ( ! empty( $event['calendar'] ) ) {
265
-			$this->calendar = max( intval( $event['calendar'] ), 0 );
264
+		if ( ! empty($event['calendar'])) {
265
+			$this->calendar = max(intval($event['calendar']), 0);
266 266
 		}
267 267
 
268 268
 		// Event parent calendar timezone.
269
-		if ( ! empty( $event['timezone'] ) ) {
270
-			$this->timezone = esc_attr( $event['timezone'] );
269
+		if ( ! empty($event['timezone'])) {
270
+			$this->timezone = esc_attr($event['timezone']);
271 271
 		}
272 272
 
273 273
 		/* ============= *
@@ -275,23 +275,23 @@  discard block
 block discarded – undo
275 275
 		 * ============= */
276 276
 
277 277
 		// Event title.
278
-		if ( ! empty( $event['title'] ) ) {
279
-			$this->title = esc_html( $event['title'] );
278
+		if ( ! empty($event['title'])) {
279
+			$this->title = esc_html($event['title']);
280 280
 		}
281 281
 
282 282
 		// Event description.
283
-		if ( ! empty( $event['description'] ) ) {
284
-			$this->description = wp_kses_post( $event['description'] );
283
+		if ( ! empty($event['description'])) {
284
+			$this->description = wp_kses_post($event['description']);
285 285
 		}
286 286
 
287 287
 		// Event link URL.
288
-		if ( ! empty( $event['link'] ) ) {
289
-			$this->link = esc_url_raw( $event['link'] );
288
+		if ( ! empty($event['link'])) {
289
+			$this->link = esc_url_raw($event['link']);
290 290
 		}
291 291
 
292 292
 		// Event visibility.
293
-		if ( ! empty( $event['visibility'] ) ) {
294
-			$this->visibility = esc_attr( $event['visibility'] );
293
+		if ( ! empty($event['visibility'])) {
294
+			$this->visibility = esc_attr($event['visibility']);
295 295
 			$this->public = $this->visibility == 'public' ? true : false;
296 296
 		}
297 297
 
@@ -299,34 +299,34 @@  discard block
 block discarded – undo
299 299
 		 * Event Start *
300 300
 		 * =========== */
301 301
 
302
-		if ( ! empty( $event['start'] ) ) {
303
-			$this->start = is_numeric( $event['start'] ) ? intval( $event['start'] ) : 0;
304
-			if ( ! empty( $event['start_utc'] ) ) {
305
-				$this->start_utc = is_numeric( $event['start_utc'] ) ? intval( $event['start_utc'] ) : 0;
302
+		if ( ! empty($event['start'])) {
303
+			$this->start = is_numeric($event['start']) ? intval($event['start']) : 0;
304
+			if ( ! empty($event['start_utc'])) {
305
+				$this->start_utc = is_numeric($event['start_utc']) ? intval($event['start_utc']) : 0;
306 306
 			}
307
-			if ( ! empty( $event['start_timezone'] ) ) {
308
-				$this->start_timezone = esc_attr( $event['start_timezone'] );
307
+			if ( ! empty($event['start_timezone'])) {
308
+				$this->start_timezone = esc_attr($event['start_timezone']);
309 309
 			}
310
-			$this->start_dt = Carbon::createFromTimestamp( $this->start, $this->start_timezone );
311
-			$start_location = isset( $event['start_location'] ) ? $event['start_location'] : '';
312
-			$this->start_location = $this->esc_location( $start_location );
310
+			$this->start_dt = Carbon::createFromTimestamp($this->start, $this->start_timezone);
311
+			$start_location = isset($event['start_location']) ? $event['start_location'] : '';
312
+			$this->start_location = $this->esc_location($start_location);
313 313
 		}
314 314
 
315 315
 		/* ========= *
316 316
 		 * Event End *
317 317
 		 * ========= */
318 318
 
319
-		if ( ! empty( $event['end'] ) ) {
320
-			$this->end = is_numeric( $event['end'] ) ? intval( $event['end'] ): false;
321
-			if ( ! empty( $event['end_utc'] ) ) {
322
-				$this->end_utc = is_numeric( $event['end_utc'] ) ? intval( $event['end_utc'] ) : false;
319
+		if ( ! empty($event['end'])) {
320
+			$this->end = is_numeric($event['end']) ? intval($event['end']) : false;
321
+			if ( ! empty($event['end_utc'])) {
322
+				$this->end_utc = is_numeric($event['end_utc']) ? intval($event['end_utc']) : false;
323 323
 			}
324
-			if ( ! empty( $event['end_timezone'] ) ) {
325
-				$this->end_timezone = esc_attr( $event['end_timezone'] );
324
+			if ( ! empty($event['end_timezone'])) {
325
+				$this->end_timezone = esc_attr($event['end_timezone']);
326 326
 			}
327
-			$this->end_dt = Carbon::createFromTimestamp( $this->end, $this->end_timezone );
328
-			$end_location = isset( $event['end_location'] ) ? $event['end_location'] : '';
329
-			$this->end_location = $this->esc_location( $end_location );
327
+			$this->end_dt = Carbon::createFromTimestamp($this->end, $this->end_timezone);
328
+			$end_location = isset($event['end_location']) ? $event['end_location'] : '';
329
+			$this->end_location = $this->esc_location($end_location);
330 330
 		}
331 331
 
332 332
 		/* ================== *
@@ -334,18 +334,18 @@  discard block
 block discarded – undo
334 334
 		 * ================== */
335 335
 
336 336
 		// Whole day event.
337
-		if ( ! empty( $event['whole_day'] ) ) {
338
-			$this->whole_day = true === $event['whole_day'] ? true: false;
337
+		if ( ! empty($event['whole_day'])) {
338
+			$this->whole_day = true === $event['whole_day'] ? true : false;
339 339
 		}
340 340
 
341 341
 		// Multi day event.
342
-		if ( ! empty( $event['multiple_days'] ) ) {
343
-			$this->multiple_days = max( absint( $event['multiple_days'] ), 1 );
342
+		if ( ! empty($event['multiple_days'])) {
343
+			$this->multiple_days = max(absint($event['multiple_days']), 1);
344 344
 		}
345 345
 
346 346
 		// Event recurrence.
347
-		if ( isset( $event['recurrence'] ) ) {
348
-			$this->recurrence = ! empty( $event['recurrence'] ) ? $event['recurrence'] : false;
347
+		if (isset($event['recurrence'])) {
348
+			$this->recurrence = ! empty($event['recurrence']) ? $event['recurrence'] : false;
349 349
 		}
350 350
 
351 351
 		/* ========== *
@@ -353,18 +353,18 @@  discard block
 block discarded – undo
353 353
 		 * ========== */
354 354
 
355 355
 		// Event has venue(s).
356
-		if ( $this->start_location['venue'] || $this->end_location['venue'] ) {
356
+		if ($this->start_location['venue'] || $this->end_location['venue']) {
357 357
 			$this->venue = true;
358 358
 		}
359 359
 
360 360
 		// Event meta.
361
-		if ( ! empty( $event['meta'] ) ) {
362
-			$this->meta = is_array( $event['meta'] ) ? $event['meta'] : array();
361
+		if ( ! empty($event['meta'])) {
362
+			$this->meta = is_array($event['meta']) ? $event['meta'] : array();
363 363
 		}
364 364
 
365 365
 		// Event template.
366
-		if ( ! empty( $event['template'] ) ) {
367
-			$this->template = wp_kses_post( $event['template'] );
366
+		if ( ! empty($event['template'])) {
367
+			$this->template = wp_kses_post($event['template']);
368 368
 		}
369 369
 
370 370
 	}
@@ -379,27 +379,27 @@  discard block
 block discarded – undo
379 379
 	 *
380 380
 	 * @return array
381 381
 	 */
382
-	private function esc_location( $var = '' ) {
382
+	private function esc_location($var = '') {
383 383
 
384 384
 		$location = array();
385 385
 
386
-		if ( is_string( $var ) ) {
386
+		if (is_string($var)) {
387 387
 			$var = array(
388 388
 				'name'    => $var,
389 389
 				'address' => $var,
390 390
 			);
391
-		} elseif ( is_bool( $var ) || is_null( $var ) ) {
391
+		} elseif (is_bool($var) || is_null($var)) {
392 392
 			$var = array();
393 393
 		} else {
394 394
 			$var = (array) $var;
395 395
 		}
396 396
 
397
-		$location['name']    = isset( $var['name'] )    ? esc_attr( strip_tags( $var['name'] ) ) : '';
398
-		$location['address'] = isset( $var['address'] ) ? esc_attr( strip_tags( $var['address'] ) ) : '';
399
-		$location['lat']     = isset( $var['lat'] )     ? $this->esc_coordinate( $var['lat'] ) : 0;
400
-		$location['lng']     = isset( $var['lng'] )     ? $this->esc_coordinate( $var['lng'] ) : 0;
397
+		$location['name']    = isset($var['name']) ? esc_attr(strip_tags($var['name'])) : '';
398
+		$location['address'] = isset($var['address']) ? esc_attr(strip_tags($var['address'])) : '';
399
+		$location['lat']     = isset($var['lat']) ? $this->esc_coordinate($var['lat']) : 0;
400
+		$location['lng']     = isset($var['lng']) ? $this->esc_coordinate($var['lng']) : 0;
401 401
 
402
-		if ( ! empty( $location['name'] ) || ! empty( $location['address'] ) ) {
402
+		if ( ! empty($location['name']) || ! empty($location['address'])) {
403 403
 			$location['venue'] = true;
404 404
 		} else {
405 405
 			$location['venue'] = false;
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 *
419 419
 	 * @return int|float
420 420
 	 */
421
-	private function esc_coordinate( $latlng = 0 ) {
422
-		return is_numeric( $latlng ) ? floatval( $latlng ) : 0;
421
+	private function esc_coordinate($latlng = 0) {
422
+		return is_numeric($latlng) ? floatval($latlng) : 0;
423 423
 	}
424 424
 
425 425
 	/**
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
 	 *
433 433
 	 * @return bool
434 434
 	 */
435
-	public function set_timezone( $tz ) {
436
-		if ( in_array( $tz, timezone_identifiers_list() ) ) {
435
+	public function set_timezone($tz) {
436
+		if (in_array($tz, timezone_identifiers_list())) {
437 437
 			$this->timezone = $tz;
438 438
 			return true;
439 439
 		}
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	 * @return bool
460 460
 	 */
461 461
 	public function starts_today() {
462
-		return $this->start_dt->setTimezone( $this->timezone )->isToday();
462
+		return $this->start_dt->setTimezone($this->timezone)->isToday();
463 463
 	}
464 464
 
465 465
 	/**
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	 * @return bool
471 471
 	 */
472 472
 	public function ends_today() {
473
-		return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isToday() : true;
473
+		return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isToday() : true;
474 474
 	}
475 475
 
476 476
 	/**
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 	 * @return bool
482 482
 	 */
483 483
 	public function starts_tomorrow() {
484
-		return $this->start_dt->setTimezone( $this->timezone )->isTomorrow();
484
+		return $this->start_dt->setTimezone($this->timezone)->isTomorrow();
485 485
 	}
486 486
 
487 487
 	/**
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	 * @return bool
493 493
 	 */
494 494
 	public function ends_tomorrow() {
495
-		return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isTomorrow() : false;
495
+		return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isTomorrow() : false;
496 496
 	}
497 497
 
498 498
 	/**
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 	 * @return bool
504 504
 	 */
505 505
 	public function started_yesterday() {
506
-		return $this->start_dt->setTimezone( $this->timezone )->isYesterday();
506
+		return $this->start_dt->setTimezone($this->timezone)->isYesterday();
507 507
 	}
508 508
 
509 509
 	/**
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 	 * @return bool
515 515
 	 */
516 516
 	public function ended_yesterday() {
517
-		return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isYesterday() : false;
517
+		return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isYesterday() : false;
518 518
 	}
519 519
 
520 520
 	/**
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 	 * @return bool
526 526
 	 */
527 527
 	public function starts_future() {
528
-		return $this->start_dt->setTimezone( $this->timezone )->isFuture();
528
+		return $this->start_dt->setTimezone($this->timezone)->isFuture();
529 529
 	}
530 530
 
531 531
 	/**
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	 * @return bool
537 537
 	 */
538 538
 	public function ends_future() {
539
-		return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isFuture() : false;
539
+		return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isFuture() : false;
540 540
 	}
541 541
 
542 542
 	/**
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	 * @return bool
548 548
 	 */
549 549
 	public function started_past() {
550
-		return $this->start_dt->setTimezone( $this->timezone )->isPast();
550
+		return $this->start_dt->setTimezone($this->timezone)->isPast();
551 551
 	}
552 552
 
553 553
 	/**
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	 * @return bool
559 559
 	 */
560 560
 	public function ended_past() {
561
-		return ! is_null( $this->end_dt ) ? $this->end_dt->setTimezone( $this->timezone )->isPast() : false;
561
+		return ! is_null($this->end_dt) ? $this->end_dt->setTimezone($this->timezone)->isPast() : false;
562 562
 	}
563 563
 
564 564
 	/**
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
 	 *
571 571
 	 * @return string
572 572
 	 */
573
-	public function get_color( $default = '' ) {
574
-		if ( isset( $this->meta['color'] ) ) {
575
-			return ! empty( $this->meta['color'] ) ? esc_attr( $this->meta['color'] ) : $default;
573
+	public function get_color($default = '') {
574
+		if (isset($this->meta['color'])) {
575
+			return ! empty($this->meta['color']) ? esc_attr($this->meta['color']) : $default;
576 576
 		}
577 577
 		return $default;
578 578
 	}
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 	 * @return array
586 586
 	 */
587 587
 	public function get_attachments() {
588
-		return isset( $this->meta['attachments'] ) ? $this->meta['attachments'] : array();
588
+		return isset($this->meta['attachments']) ? $this->meta['attachments'] : array();
589 589
 	}
590 590
 
591 591
 	/**
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	 * @return array
597 597
 	 */
598 598
 	public function get_attendees() {
599
-		return isset( $this->meta['attendees'] ) ? $this->meta['attendees'] : array();
599
+		return isset($this->meta['attendees']) ? $this->meta['attendees'] : array();
600 600
 	}
601 601
 
602 602
 	/**
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	 * @return array
608 608
 	 */
609 609
 	public function get_organizer() {
610
-		return isset( $this->meta['organizer'] ) ? $this->meta['organizer'] : array();
610
+		return isset($this->meta['organizer']) ? $this->meta['organizer'] : array();
611 611
 	}
612 612
 
613 613
 }
Please login to merge, or discard this patch.