Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
3  
FWIW there is a track ticket about this very topic core.trac.wordpress.org/ticket/22316 –  Norcross Sep 8 '13 at 21:19

1 Answer 1

up vote 12 down vote accepted

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.

share|improve this answer
1  
Good answer +1. Only in the sentence "You can call any function from the original plugin that you like" I should add "after you have checked the plugin is active and loaded" –  G. M. Sep 4 '13 at 16:28
    
@G.M. Edited, thanks for the comment. –  Ben Miller Sep 4 '13 at 16:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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