Last active
March 11, 2024 21:50
-
-
Save afragen/86ab7b2e9edac70697ecb0e7c5c49056 to your computer and use it in GitHub Desktop.
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: WP-CLI: Force Auto-Updates | |
* Description: Forces auto-updates. `wp autoupdates force` | |
* Author: WordPress Core Contributors | |
* Author URI: https://make.wordpress.org/core | |
* License: GPLv2 or later | |
* Gist Plugin URI: https://gist.github.com/afragen/86ab7b2e9edac70697ecb0e7c5c49056 | |
* Version: 1.0.0 | |
*/ | |
class WPCore_Auto_Updates { | |
public function force() { | |
add_filter( | |
'automatic_updates_is_vcs_checkout', | |
function ( $checkout, $context ) { | |
// ABSPATH = Core update, WP_CONTENT_DIR = Translation update. | |
return ABSPATH === $context || WP_CONTENT_DIR === $context; | |
}, | |
10, | |
2 | |
); | |
delete_option( 'auto_updater.lock' ); | |
add_filter( 'wp_doing_cron', '__return_true' ); | |
do_action( 'wp_maybe_auto_update' ); | |
//wp_maybe_auto_update(); | |
} | |
} | |
function wpcore_register_commands() { | |
WP_CLI::add_command( 'autoupdates', 'WPCore_Auto_Updates' ); | |
} | |
add_action( 'cli_init', 'wpcore_register_commands' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment