Skip to content

Instantly share code, notes, and snippets.

@afragen
Last active March 11, 2024 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afragen/86ab7b2e9edac70697ecb0e7c5c49056 to your computer and use it in GitHub Desktop.
Save afragen/86ab7b2e9edac70697ecb0e7c5c49056 to your computer and use it in GitHub Desktop.
<?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