WP Super Cache and ECP

Home Forums Calendar Products Events Calendar PRO WP Super Cache and ECP

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1100577
    Patrick Sasser
    Participant

    I have WP Super Cache installed on this site. http://thecrossingchurch.com/events. The problem is I want caching to be functional on the site, but I don’t want the plugin to cache things related to Events Calendar Pro (really two pages specifically /events and /calendar).

    The mini calendar on this page http://thecrossingchurch.com/events is supposed to have today’s date highlighted and it should load upcoming events for today however if the page gets cached with a previous day loaded then it will continually show a cached version of that page and display old/expired events rather than today’s/upcoming events. I have deleted the cache for today so it will be functional today, but not tomorrow. Any thoughts or ideas would be much appreciated.

    I also posted on WP Super Cache forums https://wordpress.org/support/topic/wp-super-cache-and-events-calendar-pro?replies=1#post-8257109 so that might be the best place to get a reply since this is related to their plugin but I thought that you guys might have some experience with this as well.

    Have a great day.

    #1101036
    Barry
    Member

    Hi @psasser,

    Great question!

    In WP Super Cache’s FAQ page there is an explanation of how to keep specific parts of pages (such as widgets and other things that we don’t want to be ‘frozen in time’) dynamic:

    See: “How do I make certain parts of the page stay dynamic?”

    Additionally, it’s also worth bearing in mind that most of our widgets feature ajax-driven pagination. A clever customization could make use of this to refresh the widget content as soon as the page is rendered, keeping the information nice and fresh.

    Both approaches involve a little custom development/integration work and I’m afraid we can’t assist with the fine detail of that, but this does seem like something other users might be interested in and so it could definitely be worthwhile posting a feature request on our UserVoice page for improved out-of-the-box integration with WP Super Cache.

    I hope that helps 🙂

    #1101287
    Patrick Sasser
    Participant

    Love the idea to refresh the widget once it all loads up, but I’m having a little difficulty.

    Here’s what the code looks like so far…

    jQuery(document).ready(function(){
    	if(jQuery(".tribe-mini-calendar-wrapper").length)
    	{
    		var check = new Date().getDate();
    		var year = new Date().getFullYear().toString();
    		var day = new Date().getDate().toString();
    		var month = new Date().getMonth();
    		month = month + 1;
    		month = month.toString();
    		var fulldate = year +"-"+ month +"-"+ day;
    		fulldate = year +"-"+ (month[1]?month:"0"+month[0]) +"-"+ (day[1]?day:"0"+day[0]);
    		setTimeout(function () {
    			jQuery('.tribe-mini-calendar-wrapper').find('[data-day=' + fulldate + ']').trigger( "click" );
    		}, 0);
    	}
    });

    It actually works, but I’m having to put a setTimeout in there to run it a little after the calendar loads. Is there an js event I can call after the calendar loads or something like that?? My other thought is that I could just include this script in the footer after the script for the calendar is loaded. I’m enquing my scripts via

    add_action( 'wp_enqueue_scripts', 'myScripts', 10);

    however whatever priority I put in there doesn’t enque my script after the script for the mini calendar that’s down in the footer? Any thoughts?

    Thanks much,
    patrick

    #1101377
    Barry
    Member

    Thanks for sharing your solution, great to hear you’ve got something working there 🙂

    I don’t believe we do trigger any events once the widget is set up, and would assume setting a timeout as you have done works because our own scripts aren’t ready to listen out for click events prior to document.ready (since your code is also waiting until that point, it’s probably an order of operations issue we’re looking at here).

    Enqueuing your script in the footer as you suggested is definitely an option or, if you prefer not to do that, it may simply be that bumping the priority on your wp_enqueue_scripts callback to something like 100 will do the trick.

    #1101384
    Patrick Sasser
    Participant

    add_action( 'wp_enqueue_scripts', 'myScripts', 100);

    Doesn’t do anything to fix it. I have also tried a really high priority, but the script is still enqued in the footer before

    <script type='text/javascript' src='/wp-content/plugins/events-calendar-pro/src/resources/js/widget-calendar.js?ver=179ca483085779c14960d942d9a19c1e'></script>

    Any other thoughts?

    #1101524
    Barry
    Member

    Hmm, well, one other thought is switching away from the wp_enqueue_scripts action and instead using:

    tribe_pre_get_template_part_pro/widgets/mini-calendar-widget

    In the normal run of things, this will fire after the calendar widget has enqueued its own scripts so may be a better choice.

    Unfortunately, for custom development/integration tasks like this one, we are unable to provide in-depth support and we’ll really need to bow out and leave this one to you (but please don’t forget that you can post a feature request, if you haven’t already done so, requesting that this sort of capability be officially baked in to the plugin) 🙂

    #1101731
    Patrick Sasser
    Participant

    Hey Barry,

    Thanks for the support. That worked perfectly so combined with the script I put above and adding the script to the footer using

    tribe_pre_get_template_part_pro/widgets/mini-calendar-widget

    As the action worked perfectly. I was able to ditch the setTimeout in the Script and make it work. So hopefully this should make the caching issue a non factor as it should simulate a click on today’s event only. This also eliminated another issue that on page load I really only want today’s events to show up not the most recent upcoming however many events. Anyway we should be all good. I also posted on the forum to request this feature as well.

    Thank you,
    patrick

    #1101888
    Barry
    Member

    Excellent, glad you got something working (and thanks for sharing the final solution – I’m sure other WP Super Cache users may find this useful) 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘WP Super Cache and ECP’ is closed to new replies.