-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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