Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 30, 2015 01:00 pm

Toolbox of the Smart WordPress Developer: WordPress GitHub Plugin Updater

Don't want to host your plugin in the WordPress.org Plugin Directory? Of course, you can decide not to—it's a free community after all. But you must host it somewhere so the plugin can be found, and you also should provide your users with updates to your plugin. Most people who decide not to host their plugins on WordPress.org tend to use Github but WordPress doesn't know how to update Github–hosted plugin, it needs help. And today, we will help you help WordPress update your plugins with, you guessed it, a helper class.



In this part of the "Toolbox of the Smart WordPress Developer" series, we're going to go through WordPress Github Plugin Updater, a tool to handle the update process for WordPress plugins hosted on Github.



Why Use GitHub Instead of WordPress.org?



Like every other modular content management system, WordPress has a plugin repository in WordPress.org. And I wouldn't be wrong if I said the WordPress.org Plugin Directory has become the community standard for hosting free and open sourced WordPress plugins.



But as I said in the beginning, this is a free community. WordPress doesn't require us to host every plugin and theme we make in the WordPress.org Plugin Directory. People can choose to move away from WPPD and it's perfectly natural.



The first stop people host their WordPress plugins after WPPD is GitHub. Utilizing the awesome revision control system called Git, GitHub is one of the best places to share your open sourced software with the rest of the world. And for the last couple of years, more and more WordPress developers publish their new plugins over Github.



Advantages and Disadvantages of Switching from WPPD to GitHub



I think that there is a balance between the advantages and disadvantages of hosting WordPress plugins on GitHub instead of WPPD. I'm going to lay out the ones that comes to my mind but I'd love your input on this as well, so don't hesitate to shoot a comment in the Comments section after reading this.



When you host your plugins on WordPress.org:




  • You have to use SVN.

  • Your plugin has to be approved by a WordPress.org reviewer before you can upload it. (This is both an advantage and a disadvantage to me as having a second set of eyes on the code is good for spotting security flaws.)

  • You can only use GPL (version 2 or later) as licensing.

  • Your plugin updates will be notified to your users rapidly.

  • Emergency plugin updates (for security reasons) will be pushed automatically to the users.

  • People can find your plugin straight from their admin panels, which is a huge plus.

  • You can use the support forums of WordPress.org



And when you decide to switch to GitHub:




  • You will be able to use Git.

  • You will have infinitely more freedom.

  • You can use other types of licenses (like MIT or CC, even though CC isn't recommended for software).

  • You can create a wiki, accept commits and talk about issues with your users.

  • You will not have any ratings for your plugins, which is bad for feedback.

  • You will need to finish this tutorial in order to provide plugin updates easier.



There's also a nice debate over WordPress Tavern which—I think—you should also read.



Integrating the WordPress GitHub Plugin Updater Into Your Plugin



Ready to provide update notifications for your users?



First and obviously, you need to download the WordPress GitHub Plugin Updater from its GitHub repository. You'll only need the updater.php file, so don't worry about the others.



After that, you need to put the updater.php file somewhere in your plugin folder and include it in your plugin. For example, if you put the updater.php file in a folder named github-plugin-updater and you want to include it in your main plugin file, you need to add the following line to that file:





You also need to initialize the WP_GitHub_Updater class with the correct arguments that connects your plugin to your GitHub repo:







  • slug: Your plugin's slug.


  • proper_folder_name: The name of your plugin's folder.


  • api_url: Your GitHub repo's API URL.


  • raw_url: Your GitHub repo's raw URL.


  • github_url: Your GitHub repo's URL.


  • zip_url: Your GitHub repo's ZIP URL.


  • sslverify: Whether to verify SSL or not.


  • requires: The minimum WordPress version that your plugin requires.


  • tested: The maximum WordPress version that you tested your plugin.


  • readme (deprecated): The README file to check the plugin version from.


  • access_token: Your GitHub access token, if you're using a private repo.



In order to notify your users, all you have to do is change the version of the plugin in your main file's headers. (It seems that this tool used to check the README file for a line containing ~Current Version:X.X~ but as of version 1.6, it looks for the main plugin file first.)



And that's it! Following these steps will enable update notifications for your plugin.



Wrapping Up for Today



If you want to host your WordPress plugin on GitHub, and want to provide update notifications for your users, the WordPress GitHub Plugin Updater is one of the essential tools you should be making use of.



What do you think about this tool, or hosting WordPress plugins on GitHub in general? Share your thoughts with us by commenting in the Comments section below. And if you liked the article, don't forget to share it with your friends!


Original Link:

Share this article:    Share on Facebook
No Article Link

TutsPlus - Code

Tuts+ is a site aimed at web developers and designers offering tutorials and articles on technologies, skills and techniques to improve how you design and build websites.

More About this Source Visit TutsPlus - Code