Plugin Endpoints
This tiny library allows you to register various URL endpoints. When any of these endpoints is requested, only the specified set of enabled plugins will be loaded., (*1)
, (*2)
This drastically improves performance for requests to these URL's, only loading the minimum number of required plugins to return the final response., (*3)
Results depend on many factors but it is not unusual to experience a 50% gain in speed and a decrease in memory consumption of about 30%., (*4)
Installation
Using Composer
{
"require": {
"dannyvankooten/plugin-endpoints": "dev-master"
}
}
Manually
require __DIR__ . '/plugin-endpoints/vendor/autoload.php';
Usage
Because the library needs control over which plugins are loaded, you need to instantiate the Router class and register your endpoints from your mu-plugins
folder., (*5)
The following example registers an endpoint for Easy Digital Downloads & the Software Licensing add-on., (*6)
// file: `/wp-content/mu-plugins/endpoints.php`
// load the autoloader manually (or use Composer!)
require __DIR__ . '/plugin-endpoints/vendor/autoload.php';
// instantiate the routing class
$router = new PluginEndpoints\Router;
// register an endpoint
$router->register_endpoint(
'/edd-sl-api', // listen to requests starting with /edd-sl-api
array(
'easy-digital-downloads/easy-digital-downloads.php',
'edd-software-licensing/edd-software-licenses.php'
) // only enable edd & edd sl plugins
);
// done!
Now, point a request at https://your-site/edd-sl-api....
and notice that only the specified plugins are loaded for the request., (*7)
GET http://local.wp/edd-sl-api/?edd_action=activate_license...