Proper way customize default functionality, when using methods & hooks?
-
I recently had the misfortune of dealing with WooCommerce’s 3.0 update.
It broke literally everything on any website that I had built with custom WooCommerce functionality. One website in particular took about 6 hours to clean up… I had to comb through every bit of custom code that I wrote, and change how data was accessed, replace method names, etc.
So, now I am looking to avoid that in the future — for any kind of custom “thing” I write, not just WooCommerce.
What would be the best way to build my sites in the future, so that this is no longer such a huge issue? The main thing I am looking to avoid is having to comb through every bit of code that I wrote in order to find every little detail that needs to be changed.
Best thing I’ve come up with so far is to carry around a library of functions for each major plugin that I use, and plan to customize. In that library would be my own set of functions for all of the basic “stuff” that I use the built-in methods to access.
Literally all that my functions would do is access the method using the most up-to-date methods from the plugin’s documentation, and then return the data whenever called.
What this would do is give me one core file in my custom theme or plugin that I would have to go back through and update the new/deprecated methods, since all of my template and function files would be referencing my functions, instead of directly pulling from the plugin APIs in a million different places.
My main question here, though, is: Would this be considered “good practice”, or would it be considered bad juju? Are there any performance issues that I’d have to worry about? Would there be a better way to do this?
- The topic ‘Proper way customize default functionality, when using methods & hooks?’ is closed to new replies.