Plugin authors have long wished for a way to make a WordPress.org plugin depend on another. WordPress 6.5 introduced plugin dependencies, which made this possible for .org plugins.
In this tutorial, I’ll explain how to set plugin dependencies and how it will look to the end user.
Setting a dependency
To set a dependency, just use the Requires Plugins header in your main plugin file.
<?php
/**
* Plugin Name: Reorder Terms
* Plugin URI: https://wordpress.org/plugins/reorder-terms/
* Description: Reorder Terms
* Version: 1.1.1
* Author: Ronald Huereca
* Author URI:
* License: GPL2
* Text Domain: reorder-terms
* Domain Path: /languages
* Requires Plugins: metronet-reorder-posts
*/
Code language: PHP (php)
You can also specify multiple WordPress.org plugin slugs.
* Requires Plugins: metronet-reorder-posts, plugin-slug-2, plugin-slug-3
Code language: PHP (php)
If the required plugin isn’t installed, the plugin will display a warning when it is viewed in the plugin’s list.
In the event that a dependent plugin is active before its parent can be installed, you’ll see an error like the one below:
You’ll also see a warning at the top of the plugins page.
When a parent plugin and a dependent plugin are both active, you’ll find that you can’t deactivate the parent plugin. This is designed so that nothing breaks should the parent plugin accidentally be activated.
Here’s how the plugin would look in the plugin search screen if a parent plugin isn’t installed.
Conclusion
Dependencies are a neat way for a child to reference its parent plugin. For more on dependencies, please read the developer notes, as they cover many “what-if” scenarios.
If you have any questions, please comment below or @me on X.
Like this tutorial? There's more like it. Subscribe today!
Ronald Huereca founded DLX Plugins in 2022 with the goal of providing deluxe plugins available for download. Find out more about DLX Plugins, check out some tutorials, and check out our plugins.