Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Forked from joshfeck/functions.php
Last active July 2, 2018 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/3fd39bccf1c4fbc2b3324ae236229ffa to your computer and use it in GitHub Desktop.
Save Pebblo/3fd39bccf1c4fbc2b3324ae236229ffa to your computer and use it in GitHub Desktop.
espresso_list_of_event_dates, without the times being displayed if you set a 'hide-event-times' custom field.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function espresso_list_of_event_dates( $EVT_ID = FALSE, $dt_frmt = '', $tm_frmt = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE ) {
$dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : get_option('date_format');
$tm_frmt = ! empty( $tm_frmt ) ? $tm_frmt : get_option('time_format');
$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID ,$show_expired );
//d( $datetimes );
if ( is_array( $datetimes ) && ! empty( $datetimes )) {
global $post;
$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul">' : '';
foreach ( $datetimes as $datetime ) {
if ( $datetime instanceof EE_Datetime ) {
if ( $format ) {
$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID() . '" class="ee-event-datetimes-li">';
$datetime_name = $datetime->name();
$html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : '';
$html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : '';
$html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $dt_frmt ) . '';
if(! get_post_meta( $EVT_ID, 'hide-event-times', true ) ) {
$html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : '';
$html .= '<br /><span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $tm_frmt );
}
$datetime_description = $datetime->description();
$html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : '';
$html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
$html .= '</li>';
} else {
$html .= $datetime;
$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
}
}
}
$html .= $format ? '</ul>' : '';
} else {
$html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
}
if ( $echo ) {
echo $html;
} else {
return $html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment