Creating a plugin with dependencies

Yes, it is possible to create a plugin that extends another plugin. Here are a few ideas on how you might go about it:

  1. A plugin can set up its own action and filter hooks (using the do_action and apply_filter functions) just like the WordPress core does. If the plugin you are targeting does this, you can use these hooks to change functionality.

  2. If a plugin uses an object-oriented structure, you can extend the classes and build on the original plugin.

  3. You can read the data stored in the database by the original plugin and use it in your plugin code.

  4. You can call any function from the original plugin that you like, after you have checked that the plugin is active and loaded (see below). Just be aware of any effects that the function might have besides the returned value.

You’ll need to check whether or not that original plugin is activated. You could use the is_plugin_active function; however, this only works on the admin pages. Alternatively, you could use function_exists or class_exists to check whether or not a particular function or class from the original plugin is available, which would tell you that it is running.

Remember that anytime the original plugin is updated, you need to test your plugin with the new version to look for anything new that might conflict with your plugin.

Leave a Comment