Question

I have to make some changes to some functions in a plugin that don't have hooks and aren't pluggable.

My idea was to wrap the functions I modify in a if ( ! function_exists()) and move my modifications into a separate plugin. Then whenever I need to update the plugin, I just re-add the if ( ! function_exists()) wrapper.

Please tell me why this is a bad idea and what I should be doing instead.

Was it helpful?

Solution

It seems like the plugin you are using are quite important to you and/or your client, and the plugin itself is most probably regulary updated with proper support.

I would definitely contact the author and discuss possible changes to the plugin. If a change is a constructive change and would bring some degree of usefulness to the plugin, I see no reason why the author would not implement your changes in the near future releases/updates.

Primarily, if your change is to out of scope of the current plugin, you can suggest and ask the author to just add a proper filter where needed in future releases/updates.

But yes, I would start at the plugin author for such kind of support before looking into other solutions

OTHER TIPS

I can think of not even one example to a plugin that do not use filters. Almost all plugins use options to store data and therefor use the option related hooks.

your plugin probably uses many actions and filters, they are not on its high level code, but it does not prevent you from using them to change the plugin's behavior.

Another possibility is to use output buffering to manipulate the output if there is no other way to influence its generation.

if the plugin you are wanting to manipulate exists as a class, you might be able to overwrite it with __call function in your class (extends the original). that keeps you from editing files; you might have to rewrite your plugin to keep up with the other plugin, but I think extending the plugin's class is your best option, given the author's neglect.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top