-
-
Save peterwilsoncc/b140d56e61f80b6ba04e2a1ba7d6ab46 to your computer and use it in GitHub Desktop.
Run plugin updates every ten minutes rather than every twelve hours.
This file contains 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 | |
/** | |
* Plugin Name: Schedule Update Events NOW(ish)! | |
*/ | |
namespace PWCC\FastUpdates; | |
// return; | |
// option deletion needs to be wp site option on MS installs. | |
// wp option delete auto_updater.lock; wp option delete pwccfast-wp_version_check; wp option delete pwccfast-wp_update_plugins; wp option delete pwccfast-wp_update_themes; wp option delete pwccfast-wp_maybe_auto_update; wp cron event delete wp_version_check; wp cron event delete wp_update_plugins; wp cron event delete wp_update_themes; wp cron event delete wp_maybe_auto_update | |
function now( $event ) { | |
$fast_events = array( 'wp_version_check', 'wp_update_plugins', 'wp_update_themes', 'wp_maybe_auto_update' ); | |
if ( ! in_array( $event->hook, $fast_events, true ) ) { | |
return $event; | |
} | |
if ( get_site_option( "pwccfast-{$event->hook}" ) ) { | |
return $event; | |
} | |
update_site_option( "pwccfast-{$event->hook}", '1' ); | |
$event->timestamp = time() + 60; | |
return $event; | |
} | |
add_filter( 'schedule_event', __NAMESPACE__ . '\\now' ); | |
add_filter( 'automatic_updates_is_vcs_checkout', function( $checkout, $context ) { | |
// return $checkout; | |
if ( $context === WP_PLUGIN_DIR ) { | |
return false; | |
} | |
return $checkout; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment