0

I made a few websites in WP (that was kind of my first serious web-related work where I started learning about more serious and concrete stuff other than homework type of programming exercises) and only now that some time has passed do I see some things that I did wrong in the first place that I would do differently now. One of those thins is that I hard-coded lots of custom stuff into plugins themselves and now I realize that I cannot update lots of plugins because that would break certain parts of the website.

What I am interested is how do you cope with this? I understand that this probably falls into the scope of website maintenance, but perhaps there is a common approach, a design pattern or something that could be used to minimize this problem? One could perhaps make and include a custom css file that would contain all the override/custom values, but how about custom php/html/js changes? Is there a similar way of making customizations in that area without the fear of loosing all of them once an update is in place?

2 Answers 2

3

The key to upgrade-proof customizations is to never edit plugins directly. You should use actions and filters to hook into a plugin's code. Not everything is customizable through these hooks, though. The amount of useful hooks provided depends on the quality of the plugin code.

Also see: Hooking in to plugins


If you really would like to change anything you want in a plugin, without being constrained by the provided hooks, here's an alternative approach that I can think of. Put the plugin in version control, then create your own branch with customizations. Whenever a plugin update is provided by the author, check out the master branch, run the updates, then merge the updates back into your own branch. You may have to fix some merge conflicts.

0

It might also be worth looking into Child Themes.
They're a good way of making modifications/overrides to a theme while still allowing you to update the theme itself as new updates are released.

While not strictly related to plugins, you could write any customisations to plugins (provided you can hook into them as Geert mentions) in your child theme's functions.php file. This way your changes are completely independent of both theme and plugin updates.

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.