%1$s %2$s
', esc_html__( 'All times are shown in the event timezone:', 'aisentic' ), $timezone ); } if ( '' !== $place ) { $html .= sprintf( '%1$s %2$s
', esc_html__( 'Where:', 'aisentic' ), $place ); } $html .= sprintf( '%s
', esc_html__( 'Full details will be added before this event goes live.', 'aisentic' ) ); return $html; } /** * Human readable date and time line. * * Returns one date for a one-day event and a range for a longer one. * * @param array $event Event fields. * @return string */ public static function date_line( array $event ): string { $start_date = self::format_date( (string) ( $event['start_date'] ?? '' ) ); $end_date = self::format_date( (string) ( $event['end_date'] ?? '' ) ); $start_time = substr( (string) ( $event['start_time'] ?? '' ), 0, 5 ); $end_time = substr( (string) ( $event['end_time'] ?? '' ), 0, 5 ); $parts = []; if ( '' !== $start_date && '' !== $end_date && $end_date !== $start_date ) { $parts[] = $start_date . ' - ' . $end_date; } elseif ( '' !== $start_date ) { $parts[] = $start_date; } if ( '' !== $start_time && '' !== $end_time ) { $parts[] = $start_time . ' to ' . $end_time; } return implode( ', ', $parts ); } /** * Human readable place line. * * @param array $event Event fields. * @return string */ public static function place_line( array $event ): string { $location = trim( (string) ( $event['location'] ?? '' ) ); if ( '' !== $location ) { return $location; } if ( 'online' === ( $event['event_type'] ?? '' ) ) { return __( 'Online', 'aisentic' ); } return ''; } /** * Turn YYYY-MM-DD into "12 March 2026". * * Returns the raw input when it cannot be parsed, so a bad value never * breaks event creation. * * @param string $date Date in YYYY-MM-DD format. * @return string */ private static function format_date( string $date ): string { if ( '' === trim( $date ) ) { return ''; } $parsed = \DateTime::createFromFormat( 'Y-m-d', $date ); return $parsed ? $parsed->format( 'j F Y' ) : $date; } }