conorseed
Forum Replies Created
-
Hey @oluirael, Just popping by to say I had the exact same issue. Thanks for the patch file above – it fixed the issue. However, if you could PLEASE release the patch as an update to the plugin that would be greatly appreciated. It’s not ideal to have to come to the support forum and manually install a patch, a month after the issue was brought to your attention. Thanks 🙂
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI + Pro Theme by ThemecoHey @qtwrk – apologies for not being more specific.
I was going to attach an image but must have forgotten!Here’s a screenshot of the console with all the errors with ESI enabled:
https://drive.google.com/file/d/1ax6cVpNVFEAZDQKSmH4V59N97HcBY8Iz/view?usp=sharingAs mentioned above, when ESI is disabled these errors don’t exist.
Hey @churious , I’m wanting to achieve the same thing. Did you manage to get this sorted? 🙂
Forum: Plugins
In reply to: [Advanced Ads – Ad Manager & AdSense] Bulk Upload?Hey Thomas (@webzunft),
Thanks for the quick response. I had totally missed the import & export functionality!
It makes sense but its not ideal 😉 Guess it’d be easier to use if it were .csv instead of .xml. But that’s ok, I can setup a spreadsheet for the client to fill out and convert to xml.
Thanks again for your help 🙂
Forum: Plugins
In reply to: [3D FlipBook - PDF Flipbook WordPress] Auto popup full screenHey @iberezansky,
I’d also love to be able to go straight to full screen instead of into the lightbox. Can you point in the right direction with the JS? I’m happy to code, just need direction. Thanks.
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3There we go! And we have a winner 😀 Officially resolved now!
Thanks again for all the help.
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3Brilliant response – thank you @lclarke. That helps me immensely.
I think I know what I’m doing now. Thanks to both of you for being patient with me and answering my (probably very noob) questions!
One last one for you: I’m probably missing something but is there a way I can set a TTL for the ESI block? Or do I have to manage that in the general settings somewhere?
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3@hailite Thanks for the response.
I thought no cache would be the best option in terms of making sure the block always shows the most recent information. It is linked into a booking system via API: it shows upcoming courses, as well as how many spots are left on each course.
Currently (even with the esi block set to “no-cache”), the whole page is cached. Which means it’s outdated after an hour – often showing the wrong number of spots left, or a course which is no longer available to book.
If I set it to “private”, will the block always show the most recent info for ANY user (logged in or not)?
- This reply was modified 5 years, 12 months ago by conorseed.
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3Ok, so I found in the documentation to set the below but it’s still caching the block in the public cache. Any ideas?
LiteSpeed_Cache_API::esi_url($block_id, $wrapper, $params = array(), $control = 'private,no-vary')
Set
$control = 'no-cache'
to set the ESI block as non-cacheable.Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3That makes sense now thank you! 🙂 I got it working by using the `after_setup_theme’ action as you suggested.
I do have another question though: does an ESI block load fresh every time, even for logged out users?
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3Sorry @hailite, I don’t quite understand. Can you expand on that please?
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3Hey, I get the below error. How do I include the api in my plugin? 🙂
Uncaught Error: Class 'LiteSpeed_Cache_API' not found in path/to/my/plugin
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3Ok thanks! I’ll give it a go and come back if I have any issues 🙂
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3Brilliant idea.
I assume that the $params would be the shortcode $atts? I don’t need to include any other parameters in there?
Forum: Plugins
In reply to: [LiteSpeed Cache] ESI API Help <3Sure thing 🙂 This is the quick and dirty version of it at the moment:
/* API CALL */ function cd_acuity_getCoursesv2( $course = '', $id = FALSE ){ // Vars $userID = 'XXXXXXX'; $key = 'XXXXXXXX'; $date = new DateTime(); $fdate = new DateTime(); $fdate = ($course !== 'DDC') ? $fdate->modify('+4 month') : $fdate->modify('+6 month'); // URL if( $id ){ $url = 'https://acuityscheduling.com/api/v1/availability/classes?appointmentTypeID='.$id; } else{ $url = 'https://acuityscheduling.com/api/v1/availability/classes?minDate='.$date->format('Y-m-d').'&maxDate='.$fdate->format('Y-m-d'); //includeUnavailable=true& } // Initiate curl: // GET request, so no need to worry about setting post vars: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); // Grab response as string: curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // HTTP auth: curl_setopt($ch, CURLOPT_USERPWD, "$userID:$key"); // Execute request: $result = curl_exec($ch); // Don't forget to close the connection! curl_close($ch); // Catch Error or Return JSON return json_decode($result, true); } /* SHORTCODE */ function cd_acuityShortcodev2($atts){ // Set Atts $atts = shortcode_atts( array( 'course' => '', ), $atts ); $current_time = current_time('timestamp'); // Get Saved Option $resultArr = json_decode( get_option('2ds_courses'), true ); // If Saved json older than 1 hour, get updated courses if( $current_time - $resultArr['updated'] > 3599 ){ // Vars $resultArr = array( 'data' => [], 'updated' => '' ); $ddcArr = []; // Get RF Courses $rfcourses = cd_acuity_getCoursesv2(); // Error Check if (isset($rfcourses['error'])){ return 'Uh oh. Something Went Wrong.'; } // Output RF Courses foreach ($rfcourses as $rf){ // Filter out DDC if ( strpos( $rf['name'], 'DDC' ) === FALSE ){ // Get Vars $rfcourse = []; $rfcourse['name'] = $rf['name']; $rfcourse['date'] = cd_acuityGetDate($rf['time']); $rfcourse['id'] = $rf['appointmentTypeID']; $rfcourse['slots'] = $rf['slotsAvailable']; // Push to final array array_push($resultArr['data'], $rfcourse); } } // Get DDC Courses $ddccourses = cd_acuity_getCoursesv2('DDC'); // Error Check if (isset($ddccourses['error'])){ return 'Uh oh. Something Went Wrong.'; } // Output DDC Courses foreach ($ddccourses as $ddc){ if ( strpos( $ddc['name'], 'DDC' ) !== FALSE ){ // Get Vars $ddccourse = []; $ddccourse['name'] = $ddc['name']; $ddccourse['id'] = $ddc['appointmentTypeID']; $ddccourse['slots'] = $ddc['slotsAvailable']; // Test foreach ($ddcArr as $test){ if ($test === $ddccourse['id']){ continue 2;} } // Get Dates $ddcdates = cd_acuity_getCoursesv2('', $ddccourse['id']); $ddccourse['date'] = cd_acuityGetDate($ddcdates[0]['time']); $ddccourse['date2'] = cd_acuityGetDate($ddcdates[1]['time']); $ddccourse['date3'] = cd_acuityGetDate($ddcdates[2]['time']); $ddccourse['date4'] = cd_acuityGetDate($ddcdates[3]['time']); // Push to final array array_push($resultArr['data'], $ddccourse); // Push ID to ddcArr for testing array_push($ddcArr, $ddccourse['id']); } } // Sort Final Array usort($resultArr['data'], function($a, $b){ $t1 = strtotime($a['date']); $t2 = strtotime($b['date']); return $t1 - $t2; }); // Add DateTime to Array $resultArr['updated'] = $current_time; } // Change Final Array to JSON $json = json_encode($resultArr); // Update JSON in Database if( $current_time - $resultArr['updated'] > 3599 ){ update_option( '2ds_courses', $json ); error_log('UPDATED'); } // Output $result = '<div class="acuity-courses-wrapper owl-carousel owl-theme"></div>'; $result.= '<script type="text/javascript">var acuityCoursesArr = ' . $json . ';'; $result.= 'var acuityCoursesFilter = "'.$atts['course'].'";'; $result.= <<<EOT jQuery(function(a){acuityCoursesArr.data.length>0?(a.each(acuityCoursesArr.data,function(e,s){var t=s.name,p=~t.indexOf("DDC")?s.date+", "+s.date2+", "+s.date3+", "+s.date4:s.date,r=s.id,n=s.slots;acuityCoursesFilter?~t.indexOf(acuityCoursesFilter)&&a(".acuity-courses-wrapper").append('<div class="course" type="'+t+'"><span class="acuity-name">'+t+'</span><span class="acuity-date">'+p+'</span><a target="_blank" href="https://2drivesafe.as.me/?appointmentType='+r+'">Book Now<span>'+n+" Spots Left</span></a></div>"):a(".acuity-courses-wrapper").append('<div class="course" type="'+t+'"><span class="acuity-name">'+t+'</span><span class="acuity-date">'+p+'</span><a target="_blank" href="https://2drivesafe.as.me/?appointmentType='+r+'">Book Now<span>'+n+" Seats Left</span></a></div>")}),a(".acuity-courses-wrapper").owlCarousel({loop:!0,margin:10,nav:!0,navText:["< Prev","Next >"],responsive:{0:{items:1},600:{items:2},1e3:{items:3}}})):(a(".acuity-courses-wrapper").append("No courses found."),a(".acuity-courses-wrapper").owlCarousel())}); EOT; $result.= '</script>'; return $result; } add_shortcode('acuitycourses', 'cd_acuityShortcodev2'); function cd_acuityGetDate($time){ $date = new DateTime($time); return $date->format('D j M, g:ia'); }