In an effort to streamline my site’s code, I’m attempting to remove any and all elements that aren’t absolutely necessary for the majority of my audience (standards compliant visual user agents). WordPress adds some tags by default at the top of each page that I won’t need by way of the wp_head function call. The most extensible and efficient method to remove the tags was to write a plugin, which you can download and drop in your wp-content/plugins/ directory:
The wp_head function is a WordPress action hook. There are several functions defined in the wp-includes/general-template.php that are then added as WordPress actions in the wp-includes/default-filters.php file. Here’s the code in the default-filters.php file that adds them as actions:
add_action('wp_head', 'rsd_link');
add_action('wp_head', 'wlwmanifest_link');
add_action('wp_head', 'wp_generator');
So we could comment out or delete these declarations, but that might cause an issue when we upgrade the WordPress install. Instead all we have to do is remove these actions in our plugin:
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
Finally, you may be curious as to what exactly these tags are for and why WordPress includes them by default:
- The RSD link refers to a Really Simple Discovery file, an XML format developed to make it easier for some software to interact with your blog. May be important if RSD becomes more prevalent, but for the time being I am OK with removing it.
- The wlwmanifest link references a file that is needed for Windows Live Writer interaction. I don’t use Windows Live Writer.
- The wp_generator function prints a tag displaying your version of WordPress.
Creating a good development environment is obviously very important for any new development project, and with database-driven applications, it’s often a hassle to keep files and data in sync. With this in mind, I tried to come up with an efficient method of pushing a local development copy of this site to its live server.