@@ -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,55 +609,55 @@ 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 | - $start_dt = Carbon::now( $this->timezone ); |
|
| 619 | + $start_dt = Carbon::now($this->timezone); |
|
| 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 | 624 | // Start date/time is sometimes 1 hour too early, which puts in the previous month. |
| 625 | 625 | // Maybe due to daylight savings changes in different timezones? |
| 626 | 626 | // Adding 1 hour is hackish, but fixes this. |
| 627 | 627 | |
| 628 | - if ( 'today' == $calendar_begins ) { |
|
| 629 | - $start_dt = Carbon::today( $this->timezone )->addHour(); |
|
| 630 | - } elseif ( 'days_before' == $calendar_begins ) { |
|
| 631 | - $start_dt = Carbon::today( $this->timezone )->subDays( $nth )->addHour(); |
|
| 632 | - } elseif ( 'days_after' == $calendar_begins ) { |
|
| 633 | - $start_dt = Carbon::today( $this->timezone )->addDays( $nth )->addHour(); |
|
| 634 | - } elseif ( 'this_week' == $calendar_begins ) { |
|
| 635 | - $week = new Carbon( 'now', $this->timezone ); |
|
| 636 | - $week->setWeekStartsAt( $this->week_starts ); |
|
| 628 | + if ('today' == $calendar_begins) { |
|
| 629 | + $start_dt = Carbon::today($this->timezone)->addHour(); |
|
| 630 | + } elseif ('days_before' == $calendar_begins) { |
|
| 631 | + $start_dt = Carbon::today($this->timezone)->subDays($nth)->addHour(); |
|
| 632 | + } elseif ('days_after' == $calendar_begins) { |
|
| 633 | + $start_dt = Carbon::today($this->timezone)->addDays($nth)->addHour(); |
|
| 634 | + } elseif ('this_week' == $calendar_begins) { |
|
| 635 | + $week = new Carbon('now', $this->timezone); |
|
| 636 | + $week->setWeekStartsAt($this->week_starts); |
|
| 637 | 637 | $start_dt = $week->startOfWeek()->addHour(); |
| 638 | - } elseif ( 'weeks_before' == $calendar_begins ) { |
|
| 639 | - $week = new Carbon( 'now', $this->timezone ); |
|
| 640 | - $week->setWeekStartsAt( $this->week_starts ); |
|
| 641 | - $start_dt = $week->startOfWeek()->subWeeks( $nth )->addHour(); |
|
| 642 | - } elseif ( 'weeks_after' == $calendar_begins ) { |
|
| 643 | - $week = new Carbon( 'now', $this->timezone ); |
|
| 644 | - $week->setWeekStartsAt( $this->week_starts ); |
|
| 645 | - $start_dt = $week->startOfWeek()->addWeeks( $nth )->addHour(); |
|
| 646 | - } elseif ( 'this_month' == $calendar_begins ) { |
|
| 647 | - $start_dt = Carbon::today( $this->timezone )->startOfMonth()->addHour(); |
|
| 648 | - } elseif ( 'months_before' == $calendar_begins ) { |
|
| 649 | - $start_dt = Carbon::today( $this->timezone )->subMonths( $nth )->startOfMonth()->addHour(); |
|
| 650 | - } elseif ( 'months_after' == $calendar_begins ) { |
|
| 651 | - $start_dt = Carbon::today( $this->timezone )->addMonths( $nth )->startOfMonth()->addHour(); |
|
| 652 | - } elseif ( 'this_year' == $calendar_begins ) { |
|
| 653 | - $start_dt = Carbon::today( $this->timezone )->startOfYear()->addHour(); |
|
| 654 | - } elseif ( 'years_before' == $calendar_begins ) { |
|
| 655 | - $start_dt = Carbon::today( $this->timezone )->subYears( $nth )->startOfYear()->addHour(); |
|
| 656 | - } elseif ( 'years_after' == $calendar_begins ) { |
|
| 657 | - $start_dt = Carbon::today( $this->timezone )->addYears( $nth )->startOfYear()->addHour(); |
|
| 658 | - } elseif ( 'custom_date' == $calendar_begins ) { |
|
| 659 | - if ( $date = get_post_meta( $this->id, '_calendar_begins_custom_date', true ) ) { |
|
| 660 | - $start_dt = Carbon::createFromFormat( 'Y-m-d', esc_attr( $date ), $this->timezone )->setTimezone( $this->timezone )->startOfDay()->addHour(); |
|
| 638 | + } elseif ('weeks_before' == $calendar_begins) { |
|
| 639 | + $week = new Carbon('now', $this->timezone); |
|
| 640 | + $week->setWeekStartsAt($this->week_starts); |
|
| 641 | + $start_dt = $week->startOfWeek()->subWeeks($nth)->addHour(); |
|
| 642 | + } elseif ('weeks_after' == $calendar_begins) { |
|
| 643 | + $week = new Carbon('now', $this->timezone); |
|
| 644 | + $week->setWeekStartsAt($this->week_starts); |
|
| 645 | + $start_dt = $week->startOfWeek()->addWeeks($nth)->addHour(); |
|
| 646 | + } elseif ('this_month' == $calendar_begins) { |
|
| 647 | + $start_dt = Carbon::today($this->timezone)->startOfMonth()->addHour(); |
|
| 648 | + } elseif ('months_before' == $calendar_begins) { |
|
| 649 | + $start_dt = Carbon::today($this->timezone)->subMonths($nth)->startOfMonth()->addHour(); |
|
| 650 | + } elseif ('months_after' == $calendar_begins) { |
|
| 651 | + $start_dt = Carbon::today($this->timezone)->addMonths($nth)->startOfMonth()->addHour(); |
|
| 652 | + } elseif ('this_year' == $calendar_begins) { |
|
| 653 | + $start_dt = Carbon::today($this->timezone)->startOfYear()->addHour(); |
|
| 654 | + } elseif ('years_before' == $calendar_begins) { |
|
| 655 | + $start_dt = Carbon::today($this->timezone)->subYears($nth)->startOfYear()->addHour(); |
|
| 656 | + } elseif ('years_after' == $calendar_begins) { |
|
| 657 | + $start_dt = Carbon::today($this->timezone)->addYears($nth)->startOfYear()->addHour(); |
|
| 658 | + } elseif ('custom_date' == $calendar_begins) { |
|
| 659 | + if ($date = get_post_meta($this->id, '_calendar_begins_custom_date', true)) { |
|
| 660 | + $start_dt = Carbon::createFromFormat('Y-m-d', esc_attr($date), $this->timezone)->setTimezone($this->timezone)->startOfDay()->addHour(); |
|
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | |
@@ -671,8 +671,8 @@ discard block |
||
| 671 | 671 | * |
| 672 | 672 | * @param int $timestamp |
| 673 | 673 | */ |
| 674 | - public function set_end( $timestamp = 0 ) { |
|
| 675 | - $latest = is_int( $timestamp ) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
| 674 | + public function set_end($timestamp = 0) { |
|
| 675 | + $latest = is_int($timestamp) && $timestamp !== 0 ? $timestamp : $this->latest_event; |
|
| 676 | 676 | $this->end = $latest > $this->start ? $latest : $this->start; |
| 677 | 677 | } |
| 678 | 678 | |
@@ -683,14 +683,14 @@ discard block |
||
| 683 | 683 | * |
| 684 | 684 | * @param string|bool $static |
| 685 | 685 | */ |
| 686 | - public function set_static( $static = '' ) { |
|
| 686 | + public function set_static($static = '') { |
|
| 687 | 687 | |
| 688 | - if ( ! empty( $static ) && is_bool( $static ) ) { |
|
| 688 | + if ( ! empty($static) && is_bool($static)) { |
|
| 689 | 689 | $this->static = $static; |
| 690 | 690 | return; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - if ( 'yes' == get_post_meta( $this->id, '_calendar_is_static', true ) ) { |
|
| 693 | + if ('yes' == get_post_meta($this->id, '_calendar_is_static', true)) { |
|
| 694 | 694 | $this->static = true; |
| 695 | 695 | return; |
| 696 | 696 | } |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | * |
| 719 | 719 | * @return Calendar_View |
| 720 | 720 | */ |
| 721 | - abstract public function get_view( $view = '' ); |
|
| 721 | + abstract public function get_view($view = ''); |
|
| 722 | 722 | |
| 723 | 723 | /** |
| 724 | 724 | * Get event HTML parsed by template. |
@@ -730,11 +730,11 @@ discard block |
||
| 730 | 730 | * |
| 731 | 731 | * @return string |
| 732 | 732 | */ |
| 733 | - public function get_event_html( Event $event, $template = '' ) { |
|
| 734 | - $event_builder = new Event_Builder( $event, $this ); |
|
| 733 | + public function get_event_html(Event $event, $template = '') { |
|
| 734 | + $event_builder = new Event_Builder($event, $this); |
|
| 735 | 735 | // Use the event template to parse tags; if empty, fallback to calendar post content. |
| 736 | - $template = empty( $template ) ? ( empty( $event->template ) ? $this->events_template : $event->template ) : $template; |
|
| 737 | - return $event_builder->parse_event_template_tags( $template ); |
|
| 736 | + $template = empty($template) ? (empty($event->template) ? $this->events_template : $event->template) : $template; |
|
| 737 | + return $event_builder->parse_event_template_tags($template); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | * |
| 747 | 747 | * @return string |
| 748 | 748 | */ |
| 749 | - public function get_add_to_gcal_url( Event $event ) { |
|
| 749 | + public function get_add_to_gcal_url(Event $event) { |
|
| 750 | 750 | $base_url = 'https://calendar.google.com/calendar/render'; |
| 751 | 751 | // Was https://www.google.com/calendar/render |
| 752 | 752 | |
@@ -754,30 +754,30 @@ discard block |
||
| 754 | 754 | // &dates=20160504T110000/20160504T170000 |
| 755 | 755 | // No "Z"s tacked on to preserve source timezone. |
| 756 | 756 | // All day events remove time component, but need to add a full day to show up correctly. |
| 757 | - $is_all_day = ( true == $event->whole_day ); |
|
| 757 | + $is_all_day = (true == $event->whole_day); |
|
| 758 | 758 | $gcal_dt_format = $is_all_day ? 'Ymd' : 'Ymd\THi00'; |
| 759 | - $gcal_begin_dt = $event->start_dt->format( $gcal_dt_format ); |
|
| 759 | + $gcal_begin_dt = $event->start_dt->format($gcal_dt_format); |
|
| 760 | 760 | $end_dt_raw = $is_all_day ? $event->end_dt->addDay() : $event->end_dt; |
| 761 | - $gcal_end_dt = $end_dt_raw->format( $gcal_dt_format ); |
|
| 762 | - $gcal_dt_string = $gcal_begin_dt . '/' . $gcal_end_dt; |
|
| 761 | + $gcal_end_dt = $end_dt_raw->format($gcal_dt_format); |
|
| 762 | + $gcal_dt_string = $gcal_begin_dt.'/'.$gcal_end_dt; |
|
| 763 | 763 | |
| 764 | 764 | // "details" (description) should work even when blank. |
| 765 | 765 | // "location" (address) should work with an address, just a name or blank. |
| 766 | 766 | $params = array( |
| 767 | 767 | 'action' => 'TEMPLATE', |
| 768 | - 'text' => urlencode( strip_tags( $event->title ) ), |
|
| 768 | + 'text' => urlencode(strip_tags($event->title)), |
|
| 769 | 769 | 'dates' => $gcal_dt_string, |
| 770 | - 'details' => urlencode( $event->description ), |
|
| 771 | - 'location' => urlencode( $event->start_location['address'] ), |
|
| 770 | + 'details' => urlencode($event->description), |
|
| 771 | + 'location' => urlencode($event->start_location['address']), |
|
| 772 | 772 | 'trp' => 'false', |
| 773 | 773 | ); |
| 774 | 774 | |
| 775 | 775 | // "ctz" (timezone) arg should be included unless all-day OR 'UTC'. |
| 776 | - if ( ! $is_all_day && ( 'UTC' !== $event->timezone ) ) { |
|
| 777 | - $params['ctz'] = urlencode( $event->timezone ); |
|
| 776 | + if ( ! $is_all_day && ('UTC' !== $event->timezone)) { |
|
| 777 | + $params['ctz'] = urlencode($event->timezone); |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - $url = add_query_arg( $params, $base_url ); |
|
| 780 | + $url = add_query_arg($params, $base_url); |
|
| 781 | 781 | |
| 782 | 782 | return $url; |
| 783 | 783 | } |
@@ -789,56 +789,56 @@ discard block |
||
| 789 | 789 | * |
| 790 | 790 | * @param string $view The calendar view to display. |
| 791 | 791 | */ |
| 792 | - public function html( $view = '' ) { |
|
| 792 | + public function html($view = '') { |
|
| 793 | 793 | |
| 794 | - $view = empty( $view ) ? $this->view : $this->get_view( $view ); |
|
| 794 | + $view = empty($view) ? $this->view : $this->get_view($view); |
|
| 795 | 795 | |
| 796 | - if ( $view instanceof Calendar_View ) { |
|
| 796 | + if ($view instanceof Calendar_View) { |
|
| 797 | 797 | |
| 798 | - if ( ! empty( $this->errors ) ) { |
|
| 798 | + if ( ! empty($this->errors)) { |
|
| 799 | 799 | |
| 800 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 800 | + if (current_user_can('manage_options')) { |
|
| 801 | 801 | echo '<pre><code>'; |
| 802 | - foreach ( $this->errors as $error ) { echo $error; } |
|
| 802 | + foreach ($this->errors as $error) { echo $error; } |
|
| 803 | 803 | echo '</code></pre>'; |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | } else { |
| 807 | 807 | |
| 808 | 808 | // Get a CSS class from the class name of the calendar view (minus namespace part). |
| 809 | - $view_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( get_class( $view ) ) ) ) ); |
|
| 810 | - $view_class = substr( $view_name, strrpos( $view_name, '\\' ) + 1 ); |
|
| 809 | + $view_name = implode('-', array_map('lcfirst', explode('_', strtolower(get_class($view))))); |
|
| 810 | + $view_class = substr($view_name, strrpos($view_name, '\\') + 1); |
|
| 811 | 811 | |
| 812 | - $calendar_class = trim( implode( ' simcal-', apply_filters( 'simcal_calendar_class', array( |
|
| 812 | + $calendar_class = trim(implode(' simcal-', apply_filters('simcal_calendar_class', array( |
|
| 813 | 813 | 'simcal-calendar', |
| 814 | 814 | $this->type, |
| 815 | 815 | $view_class, |
| 816 | - ), $this->id ) ) ); |
|
| 817 | - |
|
| 818 | - echo '<div class="' . $calendar_class . '" ' |
|
| 819 | - . 'data-calendar-id="' . $this->id . '" ' |
|
| 820 | - . 'data-timezone="' . $this->timezone . '" ' |
|
| 821 | - . 'data-offset="' . $this->offset . '" ' |
|
| 822 | - . 'data-week-start="' . $this->week_starts . '" ' |
|
| 823 | - . 'data-calendar-start="' . $this->start .'" ' |
|
| 824 | - . 'data-calendar-end="' . $this->end . '" ' |
|
| 825 | - . 'data-events-first="' . $this->earliest_event .'" ' |
|
| 826 | - . 'data-events-last="' . $this->latest_event . '"' |
|
| 816 | + ), $this->id))); |
|
| 817 | + |
|
| 818 | + echo '<div class="'.$calendar_class.'" ' |
|
| 819 | + . 'data-calendar-id="'.$this->id.'" ' |
|
| 820 | + . 'data-timezone="'.$this->timezone.'" ' |
|
| 821 | + . 'data-offset="'.$this->offset.'" ' |
|
| 822 | + . 'data-week-start="'.$this->week_starts.'" ' |
|
| 823 | + . 'data-calendar-start="'.$this->start.'" ' |
|
| 824 | + . 'data-calendar-end="'.$this->end.'" ' |
|
| 825 | + . 'data-events-first="'.$this->earliest_event.'" ' |
|
| 826 | + . 'data-events-last="'.$this->latest_event.'"' |
|
| 827 | 827 | . '>'; |
| 828 | 828 | |
| 829 | - do_action( 'simcal_calendar_html_before', $this->id ); |
|
| 829 | + do_action('simcal_calendar_html_before', $this->id); |
|
| 830 | 830 | |
| 831 | 831 | $view->html(); |
| 832 | 832 | |
| 833 | - do_action( 'simcal_calendar_html_after', $this->id ); |
|
| 833 | + do_action('simcal_calendar_html_after', $this->id); |
|
| 834 | 834 | |
| 835 | 835 | //$settings = get_option( 'simple-calendar_settings_calendars' ); |
| 836 | - $poweredby = get_post_meta( $this->id, '_poweredby', true ); |
|
| 836 | + $poweredby = get_post_meta($this->id, '_poweredby', true); |
|
| 837 | 837 | |
| 838 | - if ( 'yes' == $poweredby ) { |
|
| 838 | + if ('yes' == $poweredby) { |
|
| 839 | 839 | $align = is_rtl() ? 'left' : 'right'; |
| 840 | - echo '<small class="simcal-powered simcal-align-' . $align .'">' . |
|
| 841 | - sprintf( __( 'Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events' ), simcal_get_url( 'home' ) ) . |
|
| 840 | + echo '<small class="simcal-powered simcal-align-'.$align.'">'. |
|
| 841 | + sprintf(__('Powered by <a href="%s" target="_blank">Simple Calendar</a>', 'google-calendar-events'), simcal_get_url('home')). |
|
| 842 | 842 | '</small>'; |
| 843 | 843 | } |
| 844 | 844 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | namespace SimpleCalendar\Calendars\Admin; |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() { |
| 26 | 26 | |
| 27 | - if ( simcal_is_admin_screen() !== false ) { |
|
| 28 | - add_action( 'simcal_settings_meta_calendar_panel', array( $this, 'add_settings_meta_calendar_panel' ), 10, 1 ); |
|
| 27 | + if (simcal_is_admin_screen() !== false) { |
|
| 28 | + add_action('simcal_settings_meta_calendar_panel', array($this, 'add_settings_meta_calendar_panel'), 10, 1); |
|
| 29 | 29 | } |
| 30 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
| 30 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -76,47 +76,47 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @param int $post_id |
| 78 | 78 | */ |
| 79 | - public function add_settings_meta_calendar_panel( $post_id ) { |
|
| 79 | + public function add_settings_meta_calendar_panel($post_id) { |
|
| 80 | 80 | |
| 81 | 81 | ?> |
| 82 | 82 | <table id="default-calendar-settings"> |
| 83 | 83 | <thead> |
| 84 | - <tr><th colspan="2"><?php _e( 'Default Calendar', 'google-calendar-events' ); ?></th></tr> |
|
| 84 | + <tr><th colspan="2"><?php _e('Default Calendar', 'google-calendar-events'); ?></th></tr> |
|
| 85 | 85 | </thead> |
| 86 | 86 | <tbody class="simcal-panel-section"> |
| 87 | 87 | |
| 88 | 88 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
| 89 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Event Bubbles', 'google-calendar-events' ); ?></label></th> |
|
| 89 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Event Bubbles', 'google-calendar-events'); ?></label></th> |
|
| 90 | 90 | <td> |
| 91 | 91 | <?php |
| 92 | 92 | |
| 93 | - $bubbles = get_post_meta( $post_id, '_default_calendar_event_bubble_trigger', true ); |
|
| 93 | + $bubbles = get_post_meta($post_id, '_default_calendar_event_bubble_trigger', true); |
|
| 94 | 94 | |
| 95 | - simcal_print_field( array( |
|
| 95 | + simcal_print_field(array( |
|
| 96 | 96 | 'type' => 'radio', |
| 97 | 97 | 'inline' => 'inline', |
| 98 | 98 | 'name' => '_default_calendar_event_bubble_trigger', |
| 99 | 99 | 'id' => '_default_calendar_event_bubble_trigger', |
| 100 | - 'tooltip' => __( 'Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events' ), |
|
| 100 | + 'tooltip' => __('Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events'), |
|
| 101 | 101 | 'value' => $bubbles ? $bubbles : 'hover', |
| 102 | 102 | 'default' => 'hover', |
| 103 | 103 | 'options' => array( |
| 104 | - 'click' => __( 'Click', 'google-calendar-events' ), |
|
| 105 | - 'hover' => __( 'Hover', 'google-calendar-events' ), |
|
| 104 | + 'click' => __('Click', 'google-calendar-events'), |
|
| 105 | + 'hover' => __('Hover', 'google-calendar-events'), |
|
| 106 | 106 | ), |
| 107 | - ) ); |
|
| 107 | + )); |
|
| 108 | 108 | |
| 109 | 109 | ?> |
| 110 | 110 | </td> |
| 111 | 111 | </tr> |
| 112 | 112 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
| 113 | - <th><label for="_default_calendar_trim_titles"><?php _e( 'Trim Event Titles', 'google-calendar-events' ); ?></label></th> |
|
| 113 | + <th><label for="_default_calendar_trim_titles"><?php _e('Trim Event Titles', 'google-calendar-events'); ?></label></th> |
|
| 114 | 114 | <td> |
| 115 | 115 | <?php |
| 116 | 116 | |
| 117 | - $trim = get_post_meta( $post_id, '_default_calendar_trim_titles', true ); |
|
| 117 | + $trim = get_post_meta($post_id, '_default_calendar_trim_titles', true); |
|
| 118 | 118 | |
| 119 | - simcal_print_field( array( |
|
| 119 | + simcal_print_field(array( |
|
| 120 | 120 | 'type' => 'checkbox', |
| 121 | 121 | 'name' => '_default_calendar_trim_titles', |
| 122 | 122 | 'id' => '_default_calendar_trim_titles', |
@@ -127,34 +127,34 @@ discard block |
||
| 127 | 127 | 'attributes' => array( |
| 128 | 128 | 'data-show-next-if-value' => 'yes', |
| 129 | 129 | ), |
| 130 | - ) ); |
|
| 130 | + )); |
|
| 131 | 131 | |
| 132 | - simcal_print_field( array( |
|
| 132 | + simcal_print_field(array( |
|
| 133 | 133 | 'type' => 'standard', |
| 134 | 134 | 'subtype' => 'number', |
| 135 | 135 | 'name' => '_default_calendar_trim_titles_chars', |
| 136 | 136 | 'id' => '_default_calendar_trim_titles_chars', |
| 137 | - 'tooltip' => __( 'Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events' ), |
|
| 137 | + 'tooltip' => __('Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events'), |
|
| 138 | 138 | 'class' => array( |
| 139 | 139 | 'simcal-field-tiny', |
| 140 | 140 | ), |
| 141 | - 'value' => 'yes' == $trim ? strval( max( absint( get_post_meta( $post_id, '_default_calendar_trim_titles_chars', true ) ), 1 ) ) : '20', |
|
| 141 | + 'value' => 'yes' == $trim ? strval(max(absint(get_post_meta($post_id, '_default_calendar_trim_titles_chars', true)), 1)) : '20', |
|
| 142 | 142 | 'attributes' => array( |
| 143 | 143 | 'min' => '1', |
| 144 | 144 | ), |
| 145 | - ) ); |
|
| 145 | + )); |
|
| 146 | 146 | |
| 147 | 147 | ?> |
| 148 | 148 | </td> |
| 149 | 149 | </tr> |
| 150 | 150 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
| 151 | - <th><label for="_default_calendar_list_grouped_span"><?php _e( 'Span', 'google-calendar-events' ); ?></label></th> |
|
| 151 | + <th><label for="_default_calendar_list_grouped_span"><?php _e('Span', 'google-calendar-events'); ?></label></th> |
|
| 152 | 152 | <td> |
| 153 | 153 | <?php |
| 154 | 154 | |
| 155 | - $list_span = max( absint( get_post_meta( $post_id, '_default_calendar_list_range_span', true ) ), 1 ); |
|
| 155 | + $list_span = max(absint(get_post_meta($post_id, '_default_calendar_list_range_span', true)), 1); |
|
| 156 | 156 | |
| 157 | - simcal_print_field( array( |
|
| 157 | + simcal_print_field(array( |
|
| 158 | 158 | 'type' => 'standard', |
| 159 | 159 | 'subtype' => 'number', |
| 160 | 160 | 'name' => '_default_calendar_list_range_span', |
@@ -163,78 +163,78 @@ discard block |
||
| 163 | 163 | 'simcal-field-tiny', |
| 164 | 164 | 'simcal-field-inline', |
| 165 | 165 | ), |
| 166 | - 'value' => strval( $list_span ), |
|
| 166 | + 'value' => strval($list_span), |
|
| 167 | 167 | 'attributes' => array( |
| 168 | 168 | 'min' => '1', |
| 169 | 169 | ), |
| 170 | - ) ); |
|
| 170 | + )); |
|
| 171 | 171 | |
| 172 | - $list_type = get_post_meta( $post_id, '_default_calendar_list_range_type', true ); |
|
| 172 | + $list_type = get_post_meta($post_id, '_default_calendar_list_range_type', true); |
|
| 173 | 173 | |
| 174 | - simcal_print_field( array( |
|
| 174 | + simcal_print_field(array( |
|
| 175 | 175 | 'type' => 'select', |
| 176 | 176 | 'name' => '_default_calendar_list_range_type', |
| 177 | 177 | 'id' => '_default_calendar_list_range_type', |
| 178 | - 'tooltip' => __( 'Range of events to show on each calendar page.', 'google-calendar-events' ), |
|
| 178 | + 'tooltip' => __('Range of events to show on each calendar page.', 'google-calendar-events'), |
|
| 179 | 179 | 'class' => array( |
| 180 | 180 | 'simcal-field-inline', |
| 181 | 181 | ), |
| 182 | 182 | 'value' => $list_type, |
| 183 | 183 | 'options' => array( |
| 184 | - 'monthly' => __( 'Month(s)', 'google-calendar-events' ), |
|
| 185 | - 'weekly' => __( 'Week(s)', 'google-calendar-events' ), |
|
| 186 | - 'daily' => __( 'Day(s)', 'google-calendar-events' ), |
|
| 187 | - 'events' => __( 'Event(s)', 'google-calendar-events' ), |
|
| 184 | + 'monthly' => __('Month(s)', 'google-calendar-events'), |
|
| 185 | + 'weekly' => __('Week(s)', 'google-calendar-events'), |
|
| 186 | + 'daily' => __('Day(s)', 'google-calendar-events'), |
|
| 187 | + 'events' => __('Event(s)', 'google-calendar-events'), |
|
| 188 | 188 | ), |
| 189 | - ) ); |
|
| 189 | + )); |
|
| 190 | 190 | |
| 191 | 191 | ?> |
| 192 | 192 | </td> |
| 193 | 193 | </tr> |
| 194 | 194 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
| 195 | - <th><label for="_default_calendar_list_header"><?php _e( 'Hide Header', 'google-calendar-events' ); ?></label></th> |
|
| 195 | + <th><label for="_default_calendar_list_header"><?php _e('Hide Header', 'google-calendar-events'); ?></label></th> |
|
| 196 | 196 | <td> |
| 197 | 197 | <?php |
| 198 | 198 | |
| 199 | - $header = get_post_meta( $post_id, '_default_calendar_list_header', true ); |
|
| 199 | + $header = get_post_meta($post_id, '_default_calendar_list_header', true); |
|
| 200 | 200 | |
| 201 | - simcal_print_field( array( |
|
| 201 | + simcal_print_field(array( |
|
| 202 | 202 | 'type' => 'checkbox', |
| 203 | 203 | 'name' => '_default_calendar_list_header', |
| 204 | 204 | 'id' => '_default_calendar_list_header', |
| 205 | - 'tooltip' => __( 'You can use this to hide the month header for this calendar.', 'google-calendar-events' ), |
|
| 205 | + 'tooltip' => __('You can use this to hide the month header for this calendar.', 'google-calendar-events'), |
|
| 206 | 206 | 'value' => 'yes' == $header ? 'yes' : 'no', |
| 207 | - ) ); |
|
| 207 | + )); |
|
| 208 | 208 | |
| 209 | 209 | ?> |
| 210 | 210 | </td> |
| 211 | 211 | </tr> |
| 212 | 212 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
| 213 | - <th><label for="_default_calendar_compact_list"><?php _e( 'Compact List', 'google-calendar-events' ); ?></label></th> |
|
| 213 | + <th><label for="_default_calendar_compact_list"><?php _e('Compact List', 'google-calendar-events'); ?></label></th> |
|
| 214 | 214 | <td> |
| 215 | 215 | <?php |
| 216 | 216 | |
| 217 | - $compact = get_post_meta( $post_id, '_default_calendar_compact_list', true ); |
|
| 217 | + $compact = get_post_meta($post_id, '_default_calendar_compact_list', true); |
|
| 218 | 218 | |
| 219 | - simcal_print_field( array( |
|
| 219 | + simcal_print_field(array( |
|
| 220 | 220 | 'type' => 'checkbox', |
| 221 | 221 | 'name' => '_default_calendar_compact_list', |
| 222 | 222 | 'id' => '_default_calendar_compact_list', |
| 223 | - 'tooltip' => __( 'Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events' ), |
|
| 223 | + 'tooltip' => __('Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events'), |
|
| 224 | 224 | 'value' => 'yes' == $compact ? 'yes' : 'no', |
| 225 | - ) ); |
|
| 225 | + )); |
|
| 226 | 226 | |
| 227 | 227 | ?> |
| 228 | 228 | </td> |
| 229 | 229 | </tr> |
| 230 | 230 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 231 | - <th><label for="_default_calendar_limit_visible_events"><?php _e( 'Limit Visible Events', 'google-calendar-events' ); ?></label></th> |
|
| 231 | + <th><label for="_default_calendar_limit_visible_events"><?php _e('Limit Visible Events', 'google-calendar-events'); ?></label></th> |
|
| 232 | 232 | <td> |
| 233 | 233 | <?php |
| 234 | 234 | |
| 235 | - $limit = get_post_meta( $post_id, '_default_calendar_limit_visible_events', true ); |
|
| 235 | + $limit = get_post_meta($post_id, '_default_calendar_limit_visible_events', true); |
|
| 236 | 236 | |
| 237 | - simcal_print_field( array( |
|
| 237 | + simcal_print_field(array( |
|
| 238 | 238 | 'type' => 'checkbox', |
| 239 | 239 | 'name' => '_default_calendar_limit_visible_events', |
| 240 | 240 | 'id' => '_default_calendar_limit_visible_events', |
@@ -245,17 +245,17 @@ discard block |
||
| 245 | 245 | 'attributes' => array( |
| 246 | 246 | 'data-show-next-if-value' => 'yes', |
| 247 | 247 | ) |
| 248 | - ) ); |
|
| 248 | + )); |
|
| 249 | 249 | |
| 250 | - $visible_events = absint( get_post_meta( $post_id, '_default_calendar_visible_events', true ) ); |
|
| 250 | + $visible_events = absint(get_post_meta($post_id, '_default_calendar_visible_events', true)); |
|
| 251 | 251 | $visible_events = $visible_events > 0 ? $visible_events : 3; |
| 252 | 252 | |
| 253 | - simcal_print_field( array( |
|
| 253 | + simcal_print_field(array( |
|
| 254 | 254 | 'type' => 'standard', |
| 255 | 255 | 'subtype' => 'number', |
| 256 | 256 | 'name' => '_default_calendar_visible_events', |
| 257 | 257 | 'id' => '_default_calendar_visible_events', |
| 258 | - 'tooltip' => __( 'Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events' ), |
|
| 258 | + 'tooltip' => __('Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events'), |
|
| 259 | 259 | 'class' => array( |
| 260 | 260 | 'simcal-field-tiny', |
| 261 | 261 | ), |
@@ -263,39 +263,39 @@ discard block |
||
| 263 | 263 | 'attributes' => array( |
| 264 | 264 | 'min' => '1', |
| 265 | 265 | ) |
| 266 | - ) ); |
|
| 266 | + )); |
|
| 267 | 267 | |
| 268 | 268 | ?> |
| 269 | 269 | </td> |
| 270 | 270 | </tr> |
| 271 | 271 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 272 | - <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Expand Multi-day Events', 'google-calendar-events' ); ?></label></th> |
|
| 272 | + <th><label for="_default_calendar_event_bubbles_action"><?php _e('Expand Multi-day Events', 'google-calendar-events'); ?></label></th> |
|
| 273 | 273 | <td> |
| 274 | 274 | <?php |
| 275 | 275 | |
| 276 | - $post_meta = get_post_meta( $post_id ); |
|
| 276 | + $post_meta = get_post_meta($post_id); |
|
| 277 | 277 | |
| 278 | - if ( ! is_array( $post_meta ) && ! empty( $post_meta ) ) { |
|
| 278 | + if ( ! is_array($post_meta) && ! empty($post_meta)) { |
|
| 279 | 279 | $multi_day_value = 'current_day_only'; |
| 280 | 280 | } else { |
| 281 | - $multi_day_value = get_post_meta( $post_id, '_default_calendar_expand_multi_day_events', true ); |
|
| 281 | + $multi_day_value = get_post_meta($post_id, '_default_calendar_expand_multi_day_events', true); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - simcal_print_field( array( |
|
| 284 | + simcal_print_field(array( |
|
| 285 | 285 | 'type' => 'select', |
| 286 | 286 | 'name' => '_default_calendar_expand_multi_day_events', |
| 287 | 287 | 'id' => '_default_calendar_expand_multi_day_events', |
| 288 | - 'tooltip' => __( 'For events spanning multiple days, you can display them on each day of the event, ' . |
|
| 289 | - 'only on the first day of the event, or on all days of the event, but only up to the current day. ' . |
|
| 290 | - 'Third option applies to list views only.', 'google-calendar-events' ), |
|
| 288 | + 'tooltip' => __('For events spanning multiple days, you can display them on each day of the event, '. |
|
| 289 | + 'only on the first day of the event, or on all days of the event, but only up to the current day. '. |
|
| 290 | + 'Third option applies to list views only.', 'google-calendar-events'), |
|
| 291 | 291 | 'value' => $multi_day_value, |
| 292 | 292 | 'options' => array( |
| 293 | - 'yes' => __( 'Yes, display on all days of event', 'google-calendar-events' ), |
|
| 294 | - 'no' => __( 'No, display only on first day of event', 'google-calendar-events' ), |
|
| 295 | - 'current_day_only' => __( 'No, display on all days of event up to current day (list view only)', 'google-calendar-events' ), |
|
| 293 | + 'yes' => __('Yes, display on all days of event', 'google-calendar-events'), |
|
| 294 | + 'no' => __('No, display only on first day of event', 'google-calendar-events'), |
|
| 295 | + 'current_day_only' => __('No, display on all days of event up to current day (list view only)', 'google-calendar-events'), |
|
| 296 | 296 | ), |
| 297 | 297 | 'default' => 'yes', |
| 298 | - ) ); |
|
| 298 | + )); |
|
| 299 | 299 | |
| 300 | 300 | ?> |
| 301 | 301 | </td> |
@@ -304,72 +304,72 @@ discard block |
||
| 304 | 304 | <?php |
| 305 | 305 | |
| 306 | 306 | // TODO Defaults repeated here and in process_meta(). Need to consolidate at some point. |
| 307 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
| 308 | - $default_theme = isset( $settings['default-calendar']['theme'] ) ? $settings['default-calendar']['theme'] : 'light'; |
|
| 309 | - $default_today_color = isset( $settings['default-calendar']['today_color'] ) ? $settings['default-calendar']['today_color'] : '#1e73be'; |
|
| 310 | - $default_days_events_color = isset( $settings['default-calendar']['days_events_color'] ) ? $settings['default-calendar']['days_events_color'] : '#000000'; |
|
| 307 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
| 308 | + $default_theme = isset($settings['default-calendar']['theme']) ? $settings['default-calendar']['theme'] : 'light'; |
|
| 309 | + $default_today_color = isset($settings['default-calendar']['today_color']) ? $settings['default-calendar']['today_color'] : '#1e73be'; |
|
| 310 | + $default_days_events_color = isset($settings['default-calendar']['days_events_color']) ? $settings['default-calendar']['days_events_color'] : '#000000'; |
|
| 311 | 311 | |
| 312 | 312 | ?> |
| 313 | 313 | <tbody class="simcal-panel-section"> |
| 314 | 314 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 315 | - <th><label for="_default_calendar_style_theme"><?php _e( 'Theme', 'google-calendar-events' ); ?></label></th> |
|
| 315 | + <th><label for="_default_calendar_style_theme"><?php _e('Theme', 'google-calendar-events'); ?></label></th> |
|
| 316 | 316 | <td> |
| 317 | 317 | <?php |
| 318 | 318 | |
| 319 | - $saved = get_post_meta( $post_id, '_default_calendar_style_theme', true ); |
|
| 319 | + $saved = get_post_meta($post_id, '_default_calendar_style_theme', true); |
|
| 320 | 320 | $value = ! $saved ? $default_theme : $saved; |
| 321 | 321 | |
| 322 | - simcal_print_field( array( |
|
| 322 | + simcal_print_field(array( |
|
| 323 | 323 | 'type' => 'select', |
| 324 | 324 | 'name' => '_default_calendar_style_theme', |
| 325 | 325 | 'id' => '_default_calendar_style_theme', |
| 326 | 326 | 'value' => $value, |
| 327 | - 'tooltip' => __( 'Choose a calendar theme to match your site theme.', 'google-calendar-events' ), |
|
| 327 | + 'tooltip' => __('Choose a calendar theme to match your site theme.', 'google-calendar-events'), |
|
| 328 | 328 | 'options' => array( |
| 329 | - 'light' => __( 'Light', 'google-calendar-events' ), |
|
| 330 | - 'dark' => __( 'Dark', 'google-calendar-events' ), |
|
| 329 | + 'light' => __('Light', 'google-calendar-events'), |
|
| 330 | + 'dark' => __('Dark', 'google-calendar-events'), |
|
| 331 | 331 | ), |
| 332 | - ) ); |
|
| 332 | + )); |
|
| 333 | 333 | |
| 334 | 334 | ?> |
| 335 | 335 | </td> |
| 336 | 336 | </tr> |
| 337 | 337 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 338 | - <th><label for="_default_calendar_style_today"><?php _e( 'Today', 'google-calendar-events' ); ?></label></th> |
|
| 338 | + <th><label for="_default_calendar_style_today"><?php _e('Today', 'google-calendar-events'); ?></label></th> |
|
| 339 | 339 | <td> |
| 340 | 340 | <?php |
| 341 | 341 | |
| 342 | - $saved = get_post_meta( $post_id, '_default_calendar_style_today', true ); |
|
| 342 | + $saved = get_post_meta($post_id, '_default_calendar_style_today', true); |
|
| 343 | 343 | $value = ! $saved ? $default_today_color : $saved; |
| 344 | 344 | |
| 345 | - simcal_print_field( array( |
|
| 345 | + simcal_print_field(array( |
|
| 346 | 346 | 'type' => 'standard', |
| 347 | 347 | 'subtype' => 'color-picker', |
| 348 | 348 | 'name' => '_default_calendar_style_today', |
| 349 | 349 | 'id' => '_default_calendar_style_today', |
| 350 | 350 | 'value' => $value, |
| 351 | - 'tooltip' => __( "This option will set the background color for today's date. It will change the day number background and the border around the current day.", 'google-calendar-events' ), |
|
| 352 | - ) ); |
|
| 351 | + 'tooltip' => __("This option will set the background color for today's date. It will change the day number background and the border around the current day.", 'google-calendar-events'), |
|
| 352 | + )); |
|
| 353 | 353 | |
| 354 | 354 | ?> |
| 355 | 355 | </td> |
| 356 | 356 | </tr> |
| 357 | 357 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
| 358 | - <th><label for="_default_calendar_style_days_events"><?php _e( 'Days with Events', 'google-calendar-events' ); ?></label></th> |
|
| 358 | + <th><label for="_default_calendar_style_days_events"><?php _e('Days with Events', 'google-calendar-events'); ?></label></th> |
|
| 359 | 359 | <td> |
| 360 | 360 | <?php |
| 361 | 361 | |
| 362 | - $saved = get_post_meta( $post_id, '_default_calendar_style_days_events', true ); |
|
| 362 | + $saved = get_post_meta($post_id, '_default_calendar_style_days_events', true); |
|
| 363 | 363 | $value = ! $saved ? $default_days_events_color : $saved; |
| 364 | 364 | |
| 365 | - simcal_print_field( array( |
|
| 365 | + simcal_print_field(array( |
|
| 366 | 366 | 'type' => 'standard', |
| 367 | 367 | 'subtype' => 'color-picker', |
| 368 | 368 | 'name' => '_default_calendar_style_days_events', |
| 369 | 369 | 'id' => '_default_calendar_style_days_events', |
| 370 | 370 | 'value' => $value, |
| 371 | - 'tooltip' => __( 'This setting will modify the day number background for any days that have events on them.', 'google-calendar-events' ), |
|
| 372 | - ) ); |
|
| 371 | + 'tooltip' => __('This setting will modify the day number background for any days that have events on them.', 'google-calendar-events'), |
|
| 372 | + )); |
|
| 373 | 373 | |
| 374 | 374 | ?> |
| 375 | 375 | </td> |
@@ -391,55 +391,55 @@ discard block |
||
| 391 | 391 | * |
| 392 | 392 | * @param int $post_id |
| 393 | 393 | */ |
| 394 | - public function process_meta( $post_id ) { |
|
| 394 | + public function process_meta($post_id) { |
|
| 395 | 395 | |
| 396 | 396 | // Theme. |
| 397 | - $theme = isset( $_POST['_default_calendar_style_theme'] ) ? sanitize_key( $_POST['_default_calendar_style_theme'] ) : 'light'; |
|
| 398 | - update_post_meta( $post_id, '_default_calendar_style_theme', $theme ); |
|
| 397 | + $theme = isset($_POST['_default_calendar_style_theme']) ? sanitize_key($_POST['_default_calendar_style_theme']) : 'light'; |
|
| 398 | + update_post_meta($post_id, '_default_calendar_style_theme', $theme); |
|
| 399 | 399 | |
| 400 | 400 | // Today color. |
| 401 | - $today_color = isset( $_POST['_default_calendar_style_today'] ) ? sanitize_text_field( $_POST['_default_calendar_style_today'] ) : '#1e73be'; |
|
| 402 | - update_post_meta( $post_id, '_default_calendar_style_today', $today_color ); |
|
| 401 | + $today_color = isset($_POST['_default_calendar_style_today']) ? sanitize_text_field($_POST['_default_calendar_style_today']) : '#1e73be'; |
|
| 402 | + update_post_meta($post_id, '_default_calendar_style_today', $today_color); |
|
| 403 | 403 | |
| 404 | 404 | // Days with events color. |
| 405 | - $days_events_color = isset( $_POST['_default_calendar_style_days_events'] ) ? sanitize_text_field( $_POST['_default_calendar_style_days_events'] ) : '#000000'; |
|
| 406 | - update_post_meta( $post_id, '_default_calendar_style_days_events', $days_events_color ); |
|
| 405 | + $days_events_color = isset($_POST['_default_calendar_style_days_events']) ? sanitize_text_field($_POST['_default_calendar_style_days_events']) : '#000000'; |
|
| 406 | + update_post_meta($post_id, '_default_calendar_style_days_events', $days_events_color); |
|
| 407 | 407 | |
| 408 | 408 | // List range span. |
| 409 | - $span = isset( $_POST['_default_calendar_list_range_span'] ) ? max( absint( $_POST['_default_calendar_list_range_span'] ), 1 ) : 1; |
|
| 410 | - update_post_meta( $post_id, '_default_calendar_list_range_span', $span ); |
|
| 409 | + $span = isset($_POST['_default_calendar_list_range_span']) ? max(absint($_POST['_default_calendar_list_range_span']), 1) : 1; |
|
| 410 | + update_post_meta($post_id, '_default_calendar_list_range_span', $span); |
|
| 411 | 411 | |
| 412 | 412 | // List range type. |
| 413 | - $group = isset( $_POST['_default_calendar_list_range_type'] ) ? sanitize_key( $_POST['_default_calendar_list_range_type'] ) : 'monthly'; |
|
| 414 | - update_post_meta( $post_id, '_default_calendar_list_range_type', $group ); |
|
| 413 | + $group = isset($_POST['_default_calendar_list_range_type']) ? sanitize_key($_POST['_default_calendar_list_range_type']) : 'monthly'; |
|
| 414 | + update_post_meta($post_id, '_default_calendar_list_range_type', $group); |
|
| 415 | 415 | |
| 416 | 416 | // Hide header. |
| 417 | - $header = isset( $_POST['_default_calendar_list_header'] ) ? 'yes' : 'no'; |
|
| 418 | - update_post_meta( $post_id, '_default_calendar_list_header', $header ); |
|
| 417 | + $header = isset($_POST['_default_calendar_list_header']) ? 'yes' : 'no'; |
|
| 418 | + update_post_meta($post_id, '_default_calendar_list_header', $header); |
|
| 419 | 419 | |
| 420 | 420 | // Compact list. |
| 421 | - $compact = isset( $_POST['_default_calendar_compact_list'] ) ? 'yes' : 'no'; |
|
| 422 | - update_post_meta( $post_id, '_default_calendar_compact_list', $compact ); |
|
| 421 | + $compact = isset($_POST['_default_calendar_compact_list']) ? 'yes' : 'no'; |
|
| 422 | + update_post_meta($post_id, '_default_calendar_compact_list', $compact); |
|
| 423 | 423 | |
| 424 | 424 | // Limit number of initially visible daily events. |
| 425 | - $limit = isset( $_POST['_default_calendar_limit_visible_events'] ) ? 'yes' : 'no'; |
|
| 426 | - update_post_meta( $post_id, '_default_calendar_limit_visible_events', $limit ); |
|
| 427 | - $number = isset( $_POST['_default_calendar_visible_events'] ) ? absint( $_POST['_default_calendar_visible_events'] ) : 3; |
|
| 428 | - update_post_meta( $post_id, '_default_calendar_visible_events', $number ); |
|
| 425 | + $limit = isset($_POST['_default_calendar_limit_visible_events']) ? 'yes' : 'no'; |
|
| 426 | + update_post_meta($post_id, '_default_calendar_limit_visible_events', $limit); |
|
| 427 | + $number = isset($_POST['_default_calendar_visible_events']) ? absint($_POST['_default_calendar_visible_events']) : 3; |
|
| 428 | + update_post_meta($post_id, '_default_calendar_visible_events', $number); |
|
| 429 | 429 | |
| 430 | 430 | // Grid event bubbles action. |
| 431 | - $bubbles = isset( $_POST['_default_calendar_event_bubble_trigger'] ) ? esc_attr( $_POST['_default_calendar_event_bubble_trigger'] ) : 'hover'; |
|
| 432 | - update_post_meta( $post_id, '_default_calendar_event_bubble_trigger', $bubbles ); |
|
| 431 | + $bubbles = isset($_POST['_default_calendar_event_bubble_trigger']) ? esc_attr($_POST['_default_calendar_event_bubble_trigger']) : 'hover'; |
|
| 432 | + update_post_meta($post_id, '_default_calendar_event_bubble_trigger', $bubbles); |
|
| 433 | 433 | |
| 434 | 434 | // Trim event titles characters length. |
| 435 | - $trim = isset( $_POST['_default_calendar_trim_titles'] ) ? 'yes' : 'no'; |
|
| 436 | - update_post_meta( $post_id, '_default_calendar_trim_titles', $trim ); |
|
| 437 | - $chars = isset( $_POST['_default_calendar_trim_titles_chars'] ) ? max( absint( $_POST['_default_calendar_trim_titles_chars'] ), 1 ) : 20; |
|
| 438 | - update_post_meta( $post_id, '_default_calendar_trim_titles_chars', $chars ); |
|
| 435 | + $trim = isset($_POST['_default_calendar_trim_titles']) ? 'yes' : 'no'; |
|
| 436 | + update_post_meta($post_id, '_default_calendar_trim_titles', $trim); |
|
| 437 | + $chars = isset($_POST['_default_calendar_trim_titles_chars']) ? max(absint($_POST['_default_calendar_trim_titles_chars']), 1) : 20; |
|
| 438 | + update_post_meta($post_id, '_default_calendar_trim_titles_chars', $chars); |
|
| 439 | 439 | |
| 440 | 440 | // Expand multiple day events on each day. |
| 441 | - $multi_day = isset( $_POST['_default_calendar_expand_multi_day_events'] ) && ! empty( $_POST['_default_calendar_expand_multi_day_events'] ) ? sanitize_key( $_POST['_default_calendar_expand_multi_day_events'] ) : 'yes'; |
|
| 442 | - update_post_meta( $post_id, '_default_calendar_expand_multi_day_events', $multi_day ); |
|
| 441 | + $multi_day = isset($_POST['_default_calendar_expand_multi_day_events']) && ! empty($_POST['_default_calendar_expand_multi_day_events']) ? sanitize_key($_POST['_default_calendar_expand_multi_day_events']) : 'yes'; |
|
| 442 | + update_post_meta($post_id, '_default_calendar_expand_multi_day_events', $multi_day); |
|
| 443 | 443 | |
| 444 | 444 | } |
| 445 | 445 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use SimpleCalendar\Calendars\Views; |
| 14 | 14 | use SimpleCalendar\Events\Event; |
| 15 | 15 | |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 16 | +if ( ! defined('ABSPATH')) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -105,36 +105,36 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @param int|object|\WP_Post|Calendar $calendar |
| 107 | 107 | */ |
| 108 | - public function __construct( $calendar ) { |
|
| 108 | + public function __construct($calendar) { |
|
| 109 | 109 | |
| 110 | 110 | $this->type = 'default-calendar'; |
| 111 | - $this->name = __( 'Default', 'google-calendar-events' ); |
|
| 112 | - $this->views = apply_filters( 'simcal_default_calendar_views', array( |
|
| 113 | - 'grid' => __( 'Grid', 'google-calendar-events' ), |
|
| 114 | - 'list' => __( 'List', 'google-calendar-events' ), |
|
| 115 | - ) ); |
|
| 111 | + $this->name = __('Default', 'google-calendar-events'); |
|
| 112 | + $this->views = apply_filters('simcal_default_calendar_views', array( |
|
| 113 | + 'grid' => __('Grid', 'google-calendar-events'), |
|
| 114 | + 'list' => __('List', 'google-calendar-events'), |
|
| 115 | + )); |
|
| 116 | 116 | |
| 117 | - parent::__construct( $calendar ); |
|
| 117 | + parent::__construct($calendar); |
|
| 118 | 118 | |
| 119 | - if ( ! is_null( $this->post ) ) { |
|
| 119 | + if ( ! is_null($this->post)) { |
|
| 120 | 120 | |
| 121 | - $this->set_properties( $this->view->get_type() ); |
|
| 121 | + $this->set_properties($this->view->get_type()); |
|
| 122 | 122 | |
| 123 | 123 | $id = $this->id; |
| 124 | 124 | $theme = $this->theme; |
| 125 | 125 | |
| 126 | - add_filter( 'simcal_calendar_class', function ( $class, $post_id ) use ( $theme, $id ) { |
|
| 127 | - if ( in_array( 'default-calendar', $class ) && $post_id === $id ) { |
|
| 128 | - array_push( $class, 'default-calendar-' . $theme ); |
|
| 126 | + add_filter('simcal_calendar_class', function($class, $post_id) use ($theme, $id) { |
|
| 127 | + if (in_array('default-calendar', $class) && $post_id === $id) { |
|
| 128 | + array_push($class, 'default-calendar-'.$theme); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return $class; |
| 132 | - }, 10, 2 ); |
|
| 132 | + }, 10, 2); |
|
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Calendar settings handling. |
| 137 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 137 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 138 | 138 | $admin = new Default_Calendar_Admin(); |
| 139 | 139 | $this->settings = $admin->settings_fields(); |
| 140 | 140 | } |
@@ -148,49 +148,49 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @param $view |
| 150 | 150 | */ |
| 151 | - private function set_properties( $view ) { |
|
| 151 | + private function set_properties($view) { |
|
| 152 | 152 | |
| 153 | 153 | // Set styles. |
| 154 | - if ( 'dark' == get_post_meta( $this->id, '_default_calendar_style_theme', true ) ) { |
|
| 154 | + if ('dark' == get_post_meta($this->id, '_default_calendar_style_theme', true)) { |
|
| 155 | 155 | $this->theme = 'dark'; |
| 156 | 156 | } |
| 157 | - if ( $today_color = get_post_meta( $this->id, '_default_calendar_style_today', true ) ) { |
|
| 158 | - $this->today_color = esc_attr( $today_color ); |
|
| 157 | + if ($today_color = get_post_meta($this->id, '_default_calendar_style_today', true)) { |
|
| 158 | + $this->today_color = esc_attr($today_color); |
|
| 159 | 159 | } |
| 160 | - if ( $day_events_color = get_post_meta( $this->id, '_default_calendar_style_days_events', true ) ) { |
|
| 161 | - $this->days_events_color = esc_attr( $day_events_color ); |
|
| 160 | + if ($day_events_color = get_post_meta($this->id, '_default_calendar_style_days_events', true)) { |
|
| 161 | + $this->days_events_color = esc_attr($day_events_color); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // Hide too many events. |
| 165 | - if ( 'yes' == get_post_meta( $this->id, '_default_calendar_limit_visible_events', true ) ) { |
|
| 166 | - $this->events_limit = absint( get_post_meta( $this->id, '_default_calendar_visible_events', true ) ); |
|
| 165 | + if ('yes' == get_post_meta($this->id, '_default_calendar_limit_visible_events', true)) { |
|
| 166 | + $this->events_limit = absint(get_post_meta($this->id, '_default_calendar_visible_events', true)); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // Expand multiple day events. |
| 170 | - if ( 'yes' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) || ( 'list' == $view && 'current_day_only' == get_post_meta( $this->id, '_default_calendar_expand_multi_day_events', true ) ) ) { |
|
| 170 | + if ('yes' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true) || ('list' == $view && 'current_day_only' == get_post_meta($this->id, '_default_calendar_expand_multi_day_events', true))) { |
|
| 171 | 171 | $this->events = $this->expand_multiple_days_events(); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( 'grid' == $view ) { |
|
| 174 | + if ('grid' == $view) { |
|
| 175 | 175 | |
| 176 | 176 | // Use hover to open event bubbles. |
| 177 | - if ( 'hover' == get_post_meta( $this->id, '_default_calendar_event_bubble_trigger', true ) ) { |
|
| 177 | + if ('hover' == get_post_meta($this->id, '_default_calendar_event_bubble_trigger', true)) { |
|
| 178 | 178 | $this->event_bubble_trigger = 'hover'; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Trim long event titles. |
| 182 | - if ( 'yes' == get_post_meta( $this->id, '_default_calendar_trim_titles', true ) ) { |
|
| 183 | - $this->trim_titles = max( absint( get_post_meta( $this->id, '_default_calendar_trim_titles_chars', true ) ), 1 ); |
|
| 182 | + if ('yes' == get_post_meta($this->id, '_default_calendar_trim_titles', true)) { |
|
| 183 | + $this->trim_titles = max(absint(get_post_meta($this->id, '_default_calendar_trim_titles_chars', true)), 1); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | } else { |
| 187 | 187 | |
| 188 | 188 | // List range. |
| 189 | - $this->group_type = esc_attr( get_post_meta( $this->id, '_default_calendar_list_range_type', true ) ); |
|
| 190 | - $this->group_span = max( absint( get_post_meta( $this->id, '_default_calendar_list_range_span', true ) ), 1 ); |
|
| 189 | + $this->group_type = esc_attr(get_post_meta($this->id, '_default_calendar_list_range_type', true)); |
|
| 190 | + $this->group_span = max(absint(get_post_meta($this->id, '_default_calendar_list_range_span', true)), 1); |
|
| 191 | 191 | |
| 192 | 192 | // Make the list look more compact. |
| 193 | - if ( 'yes' == get_post_meta( $this->id, '_default_calendar_compact_list', true ) ) { |
|
| 193 | + if ('yes' == get_post_meta($this->id, '_default_calendar_compact_list', true)) { |
|
| 194 | 194 | $this->compact_list = true; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -211,19 +211,19 @@ discard block |
||
| 211 | 211 | $old_events = $this->events; |
| 212 | 212 | $new_events = array(); |
| 213 | 213 | |
| 214 | - if ( ! empty( $old_events ) ) { |
|
| 214 | + if ( ! empty($old_events)) { |
|
| 215 | 215 | |
| 216 | - foreach ( $old_events as $events ) { |
|
| 217 | - foreach ( $events as $event ) { |
|
| 218 | - if ( $event instanceof Event ) { |
|
| 219 | - if ( false !== $event->multiple_days ) { |
|
| 216 | + foreach ($old_events as $events) { |
|
| 217 | + foreach ($events as $event) { |
|
| 218 | + if ($event instanceof Event) { |
|
| 219 | + if (false !== $event->multiple_days) { |
|
| 220 | 220 | $days = $event->multiple_days; |
| 221 | 221 | |
| 222 | - if ( $days > 0 ) { |
|
| 222 | + if ($days > 0) { |
|
| 223 | 223 | |
| 224 | - for ( $d = 1; $d <= $days; $d++ ) { |
|
| 225 | - $current_day_ts = $event->start + ( $d * DAY_IN_SECONDS - 1 ); |
|
| 226 | - $new_events[ intval( $current_day_ts ) ][] = $event; |
|
| 224 | + for ($d = 1; $d <= $days; $d++) { |
|
| 225 | + $current_day_ts = $event->start + ($d * DAY_IN_SECONDS - 1); |
|
| 226 | + $new_events[intval($current_day_ts)][] = $event; |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $events = $old_events + $new_events; |
| 238 | - ksort( $events, SORT_NUMERIC ); |
|
| 238 | + ksort($events, SORT_NUMERIC); |
|
| 239 | 239 | |
| 240 | 240 | return $events; |
| 241 | 241 | } |
@@ -251,16 +251,16 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return null|Calendar_View |
| 253 | 253 | */ |
| 254 | - public function get_view( $view = '' ) { |
|
| 254 | + public function get_view($view = '') { |
|
| 255 | 255 | |
| 256 | - $view = ! empty( $view ) ? $view : 'grid'; |
|
| 256 | + $view = ! empty($view) ? $view : 'grid'; |
|
| 257 | 257 | |
| 258 | - do_action( 'simcal_calendar_get_view', $this->type, $view ); |
|
| 258 | + do_action('simcal_calendar_get_view', $this->type, $view); |
|
| 259 | 259 | |
| 260 | - if ( 'grid' == $view ) { |
|
| 261 | - return new Views\Default_Calendar_Grid( $this ); |
|
| 262 | - } elseif ( 'list' == $view ) { |
|
| 263 | - return new Views\Default_Calendar_List( $this ); |
|
| 260 | + if ('grid' == $view) { |
|
| 261 | + return new Views\Default_Calendar_Grid($this); |
|
| 262 | + } elseif ('list' == $view) { |
|
| 263 | + return new Views\Default_Calendar_List($this); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | return null; |
@@ -13,7 +13,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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,92 +245,92 @@ discard block |
||
| 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 | |
| 252 | - if ( ! $calendar->group_type || ! $calendar->group_span ) { |
|
| 252 | + if ( ! $calendar->group_type || ! $calendar->group_span) { |
|
| 253 | 253 | return array(); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | // Need to pass in timezone here to get beginning of day. |
| 257 | - $current = Carbon::createFromTimestamp( $timestamp, $calendar->timezone ); |
|
| 257 | + $current = Carbon::createFromTimestamp($timestamp, $calendar->timezone); |
|
| 258 | 258 | $prev = clone $current; |
| 259 | 259 | $next = clone $current; |
| 260 | 260 | |
| 261 | 261 | $this->start = $timestamp; |
| 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 | 306 | |
| 307 | - ksort( $flattened_events, SORT_NUMERIC ); |
|
| 307 | + ksort($flattened_events, SORT_NUMERIC); |
|
| 308 | 308 | |
| 309 | - $keys = array_keys( $flattened_events ); |
|
| 309 | + $keys = array_keys($flattened_events); |
|
| 310 | 310 | $current = 0; |
| 311 | - foreach ( $keys as $timestamp ) { |
|
| 312 | - if ( $timestamp < $this->start ) { |
|
| 311 | + foreach ($keys as $timestamp) { |
|
| 312 | + if ($timestamp < $this->start) { |
|
| 313 | 313 | $current++; |
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $paged_events = array_slice( $flattened_events, $current, $interval, true ); |
|
| 317 | + $paged_events = array_slice($flattened_events, $current, $interval, true); |
|
| 318 | 318 | |
| 319 | - $events_end = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $calendar->end; |
|
| 319 | + $events_end = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $calendar->end; |
|
| 320 | 320 | $this->end = $events_end > $calendar->end ? $calendar->end : $events_end; |
| 321 | 321 | |
| 322 | - $this->prev = isset( $keys[ $current - $interval ] ) ? $keys[ $current - $interval ] : $calendar->earliest_event; |
|
| 323 | - $this->next = isset( $keys[ $current + $interval ] ) ? $keys[ $current + $interval ] : $this->end; |
|
| 322 | + $this->prev = isset($keys[$current - $interval]) ? $keys[$current - $interval] : $calendar->earliest_event; |
|
| 323 | + $this->next = isset($keys[$current + $interval]) ? $keys[$current + $interval] : $this->end; |
|
| 324 | 324 | |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | // Put resulting events in an associative array, with Ymd date as key for easy retrieval in calendar days loop. |
| 328 | 328 | |
| 329 | - foreach ( $paged_events as $timestamp => $events ) { |
|
| 329 | + foreach ($paged_events as $timestamp => $events) { |
|
| 330 | 330 | |
| 331 | 331 | // TODO First $paged_events item timestamp 1 second off? Plus or minus? |
| 332 | 332 | |
| 333 | - if ( $timestamp <= $this->end ) { |
|
| 333 | + if ($timestamp <= $this->end) { |
|
| 334 | 334 | |
| 335 | 335 | // TODO Could go back to using Carbon to be consistent. |
| 336 | 336 | // $date is off by a couple hours for dates in multi-day event, but not for first event. |
@@ -349,34 +349,34 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | // Using native PHP 5.3+ (not Carbon) here. |
| 351 | 351 | // Offset value after first day same behavior as Carbon above still. |
| 352 | - $dtz = new \DateTimeZone( $calendar->timezone ); |
|
| 352 | + $dtz = new \DateTimeZone($calendar->timezone); |
|
| 353 | 353 | |
| 354 | - $date = \DateTime::createFromFormat( 'U', $timestamp ); |
|
| 354 | + $date = \DateTime::createFromFormat('U', $timestamp); |
|
| 355 | 355 | |
| 356 | 356 | // Doesn't seem to make a difference omitting timezone. |
| 357 | 357 | //$date = \DateTime::createFromFormat( 'U', $timestamp, $dtz ); |
| 358 | 358 | |
| 359 | 359 | // Add offset to timestamp to get correct date. |
| 360 | 360 | // TODO Need to add +1 second also? |
| 361 | - $offset = $dtz->getOffset( $date ); |
|
| 361 | + $offset = $dtz->getOffset($date); |
|
| 362 | 362 | $date_offset = clone $date; |
| 363 | - $date_offset->add( \DateInterval::createFromDateString( $offset . ' seconds' ) ); |
|
| 363 | + $date_offset->add(\DateInterval::createFromDateString($offset.' seconds')); |
|
| 364 | 364 | |
| 365 | 365 | // TODO Multiple day events will be off if part-way through there's daylight savings. |
| 366 | 366 | |
| 367 | - $dateYmd = $date_offset->format( 'Ymd' ); |
|
| 368 | - $daily_events[ intval( $dateYmd ) ][] = $events; |
|
| 367 | + $dateYmd = $date_offset->format('Ymd'); |
|
| 368 | + $daily_events[intval($dateYmd)][] = $events; |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - ksort( $daily_events, SORT_NUMERIC ); |
|
| 372 | + ksort($daily_events, SORT_NUMERIC); |
|
| 373 | 373 | |
| 374 | - if ( ! empty( $paged_events ) ) { |
|
| 375 | - $first_event = array_slice( $paged_events, 0, 1, true ); |
|
| 376 | - $first_event = array_pop( $first_event ); |
|
| 374 | + if ( ! empty($paged_events)) { |
|
| 375 | + $first_event = array_slice($paged_events, 0, 1, true); |
|
| 376 | + $first_event = array_pop($first_event); |
|
| 377 | 377 | $this->first_event = $first_event[0]->start; |
| 378 | 378 | |
| 379 | - $last_event = array_pop( $paged_events ); |
|
| 379 | + $last_event = array_pop($paged_events); |
|
| 380 | 380 | $this->last_event = $last_event[0]->start; |
| 381 | 381 | } |
| 382 | 382 | |
@@ -396,84 +396,84 @@ discard block |
||
| 396 | 396 | private function get_heading() { |
| 397 | 397 | |
| 398 | 398 | $calendar = $this->calendar; |
| 399 | - $start = Carbon::createFromTimestamp( $calendar->start, $calendar->timezone ); |
|
| 400 | - $end = Carbon::createFromTimestamp( $this->end, $calendar->timezone ); |
|
| 399 | + $start = Carbon::createFromTimestamp($calendar->start, $calendar->timezone); |
|
| 400 | + $end = Carbon::createFromTimestamp($this->end, $calendar->timezone); |
|
| 401 | 401 | $date_format = $this->calendar->date_format; |
| 402 | - $date_order = simcal_get_date_format_order( $date_format ); |
|
| 402 | + $date_order = simcal_get_date_format_order($date_format); |
|
| 403 | 403 | |
| 404 | - if ( $this->first_event !== 0 ) { |
|
| 405 | - $start = Carbon::createFromTimestamp( $this->first_event, $calendar->timezone ); |
|
| 404 | + if ($this->first_event !== 0) { |
|
| 405 | + $start = Carbon::createFromTimestamp($this->first_event, $calendar->timezone); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - if ( $this->last_event !== 0 ) { |
|
| 409 | - $end = Carbon::createFromTimestamp( $this->last_event, $calendar->timezone ); |
|
| 408 | + if ($this->last_event !== 0) { |
|
| 409 | + $end = Carbon::createFromTimestamp($this->last_event, $calendar->timezone); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - $st = strtotime( $start->toDateTimeString() ); |
|
| 413 | - $et = strtotime( $end->toDateTimeString() ); |
|
| 412 | + $st = strtotime($start->toDateTimeString()); |
|
| 413 | + $et = strtotime($end->toDateTimeString()); |
|
| 414 | 414 | |
| 415 | 415 | // TODO Is logic here causing the weird "29 Oct, 2016" format when navigating? |
| 416 | 416 | |
| 417 | - if ( ( $start->day == $end->day ) && ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
| 417 | + if (($start->day == $end->day) && ($start->month == $end->month) && ($start->year == $end->year)) { |
|
| 418 | 418 | // Start and end on the same day. |
| 419 | 419 | // e.g. 1 February 2020 |
| 420 | - $large = $small = date_i18n( $calendar->date_format , $st ); |
|
| 421 | - if ( ( $date_order['d'] !== false ) && ( $date_order['m'] !== false ) ) { |
|
| 422 | - if ( $date_order['m'] > $date_order['d'] ) { |
|
| 423 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
| 424 | - $small = date_i18n( 'Y, d M', $st ); |
|
| 420 | + $large = $small = date_i18n($calendar->date_format, $st); |
|
| 421 | + if (($date_order['d'] !== false) && ($date_order['m'] !== false)) { |
|
| 422 | + if ($date_order['m'] > $date_order['d']) { |
|
| 423 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
| 424 | + $small = date_i18n('Y, d M', $st); |
|
| 425 | 425 | } else { |
| 426 | - $small = date_i18n( 'd M Y', $st ); |
|
| 426 | + $small = date_i18n('d M Y', $st); |
|
| 427 | 427 | } |
| 428 | 428 | } else { |
| 429 | - if ( $date_order['y'] !== false && $date_order['y'] > $date_order['m'] ) { |
|
| 430 | - $small = date_i18n( 'Y, M d', $st ); |
|
| 429 | + if ($date_order['y'] !== false && $date_order['y'] > $date_order['m']) { |
|
| 430 | + $small = date_i18n('Y, M d', $st); |
|
| 431 | 431 | } else { |
| 432 | - $small = date_i18n( 'M d Y', $st ); |
|
| 432 | + $small = date_i18n('M d Y', $st); |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | - } elseif ( ( $start->month == $end->month ) && ( $start->year == $end->year ) ) { |
|
| 436 | + } elseif (($start->month == $end->month) && ($start->year == $end->year)) { |
|
| 437 | 437 | // Start and end days on the same month. |
| 438 | 438 | // e.g. August 2020 |
| 439 | - if ( $date_order['y'] === false ) { |
|
| 439 | + if ($date_order['y'] === false) { |
|
| 440 | 440 | // August. |
| 441 | - $large = $small = date_i18n( 'F', $st ); |
|
| 441 | + $large = $small = date_i18n('F', $st); |
|
| 442 | 442 | } else { |
| 443 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
| 443 | + if ($date_order['y'] < $date_order['m']) { |
|
| 444 | 444 | // 2020 August. |
| 445 | - $large = date_i18n( 'Y F', $st ); |
|
| 446 | - $small = date_i18n( 'Y M', $st ); |
|
| 445 | + $large = date_i18n('Y F', $st); |
|
| 446 | + $small = date_i18n('Y M', $st); |
|
| 447 | 447 | } else { |
| 448 | 448 | // August 2020. |
| 449 | - $large = date_i18n( 'F Y', $st ); |
|
| 450 | - $small = date_i18n( 'M Y', $st ); |
|
| 449 | + $large = date_i18n('F Y', $st); |
|
| 450 | + $small = date_i18n('M Y', $st); |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | - } elseif ( $start->year == $end->year ) { |
|
| 453 | + } elseif ($start->year == $end->year) { |
|
| 454 | 454 | // Start and end days on months of the same year. |
| 455 | 455 | // e.g. August - September 2020 |
| 456 | - if ( $date_order['y'] === false ) { |
|
| 456 | + if ($date_order['y'] === false) { |
|
| 457 | 457 | // August - September. |
| 458 | - $large = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ); |
|
| 459 | - $small = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ); |
|
| 458 | + $large = date_i18n('F', $st).' - '.date_i18n('F', $et); |
|
| 459 | + $small = date_i18n('M', $st).' - '.date_i18n('M', $et); |
|
| 460 | 460 | } else { |
| 461 | - if ( $date_order['y'] < $date_order['m'] ) { |
|
| 461 | + if ($date_order['y'] < $date_order['m']) { |
|
| 462 | 462 | // 2020, August - September. |
| 463 | - $large = $small = date( 'Y', $st ) . ', '; |
|
| 464 | - $large .= date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ); |
|
| 465 | - $small .= date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ); |
|
| 463 | + $large = $small = date('Y', $st).', '; |
|
| 464 | + $large .= date_i18n('F', $st).' - '.date_i18n('F', $et); |
|
| 465 | + $small .= date_i18n('M', $st).' - '.date_i18n('M', $et); |
|
| 466 | 466 | } else { |
| 467 | 467 | // August - September, 2020. |
| 468 | - $large = date_i18n( 'F', $st ) . ' - ' . date_i18n( 'F', $et ) . ', '; |
|
| 469 | - $small = date_i18n( 'M', $st ) . ' - ' . date_i18n( 'M', $et ) . ' '; |
|
| 470 | - $year = date( 'Y', $st ); |
|
| 468 | + $large = date_i18n('F', $st).' - '.date_i18n('F', $et).', '; |
|
| 469 | + $small = date_i18n('M', $st).' - '.date_i18n('M', $et).' '; |
|
| 470 | + $year = date('Y', $st); |
|
| 471 | 471 | $large .= $year; |
| 472 | 472 | $small .= $year; |
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | } else { |
| 476 | - $large = $small = date( 'Y', $st ) . ' - ' . date( 'Y', $et ); |
|
| 476 | + $large = $small = date('Y', $st).' - '.date('Y', $et); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | return array( |
@@ -495,43 +495,43 @@ discard block |
||
| 495 | 495 | * |
| 496 | 496 | * @return string |
| 497 | 497 | */ |
| 498 | - private function draw_list( $timestamp, $id = 0 ) { |
|
| 498 | + private function draw_list($timestamp, $id = 0) { |
|
| 499 | 499 | |
| 500 | 500 | $calendar = $this->calendar; |
| 501 | 501 | |
| 502 | - if ( empty( $calendar ) ) { |
|
| 503 | - $calendar = $this->calendar = simcal_get_calendar( intval( $id ) ); |
|
| 504 | - if ( ! $calendar instanceof Default_Calendar ) { |
|
| 502 | + if (empty($calendar)) { |
|
| 503 | + $calendar = $this->calendar = simcal_get_calendar(intval($id)); |
|
| 504 | + if ( ! $calendar instanceof Default_Calendar) { |
|
| 505 | 505 | return ''; |
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | $now = $calendar->now; |
| 510 | - $current_events = $this->get_events( $timestamp ); |
|
| 510 | + $current_events = $this->get_events($timestamp); |
|
| 511 | 511 | $format = $calendar->date_format; |
| 512 | 512 | |
| 513 | 513 | ob_start(); |
| 514 | 514 | |
| 515 | 515 | // Draw the events. |
| 516 | 516 | |
| 517 | - $block_tag = $calendar->compact_list && ! empty( $current_events ) ? 'div' : 'dl'; |
|
| 517 | + $block_tag = $calendar->compact_list && ! empty($current_events) ? 'div' : 'dl'; |
|
| 518 | 518 | |
| 519 | 519 | $data_heading = ''; |
| 520 | 520 | $heading = $this->get_heading(); |
| 521 | - foreach ( $heading as $k => $v ) { |
|
| 522 | - $data_heading .= ' data-heading-' . $k . '="' . $v . '"'; |
|
| 521 | + foreach ($heading as $k => $v) { |
|
| 522 | + $data_heading .= ' data-heading-'.$k.'="'.$v.'"'; |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - echo '<' . $block_tag . ' class="simcal-events-list-container"' . |
|
| 526 | - ' data-prev="' . $this->prev . '"' . |
|
| 527 | - ' data-next="' . $this->next . '"' . |
|
| 528 | - $data_heading . '>'; |
|
| 525 | + echo '<'.$block_tag.' class="simcal-events-list-container"'. |
|
| 526 | + ' data-prev="'.$this->prev.'"'. |
|
| 527 | + ' data-next="'.$this->next.'"'. |
|
| 528 | + $data_heading.'>'; |
|
| 529 | 529 | |
| 530 | - if ( ! empty( $current_events ) && is_array( $current_events ) ) : |
|
| 530 | + if ( ! empty($current_events) && is_array($current_events)) : |
|
| 531 | 531 | |
| 532 | 532 | $last_event = null; |
| 533 | 533 | |
| 534 | - foreach ( $current_events as $ymd => $events ) : |
|
| 534 | + foreach ($current_events as $ymd => $events) : |
|
| 535 | 535 | |
| 536 | 536 | // This is where we can find out if an event is a multi-day event and if it needs to be shown. |
| 537 | 537 | // Since this is for list view we are showing the event on the day viewed if it is part of that day even when |
@@ -539,20 +539,20 @@ discard block |
||
| 539 | 539 | |
| 540 | 540 | $first_event = $events[0][0]; |
| 541 | 541 | |
| 542 | - if ( isset( $first_event->multiple_days ) && $first_event->multiple_days > 0 ) { |
|
| 542 | + if (isset($first_event->multiple_days) && $first_event->multiple_days > 0) { |
|
| 543 | 543 | |
| 544 | - if ( 'current_day_only' == get_post_meta( $calendar->id, '_default_calendar_expand_multi_day_events', true ) ) { |
|
| 544 | + if ('current_day_only' == get_post_meta($calendar->id, '_default_calendar_expand_multi_day_events', true)) { |
|
| 545 | 545 | |
| 546 | - $year = substr( $ymd, 0, 4 ); |
|
| 547 | - $month = substr( $ymd, 4, 2 ); |
|
| 548 | - $day = substr( $ymd, 6, 2 ); |
|
| 546 | + $year = substr($ymd, 0, 4); |
|
| 547 | + $month = substr($ymd, 4, 2); |
|
| 548 | + $day = substr($ymd, 6, 2); |
|
| 549 | 549 | |
| 550 | - $temp_date = Carbon::createFromDate( $year, $month, $day ); |
|
| 550 | + $temp_date = Carbon::createFromDate($year, $month, $day); |
|
| 551 | 551 | |
| 552 | - if ( ! ( $temp_date < Carbon::now()->endOfDay() ) ) { |
|
| 552 | + if ( ! ($temp_date < Carbon::now()->endOfDay())) { |
|
| 553 | 553 | |
| 554 | 554 | // Break here only if event already shown once. |
| 555 | - if ( $last_event == $first_event ) { |
|
| 555 | + if ($last_event == $first_event) { |
|
| 556 | 556 | continue; |
| 557 | 557 | } else { |
| 558 | 558 | // Save event as "last" for next time through, then break. |
@@ -563,139 +563,139 @@ discard block |
||
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | // Add offset offset for list view day headings. |
| 566 | - $day_date = Carbon::createFromFormat( 'Ymd', $ymd, $calendar->timezone ); |
|
| 566 | + $day_date = Carbon::createFromFormat('Ymd', $ymd, $calendar->timezone); |
|
| 567 | 567 | $day_date_offset = clone $day_date; |
| 568 | - $day_date_offset->addSeconds( $day_date->offset ); |
|
| 568 | + $day_date_offset->addSeconds($day_date->offset); |
|
| 569 | 569 | $day_date_ts_offset = $day_date_offset->timestamp; |
| 570 | 570 | |
| 571 | - if ( ! $calendar->compact_list ) { |
|
| 572 | - if ( $day_date_offset->isToday() ) { |
|
| 573 | - $the_color = new Color( $calendar->today_color ); |
|
| 571 | + if ( ! $calendar->compact_list) { |
|
| 572 | + if ($day_date_offset->isToday()) { |
|
| 573 | + $the_color = new Color($calendar->today_color); |
|
| 574 | 574 | } else { |
| 575 | - $the_color = new Color( $calendar->days_events_color ); |
|
| 575 | + $the_color = new Color($calendar->days_events_color); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $bg_color = '#' . $the_color->getHex(); |
|
| 578 | + $bg_color = '#'.$the_color->getHex(); |
|
| 579 | 579 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
| 580 | - $border_style = ' style="border-bottom: 1px solid ' . $bg_color . ';" '; |
|
| 581 | - $bg_style = ' style="background-color: ' . $bg_color . '; color: ' . $color . ';"'; |
|
| 580 | + $border_style = ' style="border-bottom: 1px solid '.$bg_color.';" '; |
|
| 581 | + $bg_style = ' style="background-color: '.$bg_color.'; color: '.$color.';"'; |
|
| 582 | 582 | |
| 583 | - echo "\t" . '<dt class="simcal-day-label"' . $border_style . '>'; |
|
| 584 | - echo '<span' . $bg_style . '>'; |
|
| 583 | + echo "\t".'<dt class="simcal-day-label"'.$border_style.'>'; |
|
| 584 | + echo '<span'.$bg_style.'>'; |
|
| 585 | 585 | |
| 586 | - echo $format ? '<span class="simcal-date-format" data-date-format="' . $format . '">' . date_i18n( $format, $day_date_ts_offset, strtotime( $day_date_offset->toDateTimeString() ) ) . '</span> ' : ' '; |
|
| 586 | + echo $format ? '<span class="simcal-date-format" data-date-format="'.$format.'">'.date_i18n($format, $day_date_ts_offset, strtotime($day_date_offset->toDateTimeString())).'</span> ' : ' '; |
|
| 587 | 587 | |
| 588 | 588 | echo '</span>'; |
| 589 | - echo '</dt>' . "\n"; |
|
| 589 | + echo '</dt>'."\n"; |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - $list_events = '<ul class="simcal-events">' . "\n"; |
|
| 592 | + $list_events = '<ul class="simcal-events">'."\n"; |
|
| 593 | 593 | |
| 594 | 594 | $calendar_classes = array(); |
| 595 | 595 | |
| 596 | 596 | // Add day of week number to CSS class. |
| 597 | - $day_classes = 'simcal-weekday-' . date( 'w', $day_date_ts_offset ); |
|
| 597 | + $day_classes = 'simcal-weekday-'.date('w', $day_date_ts_offset); |
|
| 598 | 598 | |
| 599 | 599 | // Is this the present, the past or the future, Doc? |
| 600 | - if ( $timestamp <= $now && $timestamp >= $now ) { |
|
| 600 | + if ($timestamp <= $now && $timestamp >= $now) { |
|
| 601 | 601 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
| 602 | - } elseif ( $timestamp < $now ) { |
|
| 602 | + } elseif ($timestamp < $now) { |
|
| 603 | 603 | $day_classes .= ' simcal-past simcal-day'; |
| 604 | - } elseif ( $this->end > $now ) { |
|
| 604 | + } elseif ($this->end > $now) { |
|
| 605 | 605 | $day_classes .= ' simcal-future simcal-day'; |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | $count = 0; |
| 609 | 609 | |
| 610 | - foreach ( $events as $day_events ) : |
|
| 611 | - foreach ( $day_events as $event ) : |
|
| 610 | + foreach ($events as $day_events) : |
|
| 611 | + foreach ($day_events as $event) : |
|
| 612 | 612 | |
| 613 | - if ( $event instanceof Event ) : |
|
| 613 | + if ($event instanceof Event) : |
|
| 614 | 614 | |
| 615 | 615 | $event_classes = $event_visibility = ''; |
| 616 | 616 | |
| 617 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
| 617 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
| 618 | 618 | $calendar_classes[] = $calendar_class; |
| 619 | 619 | |
| 620 | 620 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
| 621 | 621 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
| 622 | 622 | |
| 623 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class; |
|
| 623 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class; |
|
| 624 | 624 | |
| 625 | 625 | // Toggle some events visibility if more than optional limit. |
| 626 | - if ( ( $calendar->events_limit > - 1 ) && ( $count >= $calendar->events_limit ) ) : |
|
| 626 | + if (($calendar->events_limit > - 1) && ($count >= $calendar->events_limit)) : |
|
| 627 | 627 | $event_classes .= ' simcal-event-toggled'; |
| 628 | 628 | $event_visibility = ' style="display: none"'; |
| 629 | 629 | endif; |
| 630 | 630 | |
| 631 | 631 | $event_color = $event->get_color(); |
| 632 | - if ( ! empty( $event_color ) ) { |
|
| 632 | + if ( ! empty($event_color)) { |
|
| 633 | 633 | $side = is_rtl() ? 'right' : 'left'; |
| 634 | - $event_color = ' style="border-' . $side . ': 4px solid ' . $event_color . '; padding-' . $side . ': 8px;"'; |
|
| 634 | + $event_color = ' style="border-'.$side.': 4px solid '.$event_color.'; padding-'.$side.': 8px;"'; |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . $event_color . ' itemscope itemtype="http://schema.org/Event" data-start="' . esc_attr( $event->start ) . '">' . "\n"; |
|
| 638 | - $list_events .= "\t\t" . '<div class="simcal-event-details">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
| 639 | - $list_events .= "\t" . '</li>' . "\n"; |
|
| 637 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.$event_color.' itemscope itemtype="http://schema.org/Event" data-start="'.esc_attr($event->start).'">'."\n"; |
|
| 638 | + $list_events .= "\t\t".'<div class="simcal-event-details">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
| 639 | + $list_events .= "\t".'</li>'."\n"; |
|
| 640 | 640 | |
| 641 | - $count ++; |
|
| 641 | + $count++; |
|
| 642 | 642 | |
| 643 | 643 | // Event falls within today. |
| 644 | - if ( ( $this->end <= $now ) && ( $this->start >= $now ) ) : |
|
| 644 | + if (($this->end <= $now) && ($this->start >= $now)) : |
|
| 645 | 645 | $day_classes .= ' simcal-today-has-events'; |
| 646 | 646 | endif; |
| 647 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
| 647 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
| 648 | 648 | |
| 649 | - if ( $calendar_classes ) : |
|
| 650 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
| 649 | + if ($calendar_classes) : |
|
| 650 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
| 651 | 651 | endif; |
| 652 | 652 | |
| 653 | 653 | endif; |
| 654 | 654 | endforeach; |
| 655 | 655 | endforeach; |
| 656 | 656 | |
| 657 | - $list_events .= '</ul>' . "\n"; |
|
| 657 | + $list_events .= '</ul>'."\n"; |
|
| 658 | 658 | |
| 659 | 659 | // If events visibility is limited, print the button toggle. |
| 660 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
| 660 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
| 661 | 661 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
| 662 | 662 | endif; |
| 663 | 663 | |
| 664 | 664 | // Print final list of events for the current day. |
| 665 | 665 | $tag = $calendar->compact_list ? 'div' : 'dd'; |
| 666 | - echo '<' . $tag . ' class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
| 667 | - echo "\t" . $list_events . "\n"; |
|
| 668 | - echo '</' . $tag . '>' . "\n"; |
|
| 666 | + echo '<'.$tag.' class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
| 667 | + echo "\t".$list_events."\n"; |
|
| 668 | + echo '</'.$tag.'>'."\n"; |
|
| 669 | 669 | |
| 670 | 670 | endforeach; |
| 671 | 671 | |
| 672 | 672 | else : |
| 673 | 673 | |
| 674 | - echo "\t" . '<p>'; |
|
| 674 | + echo "\t".'<p>'; |
|
| 675 | 675 | |
| 676 | - $message = get_post_meta( $calendar->id, '_no_events_message', true ); |
|
| 676 | + $message = get_post_meta($calendar->id, '_no_events_message', true); |
|
| 677 | 677 | |
| 678 | - if ( 'events' == $calendar->group_type ) { |
|
| 679 | - echo ! empty( $message ) ? $message : __( 'There are no upcoming events.', 'google-calendar-events' ); |
|
| 678 | + if ('events' == $calendar->group_type) { |
|
| 679 | + echo ! empty($message) ? $message : __('There are no upcoming events.', 'google-calendar-events'); |
|
| 680 | 680 | } else { |
| 681 | - if ( ! empty( $message ) ) { |
|
| 681 | + if ( ! empty($message)) { |
|
| 682 | 682 | echo $message; |
| 683 | 683 | } else { |
| 684 | - $from = Carbon::createFromTimestamp( $this->start, $calendar->timezone )->getTimestamp(); |
|
| 685 | - $to = Carbon::createFromTimestamp( $this->end, $calendar->timezone )->getTimestamp(); |
|
| 686 | - echo apply_filters( 'simcal_no_events_message', sprintf( |
|
| 687 | - __( 'Nothing from %1$s to %2$s.', 'google-calendar-events' ), |
|
| 688 | - date_i18n( $calendar->date_format, $from ), |
|
| 689 | - date_i18n( $calendar->date_format, $to ) |
|
| 690 | - ), $calendar->id, $from, $to ); |
|
| 684 | + $from = Carbon::createFromTimestamp($this->start, $calendar->timezone)->getTimestamp(); |
|
| 685 | + $to = Carbon::createFromTimestamp($this->end, $calendar->timezone)->getTimestamp(); |
|
| 686 | + echo apply_filters('simcal_no_events_message', sprintf( |
|
| 687 | + __('Nothing from %1$s to %2$s.', 'google-calendar-events'), |
|
| 688 | + date_i18n($calendar->date_format, $from), |
|
| 689 | + date_i18n($calendar->date_format, $to) |
|
| 690 | + ), $calendar->id, $from, $to); |
|
| 691 | 691 | } |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | - echo "\t" . '</p>' . "\n"; |
|
| 694 | + echo "\t".'</p>'."\n"; |
|
| 695 | 695 | |
| 696 | 696 | endif; |
| 697 | 697 | |
| 698 | - echo '</' . $block_tag . '>'; |
|
| 698 | + echo '</'.$block_tag.'>'; |
|
| 699 | 699 | |
| 700 | 700 | return ob_get_clean(); |
| 701 | 701 | } |
@@ -707,16 +707,16 @@ discard block |
||
| 707 | 707 | */ |
| 708 | 708 | public function draw_list_ajax() { |
| 709 | 709 | |
| 710 | - if ( isset( $_POST['ts'] ) && isset( $_POST['id'] ) ) { |
|
| 710 | + if (isset($_POST['ts']) && isset($_POST['id'])) { |
|
| 711 | 711 | |
| 712 | - $ts = absint( $_POST['ts'] ); |
|
| 713 | - $id = absint( $_POST['id'] ); |
|
| 712 | + $ts = absint($_POST['ts']); |
|
| 713 | + $id = absint($_POST['id']); |
|
| 714 | 714 | |
| 715 | - wp_send_json_success( $this->draw_list( $ts, $id ) ); |
|
| 715 | + wp_send_json_success($this->draw_list($ts, $id)); |
|
| 716 | 716 | |
| 717 | 717 | } else { |
| 718 | 718 | |
| 719 | - wp_send_json_error( 'Missing arguments in default calendar list ajax request.' ); |
|
| 719 | + wp_send_json_error('Missing arguments in default calendar list ajax request.'); |
|
| 720 | 720 | |
| 721 | 721 | } |
| 722 | 722 | } |
@@ -731,8 +731,8 @@ discard block |
||
| 731 | 731 | * |
| 732 | 732 | * @return bool |
| 733 | 733 | */ |
| 734 | - private function filter_events_before( $event ) { |
|
| 735 | - return intval( $event ) >= intval( $this->start ); |
|
| 734 | + private function filter_events_before($event) { |
|
| 735 | + return intval($event) >= intval($this->start); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -745,8 +745,8 @@ discard block |
||
| 745 | 745 | * |
| 746 | 746 | * @return bool |
| 747 | 747 | */ |
| 748 | - private function filter_events_after( $event ) { |
|
| 749 | - return intval( $event ) < intval( $this->end ); |
|
| 748 | + private function filter_events_after($event) { |
|
| 749 | + return intval($event) < intval($this->end); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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,12 +299,12 @@ discard block |
||
| 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 | } |
@@ -313,68 +313,68 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | // Variables to cycle days in current month and find today in calendar. |
| 315 | 315 | $now = $calendar->now; |
| 316 | - $current = Carbon::create( $year, $month, 1, 0, 0, 0, $calendar->timezone ); |
|
| 316 | + $current = Carbon::create($year, $month, 1, 0, 0, 0, $calendar->timezone); |
|
| 317 | 317 | $current_min = $current->getTimestamp(); |
| 318 | 318 | $current_max = $current->endOfDay()->getTimestamp(); |
| 319 | 319 | |
| 320 | 320 | // Calendar grid variables. |
| 321 | 321 | $week_starts = $calendar->week_starts; |
| 322 | - $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
| 323 | - $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
| 324 | - $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
| 322 | + $week_of_year = $current->weekOfYear; // Relative count of the week number of the year. |
|
| 323 | + $month_starts = $current->dayOfWeek; // Day upon which the month starts. |
|
| 324 | + $days_in_month = $current->daysInMonth; // Number of days in the given month. |
|
| 325 | 325 | |
| 326 | 326 | // Set current month events timestamp boundaries. |
| 327 | 327 | $this->start = $current_min; |
| 328 | 328 | $this->end = $current->endOfMonth()->getTimestamp(); |
| 329 | 329 | |
| 330 | 330 | // Get daily events for this month. |
| 331 | - if ( $events && is_array( $events ) ) { |
|
| 331 | + if ($events && is_array($events)) { |
|
| 332 | 332 | |
| 333 | 333 | // Filter events within the boundaries previously set above. |
| 334 | - $timestamps = array_keys( $events ); |
|
| 335 | - $lower_bound = array_filter( $timestamps, array( $this, 'filter_events_before' ) ); |
|
| 336 | - $higher_bound = array_filter( $lower_bound, array( $this, 'filter_events_after' ) ); |
|
| 337 | - $filtered = ( is_array( $events ) && is_array( $higher_bound) ) && ! empty( $events ) && ! empty( $higher_bound ) ? array_intersect_key( $events, array_combine( $higher_bound, $higher_bound ) ) : array(); |
|
| 334 | + $timestamps = array_keys($events); |
|
| 335 | + $lower_bound = array_filter($timestamps, array($this, 'filter_events_before')); |
|
| 336 | + $higher_bound = array_filter($lower_bound, array($this, 'filter_events_after')); |
|
| 337 | + $filtered = (is_array($events) && is_array($higher_bound)) && ! empty($events) && ! empty($higher_bound) ? array_intersect_key($events, array_combine($higher_bound, $higher_bound)) : array(); |
|
| 338 | 338 | |
| 339 | 339 | // Put resulting events in an associative array, with day of the month as key for easy retrieval in calendar days loop. |
| 340 | 340 | $day_events = array(); |
| 341 | - foreach ( $filtered as $timestamp => $events_in_day ) { |
|
| 342 | - foreach ( $events_in_day as $event ) { |
|
| 343 | - if ( $event instanceof Event ){ |
|
| 344 | - $day = intval( Carbon::createFromTimestamp( $timestamp, $calendar->timezone )->endOfDay()->day ); |
|
| 345 | - $day_events[ $day ][] = $event; |
|
| 341 | + foreach ($filtered as $timestamp => $events_in_day) { |
|
| 342 | + foreach ($events_in_day as $event) { |
|
| 343 | + if ($event instanceof Event) { |
|
| 344 | + $day = intval(Carbon::createFromTimestamp($timestamp, $calendar->timezone)->endOfDay()->day); |
|
| 345 | + $day_events[$day][] = $event; |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - ksort( $day_events, SORT_NUMERIC ); |
|
| 350 | + ksort($day_events, SORT_NUMERIC); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | ob_start(); |
| 354 | 354 | |
| 355 | - echo '<tbody class="simcal-month simcal-month-' . $month . '">' . "\n"; |
|
| 356 | - echo "\t" . '<tr class="simcal-week simcal-week-' . $week_of_year . '">'; |
|
| 355 | + echo '<tbody class="simcal-month simcal-month-'.$month.'">'."\n"; |
|
| 356 | + echo "\t".'<tr class="simcal-week simcal-week-'.$week_of_year.'">'; |
|
| 357 | 357 | |
| 358 | 358 | $days_in_row = 0; |
| 359 | 359 | // Week may start on an arbitrary day (sun, 0 - sat, 6). |
| 360 | 360 | $week_day = $week_starts; |
| 361 | 361 | |
| 362 | 362 | // This fixes a possible bug when a month starts by Sunday (0). |
| 363 | - if ( 0 !== $week_starts ) { |
|
| 363 | + if (0 !== $week_starts) { |
|
| 364 | 364 | $b = $month_starts === 0 ? 7 : $month_starts; |
| 365 | 365 | } else { |
| 366 | 366 | $b = $month_starts; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | // Void days in first week. |
| 370 | - for ( $a = $week_starts; $a < $b; $a++ ) : |
|
| 370 | + for ($a = $week_starts; $a < $b; $a++) : |
|
| 371 | 371 | |
| 372 | - $last_void_day_class = ( $a === ( $b - 1 ) ) ? 'simcal-day-void-last' : ''; |
|
| 372 | + $last_void_day_class = ($a === ($b - 1)) ? 'simcal-day-void-last' : ''; |
|
| 373 | 373 | |
| 374 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
| 374 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
| 375 | 375 | |
| 376 | 376 | // Reset day of the week count (sun, 0 - sat, 6). |
| 377 | - if ( $week_day === 6 ) { |
|
| 377 | + if ($week_day === 6) { |
|
| 378 | 378 | $week_day = -1; |
| 379 | 379 | } |
| 380 | 380 | $week_day++; |
@@ -384,97 +384,97 @@ discard block |
||
| 384 | 384 | endfor; |
| 385 | 385 | |
| 386 | 386 | // Actual days of the month. |
| 387 | - for ( $day = 1; $day <= $days_in_month; $day++ ) : |
|
| 387 | + for ($day = 1; $day <= $days_in_month; $day++) : |
|
| 388 | 388 | |
| 389 | 389 | $count = 0; |
| 390 | 390 | $calendar_classes = array(); |
| 391 | - $day_classes = 'simcal-day-' . $day . ' simcal-weekday-' . $week_day; |
|
| 391 | + $day_classes = 'simcal-day-'.$day.' simcal-weekday-'.$week_day; |
|
| 392 | 392 | |
| 393 | 393 | $border_style = $bg_color = $color = ''; |
| 394 | 394 | |
| 395 | 395 | // Is this the present, the past or the future, Doc? |
| 396 | - if ( $current_min <= $now && $current_max >= $now ) { |
|
| 396 | + if ($current_min <= $now && $current_max >= $now) { |
|
| 397 | 397 | $day_classes .= ' simcal-today simcal-present simcal-day'; |
| 398 | - $the_color = new Color( $calendar->today_color ); |
|
| 399 | - $bg_color = '#' . $the_color->getHex(); |
|
| 398 | + $the_color = new Color($calendar->today_color); |
|
| 399 | + $bg_color = '#'.$the_color->getHex(); |
|
| 400 | 400 | $color = $the_color->isDark() ? '#ffffff' : '#000000'; |
| 401 | - $border_style = ' style="border: 1px solid ' . $bg_color . ';"'; |
|
| 402 | - } elseif ( $current_max < $now ) { |
|
| 401 | + $border_style = ' style="border: 1px solid '.$bg_color.';"'; |
|
| 402 | + } elseif ($current_max < $now) { |
|
| 403 | 403 | $day_classes .= ' simcal-past simcal-day'; |
| 404 | - } elseif ( $current_min > $now ) { |
|
| 404 | + } elseif ($current_min > $now) { |
|
| 405 | 405 | $day_classes .= ' simcal-future simcal-day'; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // Print events for the current day in loop, if found any. |
| 409 | - if ( isset( $day_events[ $day ] ) ) : |
|
| 409 | + if (isset($day_events[$day])) : |
|
| 410 | 410 | |
| 411 | 411 | $bullet_colors = array(); |
| 412 | 412 | |
| 413 | 413 | $list_events = '<ul class="simcal-events">'; |
| 414 | 414 | |
| 415 | - foreach ( $day_events[ $day ] as $event ) : |
|
| 415 | + foreach ($day_events[$day] as $event) : |
|
| 416 | 416 | |
| 417 | 417 | $event_classes = $event_visibility = ''; |
| 418 | 418 | |
| 419 | - if ( $event instanceof Event ) : |
|
| 419 | + if ($event instanceof Event) : |
|
| 420 | 420 | |
| 421 | 421 | // Store the calendar id where the event belongs (useful in grouped calendar feeds) |
| 422 | - $calendar_class = 'simcal-events-calendar-' . strval( $event->calendar ); |
|
| 423 | - $calendar_classes[] = $calendar_class ; |
|
| 422 | + $calendar_class = 'simcal-events-calendar-'.strval($event->calendar); |
|
| 423 | + $calendar_classes[] = $calendar_class; |
|
| 424 | 424 | |
| 425 | 425 | $recurring = $event->recurrence ? 'simcal-event-recurring ' : ''; |
| 426 | 426 | $has_location = $event->venue ? 'simcal-event-has-location ' : ''; |
| 427 | 427 | |
| 428 | - $event_classes .= 'simcal-event ' . $recurring . $has_location . $calendar_class . ' simcal-tooltip'; |
|
| 428 | + $event_classes .= 'simcal-event '.$recurring.$has_location.$calendar_class.' simcal-tooltip'; |
|
| 429 | 429 | |
| 430 | 430 | // Toggle some events visibility if more than optional limit. |
| 431 | - if ( ( $calendar->events_limit > -1 ) && ( $count >= $calendar->events_limit ) ) : |
|
| 431 | + if (($calendar->events_limit > -1) && ($count >= $calendar->events_limit)) : |
|
| 432 | 432 | $event_classes .= ' simcal-event-toggled'; |
| 433 | 433 | $event_visibility = ' style="display: none"'; |
| 434 | 434 | endif; |
| 435 | 435 | |
| 436 | 436 | // Event title in list. |
| 437 | - $title = ! empty( $event->title ) ? trim( $event->title ) : __( 'Event', 'google-calendar-events' ); |
|
| 438 | - if ( $calendar->trim_titles >= 1 ) { |
|
| 439 | - $title = strlen( $title ) > $calendar->trim_titles ? mb_substr( $title, 0, $calendar->trim_titles ) . '…' : $title; |
|
| 437 | + $title = ! empty($event->title) ? trim($event->title) : __('Event', 'google-calendar-events'); |
|
| 438 | + if ($calendar->trim_titles >= 1) { |
|
| 439 | + $title = strlen($title) > $calendar->trim_titles ? mb_substr($title, 0, $calendar->trim_titles).'…' : $title; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | // Event color. |
| 443 | 443 | $bullet = ''; |
| 444 | 444 | //$bullet_color = '#000'; |
| 445 | 445 | $event_color = $event->get_color(); |
| 446 | - if ( ! empty( $event_color ) ) { |
|
| 447 | - $bullet = '<span style="color: ' . $event_color . ';">■</span> '; |
|
| 446 | + if ( ! empty($event_color)) { |
|
| 447 | + $bullet = '<span style="color: '.$event_color.';">■</span> '; |
|
| 448 | 448 | $bullet_colors[] = $event_color; |
| 449 | 449 | } else { |
| 450 | 450 | $bullet_colors[] = '#000'; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | // Event contents. |
| 454 | - $list_events .= "\t" . '<li class="' . $event_classes . '"' . $event_visibility . ' itemscope itemtype="http://schema.org/Event">' . "\n"; |
|
| 455 | - $list_events .= "\t\t" . '<span class="simcal-event-title">' . $bullet . $title . '</span>' . "\n"; |
|
| 456 | - $list_events .= "\t\t" . '<div class="simcal-event-details simcal-tooltip-content" style="display: none;">' . $calendar->get_event_html( $event ) . '</div>' . "\n"; |
|
| 457 | - $list_events .= "\t" . '</li>' . "\n"; |
|
| 454 | + $list_events .= "\t".'<li class="'.$event_classes.'"'.$event_visibility.' itemscope itemtype="http://schema.org/Event">'."\n"; |
|
| 455 | + $list_events .= "\t\t".'<span class="simcal-event-title">'.$bullet.$title.'</span>'."\n"; |
|
| 456 | + $list_events .= "\t\t".'<div class="simcal-event-details simcal-tooltip-content" style="display: none;">'.$calendar->get_event_html($event).'</div>'."\n"; |
|
| 457 | + $list_events .= "\t".'</li>'."\n"; |
|
| 458 | 458 | |
| 459 | - $count ++; |
|
| 459 | + $count++; |
|
| 460 | 460 | |
| 461 | 461 | endif; |
| 462 | 462 | |
| 463 | 463 | endforeach; |
| 464 | 464 | |
| 465 | - if ( ( $current_min <= $now ) && ( $current_max >= $now ) ) { |
|
| 465 | + if (($current_min <= $now) && ($current_max >= $now)) { |
|
| 466 | 466 | $day_classes .= ' simcal-today-has-events'; |
| 467 | 467 | } |
| 468 | - $day_classes .= ' simcal-day-has-events simcal-day-has-' . strval( $count ) . '-events'; |
|
| 468 | + $day_classes .= ' simcal-day-has-events simcal-day-has-'.strval($count).'-events'; |
|
| 469 | 469 | |
| 470 | - if ( $calendar_classes ) { |
|
| 471 | - $day_classes .= ' ' . trim( implode( ' ', array_unique( $calendar_classes ) ) ); |
|
| 470 | + if ($calendar_classes) { |
|
| 471 | + $day_classes .= ' '.trim(implode(' ', array_unique($calendar_classes))); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - $list_events .= '</ul>' . "\n"; |
|
| 474 | + $list_events .= '</ul>'."\n"; |
|
| 475 | 475 | |
| 476 | 476 | // Optional button to toggle hidden events in list. |
| 477 | - if ( ( $calendar->events_limit > -1 ) && ( $count > $calendar->events_limit ) ) : |
|
| 477 | + if (($calendar->events_limit > -1) && ($count > $calendar->events_limit)) : |
|
| 478 | 478 | $list_events .= '<button class="simcal-events-toggle"><i class="simcal-icon-down simcal-icon-animate"></i></button>'; |
| 479 | 479 | endif; |
| 480 | 480 | |
@@ -486,49 +486,49 @@ discard block |
||
| 486 | 486 | endif; |
| 487 | 487 | |
| 488 | 488 | // The actual days with numbers and events in each row cell. |
| 489 | - echo '<td class="' . $day_classes . '" data-events-count="' . strval( $count ) . '">' . "\n"; |
|
| 490 | - |
|
| 491 | - if ( $color ) { |
|
| 492 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
| 493 | - } elseif ( $count > 0 ) { |
|
| 494 | - $the_color = new Color( $calendar->days_events_color ); |
|
| 495 | - $color = ! $color ? ( $the_color->isDark() ? '#ffffff' : '#000000' ) : $color; |
|
| 496 | - $bg_color = ! $bg_color ? '#' . $the_color->getHex() : $bg_color; |
|
| 497 | - $day_style = ' style="background-color: ' . $bg_color . '; color: ' . $color .'"'; |
|
| 489 | + echo '<td class="'.$day_classes.'" data-events-count="'.strval($count).'">'."\n"; |
|
| 490 | + |
|
| 491 | + if ($color) { |
|
| 492 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
| 493 | + } elseif ($count > 0) { |
|
| 494 | + $the_color = new Color($calendar->days_events_color); |
|
| 495 | + $color = ! $color ? ($the_color->isDark() ? '#ffffff' : '#000000') : $color; |
|
| 496 | + $bg_color = ! $bg_color ? '#'.$the_color->getHex() : $bg_color; |
|
| 497 | + $day_style = ' style="background-color: '.$bg_color.'; color: '.$color.'"'; |
|
| 498 | 498 | } else { |
| 499 | 499 | $day_style = ''; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - echo "\t" . '<div' . $border_style . '>' . "\n"; |
|
| 503 | - echo "\t\t" . '<span class="simcal-day-label simcal-day-number"' . $day_style . '>' . $day . '</span>' . "\n"; |
|
| 504 | - echo "\t\t" . $list_events . "\n"; |
|
| 502 | + echo "\t".'<div'.$border_style.'>'."\n"; |
|
| 503 | + echo "\t\t".'<span class="simcal-day-label simcal-day-number"'.$day_style.'>'.$day.'</span>'."\n"; |
|
| 504 | + echo "\t\t".$list_events."\n"; |
|
| 505 | 505 | echo "\t\t"; |
| 506 | 506 | echo '<span class="simcal-events-dots" style="display: none;">'; |
| 507 | 507 | |
| 508 | 508 | // Event bullets for calendar mobile mode. |
| 509 | - for( $i = 0; $i < $count; $i++ ) { |
|
| 510 | - echo '<b style="color: ' . $bullet_colors[ $i ] . ';"> • </b>'; |
|
| 509 | + for ($i = 0; $i < $count; $i++) { |
|
| 510 | + echo '<b style="color: '.$bullet_colors[$i].';"> • </b>'; |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | - echo '</span>' . "\n"; |
|
| 514 | - echo "\t" . '</div>' . "\n"; |
|
| 515 | - echo '</td>' . "\n"; |
|
| 513 | + echo '</span>'."\n"; |
|
| 514 | + echo "\t".'</div>'."\n"; |
|
| 515 | + echo '</td>'."\n"; |
|
| 516 | 516 | |
| 517 | 517 | // Reset day of the week count (sun, 0 - sat, 6). |
| 518 | - if ( $week_day === 6 ) { |
|
| 518 | + if ($week_day === 6) { |
|
| 519 | 519 | $week_day = - 1; |
| 520 | 520 | } |
| 521 | 521 | $week_day++; |
| 522 | 522 | |
| 523 | 523 | // Reset count of days for this row (0-6). |
| 524 | - if ( $days_in_row === 6 ) : |
|
| 524 | + if ($days_in_row === 6) : |
|
| 525 | 525 | |
| 526 | 526 | // Close the week row. |
| 527 | 527 | echo '</tr>'; |
| 528 | 528 | |
| 529 | 529 | // Open a new week row. |
| 530 | - if ( $day < $days_in_month ) { |
|
| 531 | - echo '<tr class="simcal-week simcal-week-' . $week_of_year++ . '">' . "\n"; |
|
| 530 | + if ($day < $days_in_month) { |
|
| 531 | + echo '<tr class="simcal-week simcal-week-'.$week_of_year++.'">'."\n"; |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | $days_in_row = -1; |
@@ -537,25 +537,25 @@ discard block |
||
| 537 | 537 | |
| 538 | 538 | $days_in_row++; |
| 539 | 539 | |
| 540 | - $current_min = Carbon::createFromTimestamp( $current_min, $calendar->timezone )->addDay()->getTimestamp(); |
|
| 541 | - $current_max = Carbon::createFromTimestamp( $current_max, $calendar->timezone )->addDay()->getTimestamp(); |
|
| 540 | + $current_min = Carbon::createFromTimestamp($current_min, $calendar->timezone)->addDay()->getTimestamp(); |
|
| 541 | + $current_max = Carbon::createFromTimestamp($current_max, $calendar->timezone)->addDay()->getTimestamp(); |
|
| 542 | 542 | |
| 543 | 543 | endfor; |
| 544 | 544 | |
| 545 | 545 | // Void days at the end of the month. |
| 546 | - $remainder_days = ( 6 - $days_in_row ); |
|
| 546 | + $remainder_days = (6 - $days_in_row); |
|
| 547 | 547 | |
| 548 | - for ( $i = 0; $i <= $remainder_days; $i ++ ) { |
|
| 548 | + for ($i = 0; $i <= $remainder_days; $i++) { |
|
| 549 | 549 | |
| 550 | - $last_void_day_class = ( $i == $remainder_days ) ? 'simcal-day-void-last' : ''; |
|
| 550 | + $last_void_day_class = ($i == $remainder_days) ? 'simcal-day-void-last' : ''; |
|
| 551 | 551 | |
| 552 | - echo '<td class="simcal-day simcal-day-void ' . $last_void_day_class . '"></td>' . "\n"; |
|
| 552 | + echo '<td class="simcal-day simcal-day-void '.$last_void_day_class.'"></td>'."\n"; |
|
| 553 | 553 | |
| 554 | 554 | $week_day++; |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - echo "\t" . '</tr>' . "\n"; |
|
| 558 | - echo '</tbody>' . "\n"; |
|
| 557 | + echo "\t".'</tr>'."\n"; |
|
| 558 | + echo '</tbody>'."\n"; |
|
| 559 | 559 | |
| 560 | 560 | return ob_get_clean(); |
| 561 | 561 | } |
@@ -567,17 +567,17 @@ discard block |
||
| 567 | 567 | */ |
| 568 | 568 | public function draw_grid_ajax() { |
| 569 | 569 | |
| 570 | - if ( isset( $_POST['month'] ) && isset( $_POST['year'] ) && isset( $_POST['id'] ) ) { |
|
| 570 | + if (isset($_POST['month']) && isset($_POST['year']) && isset($_POST['id'])) { |
|
| 571 | 571 | |
| 572 | - $month = absint( $_POST['month'] ); |
|
| 573 | - $year = absint( $_POST['year'] ); |
|
| 574 | - $id = absint( $_POST['id'] ); |
|
| 572 | + $month = absint($_POST['month']); |
|
| 573 | + $year = absint($_POST['year']); |
|
| 574 | + $id = absint($_POST['id']); |
|
| 575 | 575 | |
| 576 | - wp_send_json_success( $this->draw_month( $month, $year, $id ) ); |
|
| 576 | + wp_send_json_success($this->draw_month($month, $year, $id)); |
|
| 577 | 577 | |
| 578 | 578 | } else { |
| 579 | 579 | |
| 580 | - wp_send_json_error( 'Missing arguments in default calendar grid ajax request.' ); |
|
| 580 | + wp_send_json_error('Missing arguments in default calendar grid ajax request.'); |
|
| 581 | 581 | |
| 582 | 582 | } |
| 583 | 583 | |
@@ -593,8 +593,8 @@ discard block |
||
| 593 | 593 | * |
| 594 | 594 | * @return bool |
| 595 | 595 | */ |
| 596 | - private function filter_events_before( $event ) { |
|
| 597 | - return intval( $event ) >= intval( $this->start ); |
|
| 596 | + private function filter_events_before($event) { |
|
| 597 | + return intval($event) >= intval($this->start); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | /** |
@@ -607,8 +607,8 @@ discard block |
||
| 607 | 607 | * |
| 608 | 608 | * @return bool |
| 609 | 609 | */ |
| 610 | - private function filter_events_after( $event ) { |
|
| 611 | - return intval( $event ) < intval( $this->end ); |
|
| 610 | + private function filter_events_after($event) { |
|
| 611 | + return intval($event) < intval($this->end); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | } |