10/07
2015
A simplified interface to insure that a WordPress plugin has been loaded
WP Plugin Loader provides an interface for loading plugin dependencies., (*1)
Add WP Plugin loader as a dependency with Composer:, (*2)
composer require voceconnect/wp-plugin-loader, (*3)
Then ensure that your composer autoload file is properly included:, (*4)
require_once 'vendor/autoload.php';
Initialize the PluginLoader:, (*5)
$pluginLoader = new Voce\PluginLoader\PluginLoader(); $pluginLoader->registerHooks();
To be sure that a plugin is loaded, pass the plugin details to the wp_load_plugin
action. For example, the below will load the 'Hello Dolly' plugin:, (*6)
do_action('wp_load_plugin', 'hello-dolly', 'hello.php');
Alternatively, the action name can be retrieved from the class constant LOAD_ACTION
:, (*7)
do_action(Voce\PluginLoader\PluginLoader::LOAD_ACTION, 'hello-dolly', 'hello.php');
...of course this is much shorter if you're already using the use
statement., (*8)