Timeline for Cron task for creating a file of bookings.ics
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 15 at 9:14 | comment | added | Oris Sin | Alright, I think it's a nice way to put it. I already tested it and it stores the string I want to in wp_options of WPDB like this _transient_example_transient. What I did basically was to store a set_transient( 'example_transient', 'Sample Data', 3600 ); Now, the next question is: would it be possible to regenerate that every hour or 10 minutes ? I think I would have to trigger a crontask. I don't really get how to output the content and refresh as for it to be trigerred, you would have to browse through that link bookings?ical=1 "manually" let's say. | |
| Jul 14 at 16:17 | comment | added | Tom J Nowell♦ | yes that's exactly what I meant, note that in WP it's rare and unusual to create custom tables for things or to modify the core tables. It's usually bad practice unless you have good performance reasons that you can demonstrate, otherwise things such as custom post types, custom taxonomies, post meta, user meta, etc are better | |
| Jul 14 at 12:28 | comment | added | Oris Sin | @TomJNowell I am actually doing that at the moment but I am not storing it in my WP database. Would I have to store it in a separate new table of my WP database ? Because I am not really database connoisseur of MySql databases, what does it mean "Put it in a transient" ? Do you mean that developer.wordpress.org/reference/functions/get_transient ? Thanks in advance | |
| Jul 14 at 12:25 | comment | added | Oris Sin | @ChrisCox well, I am not quite sure about that. I can enter into my hosting but I suppose I have to subscribe to a new service for being able to use the crontab if I am not mistaken. As I wanted an API service, it would take more money and a VPS in order to connect Google Calendar with my Calendar service which is feeded through Wordpress. | |
| Jul 14 at 11:47 | comment | added | Tom J Nowell♦ | As an aside, have you considered instead of writing this to an ICS file in your uploads, just outputting it directly? Then putting https://mywebsite.com/booking?ical=1 into google cal rather than wp-content/uploads/booking.ics? Then you can remove cron entirely, and cache the result in the DB to speed things up. Put it in a transient that expires after 15/20 minutes and you've sidestepped the problem entirely! | |
| Jul 14 at 11:44 | comment | added | Tom J Nowell♦ | to clarify on Chris' comment, you can run the cron via WP CLI and avoid URLs and PHP time limits, Alternatively you can implement it as a WP CLI command and trigger it directly | |
| Jul 14 at 11:26 | comment | added | Chris Cox | Do you have access to the server's crontab? That would be a lot more reliable than WP's shonky "run if there's a request around the right time" pseudo-cron. | |
| S Jul 14 at 9:59 | review | First questions | |||
| Jul 15 at 14:34 | |||||
| S Jul 14 at 9:59 | history | asked | Oris Sin | CC BY-SA 4.0 |