Skip to content

Instantly share code, notes, and snippets.

@rickalday
Created January 8, 2026 16:55
Show Gist options
  • Select an option

  • Save rickalday/7445f7fe6e10a81feff434c6af5be80d to your computer and use it in GitHub Desktop.

Select an option

Save rickalday/7445f7fe6e10a81feff434c6af5be80d to your computer and use it in GitHub Desktop.
Add a custom 'monthly' interval to WordPress cron schedules to delete wp_give_zapier_trigger from autoload
/**
* Add a custom 'monthly' interval to WordPress cron schedules.
*/
add_filter( 'cron_schedules', 'add_custom_monthly_cron_schedule' );
function add_custom_monthly_cron_schedule( $schedules ) {
$schedules['monthly'] = array(
'interval' => MONTH_IN_SECONDS, // Approximately 30 days
'display' => __( 'Once Monthly', 'text-domain' )
);
return $schedules;
}
/**
* Schedule the cron event for monthly cleanup.
* This ensures the event is scheduled only once.
*/
add_action( 'wp', 'schedule_give_zapier_trigger_cleanup' );
function schedule_give_zapier_trigger_cleanup() {
if ( ! wp_next_scheduled( 'delete_give_zapier_trigger_options_hook' ) ) {
wp_schedule_event( time(), 'monthly', 'delete_give_zapier_trigger_options_hook' );
}
}
/**
* Hooked function to perform the database deletion.
* Deletes options matching the specified criteria.
*/
add_action( 'delete_give_zapier_trigger_options_hook', 'execute_give_zapier_trigger_cleanup' );
function execute_give_zapier_trigger_cleanup() {
global $wpdb;
$wpdb->query(
$wpdb->prepare(
"DELETE FROM wp_options WHERE option_name LIKE '%wp_give_zapier_trigger%'"
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment