Safely load bundled WordPress plugins inside a host plugin — togglable or always-on — without re-declaration fatal errors.
Requires PHP 7.4+ and WordPress 6.4+.
composer require stellarwp/plugin-absorberUse Strauss — two plugins shipping different versions of this library will collide otherwise. See Installing for the one prefixing rule you must not get wrong.
useNexcess\PluginAbsorber\Config;
Config::set_hook_prefix( 'give' ); // required — keys the hooks and options
Config::set_container( give()->container ); // optional — lets you rebind collaboratorsEach sub-plugin is then described by a config array:
[
'slug' => 'give-stripe',
'bundled_plugin_file' => __DIR__ . '/sub-plugins/give-stripe/give-stripe.php',
'plugin_loaded_constant' => 'GIVE_STRIPE_VERSION',
'standalone_plugin_basename' => 'give-stripe/give-stripe.php',
]- Installing — Composer, Strauss, and the constants Strauss must leave alone.
- Configuration — the hook prefix, the container, every sub-plugin key.
- Conflict handling — the policies, the load guard, and its limits.
- Filters — the runtime overrides for policies and notice text.
- Notices — where the queue lives, who may see it, and how to render it yourself.
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version. See LICENSE.