Add Snippet To Project
If you’re using WordPress, you may have come across Windows Live Writer at some point. While it can be a useful tool for some, it might not be for everyone. This tool, which is integrated into your WordPress xmlrpc.php file, can sometimes clog up your website and can occasionally be a gateway for hackers. If you’re no longer finding it beneficial or if it’s causing more issues than solutions, it may be time to remove it. Read on as we guide you through the easy steps of removing Windows Live Writer from your WordPress site.
function wpturbo_remove_windows_live_writer() {
remove_action('wp_head', 'wlwmanifest_link');
}
add_action('init', 'wpturbo_remove_windows_live_writer');
The code snippet aims to remove Windows Live Writer’s link from the head of your WordPress site. To get a better understanding of this code snippet, let’s breakdown it piece by piece:
Firstly, a new function named wpturbo_remove_windows_live_writer()
is declared. This function utilizes the WordPress remove_action()
statement, which is used to remove a function from a specified action hook. WordPress uses action hooks as points of execution; actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur.
function wpturbo_remove_windows_live_writer() {
remove_action('wp_head', 'wlwmanifest_link');
}
The remove_action()
just like its name removes an action from imperative execution, here it’s being used to remove ‘wlwmanifest_link’ function hooked on ‘wp_head’ action hook.
Here, ‘wp_head’ is the action hook. This hook is called in the header section of the WordPress site—right before closing the tag. Many plugins and themes add their necessary script or meta information into ‘wp_head,’ WordPress’s core does it too. The ‘wlwmanifest_link’ function is the one adding Windows live writer’s link on this ‘wp_head’ action hook.
Windows Live Writer is a retired blog-publishing application that adds a manifest file link in the head of your WordPress site. Likely, you won’t need this if you’re not using windows live writer or publishing from windows live spaces. So, you might want to remove it.
Finally, the function wpturbo_remove_windows_live_writer()
is hooked into WordPress ‘init’ action hook using the add_action()
function. ‘Init’ is one of the earliest action hooked a typical WordPress request, hooking the function here make sure it fires as soon as WordPress finishes loading but before any headers are sent.
add_action('init', 'wpturbo_remove_windows_live_writer');
Overall, this action will execute wpturbo_remove_windows_live_writer()
in the ‘init’ phase of the WordPress flow, effectively removing the Windows Live Writer link from your site’s document head. It’s a neat and efficient block of code for reducing unnecessary meta-data from your WordPress site head.