Home › Forums › Calendar Products › Events Calendar PRO › WP Super Cache and ECP
- This topic has 7 replies, 2 voices, and was last updated 10 years ago by
Barry.
-
AuthorPosts
-
April 10, 2016 at 6:37 am #1100577
Patrick Sasser
ParticipantI 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.
April 11, 2016 at 3:34 pm #1101036Barry
MemberHi @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 🙂
April 12, 2016 at 7:30 am #1101287Patrick Sasser
ParticipantLove 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,
patrickApril 12, 2016 at 9:12 am #1101377Barry
MemberThanks 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.
April 12, 2016 at 9:22 am #1101384Patrick Sasser
Participantadd_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?
April 12, 2016 at 11:33 am #1101524Barry
MemberHmm, 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) 🙂
April 12, 2016 at 8:33 pm #1101731Patrick Sasser
ParticipantHey 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-widgetAs 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,
patrickApril 13, 2016 at 6:32 am #1101888Barry
MemberExcellent, glad you got something working (and thanks for sharing the final solution – I’m sure other WP Super Cache users may find this useful) 🙂
-
AuthorPosts
- The topic ‘WP Super Cache and ECP’ is closed to new replies.
