Support » Fixing WordPress » Programmatically check latest WP release?

  • 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
    2. Screen-scrape the download page.
    3. Download 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?


Viewing 7 replies - 1 through 7 (of 7 total)
  • 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.

    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!

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

    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.

    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.

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Programmatically check latest WP release?’ is closed to new replies.