Most wordpress websites has SEO yoast plugin. On installation of SEO Yoast plugin which will add some unwanted codes to header of the website in which it was installed. Which will become a loop hole for hackers to hack the website by viewing the version of the plugin to avoid such situation we will remove it.

For removing the code you need to add the below code to functions.php file in your wordpress active theme or child theme.

add_action('get_header', 'start_ob');
add_action('wp_head', 'end_ob', 999);
function start_ob() {
ob_start('remove_yoast');
}
function end_ob() {
ob_end_flush();
}

function remove_yoast($output) {
if (defined('WPSEO_VERSION')) {
$targets = array(
'',
''
);
$output = str_ireplace($targets, '', $output);
$output = trim($output);
$output = preg_replace('/^[ \t]*[\r\n]+/m', '', $output);
}
return $output;
}

Hope this tutorial help you. If you have any doubts you can place a comment. Happy blogging.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *