TGM Plugin Activation

The best way to require and recommend plugins for WordPress themes (and other plugins).

Frequently asked questions

Question index

How do I add TGMPA to my theme/plugin ?

Follow the Installation and Configuration Instructions.

Back to Top

How do I upgrade TGMPA ?

If you already use TGMPA in your theme or plugin and want to upgrade to a newer version, follow the instructions below:

  1. Download the latest release.
  2. Read the Changelog to see what has been fixed/changed/improved in the new version.
  3. Replace the old class file class-tgm-plugin-activation.php with the new version.
  4. Carefully check the example.php file which is included in the release for new or changed options and code and adjust your existing function accordingly if necessary. The following page will always contain up-to-date information on the current configuration options.
  5. Release an updated version of your theme/plugin.

Back to Top

How do I remove TGMPA from my theme/plugin ?

If your theme or plugin no longer needs TGM Plugin Activation (TGMPA) support, then these are the steps you need to take to remove TGMPA. Some initiative may be needed depending on how the theme or plugin author has added it in, and it is assumed you are comfortable editing PHP files / FTP as needed.

  1. Find and delete the plugin registration function. It will look something like:
    <?php
    /**
     * Required and Recommended Plugins
     */
    function prefix_register_plugins() {
    
    	/**
    	 * Array of plugin arrays. Required keys are name and slug.
    	 * If the source is NOT from the .org repo, then source is also required.
    	 */
    	$plugins = array(
    
    		// WordPress SEO
    		array(
    			'name'     => 'WordPress SEO by Yoast',
    			'slug'     => 'wordpress-seo',
    			'required' => false,
    		),
    		...
    	);
    
    	tgmpa( $plugins );
    }
    add_action( 'tgmpa_register', 'prefix_register_plugins' );
    
    There should only be one instance of tgmpa( or tgmpa_register in your theme or plugin (other than the TGMPA class file), so search for that. The registration function may be with other code in functions.php, init.php or a separate file such as include/tgmpa.php or other file.
  2. Find and delete the require_once() call that references the TGMPA class file:
    <?php
    /**
     * Include the TGM_Plugin_Activation class.
     */
    require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php';
    
    The file name is almost certainly unique, so search your theme or plugin for that. The theme or plugin author may have used require, include or include_once instead of require_once, and they may have added extra ( ) around the file path.
  3. Find and delete the TGMPA class file. Since the class file is no longer referenced, the whole class-tgm-plugin-activation.php file (or equivalent if renamed) can be deleted from your theme or plugin.

With the plugins registration, the class file reference, and the class file itself all removed, your theme or plugin will no longer be using TGMPA.

Back to Top

My theme does not pass the theme review if I include TGMPA. How do I fix this ?

If you are submitting a theme to wordpress.org or to a commercial theme repository, such as ThemeForest, your theme will be reviewed before being accepted and the Theme Check plugin is one of the tools used during these reviews.

  1. Typical review feedback which you might see if you include TGMPA is:

    REQUIRED: path/to/class-tgm-plugin-activation.php. Themes should use add_theme_page() for adding admin pages.

    WARNING: More than one text-domain is being used in this theme. This means the theme will not be compatible with WordPress.org language packs. The domains found are your-text-domain, tgmpa

    Solution: To fix this, download a fresh copy of TGMPA using the Custom Generator and indicate your distribution channel to get the correct version which will pass the Theme Check rules.

  2. With older versions of TGMPA you might also encounter the following feedback from Theme Check:

    WARNING: Found a translation function that is missing a text-domain. Function _n_noop, with the arguments …

    REQUIRED: screen_icon() found in the file class-tgm-plugin-activation.php. Deprecated since version 3.8.

    Solution: Both these issues indicate that you are using a very old version of TGMPA and you should really upgrade to the latest version.

  3. A last issue you might encounter if you distribute your theme via ThemeForest is feedback along the lines of:

    All translated strings must be escaped.

    Let us reassure you: all TGMPA output strings are escaped.

    Most strings are escaped late, i.e. at the point where they are echo-ed out, as only then you know the context in which the string is used. This means you will often not find the escape call together with the translation call. This is correct and is nothing to worry about.

Back to Top

How can I exclude the TGMPA text strings from my `.pot` file ?

As TGMPA - since version 2.6.0 - comes with its own translation files, you can save the translators of your theme or plugin some work, by excluding the TGMPA strings from your .pot file.

WARNING: Only do this if you are distributing the TGMPA translation files with your theme/plugin! In other words: do not do this if you distribute your theme via wordpress.org!

The easiest way to set this up, is by using the program Poedit. So install this first if you haven’t got it already.

  1. Open your .pot file in Poedit.
  2. Use the menu at the top to go to CatalogueProperties or just press the key combination Alt+Enter.
  3. Go to the second tab Sources paths.
  4. At the bottom of this screen you can add files or folders to be excluded when generating or updating the .pot file:

    screenshot-1

    You can either exclude a whole directory …

    screenshot-2

    … or exclude individual files from parsing by the .pot generator.

    screenshot-3

  5. Once you’re finished, click OK and then use CatalogueUpdate from sources to update your .pot file and the TGMPA strings will no longer be included.

Back to Top

My theme/plugin includes the latest version of TGMPA, but it seems an older version of TGMPA is used. What gives ?

There may be more themes/plugins active on your WordPress install which use TGMPA. The first version of TGMPA WordPress encounters will be used. This may not be the version included in your theme/plugin.

If you or your end-user experience bugs which have been solved in recent versions of TGMPA, try and find out which other theme/plugin is installed which includes TGMPA and contact the theme/plugin author and urge them to upgrade their TGMPA version.

FYI - the loading order within WordPress is as follows:

  1. Must-use plugins in alphabetical order
  2. Plugins
  3. The active theme

Back to Top

How can I find out what version of TGMPA is being used ?

For TGMPA 2.5 and up, you’ll see the version used displayed on the bottom right-hand side of the TGMPA page.

For earlier versions, you’ll have to check the actual TGMPA file and look for the version number in the file header. Please do keep the above mentioned loading order in mind and search your WP install to see if there are several versions of TGMPA in use and check all version numbers.

Back to Top

A plugin says it needs an update, but when I try to update, it says 'The plugin is at the latest version'.

Some - especially commercial - plugins will include their own upgrade routines which may overrule the TGMPA upgrade instructions. Try deactivating the plugin before trying to update. If the upgrade works when the plugin is deactivated, the above will be the reason the update didn’t work earlier.

If the update still doesn’t work, please report this as a bug.

Back to Top

I've bundled a new version of a plugin with my theme. Why does TGMPA not show there is an update available ?

Updating with bundled plugins can only be done by setting a minimum required version of the plugin in the settings file - the version array key. Set this to the version number of the updated bundled plugin and things should be fine.

TGMPA cannot obtain information about the version number of bundled plugins itself, so it relies on the information you provide in the settings file to determine if there is an update.

Back to Top

I've bundled a new version of Visual Composer with my theme. Why doesn't updating via TGMPA work ?

This particular situation (only) occurs when you, as a theme developer, have a developers license for Visual Composer allowing you to distribute it with your theme.

Visual Composer - by design - looks at the Envato Market place server to see if there are updates available for the plugin. If you ship the update as a zip file bundled in with your theme, the update routine within Visual Composer will overrule your bundled update, making the update fail.

To fix this, add the below line of code to your functions.php to disable the external updater in Visual Composer:

vc_set_as_theme();

For more information - see the Visual Composer developers documentation.

Back to Top

I get a fatal PHP error 'Call to protected TGM_Plugin_Activation::__construct() from invalid context'. Help!

This issue was fixed in TGMPA v2.5.2. There are at least two copies of TGMPA active in your WP install and both of them are out-of-date. Please contact the theme/plugin authors of the theme/plugins using the old version of TGMPA and urge them to upgrade the TGMPA version they include.

Back to Top

I get a fatal PHP error 'Class TGM_Bulk_Installer not found'. Help!

This error has been fixed in TGMPA v2.4.2. Please upgrade your version of TGMPA or contact the theme/plugin owner using an old version of TGMPA and urge them to upgrade the version they include.

Back to Top