Force WordPress security upgrade to latest minor version

Create a file in the WP root directory called force-minor-update.php and call it via your web browser.

Use this code:

require( dirname(__FILE__) . '/wp-load.php' );

//Clear transients
global $wpdb;
$sql = "DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_%'";
$clean = $wpdb->query( $sql );

//Clear object cache
wp_cache_flush();

//Attempt auto update
wp_maybe_auto_update();

Original source

3 thoughts on “Force WordPress security upgrade to latest minor version

  1. DrLightman

    If you want to use the underscore in like sql statement as a literal, you have to escape it, otherwise it works as a single character wildcard. Maybe there you have to escape with two backslashes since it’s inside a php string too.

    Reply
  2. Seven

    Thank you, used your script to upgrade an old WordPress, from 4.8 to 4.8.9 without any problem. Sometimes you don’t want to upgrade an old website to the last WordPress version because it can break plugins or themes. Upgrading to the last minor version takes advantage of security and bug updates, without the risk off breaking the website.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Markdown is allowed in comments.