Thursday, August 6, 2015

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 plugins—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 its own plugin repository. And I wouldn't be wrong if I said the WordPress.org Plugin Directory has become the community standard for hosting free and open source 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 it, and that's perfectly natural.

The first place people host their WordPress plugins after the WordPress.org Plugin Directory is GitHub. Utilizing the awesome revision control system called Git, GitHub is one of the best places to share your open source software with the rest of the world. And for the last couple of years, more and more WordPress developers have been publishing their new plugins over GitHub.

Advantages and Disadvantages of Switching From the WordPress.org Plugin Directory to GitHub

I think that there is a balance between the advantages and disadvantages of hosting WordPress plugins on GitHub instead of the WordPress.org Plugin Directory. I'm going to lay out the ones that come 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 more easily.

There's also a nice debate over on 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 to connect 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 with which 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!


by Barış Ünver via Tuts+ Code

How to Get Good Clients by Utilizing Influencers

Trying to land freelance clients can be difficult. Confusing, even. Where do you find them? And once you find them, how do you compete with all the other freelancers out there? Finding clients can also be time consuming. You could easily spend hours responding to bids, cold calling or emailing, and scrabbling for scraps. At […]

Continue reading %How to Get Good Clients by Utilizing Influencers%


by Joyce Akiko via SitePoint

Quick Add To Cart with CSS and jQuery

A handy snippet to let users customize a product directly from the products gallery, and add it to the cart.


by via jQuery-Plugins.net RSS Feed

Free Course: Add Sound to Your Site With Web Audio

Roadiz

opl-small

Multi-scrolling One Pager for a new CMS called 'Roadiz'. At first appearance you'd think this is not a Single Page website but the top navigation links to Documentation and API subdomains, the main navigation slides in content horizontally and the footer license link can be considered a "Terms" page. Read our comprehensive article about what is considered a One Pager.

by Rob Hope via One Page Love

Phoenix for Railsies

So, what is Phoenix? It's a Rails-like framework built for Elixir. You might ask: what on Earth is the point of learning yet another framework for yet another language that nobody really seems to be using (yet)? There are a couple of reasons. First of all, the Erlang VM is pretty darn fast and Elixir inherits this speed. There are benchmarks that show this. But of course, we can sit around all day and poke holes in those so you'll just have to build something with both technologies to believe it.

Secondly, Elixir is an interesting language because it manages to combine functional programming, OOP, and a Lisp-like conception of metaprogramming (Elixir's macros are pretty insanely powerful). Finally, Rails definitely feels a bit behind-the-curve when it comes to things like WebSockets. Phoenix comes with these right of the box. Best of all, you get most of these benefits without having to leave the niceties of Rails behind. Granted, there aren't as many packages for Phoenix as there are for Rails but the framework itself is fairly feature-complete. Let's take a look at the basics of Phoenix.

Continue reading %Phoenix for Railsies%


by Dhaivat Pandya via SitePoint

Mastering AngularJS Directives