@@ -784,8 +784,8 @@ |
||
784 | 784 | if ( 'yes' == $poweredby ) { |
785 | 785 | $align = is_rtl() ? 'left' : 'right'; |
786 | 786 | echo '<small class="simcal-powered simcal-align-' . $align .'">' . |
787 | - sprintf( __( 'Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events' ), simcal_get_url( 'home' ) ) . |
|
788 | - '</small>'; |
|
787 | + sprintf( __( 'Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events' ), simcal_get_url( 'home' ) ) . |
|
788 | + '</small>'; |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | echo '</div>'; |
@@ -11,7 +11,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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,58 +783,58 @@ discard block |
||
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 | - date_default_timezone_set( $this->timezone ); |
|
824 | - do_action( 'simcal_calendar_html_before', $this->id ); |
|
823 | + date_default_timezone_set($this->timezone); |
|
824 | + do_action('simcal_calendar_html_before', $this->id); |
|
825 | 825 | |
826 | 826 | $view->html(); |
827 | 827 | |
828 | - do_action( 'simcal_calendar_html_after', $this->id ); |
|
829 | - date_default_timezone_set( $this->site_timezone ); |
|
828 | + do_action('simcal_calendar_html_after', $this->id); |
|
829 | + date_default_timezone_set($this->site_timezone); |
|
830 | 830 | |
831 | 831 | //$settings = get_option( 'simple-calendar_settings_calendars' ); |
832 | - $poweredby = get_post_meta( $this->id, '_poweredby', true ); |
|
832 | + $poweredby = get_post_meta($this->id, '_poweredby', true); |
|
833 | 833 | |
834 | - if ( 'yes' == $poweredby ) { |
|
834 | + if ('yes' == $poweredby) { |
|
835 | 835 | $align = is_rtl() ? 'left' : 'right'; |
836 | - echo '<small class="simcal-powered simcal-align-' . $align .'">' . |
|
837 | - sprintf( __( 'Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events' ), simcal_get_url( 'home' ) ) . |
|
836 | + echo '<small class="simcal-powered simcal-align-'.$align.'">'. |
|
837 | + sprintf(__('Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events'), simcal_get_url('home')). |
|
838 | 838 | '</small>'; |
839 | 839 | } |
840 | 840 |