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 would like to add some additional features/functionality with already available WordPress plugin.

Is it possible to carry over my customization while updating the plugin?

share|improve this question
add comment

2 Answers

Probably not.

The recommended way to get your enhancements into the plugin is: Send your fixes to the developer and ask her to merge them into the original. If your changes are rather personal customizations, this won’t happen.

If the plugin is written in a strict OOP style you can create a second plugin which extends just the classes from the original as you need it (sort of a child plugin). Unfortunately most plugin developers don’t see this need and don’t write their code accordingly. Be aware of the load order problem.

We could help better if you would describe which plugin you want to extend and what exactly you want to change.

share|improve this answer
    
thanks for your response :-) –  notme Oct 6 '11 at 12:14
add comment

Unfortunately it totally depends on the plugin (or more accurately, on the plugin author!) If the author was thinking pro-actively and created the plugin in such a way to make it extensible, then yes, you can create your OWN plugin that adds to the functionality in the existing plugin.

Do make note of what Toscho pointed out - that your plugin order matters (the link again is here).

Hooks

The most common way to make a plugin extensible is to add hooks (action and filter hooks) that you can then leverage with your own plugin. If you have a good code editor (right now I'm rocking out on NetBeans) you should do a search through the plugin source files for: do_action and apply_filters. If the plugin author has provided those hooks, this is a very convenient and easy way for you to over-ride defaults, or inject your own code.

Pluggable Functions

If the plugin author is savvy, but is using the global namespace for the plugin functions, he/she may have wrapped the plugin's functions within if ( function_exists() ) conditional statements. For this to work to your advantage, you have to make sure your plugin loads first (which may be a challenge). All you have to do is declare your function by the exact same name within the exact same namespace and then your function will replace the one used by the plugin.

Extension

If the plugin author is a good OOP coder, he/she may write the plugin code in a granular enough way that is open for extension (since, as the GOF would say, it is definitely closed for modification). Look for lots of granularity in the plugin class - that is to say methods that perform small, highly specific tasks - that can be overridden in your own class that extends the plugin's class. Of course, as Toscho mentions, the class needs to be architected in such a way that it can be overridden, and that its default implementation doesn't invoke itself completely.

Fork or Patch

If the plugin author is using gitHub, or has opened the source in some other way, you can either submit a patch to the author with your proposed modifications (your best bet is to modify the plugin to make it MORE flexible or powerful without removing or changing existing features or functionality), or you can just download the source, modify the plugin header to the extent that it will no longer be updated when the original author pushes an update out, and preferably submit your updated version to the author, or as its own entity directly to WordPress. Be aware that if you do submit the plugin to WP you will need to have a site for it and should be prepared to support it if others download it.

share|improve this answer
add comment

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.