Created
October 19, 2023 21:55
-
-
Save afragen/e265e008fa3f54d2e6e9caf2a5326336 to your computer and use it in GitHub Desktop.
A modified plugin from Peter Wilson for testing auto-updates
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 | |
/** | |
* Plugin Name: Schedule Update Events NOW(ish)! | |
* Description: Schedules auto-updates every 60 seconds (if not already running). If they don't start, refresh. You can run the long command if impatient. But don't be impatient 😉 | |
*/ | |
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 cron event delete wp_version_check; wp cron event delete wp_update_plugins; wp cron event delete wp_update_themes | |
// npm run env:cli option delete auto_updater.lock; npm run env:cli cron event delete wp_update_plugins; npm run env:cli cron event delete wp_update_themes; npm run env:cli cron event delete wp_version_check | |
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', 10, 1 ); | |
add_filter( 'automatic_updates_is_vcs_checkout', function( $checkout, $context ) { | |
// return $checkout; | |
if ( $context === WP_PLUGIN_DIR || $context === WP_CONTENT_DIR . '/themes' ) { | |
return false; | |
} | |
return $checkout; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment