Programmatically check latest WP release? (8 posts)

  1. Kenn Wilson
    Posted 8 years ago #

    Is there an easy way to programmatically check the current WP version number? My options as I see them currently are:

    1. Parse the output from http://svn.automattic.com/wordpress/tags
    2. Screen-scrape the download page.
    3. Download http://wordpress.org/latest and parse the filename.

    But I'm hoping there's a better way. I need to check them out from Subversion so I can't just download that zip file at /latest.

    Ideally, there would be a version.txt file or something on the WP site containing just the current version number. Failing that, is there something else I could check for this information?


  2. Adam Brown
    Posted 8 years ago #

    If you scrape for it, try scraping this for the latest dev version (but scrape tags for latest stable tag):


    If there's a better way, I don't know it.

  3. Alex Concha
    Posted 8 years ago #

  4. Kenn Wilson
    Posted 8 years ago #

    Thanks for the suggestions.

    update.php doesn't actually contain the latest version number (currently 2.3.2).

    My thought, with regard to screen scraping, is that I could grep the download page for the line "The latest stable release of WordPress (Version 2.3.2)" and grab whatever the version number happens to be. This will obviously break the first time someone changes the wording on that page (and thus the main problem with screen scraping in general).

    The tag listing from Subversion would be a little easier, as I could just grab them all, parse out the numbers into an array, and sort them. I'll probably go this route unless there's an easier way to check. I'm only interested in stable releases, not nightlies.

    WP devs: This might be a good bit of info to add to the site, say at http://wordpress.org/version.txt!

  5. Adam Brown
    Posted 8 years ago #

    I think xknown was suggesting that you use the function in update.php. It's got a function in it that checks versions.

  6. Kenn Wilson
    Posted 8 years ago #

    Ah, mea culpa. That flew right over my head. Sorry about that xknown.

    Looking over wp_version_check() got me a little closer but not quite close enough. Contrary to the name, it doesn't actually check the WP version; it checks if there's an update available, which is a slightly different thing.

    Hitting the below URL will return "upgrade" if the provided version is older than the latest, or "latest" if there are no updates available.


    This would work nicely except that it doesn't return the current version, so I can't just turn around use the response to check out a new tagged release from Subversion.

  7. Alex Concha
    Posted 8 years ago #

    Well, the third option of your first message seems to be the right one -- you don't need to download any file, just send a HEAD request and the parse the Content-Disposition header.

  8. Kenn Wilson
    Posted 8 years ago #

    Good idea. I had forgotten I could get that information in a HEAD request and could therefore not have to download the file every time. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.