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.
Yes, it is possible to create a plugin that extends another plugin. Here are a few ideas on how you might go about it:
A plugin can set up its own action and filter hooks (using the
do_action
andapply_filter
functions) just like the WordPress core does. If the plugin you are targeting does this, you can use these hooks to change functionality.If a plugin uses an object-oriented structure, you can extend the classes and build on the original plugin.
You can read the data stored in the database by the original plugin and use it in your plugin code.
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 usefunction_exists
orclass_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.