Auto Update Script For Plugins Not Hosted On WordPress.org

Auto Update script for WP Plugins not hosted on WordPress.org

This script can be used for WordPress plugins that are not hosted on WordPress.org. It works transparently for users providing same experience as if the plugin was hosted on WordPress.org.

WordPress.org is a very capable platform for plugin/theme developers to host their creations. There are many advantages of hosting your plugin on WordPress.org, for example –

  • Exposure to millions of WordPress users without actually spending anything on advertising
  • An easy source control repository option – subversion
  • Automatic release management and automatic updates to users
  • Automatic web-page generation for the plugin using simple to write README
  • Download statistics for the plugin
  • A very good rating system too

However, recently WordPress has become very strict on licensing of code uploaded on their repositories. They no more allow you to use any code that is licensed under Creative Commons. This is a big problem for me as I’m using a third-party tool licensed under creative commons, and many of my users were dissapointed when I had to remove this tool from my plugin.

So, I decided to host my plugin somewhere else to be able to use code licensed under creative commons. The most important aspect of this decision is that, I’ll loose ability to provide auto-update for my plugins. Then I came across this excellent script written by Kaspars. It allows you to setup auto-update mechanism for your plugin which is not hosted on WordPress.org.

When I started using this script, I realized that there is huge potential in this script to be useful for many more WordPress developers like me. So I developed this script further to make it easier to deploy and added more features to it, for example –

  • Serve multiple plugins using same script
  • Serve different types of versions like stable, alpha, beta, lite, pro, test etc.
  • Easy to configure ini file

I plan to add some more features to this script in future, so I uploaded the same on GitHub.com as a project.

Visit the project page of this script on GitHub.com to download this script or get more details.

Author: Ronak Gandhi

I'm a software developer, who is also passionate about driving, traveling, automobiles, photography, computers and games. TT (Ping Pong as some people say) is the latest entry to my list of hobbies. I'm slowly getting better, but not there yet.

18 thoughts on “Auto Update Script For Plugins Not Hosted On WordPress.org”

  1. Hey! Just wanted to say “thank you!” I’m going to use this in my plugin. I already set it up and modified it with my very own license check. Will give you a hint/link on launch

  2. Hi, Sorry to be a bit nit picky … but when you say ‘not hosted on WordPress.org’ do you not actually mean ‘not hosted on WordPress.COM’?

    .COM is where you have your blog hosted with WordPress. Whereas, .ORG is where they keep the platform and plugins files and etc for those of us who use our own hosting.

    On the upside, your information and plugin are great! 😀

  3. A tip to people who want to use this for multiple plugins: Rewrite the test-plugin into a generic “Custom Update Enabler” plugin, then you can use Plugin Dependencies ( http://wordpress.org/extend/plugins/plugin-dependencies/ ) and make all your private plugins depend on your Custom Update Enabler plugin.

    This way, you only need to include only the “new WpPluginAutoUpdate”.. line and the add_filters in your other private plugins, and they can all update from a central (private) source.

    Cheers!

  4. @Andrew, I’m assuming you are talking about the markdown in the ini file? That is to generate the HTML description and other relevant information about the plugin.

    When the update notification about the plugin appears on WordPress dashboard, it generates a link to the details of new version. The HTML code generated out of markdown is what is shown there in the popup.

    log_analytics is just a placeholder right now, which you can use to track some analytics about the plugin downloads etc. You can safely remove it, if you’re not using it.

  5. Hi Ronak,
    Thanks for this… it’s exactly what I needed.

    What are we to do with the markdown and log_analytics code?

    Andrew

  6. Hi, I can’t get it to work…
     
    Copy contents of this project (excluding test-plugin/) to a location on your website
    OK
    Rename test-plugin.ini to your-plugin-slug.ini Modify your-plugin-slug.ini file according the help instructions in the file
    WHAT IS THE PLUGIN SLUG? FILE NAME?
    Modify test-plugin/test-plugin.php file to reflect the location of index.php on your website
    DO WE CHANGE api_url? WHERE DO WE POINT TO index.php??? api_url = “http://example.com” ???
    Copy contents of test-plugin/test-plugin.php file to your plugin’s main file
    OK

      1. Hi, RonakG. Thank you for putting the time and effort into this tutorial and code. I’m stuck at the last step and I can’t figure it out. In your /test-plugin/test-plugin.php file I cannot figure out where to put the reference to the index.php file. To be quite honest, I’m not even sure what the code should look like. I’ve tried to insert:

        $api_url = ‘http://update-site.com/plugin-directory/’;

        on line 32 but that just causes an error. I’ve also tried the same code on line 40 but that doesn’t help either. I also put that same line of code in my main plugin file after the statement

        include ‘test-plugin.php’;

        but that doesn’t help either. I’m stuck. Can you help please?

        Some notes…

        — To keep the code a little cleaner, I left my plugin as-is and I’m including your code via an “include” statement near the top of my plugin (with two other includes).

        — I have the plugin running on domain-x.com but it’s looking to domain-y.com for the updates. domain-y.com is where the other files are–index.php, markdown.php, and the .ini file.

        — Both domain-x.com and domain-y.com are two separate independent WordPress network sites using the WordPress MU Domain Mapping plugin to dynamically map domains such that http://domain-x.com/domainz/ is actually shown as http://domain-z.com in the browser. The directory /domainz/ does not actually exist–it’s mapped virtually.

        Any help you could provide would be most appreciated. Thank you very much.

  7. Thanks for sharing this on Github! I’d like to allow automatic updates only for users with a valid api key. My idea is to have the download link be something like this: http://mydomain.com/download.php?api=hash&file=wptheme.zip

    I was thinking I could generate the api key as a user meta field. I should be able to do this, but I’m not certain what to put in the download.php to make it happen.

    Do you have any examples of doing something like this? 

    Thanks for your feedback..
    Jack

Have something to comment on the article?