File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -448,4 +448,12 @@ public function cleanup_failed_cron() {
448448 $ this ->locker ->delete_lock_file ( $ this ->init_time );
449449 }
450450
451+ /**
452+ * Allow cleanup of the locker.
453+ *
454+ * @return void
455+ */
456+ public function cleanup_locker () {
457+ $ this ->locker ->delete_lock_file ();
458+ }
451459}
Original file line number Diff line number Diff line change @@ -479,6 +479,7 @@ protected function cleanup() {
479479 $ this ->cleanup_post_type ();
480480 $ this ->drop_tables ();
481481 $ this ->cleanup_options ();
482+ $ this ->cleanup_cron ();
482483
483484 // If we got this far, let's remove the cron event.
484485 wp_clear_scheduled_hook ( 'cloudinary_cleanup_event ' );
@@ -600,4 +601,28 @@ protected function cleanup_options() {
600601 delete_transient ( $ key );
601602 }
602603 }
604+
605+ /**
606+ * Remove all cron-related tasks.
607+ *
608+ * @return void
609+ */
610+ protected function cleanup_cron () {
611+ // Get the Cron instance.
612+ $ cron_instance = Cron::get_instance ();
613+ $ schedule = $ cron_instance ->get_schedule ();
614+
615+ // Unregister all registered schedules.
616+ if ( ! empty ( $ schedule ) ) {
617+ foreach ( array_keys ( $ schedule ) as $ schedule_name ) {
618+ $ cron_instance ->unregister_schedule ( $ schedule_name );
619+ }
620+ }
621+
622+ // Remove any lock files or objects used by the Locker instance.
623+ $ cron_instance ->cleanup_locker ();
624+
625+ // Delete the cron schedule option saved in database.
626+ delete_option ( Cron::CRON_META_KEY );
627+ }
603628}
You can’t perform that action at this time.
0 commit comments