22

I am trying to extend the functionality of another plugin. I need to get data from it into an array to use in a different manner than the original plugin. (In this case, WPMUDev Categories and Listings plugins). Is there something in the Codex? How can I create a plugin that can use another plugins functions? Can I extend them and construct the parent nodes functions? I am not sure if these plugins are using classes or just straight functions.

I am just trying to get data from the plugin into a sidebar widget (in a form option element), but eventually I will be using this for the content area as well by using custom shortcodes. For now I just need a place to get started.

1

1 Answer 1

22

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.