WordPress Plugin Dependencies: How to Make an Add-on Require Its Main Plugin
WordPress sites often rely on plugins to add features, and some plugins are designed to extend a specific main plugin rather than work on their own.
That relationship matters to site owners and developers because loading an add-on without its required plugin can cause errors or leave its features unavailable.
Making the dependency clear helps an add-on behave predictably and gives administrators a straightforward path when the main plugin is missing or inactive.
Here’s how to make a WordPress add-on require its main plugin.
Decide When Your Add-on Needs the Main Plugin
Before you build an add-on, decide whether it can work on its own or needs the main plugin to provide its features and data. If it only adds convenience, such as an extra report or display option, let people use it independently where practical.
If it relies on the main plugin’s saved content, settings, or core services, treat that plugin as essential. Clear optional integration boundaries help you separate features that can run alone from those that need a connection.
For example, an add-on might show basic information without the main plugin, then add filters when it’s available. Plan graceful feature fallback: hide dependent controls, explain what’s unavailable, and preserve unrelated features.
This keeps the add-on useful without confusing users or causing errors when the main plugin isn’t active. Check each feature’s real data needs before choosing its boundary.
Choose a WordPress Plugin Dependency Check
Once you’ve decided which features depend on the main plugin, choose how your add-on will check whether it’s available. Your choice affects maintenance, user feedback, and how safely the add-on handles missing features.
Compare your options
| Method | Best use |
|---|---|
| Plugin API | Inspect active plugins centrally |
| Class check | Confirm a required class exists |
| Function check | Confirm a specific function exists |
| Version check | Require a minimum supported release |
These dependency alternatives suit different setups. Pick one that matches how the main plugin exposes its features, and avoid relying on internal details that may change without notice.
Set a compatibility strategy
- Check the main plugin’s documented hooks, classes, or functions.
- Decide whether you need to support multiple versions.
- Plan what your add-on should do when a dependency is unavailable, such as hiding dependent features or showing a clear admin notice.
Choose a method you can maintain and test across supported versions.
Check If the Main Plugin Is Installed
To check whether the main plugin is installed, use WordPress’s plugin list rather than relying only on a class or function check. A class may not load until later, and another plugin could define the same function.
Use WordPress’s plugin list to check whether the main plugin is installed; classes may load later, and functions can conflict.
You can inspect installed plugin files with get_plugins(), from wp-admin/includes/plugin.php. Load that file if needed, then check for the main plugin’s known plugin file path:
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$installed = array_key_exists(
'main-plugin/main-plugin.php',
get_plugins()
);Use the exact relative path shown in the main plugin’s plugin metadata or plugin directory. Don’t guess from its display name, which can change.
This check tells you whether WordPress can find the plugin’s files; it doesn’t tell you whether the plugin is running. For broader compatibility, review dependency APIs before choosing your implementation.
Check If the Main Plugin Is Active
Check whether the main plugin is active before calling its features, since an installed plugin may still be deactivated. Add a runtime activation check to your add-on’s startup routine, then stop its feature code when the dependency isn’t available.
For example, WordPress provides is_plugin_active(), but you must load its function file first when checking from front-end code. You can also use a reliable function or class that the main plugin defines, if it’s available only after activation.
Check the plugin’s active status before registering integrations, loading dependent classes, or calling its functions. Don’t assume installation means those features are ready.
If the main plugin can be network-activated, account for that status too, especially on multisite sites.
Use dependency status logging during development to record whether your check passes, and remove noisy logs before release. This makes activation issues easier to trace.
Show a Clear Dependency Notice
Show a clear notice when a required plugin isn’t active, so you know what’s missing. Explain how to install or activate it, and where to get help if you can’t proceed.
Display a Clear Notice
When a required plugin is missing or inactive, give users a clear notice that names the dependency and explains what to do next. Show the message in the WordPress admin, where users can see it while managing plugins. Keep your admin notice wording short and specific: “Example Add-on requires Example Plugin to work.” This avoids vague dependency error messaging that leaves users guessing which plugin caused the problem.
Check the dependency’s status before displaying the notice, so you don’t warn users when the main plugin is active. Use a standard WordPress notice style, such as a warning box, and make the text readable with a clear heading or sentence. Don’t show the same alert repeatedly on unrelated admin screens.
Keep the notice focused on the missing or inactive dependency, and avoid technical terms users may not recognize. That clarity helps users understand the issue.
Explain How to Proceed
If a required plugin is missing or inactive, tell users how to fix it, not just what’s wrong. Name the main plugin and explain the next step: install and activate it, or reactivate it if it’s already installed. Include a link to its WordPress.org page or your installation guide when possible.
Make the notice useful
- Use a clear message. For example: “This add-on requires Main Plugin. Install and activate Main Plugin to use these features.”
- Offer a safe action. Show an install or activation link only when the user has permission to use it. Otherwise, ask them to contact an administrator.
- Keep the add-on disabled. Don’t run its features until the dependency is active.
Your dependency strategy should account for both missing and inactive states.
During release planning, test each case, verify the notice and links, and check that dismissing it won’t hide a needed fix.
Link Users to Install or Activate the Plugin
After checking a plugin dependency, give users a clear link to install or activate the missing plugin instead of leaving them to search for it. Show the right action for each case, and explain what happens when they click.
Link directly to install or activate the missing plugin, then tell users to return and try the add-on again.
- If the main plugin isn’t installed, link to its WordPress.org page or open the Plugins screen with an install action. Check that the user has permission before showing this option.
- If it’s installed but inactive, link to the Plugins screen and identify the plugin by name, so users can find its Activate control without guesswork.
- Add concise installation guidance beside the notice, then offer activation walkthroughs if your setup needs extra steps.
Use clear labels such as “Install Main Plugin” or “Activate Main Plugin.” After the action, tell users to return to the add-on page and try again. Keep links secure, relevant, and easy to understand. Don’t send users to a generic help page when a direct admin link can guide them.
Stop Add-on Code Until the Plugin Is Ready
Before loading add-on code, check that the main plugin is active and ready. If it isn’t, stop the add-on from running to avoid errors.
Then load its features only after the dependency is available.
Check the Main Plugin
Check that the main plugin is active before your add-on runs, so it won’t call functions or classes that aren’t available. Use a check that matches the main plugin’s plugin identity, such as a function it defines or a class it loads. Don’t rely on a vague check that could pass because another plugin uses the same name.
- Confirm the exact function or class your add-on needs, then check whether it exists.
- If the check fails, stop your add-on’s dependent code and show a clear admin notice explaining which plugin is missing.
- Test with the main plugin active, inactive, and unavailable, so you can catch errors before users do.
Keep dependency documentation accurate, including the required plugin name and version when needed. A careful check protects your users from fatal errors and gives them a clear next step. Make the check specific, and avoid treating an unrelated plugin as a valid substitute.
Delay Add-on Loading
If the main plugin loads later, your add-on can pass its dependency check but still run too soon. Use deferred initialization to wait until WordPress has loaded the main plugin’s files before starting add-on features.
Choose a safe hook
Register your startup callback on a hook that runs after the main plugin initializes. Check the plugin’s function or class inside that callback, then load your add-on only when it exists. This conditional bootstrapping avoids fatal errors when load order changes.
| Step | Action | Check |
|---|---|---|
| 1 | Register a callback | Runs later |
| 2 | Check the main class | Class exists |
| 3 | Load add-on files | Dependency is ready |
| 4 | Otherwise, stop | No fatal error |
Don’t include dependent files at the top level, since PHP executes them immediately. Pick a hook that matches the main plugin’s documented setup timing. If no suitable hook exists, use plugins_loaded with a priority that runs after the main plugin’s callback.
Set Plugin Slug and Version Requirements
Starting with WordPress 6.5, declare a plugin dependency with the Requires Plugins header using the dependency’s WordPress.org plugin slug. For example, add Requires Plugins: example-main to your plugin’s header. The header does not enforce minimum versions; document and check those separately. Use the stable plugin slug, not the plugin’s display name, because WordPress uses the slug to identify the dependency.
Choose a minimum supported version that reflects the oldest release with the features your add-on uses.
- Find the slug. Check the plugin’s WordPress.org page URL. For example,
example-mainis the slug inwordpress.org/plugins/example-main/. - Set a minimum version. If your add-on relies on a feature added in version 2.4.0, require at least 2.4.0. Don’t set a higher minimum without a clear reason, or you’ll block users unnecessarily.
- Keep it accurate. Update the requirement when your code starts relying on newer behavior, and document the reason in your release notes. This helps you avoid confusing compatibility limits.
Test Missing, Inactive, and Active States
Test your dependency handling with the required plugin missing, installed but inactive, and active, so you can confirm your plugin responds correctly in each state.
Build test state fixtures for all three cases, then run the same checks against each fixture. When the main plugin is missing, verify your add-on stays inactive or shows a clear admin notice, as intended. When it’s installed but inactive, check that your notice explains how to activate it. When it’s active, confirm your add-on loads its features without warnings.
Check each state
- Create a dependency state matrix listing each setup and the expected result.
- Run your tests in a clean WordPress install, then repeat them after changing plugin status.
- Check both the admin screen and front end, and review logs for errors.
Retest after changing version requirements, since an older main plugin may count as unavailable.
Frequently Asked Questions
Can a Dependent Plugin Create Security Risks if the Main Plugin Is Missing?
Yes, you can face risks if a dependent plugin runs without its main plugin. Its dependency attack surface may expose unprotected features, while orphaned API exposure can leave endpoints accessible. Disable the add-on and verify access controls.
How Should Plugin Dependencies Be Documented for Users and Developers?
Document dependencies clearly. Explain installation, version requirements, activation order, and what happens when a dependency is missing, for both users and developers.
Can Multiple Add-Ons Depend on the Same Main Plugin?
Yes, you can have multiple add-ons depend on one shared main plugin. You’ll build an add-on ecosystem where each extension adds distinct features, while users install the main plugin once and activate compatible add-ons independently.
What Happens to Add-On Data if the Main Plugin Is Uninstalled?
If you pull the plug, your add-on data may remain or be deleted, depending on its uninstall code. Check data retention settings and backups; uninstall recovery may restore data only if you’ve preserved it.
How Can Dependency Checks Be Kept Compatible With Future WordPress Updates?
Use WordPress API compatibility best practices: check dependencies through supported APIs, avoid version-specific internals, and test against current and upcoming releases. You’ll improve forward compatibility by documenting minimum versions and monitoring WordPress changes before updating your add-on.
- Activation checks
- Plugin dependencies
- WordPress plugins
About the author
Vladimir Mrkela
Senior WordPress Developer
I’m a senior WordPress developer and co-founder of Pixel Industry. I’ve spent more than 12 years building websites, custom plugins, and integrations for all kinds of projects. I enjoy working on complex architecture, solving tricky problems, and sharing what I learn along the way.