17

the question is simple :) I am making a theme that i will use in lots of sites. So, i don't want to go all the site and ftp the files every time i fix a bug or do a theme upgrade.

Is there any way i can make a update system like the plugins hosted in wordpress plugin directory.

Looking forward to your answer. Thanks!

Solved:

Thanks Chip Bennett for his excellent link. The update library for themes is now available in that site. You can find it here: http://w-shadow.com/blog/2011/06/02/automatic-updates-for-commercial-themes/

Always consider donation if you see some excellent work that made available for free.

1

2 Answers 2

9

You can also hook into the core update routine. (I'm looking for tutorial links, but my Google-fu is failing me this morning.)

EDIT:

See if this tutorial helps. It explains how to implement automatic upgrades for private/commercial (i.e. non-repository-hosted) Plugins.

4
  • 1
    I think it is pre_set_site_transient_update_plugins
    – Wyck
    May 1, 2011 at 15:27
  • Thanks! I go through you link and the plugin codes did not worked but i request the guy for modifying the library for themes couple of days later he made one! And now its working great! I will put the link in my question. Thanks!!
    – Sisir
    Jun 8, 2011 at 17:01
  • 1
    Here is tutorial for automatic upgrades of themes also from the same site: w-shadow.com/blog/2011/06/02/… Jan 11, 2016 at 18:38
  • pre_set_site_transient_update_plugins runs only the activated theme on main site. all other custom theme update will not be checked even if it is multi site and activated other custom theme on other sites.
    – vee
    Nov 21, 2016 at 4:01
3

An interest question! In fact, I think you should make a service to check update! Such as yourdomain.comn/api/update-check! Then this can return XML or JSON or some useful information related to update such as version, the url of update file (updated file should be a zip file)!

In your theme you can have:

    <?php define('OWN_THEME_VERSION', '1.1');

So, when you detected an update from above url(yourdomain.comn/api/update-check), assume it returns JSO data as following: {"version":"1.2","file":"theme.zip"}

You compare version to check for new update! Then switch to default theme with this function http://codex.wordpress.org/Function_Reference/switch_theme (in order when users access the site, they see a worlking site)! Next, your code can use curl or even file_get_contents to download zip file (theme.zip in this case)! Next, you delete all file of in your theme folder, then extrat zip file and copy its content into theme folder! I think this way it should work!

You may want to take a look on what WordPress did! I found it's in file wp-admin/includes/update-core.php, line 288, function update_core

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.