I install WordPress a lot — at least, a lot more than the average Joe or Jane. And since I tend to install WordPress manually each time, I prefer to optimize the process as much as I can. In that vein, I keep a tally of all the must-be-done core hacks for each version and I administer them as soon as I download and unzip the files. It then becomes my stock WordPress install.

Let me just back up for a moment and explain my system a little better. On my computer, I keep a Tools folder for all the tools I use online (i.e. WordPress, robots.txt template, .htaccess file, and so forth).

WordPress Folder Names Each time a new WordPress release comes out, I immediately download and unzip the files into my Tools folder and then change the default wordpress folder to wordpress-version (example: wordpress-2.5.1).

From there, I go in and add the stock themes, plugins, robots.txt, and .htaccess files. Then, I make each of my core hacks. I then use this version of WordPress for every new installation or upgrade until a new version is released.

This system works for me; it means that all of the themes, plugins, and files I typically use will already be ready and waiting for me and I don’t need to repeat unnecessary tasks for each install.

Now that you know my system, I’ll run down each of the core hacks I make (current as of the 2.5.x branch). It should go without saying that these hacks should not be attempted if you don’t feel comfortable working with PHP code because you could seriously cripple your WordPress installation files if you aren’t careful. You assume all responsibility should your server blow up as a result of following my hacks.

Finagling the Installation

One thing I prefer when installing WordPress is the ability to remove excess clicks (i.e. the clicks necessary to delete all the default cruft).

WordPress will insert links (after the heated debate, the default links were changed to WordPress resources, but they’re still cruft to me), a default post, page, and comment. Rather than have to delete these items later, I just nip it in the bud.

The files involved:

  • /wp-admin/includes/upgrade.php

Changes to make:

  • Comment out lines 76-95 to remove the default blogroll links
  • Comment out lines 98-102 to remove the first post
  • Comment out line 105 to remove the first comment
  • Comment out lines 108-109 to remove the first page (i.e. the About page)
  • On line 67, change the category post count 1 to 0
  • On line 73, change the link count from 7 to 0

Meta Generator & Version Number: What Stats and Why?

For some unknown reason, WordPress has rolled its meta generator tag into core. As a result, simply leaving that information (or altering it) in the theme’s header.php file means nothing — it will still appear (in some cases, twice). I can understand them wanting it "[left] for stats", but frankly, I’d rather not.

The files involved:

  • /wp-includes/general-template.php

Changes to make:

  • Comment out line 1166 (since I still like to quickly see which version of WP I’m running by glancing at the source code, I replace it with a toned down HTML comment; instead of commenting out line 1166, I’ll change it to $gen = '<!--'. get_bloginfo('version') .'-->';)
  • Optional, replace lines 1169, 1172, 1175, 1178, 1181, and 1184 with $gen = ''; 

Alternatively, if you’d still like the generator to display WordPress, you can just delete the version number by removing the get_bloginfo('version') template tag wherever it exists or change the <meta name="generator" … /> code to an HTML comment.

NB: It’s conceivable that people trying to give you help will check your source code to figure out which version of WordPress you’re using — I’ve been known to do this myself — so if you do remove this data, it’s imperative that you tell the people from whom you’re seeking help which version of WordPress you’re using.

WP Don’t Phone Home

When WordPress 2.3.x arrived on the scene, there was a huge kerfuffle over the privacy implications of its new update notification feature. Since I see no point in storing the blog details in a DB when checking whether a version is up to date or not, I simply remove the blog URL that’s transmitted. (There is a plugin which disables this feature, but you also will not receive update notifications if you activate it.)

The files involved:

  • /wp-includes/update.php
  • /wp-admin/includes/update.php

Changes to make:

  • Remove get_bloginfo('url') from line 45 and line 98 (in the respective files), or you can replace it with another URL of your choice (i.e. 'http://google.com/').

Get The RSS Import Up & Running (Properly)

Sometimes I import data directly from an RSS feed, unfortunately, there’s a bug in the WordPress RSS import script which prohibits the clean importing of these feeds. It doesn’t appear to be a priority (I assume because not that many people use the RSS import feature), so it’s a bug which has been in since pre-2x. It should go without saying that if you don’t plan to import any RSS files, then you don’t need to worry about this one.

The files involved:

  • /wp-admin/import/rss.php

Changes to make:

  • Add the following code directly below line 86: $post_content = str_replace(array ('<![CDATA[', ']]>’),”,$post_content);

In case you’d like a reference, line 86 should be $post_content = $wpdb->escape($this->unhtmlentities(trim($post_content[1])));

Some Other Changes

There are a couple other changes that I make to core files that I didn’t express in detail. For completeness, I’ll list them below, but won’t provide the nuts and bolts simply because 1) it’s quite involved and a slight mistake could mean the sky falls on your head (for real) or 2) it’s a trivial change that can be accomplished with a plugin.

  • During the installation, I enjoy creating my username (admin is default), blog description, default category, and display name rather than having to update them later, so I tweak the installation to allow their customization. (This is the involved one which requires multiple file changes.)
  • And since I’m perfectly capable of choosing who to follow and take care of my blogs, the rel="nofollow" attribute being forced upon me is rather useless (at least where comments are concerned); if I don’t like a URL, I just delete it. Therefore, I completely remove all traces of the rel="nofollow" attribute. (There are plenty of plugins which give you back control of your comment link love. It’s just easier for me to nuke it completely.)

There you have it, my relatively short list of WordPress core hacks I recreate each time a new version of WordPress is released.