WordPress.org

Ready to get started?Download WordPress

Forums

Programmatically update WordPress (3 posts)

  1. azend
    Member
    Posted 2 years ago #

    Hi WordPress Community,

    I'm trying to figure out how I can programmatically update the version of wordpress through a wordpress plugin. I've been searching around ( the wordpress source and the codex ) all day but I couldn't seem to find anything that would work. Because of the nature of the plugin, I want to find a function that does not echo out a bunch of html forms and such if it is possible. ( I can always filter it out later but less is more convenient ) Hopefully later I could also find something to update the plugins as well.

    Thanks!

  2. coombesy
    Member
    Posted 1 year ago #

    7 month old post, so probably a bit late but hope this helps anybody else thats looking for the same answer. To get a list of plugins that need updating use:
    get_plugin_updates() (in /wp-admin/includes/update.php)

    To update the plugins use:
    wp_update_plugin() (also in /wp-admin/includes/update.php)

    The wp_update_plugin() param is the index file of the plugin being updated and not the results of calling get_plugin_updates(). So for example to update the well known Akismet plugin you would call:
    wp_update_plugin( 'akismet/akismet.php' );

    hope this helps ;)

  3. praeix
    Member
    Posted 1 year ago #

    I was actually just thinking about something like this the other day. From the sounds of it, you would need to execute a CRON every so often to check for updates from WordPress and then execute the update if the version found is newer. I don't know the specifics involved in all of that, but I believe the logic is sound.

    @coombesy - I think they want to know how to update the WordPress core on a set schedule, although your method could probably be used to make plugins do that as well, but you'd still need a self-executing script and the only thing I can think of is CRON.

Topic Closed

This topic has been closed to new replies.

About this Topic