Last active
January 10, 2019 16:57
-
-
Save cliffordp/94012b1623319b20c93b04aa050ce917 to your computer and use it in GitHub Desktop.
The Events Calendar: Remove the month, day, and datetime separator from an event's start time display.
This file contains 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 | |
/** | |
* The Events Calendar: Remove the month, day, and datetime separator from an event's start time display. | |
* | |
* Example: | |
* Before: <span class="tribe-event-date-start">January 31 @ 10:30 pm</span> - <span ... | |
* After: <span class="tribe-event-date-start">10:30 pm</span> - <span ... | |
* DOES NOT APPLY WHEN USING WordPress 5's BLOCK EDITOR. For block editor, just use this CSS: | |
* .tribe-events-schedule__datetime > .tribe-events-schedule__date--start, | |
* .tribe-events-schedule__datetime > .tribe-events-schedule__separator--date { | |
* display: none; | |
* } | |
* | |
* @link https://gist.github.com/cliffordp/94012b1623319b20c93b04aa050ce917 This snippet. | |
* | |
* @see tribe_events_event_schedule_details() | |
* | |
* @param string $inner | |
* @param int $event_id | |
* | |
* @return string | |
*/ | |
function cliff_tribe_remove_day_from_start( $inner, $event_id ) { | |
$start = '<span class="tribe-event-date-start">'; | |
// If doesn't start as expected, bail | |
if ( 0 !== strpos( $inner, $start ) ) { | |
return $inner; | |
} | |
$datetime_separator = tribe_get_option( 'dateTimeSeparator', ' @ ' ); | |
$remove_this = tribe_get_start_date( $event_id, false, '' ) . $datetime_separator; | |
$inner = str_replace( $remove_this, '', $inner ); | |
return $inner; | |
} | |
add_filter( 'tribe_events_event_schedule_details_inner', 'cliff_tribe_remove_day_from_start', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment