Bug in event-datetime.php template
-
I have found a bug in src/views/blocks/event-datetime.php.
In the template, a check is run to see if we should format the event date without the year. The result is true if the event is happening in the current year (line 29):
$use_yearless_format = apply_filters( 'tribe_events_event_block_datetime_use_yearless_format', ( tribe_get_start_date( $event_id, false, 'Y' ) === date_i18n( 'Y' ) && tribe_get_end_date( $event_id, false, 'Y' ) === date_i18n( 'Y' ) ), $event );
Then, on line 38, the tribe_get_date_format() function is called, using the value of $use_yearless_format obtained above.
$date_format = tribe_get_date_format( $use_yearless_format );
If the event is happening in the current year, $use_yearless_format is true, so a value of true is passed to the tribe_get_date_format() function.
The problem is that the tribe_get_date_format() function takes a value of $with_year. If $with_year is true, the year is included with the event date (common/src/functions/template-tags/general.php, line 162):
function tribe_get_date_format( $with_year = false ) { if ( $with_year ) { $format = tribe_get_date_option( 'dateWithYearFormat', get_option( 'date_format' ) ); } else { $format = tribe_get_date_option( 'dateWithoutYearFormat', 'F j' ); } return apply_filters( 'tribe_date_format', $format ); }
So we’re passing the opposite value we want when calling the tribe_get_date_format() function from event-datetime.php. As a result, the year is included for events happening in the current year, but not for events happening in other years.
Please address this issue in a future release.
- The topic ‘Bug in event-datetime.php template’ is closed to new replies.