Hi,
What I’ve been dreaming of!!!!
I tried to modify my theme’s functions.php with great hope, but it does not work : instead of a tidy date, I get “#_CUSTOMDATEPLACEHOLDERNAME” – or “#_CUSTOMEVENTDATES” according to what modification I did.
This is what I added in my theme’s functions.php around line 87 (I replaced ‘M’ by ‘F’ as in my settings – full month in French).
Any idea why it goes wrong?
Thank you
// DATE TIDIER
add_filter( ’em_event_output_placeholder’, ‘my_custom_event_placeholders’, 1, 3);
/**
* Custom Events Manager placeholders
* @param string $result
* @param EM_Event $EM_Event
* @param string $placeholder
* @return string
*/
function my_custom_event_placeholders( $replace, $EM_Event, $result ) {
switch ( $result ) {
case ‘#_CUSTOMEVENTDATES’:
$replace = ”;
$start_date = strtotime( $EM_Event->event_start_date );
$end_date = strtotime( $EM_Event->event_end_date );
$timediff = $end_date – $start_date;
// Check if the number of the day is different
if ( $timediff >= 86400 ) {
// Check if is the same month
if ( date_i18n( ‘F’, $end_date ) == date_i18n( ‘F’, $start_date ) ) {
// Print only the start day
$replace = date_i18n( ‘j’, $start_date ). ‘ – ‘ . date_i18n( ‘j F Y’, $end_date );
}else{
// Check if is the same year
if ( date_i18n( ‘Y’, $end_date ) == date_i18n( ‘Y’, $start_date ) ) {
// Print only the start day and month
$replace = date_i18n( ‘j F’, $start_date ). ‘ – ‘ . date_i18n( ‘j F Y’, $end_date );
}else{
// Print the complete start and end date
$replace = date_i18n( ‘j F Y’, $start_date ). ‘ – ‘ . date_i18n( ‘j F Y’, $end_date );
}
}
}else{
$replace = date_i18n( ‘j F Y’, $start_date );
}
break;
}
return $replace;
}