Viewing 8 replies - 16 through 23 (of 23 total)
  • Thread Starter Daniele

    (@lele_82)

    Hi,

    thanks for your patience. I’ll try to follow your suggestions and I’ll keep you update ??

    Thread Starter Daniele

    (@lele_82)

    I found the implied piece of code that gives me problems…

    $replace = __( apply_filters( 'em_event_output_placeholder', $replace ) );

    If i disable it, all works fine without errors/warnings… can you explain me why?

    These are the warnings gave from the above line of code…

    Warning: Missing argument 2 for em_event_output_placeholder() in
    …/wp-content/plugins/events-manager/classes/em-event.php on line 2144

    Warning: Missing argument 3 for em_event_output_placeholder() in
    …/wp-content/plugins/events-manager/classes/em-event.php on line 2144

    Warning: Missing argument 2 for my_custom_event_placeholders() in
    …/wp-content/plugins/my-em-custom/my-em-custom.php on line 17

    Warning: Missing argument 3 for my_custom_event_placeholders() in /web/htdocs/www.vitaecrescita.com/home/wp-content/plugins/my-em-custom/my-em-custom.php on line 17

    Thread Starter Daniele

    (@lele_82)

    What would does it for this piece of code $replace = __( apply_filters( 'em_event_output_placeholder', $replace ) ); and why if i disable it, the code still works?

    That line is disabled in my original code above. I don’t remember why it’s there in the first place – perhaps it’s a leftover from an old version of EM, where we took the original piece of code in the first place and then started modifying until it did what we wanted. Perhaps it served some theoretical purpose, so we left it as disabled instead of removing it entirely, but the theoretical need has never become a practice.

    You can remove that line entirely or leave it commented.

    That’s one of the troubles with having custom placeholders instead of ones supported by core: when something changes in core, it’s up to you to reflect the change. Of course on the other hand this way there’s less work for EM developers, so the plugin development proceeds faster.

    Thread Starter Daniele

    (@lele_82)

    Thanks Deadlon for your support. It was been precoius! ??

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you can try something like

    add_filter('em_event_output_placeholder','my_em_placeholder_mod',1,3);
    function my_em_placeholder_mod($replace, $EM_Event, $result){
    	-------
    	return $replace;
    }

    Glad to hear of your appreciation, Daniele ??

    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;
    }

Viewing 8 replies - 16 through 23 (of 23 total)
  • The topic ‘Display a date between 2 month’ is closed to new replies.