I was looking for a solution to remove the Layer Slider meta generator, I did not find much help on any of the few sites I looked at, they all share the same information that applies only to WordPress generator or popular plugins like WooCommerce .
The problem is that each plugin will have its own hook names and naming conventions, so it will be almost impossible to find or recognize them all. I think the easiest way is simple PHP with preg_replace .
Working code tested in WordPress 4.7.2 . Paste this code inside the functions.php of your theme and it should work.
//Remove All Meta Generators ini_set('output_buffering', 'on'); // turns on output_buffering function remove_meta_generators($html) { $pattern = '/<meta name(.*)=(.*)"generator"(.*)>/i'; $html = preg_replace($pattern, '', $html); return $html; } function clean_meta_generators($html) { ob_start('remove_meta_generators'); } add_action('get_header', 'clean_meta_generators', 100); add_action('wp_footer', function(){ ob_end_flush(); }, 100);
I use regex to capture meta . It covers whether they put spaces between the equal sign or not. Using ob_start to cover the entire document. Therefore, we add preg_replace from the header to the preg_replace header. See how ob_start works in the PHP manual, sometimes WordPress code states that it should use ob_start .
If you find this helpful, please add a thumbs up so that the next seeker can find a working solution covering all the meta-generators. I consider it poor security for plugin and platform developers to embed version numbers of meta generators in code. Especially with constantly emerging vulnerabilities.
I also added a plugin that does exactly that in the WordPress repository .
Remove meta generators
webbernaut
source share