Have WP Theme update from Git Repository

I have a client’s theme currently hosted on github. Instead of doing a git deploy or using a service like Beanstalk’s deployments. I will be pushing the same theme across many sites (79 to be exact) and want them to be able to update themselves just like a WP repo hosted theme. A good example is how the Genesis framework has it’s updates work. I’ve seen things where you have another plugin installed to do this, but i’m looking for a more minimalist solution (if there is anyway to keep this functionality within the theme itself)?

Solutions Collecting From Web of "Have WP Theme update from Git Repository"

There’re a couple of libraries out there. One of the more well known is from Joey Kudish and hosted on GitHub itself.

Basically it does the following:

  • utilizes the GitHub API
  • Adds a callback to the 'pre_set_site_transient_update_plugins' filter
  • Adds another callback to the 'plugins_api' filter
  • finally utilizes the WP HTTP API and does a wp_remote_get() to the GitHub repo.

Oh, yes – close to have forgotten this – it adds a transient to avoid checking the remote repo on every request.

You need 2 basic things to accomplish this

  • Hook into pre_set_site_transient_update_themes
  • Use the HTTP API to query whatever url has your update

The basic premise is your theme’s version is stored in a transient that checks a remote URL every x hours and compares the $version.

Notes:

The URL can be anything, the HTTP API supports authentication (private repo) or anything you want to send via the header.

The check can be any variable comparison, though typically you use a version.

The file can be anything that can be parsed (.xml, .txt) but typically you use the style.css

Instead of me adding code to this check this out: https://github.com/jeremyclark13/automatic-theme-plugin-update , specifically the theme part.