Advertisement

Intro To TGM Plugin Activation Class For WordPress, A Video

by
Student iconAre you a student? Get a yearly Tuts+ subscription for $45 →

Looking to "bake" a plugin directly into your WordPress theme? This article will give a brief introduction on how to integrate the TGM Plugin Activation class with your WordPress theme, which essentially allows us to include a plugin with our WordPress theme upon activation.


Plugin, Meet Theme. Theme, Meet Plugin

There are lots of cases where you might want to include a WordPress plugin with a Wordpress theme. Take contact forms for instance... it's often a huge help if you can provide a pre-styled set of CSS rules for a particular contact form plugin right inside your theme. The problem is, doing this usually requires telling your theme users to grab the plugin themselves... which isn't really a great system.

If you've ever tried to manually include a plugin with a theme, you'll know that there's one central problem: It requires you to A) copy that entire plugin to your theme and B) update the plugin folder manually each time an update becomes available.

There are lots of issues with this (we won't go into the ethical stuff)... but let's just look at one problem: it's a horrible workflow. If you have, say, 30 themes that you've worked on in the past year and you've used 3 plugins on each one, you need to manually update 90 plugins by copying/pasting the plugin folders to your theme folder. Not cool. Not cool at all.

This class will revolutionize how plugins can be handled for WordPress themes. By using classes that are utilized within WordPress, the TGM_Plugin_Activation class can automatically install and activate multiple plugins that are either pre-packaged with a theme or downloaded from the WordPress Plugin Repository.

This has a variety of great and wonderful implications... but for our example above, it means that you no longer need to worry about manually updating plugins. You can simply visit each site, hit "update" on each plugin and you're good to go. It's still a fair bit of work, but it's a lot less hairy than how we used to do it in the olden days (and by that, I mean last month).

Expand this example to themes that are distributed on a wide-spread basis (like from ThemeForest or the WP theme directory) and you can see that this is a much, much bigger deal than a neat little workflow trick; It is, as Thomas Griffin suggests, revolutionary.


The Screencast

TGM Plugin Activation Class

The TGM Plugin Activation class allows you to package plugins for installation with your WordPress theme, including directly from the WordPress.org plugin repository. Japh, our Envato WordPress Evangelist, has recorded a great little video explaining how to use it.

If you didn't catch the link already, you can download the class from Thomas Griffin's GitHub page and start playing around with this yourself.

Oh, and this goes without saying, but thanks for Thomas and Gary for taking on this problem!

Advertisement