github-theme-updater

This is a simple class that lets you use github releases in your repository to handle your theme updates. A more robust solution would be to use the github-updater plugin, but I simply refuse to include a 540kb library in my theme when I can accomplish what I need in less than 200 lines of code.
Is it perfect? No. Does it get the job done? Yes.

Implementing in the theme:

  1. Download the php file from this repo and include it in your theme, or require it using composer:
     composer require aristath/github-theme-updater
    
  2. Change the namespace on the top of the file to match the one you use in your theme (you are using namespaces, right?).
  3. Include the updater class in your functions.php file:
     add_action( 'after_setup_theme', function() {
         get_template_part( 'inc/classes/Updater' );
     });
    
  4. At the bottom of the Updater.php file init the updater:
     new Updater(
         [
             'name' => 'Gridd',                     // Theme Name.
             'repo' => 'wplemon/gridd',             // Theme repository.
             'slug' => 'gridd',                     // Theme Slug.
             'url'  => 'https://wplemon.com/gridd', // Theme URL.
             'ver'  => 1.2                          // Theme Version.
         ]
     );
    

Releasing an update on Github

When you want to release an update you can simply go to your repository > Releases and create a new release.

Advice

Why was this created?

This project was created out of necessity for a theme submitted on wordpress.org. The theme-review process on wordpress.org takes a long time…

Overall a theme review can easily take more than 6 months.

In the meantime, life goes on. If your business depends on your themes, then you may want to implement an alternative method to provide updates for your theme so people can start using it and you can start growing.

Releasing your theme on w.org

Remember to remove the script when uploading an update on w.org. When your theme goes live you can remove it from the repository as well, this is only meant as a stepping stone.

Until your theme goes live you can ignore the class inclusion if you did it using get_template_part as in the example above. If the file doesn’t exist nothing bad will happen.

Personally I prefer using a .gitattributes file to exclude the development files like .sass, .map, .editorconfig etc. If you use such a file on your project, you can just add Updater.php export-ignore in there and it won’t be included in your theme export when you get your build ready for w.org

That’s all. I hope you enjoy using this and it makes your life somewhat easier.