How to override wordpress core php files.
-
I’ve been googling this topic and forum moderators seem reluctant to answer the question and instead only offer solutions to the underlying problem. But the real question is: What is the suggested way to override a WordPress core php file (ie. something in the wp-admin or wp-includes dirs)?
Yes, yes, I know, this is not recommended because when WP updates are made, any files that overwrite the updated files will either be overwritten, or just cause problems…
But there are times when the core files just don’t provide the flexibility to filter their output, so what can you do? You have to hack the core!
Solution 1:
I could write a script to modify the latest core file every time I update wordpress; but that is a pain in the arse.Solution 2:
I could copy the core .php file into my theme dir and then include() it or possibly enqueue() it and then what? remove_action() add_action(), but the problem I see with that is that the new add_action function handle needs to be the same as the old in order for it to be called by existing scripts. So it would be nice to have some guidance for the proper way of doing this.Note: I’ll open a separate question related to the underlying problem I’m having with a particular core file.
- The topic ‘How to override wordpress core php files.’ is closed to new replies.