Created
July 19, 2017 01:02
-
-
Save imvaskii/d14da925f1f8df8847312433954cd755 to your computer and use it in GitHub Desktop.
Limitize WordPress default scheduled events.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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