Filter not working during ajax call

Home Forums Calendar Products Events Calendar PRO Filter not working during ajax call

  • This topic has 5 replies, 2 voices, and was last updated 9 years ago by Andy Williams.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1265159
    Andy Williams
    Participant

    Hi,
    We are using a filter on “tribe_events_event_schedule_details” to change some of the formatting of our events in the photo view (using this shortcode [tribe_events view=”photo”])

    This works as expected on page load, however, during an ajax call (clicking previous/next buttons or using tribe bar filter), the filter gets ignored and the original formatting built into the plugin gets loaded

    //the filter we have in place, I’m not including the callback function for brevity sake, doesn’t seem to make a difference what it is though, it gets ignored
    add_filter( ‘tribe_events_event_schedule_details’, ‘filter_tribe_data_events_page’, 10, 2 );

    Here is the location of the original tribe_events_event_schedule_details function:

    /plugins/the-events-calendar/src/functions/template-tags/general.php line 961

    Here is the spot in the photo template that we are overwriting the function for

    /plugins/events-calendar-pro/src/views/pro/photo/single-event.php line 44

    I am writing this in a hurry, so I may have left out info you need, if so let me know. Any help would be amazing

    Thanks!

    #1266556
    Nico
    Member

    Hi there Kyle,

    Thanks for reaching out to report this issue and thanks for taking the time to include the references to the code 🙂

    Can you please send me the snippet you are using? Also where are you placing it? In a custom plugin? Theme or Child theme functions.php file?

    Please let me know about it,
    Best,
    Nico

    #1266591
    Andy Williams
    Participant

    My filter is in a child theme functions file, here is the filter:

    add_filter( 'tribe_events_event_schedule_details', 'filter_tribe_data_events_page', 10, 2 );

    Here is the function:

    function filter_tribe_data_events_page( $results, $id ) {
    global $global_jesintranet_event_image_bool;
    $start_date = tribe_get_start_date( $id, false, 'M d' );
    $start_day = tribe_get_start_date( $id, true, 'l ' );
    $start_time = tribe_get_start_date( $id, true, 'g:i A' );
    $end_date = tribe_get_end_date( $id, false, 'M d' );
    $end_time = tribe_get_end_date( $id, true, 'g:i A' );
    $time_zone = tribe_get_end_date( $id, true, 'T' );
    $address = tribe_get_address( $id );
    $address = !empty( $address ) ? $address : '';
    $city = tribe_get_city( $id );
    $city = !empty( $city ) ? $city : '';
    $state = tribe_get_state( $id );
    $state = !empty( $state ) ? $state : '';
    $zip = tribe_get_zip( $id );
    $zip = !empty( $zip ) ? $zip : '';
    $empty = '';
    if( $start_date !== $end_date ) {
    $end_time = '';
    }
    else {
    $end_time = ' - ' . $end_time;
    }
    $title = get_the_title( $id );
    $event_data = '

    ';
    $event_data .= '

    ' . $start_date . '

    ';
    $event_data .= '

    ' . $start_day . '

    ' . $start_time . '' . $end_time . '

    ';
    $event_data .= '

    ' . $title . '

    ';
    if( isset( $global_jesintranet_event_image_bool ) && $global_jesintranet_event_image_bool ) {
    $event_data .= '

    ' . tribe_event_featured_image( null, 'events-list' );
    $event_data .= '' . tribe_events_get_the_excerpt() . '';
    $event_data .= '

    Learn more

    ';
    }
    else {
    $event_data .= '' . tribe_events_get_the_excerpt() . '';
    $event_data .= '

    Learn more

    ';
    }

    if ( $address ) {
    $event_data .= '

    ' . $address . ' ' . $city . ', ' . $state . ' ' . $zip . '

    ';
    }
    $event_data .= '

    ';
    return $event_data;
    }

    I have even tried replacing the contents of my function with the contents of the original function from /plugins/the-events-calendar/src/functions/template-tags/general.php line 961 (altering the return statement to return $schedule instead of the filter to avoid the ol’ infinite loop, of course). Added ‘this is mine’ to the html, which displays as expected on load, but not after the ajax call, so same problem.

    Thanks!

    #1269955
    Nico
    Member

    Hey Kyle, thanks for following up with the code and sorry for the delay in my reply!

    I just made this super simple test in my local install and it’s working for me:

    add_filter( 'tribe_events_event_schedule_details', 'tribe_sample_filter', 10, 4 );

    function tribe_sample_filter ( $schedule, $event_ID, $before, $after ) {
    return ' xxx ' . $schedule;
    }

    Just paste the above snippet in your theme’s (or child theme’s) functions.php file. It’s working for me in photo view and in photo view inserted via shortcode. Can you test it out? It’s just the same as you were testing, you were not passing all parameters to the callback not sure that caused it not to work but just in case I wanted to point this out.

    If it doesn’t work right away then please check the following:

    – Is it working for photo view (without shortcode)?
    – Do you have any cache plugins that might be getting in the way? If so can you disable those and re-test?
    – Can you please disable all non-tribe plugins and switch to a default theme (like TweentySeventeen), move the snippet to the default theme and re-test?

    Please let me know about it,
    Best,
    Nico

    #1279802
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Filter not working during ajax call’ is closed to new replies.