I’m developing plugin B that depends on plugin A.
The first approach is to add a message, either in the readme file or as an admin notice, stating that plugin B will require plugin A to work; the user installing plugin B will then install plugin A manually and re-activate plugin B.
A second approach might be to use some plugin solution or a library solution to the problem.
A third approach, the one I use, is to use Composer to pull in the required WordPress plugin inside the current one, an embedding of sorts.
This latter approach will require each dependency plugin to declare a composer.json file or have the dependent plugin (“B”) use the Composer package option to provide a virtual one.
The limits of the latter possibility are few but those dictated by common sense: embedding BuddyPress in a plugin might not be the best course of action.
When I download a plugin I expect it to work out of the box.
This means that distributing a plugin that will require the user to run composer update from the root folder is not the best of approaches.
I will run composer update locally and make sure all of the plugins fundamental dependencies are there in their updated and “lighter” version.
I’m taking advantage of any possibility Composer can offer and I can use in a PHP 5.2 project to autoload the embedded plugins bootstrap files, init.php from Custom Meta Boxes 2 and the tad-reschedule.php file from tad-reschedule utility plugin as well as the plugin classes themselves.
In the repositories section of the file I’m specifying I will pull in the latest version directly from GitHub for both and that means I will get a lot of folders and files I do not need, first among them the .git folder, when running compser update.
In the last lines I’m creating PHP 5.2 compatible autoload files and running a Grunt task after that.
In the Gruntfile.js file I’m using the tasks to remove nested .git folders and other files and folders that will not be needed in a distributed version of the plugin like the tests folder, Codeception, PHPUnit and Travis configuration files.
After that the task will add the clean dependencies to the plugin repository.
It’s not covering everything I might ever need but it’s a starting point.