How to update WordPress and plugins at specific day and time in PHP?

There’s a question and an answer regarding WP (auto) updates here, How To/What triggers a WordPress auto update?

The answer also has a link to a blog post on how to force WordPress auto-update.

Code snippet posted on the referenced blog,

<?php
  // request-update.php
  require( dirname(__FILE__) . '/wp-load.php' );
  wp_maybe_auto_update();
?>

and

php ./request-update.php

Perhaps you can use this and a real (not WP) cron job to update your site(s) at a certain day and time.

Edit

Then there’s the do_core_upgrade function.

Edit 2

Oh, and then there’s wp_update_plugins and wp_update_themes, too. These are defined in wp-includes/update.php (trac).

Edit 3

Actually, wp_ajax_update_plugin might be better reference point for creating a custom plugin update process. There’s also the Plugin_Upgrader class. For themes there’s wp_ajax_update_theme for reference and Theme_Upgrader class.

Leave a Comment