What are some reasons why you should not hack WordPress core files?

The best reason not to hack core is that whatever you are doing should be reworked as a patch for core instead!

Obviously ALL of your code would not make a good patch at all, or at least it rarely would. Instead you need to figure out what hook (action or filter) is missing in core that would let you do whatever it is you need to do without hacking core. We don’t need to hack core when there are adequate filters/actions, so finding what the missing hook is will always remove the need to hack core.

This can often require some tough problem-solving and tricky legwork, but more often then not what happens is you discover that there already is a hook to solve your problem, so you don’t have to hack core!

In the rare scenario where there really is no hook you just need to post on trac explaining why your hook needs to exist. If you get your new hook committed then you have a temporary 1-line hack to core that won’t need to be worried about the next time you update.

Even if your suck at getting stuff done in the Core trac (it takes some convincing to get stuff committed), you have at least boiled your core hack to the minimum possible: 1 line of code for your action/filter. When you update WP you’ve now replaced all the code you shoved into core with one line that needs to be updated, and your plugin can stay the same!

Leave a Comment