Will I get an error if I try unscheduling a WP Cron scheduled task that wasn’t scheduled?

So yeah, it does give errors for trying to unschedule something that isn’t scheduled, but the answer is pretty easy and simple: $timestamp = wp_next_scheduled( ‘scheduled_hook’ ); if ($timestamp) wp_unschedule_event( $timestamp, ‘scheduled_hook’ ); Since wp_next_scheduled will return false for unscheduled hooks, a simple if in front of the call to wp_unschedule_event will prevent it from … Read more

WordPress cron hooks – same callback for completely different action?

No, not quite. When you say this: wp_schedule_single_event( $sent_on, ‘my_custom_cron’, [ $notif_id, $notif_name, $membership_id, $lesson_id ] ); You are essentially saying is when the current time passes $sent_on, do: do_action( ‘my_custom_cron’, [ $notif_id, $notif_name, $membership_id, $lesson_id ] ); Cron jobs are just a TODO note to fire an action with some arguments in the future. … Read more

A unique wp_schedule_single_event() for each post?

You can pass arguments to the wp_schedule_single_event function: wp_schedule_single_event($newdate, “one_day_before_event”, array($post->ID)); Then if you do an add_action you can say how many arguments it will receive (in this case 1). add_action( ‘one_day_before_event’, ‘some_function’, 10, 1 ); Then in your function you can access the variable: function some_function($post_id) { // Do something with $post_id }

Are uploads directories created on a schedule?

I believe by default these folders are created by user interaction, however, it’s possible that a plugin may be calling a function to create these monthly upload folders. Note that using this function will create a subfolder in your Uploads folder corresponding to the queried month (or current month, if no $time argument is provided), … Read more