From ab57052a911e48d2ac4cf462686cadde9f4e9259 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Tue, 17 Dec 2024 16:01:32 -0600 Subject: [PATCH] Add `mc_date_badge()` to format a date badge. --- src/my-calendar-templates.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/my-calendar-templates.php b/src/my-calendar-templates.php index 17cf4c5b..db3da9fc 100644 --- a/src/my-calendar-templates.php +++ b/src/my-calendar-templates.php @@ -523,7 +523,7 @@ function mc_create_tags( $event, $context = 'filters' ) { $e['dtend'] = mc_date( 'Y-m-d\TH:i:s', $hcal_dt_end, false ); // Date: hcal formatted end. $e['userstart'] = ''; $e['userend'] = ''; - $e['datebadge'] = ''; + $e['datebadge'] = mc_date_badge( $real_begin_date ); /** * Start date format used in 'date' and 'daterange' template tags. Fallback value for `datespan`. Default from My Calendar settings. * @@ -1001,6 +1001,30 @@ function mc_get_details_label( $event, $e ) { return $e_label; } +/** + * Format a date into a badge. + * + * @param int $date Datestamp. + * + * @return string + */ +function mc_date_badge( $date ) { + $badge = ''; + /** + * Filter the date badge HTML. + * + * @hook mc_date_badge + * + * @param {string} $badge HTML output of the badge. + * @param {int} $date Datestamp. + * + * @return {string} + */ + $badge = apply_filters( 'mc_date_badge', $badge, $date ); + + return $badge; +} + /** * Format a timestamp for use in iCal. *