Skip to content

Instantly share code, notes, and snippets.

@nacin
Last active March 11, 2019 17:17
Show Gist options
  • Save nacin/7047909 to your computer and use it in GitHub Desktop.
Save nacin/7047909 to your computer and use it in GitHub Desktop.
This is how @dd32 and I test automatic background updates in WordPress 3.7. Then just do example.com/?wp_maybe_auto_update. (If you use a checkout of develop.svn.wordpress.org, you can run this on the `build` directory, then simply run `grunt copy` between updates to copy over the latest code from `src`. This is how we are able to make adjustmen…
<?php
// Add this as a mu-plugin.
if ( isset( $_GET['wp_maybe_auto_update'] ) ) {
add_filter( 'automatic_updates_is_vcs_checkout', '__return_false' );
add_action( 'template_redirect', function() {
$time = date( 'r' );
echo "Starting... $time<br />";
delete_site_option( 'auto_core_update_failed' );
delete_option( 'auto_upgrader.lock' );
delete_site_transient( 'update_core' );
wp_maybe_auto_update();
die( 'Done, check your email.' );
} );
}
@fatihtoprak
Copy link

looks like great (: Thanks.

@nacin
Copy link
Author

nacin commented Oct 27, 2013

One other thing you could do:

Open src/wp-admin/includes/class-wp-upgrader.php, and uncomment these lines at the bottom of the file, in the WP_Automatic_Updater::send_debug_email() method:

//echo "<h1>\n$subject\n</h1>\n";
//echo "<pre>\n" . implode( "\n", $body ) . "\n</pre>";

We should probably add a hook there so this can be done in a plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment