Skip to content

Instantly share code, notes, and snippets.

@VoidMonk
Forked from leekelleher/remove-wp-meta.php
Last active September 18, 2018 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VoidMonk/f8ebd732b30fcc1c18811e5b12a6e729 to your computer and use it in GitHub Desktop.
Save VoidMonk/f8ebd732b30fcc1c18811e5b12a6e729 to your computer and use it in GitHub Desktop.
WordPress plugin to remove the auto-generated meta tags, and version from JS/CSS asset URLs (allows better caching).
<?php
/*
Plugin Name: Remove WP Meta and Version
Plugin URI: https://gist.github.com/voidmonk/f8ebd732b30fcc1c18811e5b12a6e729
Description: This plugin removes the auto-generated WP meta tags from each webpage.
Author: Lee Kelleher
Version: 0.3.0
Author URI: http://leekelleher.com/
*/
// remove the unwanted <meta> links
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wp_shortlink_wp_head');
// remove Visual Composer (WPBakery) <meta> data
function remove_visual_composer_metadata() {
if (function_exists('visual_composer') || class_exists('Vc_Manager')) {
remove_action('wp_head', array(visual_composer(), 'addMetaData'));
}
}
add_action('wp_head', 'remove_visual_composer_metadata', 1);
// remove the X-Pingback header
function remove_x_pingback($headers) {
unset($headers['X-Pingback']);
return $headers;
}
add_filter('wp_headers', 'remove_x_pingback');
// remove WordPress version number in URL parameters from JS/CSS
function hide_wordpress_version_in_asset($src) {
$src = remove_query_arg('ver', $src);
return $src;
}
add_filter('style_loader_src', 'hide_wordpress_version_in_asset');
add_filter('script_loader_src', 'hide_wordpress_version_in_asset');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment