TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.75k stars 431 forks source link

Check if did_action function exists #688

Closed terence1990 closed 6 years ago

terence1990 commented 6 years ago

This is an edge case but when using frameworks such as Themosis or Bedrock, these work by loading up dependancies at root level before Wordpress is instantiated, along with any composer autoload files - so functions like did_action in your autoload file do not exist yet, and throw a fatal error.

The way these frameworks work is to load up instantiation of dependant functions and processes through ServiceProviders on boot, and it here that we would call load_tgm_plugin_activation, and not in the composer autoload.

See below ServiceProvider we are using for TGMPA integration with our framework which works nicely when this pull request is applied:

https://github.com/wp-kit/tgmpa-integration/blob/master/src/Tgmpa/TgmpaServiceProvider.php#L22