Last active
August 5, 2016 05:36
-
-
Save elimn/310d67f65c2bebdfce2ca42146f6ebcb to your computer and use it in GitHub Desktop.
MT | TEC | Add CSS classes to month view multiday events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Add CSS classes to month view multiday events | |
| * Three classes are added: tribe-month-multiday-event, tribe-month-multiday-start-date, tribe-month-multiday-end-date | |
| */ | |
| function tribe_add_ongoing_class_month_view ( $classes ) { | |
| global $post; | |
| $event_id = $post->ID; | |
| if( ! $event_id ) return $classes; | |
| if( ! tribe_is_month() ) return $classes; | |
| $cur_day = tribe_events_get_current_month_day(); | |
| $event_start = tribe_get_start_date( $event_id, false, 'Y-m-d' ); | |
| $event_end = tribe_get_end_date( $event_id, false, 'Y-m-d' ); | |
| $event_is_multiday = tribe_event_is_multiday( $event_id ); | |
| if ( ! $event_is_multiday ) return $classes; | |
| $classes[] = 'tribe-month-multiday-event'; | |
| if( $cur_day[ 'date' ] === $event_start ) | |
| $classes[] = 'tribe-month-multiday-start-date'; | |
| if( $cur_day[ 'date' ] === $event_end ) | |
| $classes[] = 'tribe-month-multiday-end-date'; | |
| return $classes; | |
| } | |
| add_filter( 'tribe_events_event_classes', 'tribe_add_ongoing_class_month_view', 999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment