Skip to content

Instantly share code, notes, and snippets.

@imvaskii
Created July 19, 2017 01:02
Show Gist options
  • Save imvaskii/d14da925f1f8df8847312433954cd755 to your computer and use it in GitHub Desktop.
Save imvaskii/d14da925f1f8df8847312433954cd755 to your computer and use it in GitHub Desktop.
Limitize WordPress default scheduled events.
<?php
add_filter( 'schedule_event', 'limit_cron_events' );
if ( ! funciton_exists( 'limit_cron_events' ) ) {
/**
* Limitize WordPress default scheduled tasks
* https://codex.wordpress.org/Plugin_API/Filter_Reference/schedule_event
*
* @param object $event event being scheduled
* @return void
*/
function limit_cron_events( $event ) {
$array_allowed_cron_hooks = [ 'publish_future_posts' ];
if ( ! in_array( $event->hook, $array_allowed_cron_hooks ) ) {
return false;
}
return $event;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment