Wordpress plugin: <head> cleanup

Note: I am not actively maintaining this plugin since I migrated away from WordPress for my main website. However, I don’t plan to get rid of it, and I think this code can still be a helpful learning resource.

This plugin removes a lot of the default markup which isn’t needed for most professional blogs from the <head> of a WordPress website. I wrote it as a quick and dirty way of making my website more efficient and secure. These are the elements that the plugin removes:

  • REST API links added by the rest_output_link_wp_head action
  • Meta generator tag with exact WordPress version added by the wp_generator action
  • Windows Live Writer metadata added by the wlwmanifest_link action
  • XML-RPC link for third-party software added by the rsd_link action
  • Shortlink added by wp_shortlink_wp_head action (you can still use shortlinks without this)
  • Adjacent post links added by adjacent_posts_rel_link_wp_head action
  • Prefetch hints added by wp_resource_hints action
  • Emoji styles and scripts

None of these are things I really need on my website (especially emojis), and some, like the WordPress version, could be harmful from a security standpoint. Feel free to grab a copy from my GitHub repository and use it however you like!

Thumbnail photo by Joe Dunckley used under CC BY-NC-SA 2.0 license. Cropped and resized slightly but otherwise unmodified.