5

Reading this question on meta, I thought it would be a good idea to have a question about altering core, that can be referenced. The idea is not have answers simply saying this is bad, but I was aiming for a question with an answer that will explain things a bit for new comers.

Why is it a bad thing to do?
If you think you really need to do it, what do you need to be aware of?
You know all this but simply have to alter WordPress, how do you do it?

I could probably for the most part answer this question myself, but I'm hoping one of you gurus can write up a really good answer, explaining things, all the details.

Update:
I added a new question as a CW link. I think the initial question has it's merits too, but for something we can use as a reference, we should have one that is a CW, so that's why I made a new question for the cause. I tried to make an introduction, but let the bulk explanation be formed as answers. We could over time consider making an answer with all contributions that I can mark as accepted answer to make it stick to the top.

2
  • 3
    @googletorp: Excellent idea, and also what the StackExchange folks recommended in a recent moderator chat. However you can retitle and reword this question to be something like "Reasons Why Your Should NEVER Hack WordPress Core" and then give an intro that explains the purpose of this question (i.e. so we can point to it) and remove the discussions of if we should do use this question for that purpose because people will be confused by that. Alternately leave as is and create a new question we can point to. Or let me know and I'll do the editing but I wanted to give you the first chance. Commented Sep 10, 2010 at 0:18
  • Keep in mind that hacking core is viable, e.g. fixing bugs, submit code and all that stuff. It's not always bad.
    – hakre
    Commented Sep 14, 2010 at 22:10

2 Answers 2

3

FYI:

Photo: Don't Hack WordPress Core; Or the Kitten Get's it!

4
  • 1
    I think hacking core has its place in the world, but +1 sir.
    – user66
    Commented Oct 6, 2010 at 21:28
  • BTW, that image can directly from Andrew Nacin on the wp-hackers list. :) Commented Oct 7, 2010 at 2:04
  • I feel like I need to validate my earlier "hacking core" comment, since it's a hot button issue: hack core if you are familiar with the WordPress internals, are sure that WordPress can't natively do what you need it to do, are have submitted a ticket on the issue and are pushing your changes back to core. Don't do it because you're inexperienced, or because it's "faster," or without a goal of making WordPress better.
    – user66
    Commented Oct 25, 2011 at 10:30
  • @Adam Backstrom I would argue that your justification is okay with a caveat, and that caveat is that you apply the patch the WordPress team has accepted for the next major version of WordPress, and that release is pending in any day. For example if you hack the core and you are on v3.3 and then v3.3.1 comes out your hacks will be gone as soon as someone updates your site. Or if you are on v3.3 and you've submitted a ticket but they push to "future" your site will break next time it is updated. I stand by my position you can get around (almost?) anything in WordPress w/o hacking the core. Commented Oct 25, 2011 at 21:06
2

1 - It leaves the developer vulnerable to major errors when upgrading the code. If all WordPress mods are done via plugins and themes, when the developer upgrades the WordPress installation, the mods are left alone. If the dev modifies the core code, the changes will be overwritten in the upgrade.

2 - DOCUMENT ALL OF THE CHANGES! Keep in mind that you will need to make the same changes on the new code when you upgrade. Also, the mods you made might not work with the newest version of WordPress.

3 - I have a document where I note any and all changes I have made to the source code. I also use my initials to comment the change so that I can do a find and list them all.

All in all, editing the core files isn't the end of the world. It's dangerous, but you can lower the risks by being careful, documenting your changes, and remember during the upgrade that something MIGHT go wrong :)

11
  • 1
    You might want to copy this answer to the actual question on the main site. This is just a notice about that question, most people won't see it here, and upvotes won't give you a reputation increase.
    – Jan Fabry
    Commented Sep 9, 2010 at 20:46
  • 1
    @Jan Fabry: Creating questions like googletorp suggested here in meta are exactly what Robert Cartaino & Jeff Atwood suggested we do when we need to have something to point to like this. Commented Sep 10, 2010 at 0:14
  • Hi @danhgilmore: Not sure who voted this down but I agree with them even though I'm not going to vote it down. Your answers starts by saying "You shouldn't, but if you do here's how to protect yourself when you do." That's a bit like saying "Don't do Crystal Meth, here's how to try and keep from ruining your life when you do." I think I speak for the other moderators @EAMann and @tnorthcutt in saying that our policy is "DON'T" and we leave it at that. Commented Sep 10, 2010 at 0:22
  • @Mike: I understood this question as a call from googletorp to get attention to his (already created) question on the main site. I see the question as a very valid question about WordPress, not just about this site, so I think it fits on the main and not on the meta site. Similar "core" questions appear on the main Stack Overflow site, not on meta.
    – Jan Fabry
    Commented Sep 11, 2010 at 10:20
  • @Mike: Why wouldn't you vote an answer down if you think it is a bad answer? Isn't that how the system is supposed to work? Sure, it's better if you also leave a comment why you disagree, but voting up or down is the primary way to get good answers to the top, and bad to the bottom.
    – Jan Fabry
    Commented Sep 11, 2010 at 10:22
  • @Mike: I don't think there is a moderator-agreed policy to never discuss modifying core, as EAMann answered: "Hacking core isn't necessarily a no-no". Furthermore, I don't think it is up to the moderators to define this kind of policy. If the community decides, here on the meta site, where we draw the boundaries around content, then the moderators could help enforce them. But moderators should not decide on this on their own.
    – Jan Fabry
    Commented Sep 11, 2010 at 10:22
  • @Jan: Too many things to respond to at once... I have a strong opinion about this subject, but you are wearing me down. I wouldn't vote down someone I respect out of courtesy; it's painful when I see a negative vote and I don't want to inflict that pain on others unless their contribution is egregious. I'll let the system work by not up-voting instead. @EAMann and @tnorthcutt have not commented on my comments; maybe let them do so instead of speaking for them? Commented Sep 12, 2010 at 10:56
  • @Jan: We don't currently have enough people here to get a valid consensus; mostly it's the 3 moderators and you and @hakre. Until we have a lot more people participating here frequently there just isn't enough traffic on meta to get any significant level of consensus. I look forward to having enough participation here that community edicts can become clear but until then we either take action or nothing gets done. I've learned if you want progress it's better to more forward than wait for everyone to agree. And if it's wrong, it can be changed later. Commented Sep 12, 2010 at 11:02
  • @Mike: I apologize for wearing you down, I didn't realize my actions had this effect on you. We seem to have a different idea about the "graveness" of a downvote. I have opened a question on this, so we can have a open discussion and you don't have to voice your feelings in the limited format of the comments.
    – Jan Fabry
    Commented Sep 12, 2010 at 15:04
  • RE: policy against hacking core ... Just to weigh in, I'm all for discussing how to hack core so long as we are very clear regarding the risks of doing so. I've had to fix too many sites broken by novice developers who tried to "tweak" something on their own to want to fill up this space with "how-to-destroy-your-blog" questions and answers ...
    – EAMann
    Commented Sep 14, 2010 at 16:40
  • Thanks @EAMann - My fear is discussing it will cause people to use it as a rationalization. I can't count the number of people who tell me they can't upgrade because they (or worse their developer) hacked on core. But, I'm wearing down on this issue so it's the last I'll say (in the near future, that is.) Commented Sep 15, 2010 at 9:13

You must log in to answer this question.