lapsrj / wp-dependencies-manager
Library that helps WordPress plugin dependency management.
Requires
- php: >=5.6
This package is auto-updated.
Last update: 2026-04-23 01:36:45 UTC
README
- Tags: plugin, dependency, install
- Requires at least: 5.1
- Requires PHP: 5.6
- License: MIT
A lightweight WordPress library for managing plugin dependencies. Declare required and recommended plugins via JSON, auto-install and activate them, and provide admins with a Dependencies page under the Plugins menu. Supports WordPress.org, GitHub, GitLab, Bitbucket, Gitea, direct URLs, and bundled ZIP files.
Based on WP Dependency Installer.
Description
You can use composer to install this package within your WordPress plugin / theme.
- Within your plugin or theme root folder, run the following command:
composer require lapsrj/wp-dependencies-manager
- Then create a
wp-dependencies.jsonfile:
[
{
"name": "Classic Editor",
"host": "wordpress",
"slug": "classic-editor/classic-editor.php",
"uri": "https://wordpress.org/plugins/classic-editor/",
"required": true
},
{
"name": "Query Monitor",
"host": "wordpress",
"slug": "query-monitor/query-monitor.php",
"uri": "https://wordpress.org/plugins/query-monitor/",
"optional": true
}
]
- Add the following lines to your plugin or theme's
functions.phpfile:
require_once __DIR__ . '/vendor/autoload.php'; add_action( 'after_setup_theme', static function() { WP_Dependencies_Manager::instance( __DIR__ )->run(); });
For plugins, use the plugins_loaded hook instead of after_setup_theme.
Bundled Plugins (Local ZIP)
You can bundle plugin ZIP files directly within your theme or plugin to distribute premium or private plugins. Place the ZIP file in a directory (e.g. bundled-plugins/) and reference it using "host": "local":
{
"name": "My Premium Plugin",
"host": "local",
"slug": "my-premium-plugin/my-premium-plugin.php",
"uri": "bundled-plugins/my-premium-plugin.zip",
"required": true
}
The uri is a relative path from your theme or plugin root to the ZIP file.
Using PHP instead of JSON
You can also register dependencies programmatically, which works the same way for bundled plugins:
require_once __DIR__ . '/vendor/autoload.php'; add_action( 'after_setup_theme', static function() { $manager = WP_Dependencies_Manager::instance( __DIR__ ); $manager->register( [ [ 'name' => 'My Premium Plugin', 'host' => 'local', 'slug' => 'my-premium-plugin/my-premium-plugin.php', 'uri' => 'bundled-plugins/my-premium-plugin.zip', 'required' => true, ], [ 'name' => 'Classic Editor', 'host' => 'wordpress', 'slug' => 'classic-editor/classic-editor.php', 'uri' => 'https://wordpress.org/plugins/classic-editor/', 'required' => true, ], ], __DIR__ ); $manager->run(); });
When using register() directly, pass the caller directory as the second argument so that local paths resolve correctly.
Contributors
- Leandro
- Andy Fragen (original author)
- Matt Gibbs (original author)
- Raruto (original author)