Created
July 5, 2013 08:29
-
-
Save issunboshi/5932951 to your computer and use it in GitHub Desktop.
Standard snippets I add to most WP projects -security, usability, cleaner code etc.
This file contains 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
//Remove specific login errors to prevent hackers knowing that they got either the password or username correct. Renable if users are facing issues. | |
add_filter('login_errors',create_function('$a', "return null;")); | |
//Remove multiple jQuery script tags and import one using the specified version | |
if( !is_admin()){ | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"), false, '1.9.1'); | |
wp_enqueue_script('jquery'); | |
} | |
// remove junk from wp_head | |
remove_action('wp_head', 'rsd_link'); | |
remove_action('wp_head', 'wp_generator'); | |
remove_action('wp_head', 'feed_links', 2); | |
remove_action('wp_head', 'index_rel_link'); | |
remove_action('wp_head', 'wlwmanifest_link'); | |
remove_action('wp_head', 'feed_links_extra', 3); | |
remove_action('wp_head', 'start_post_rel_link', 10, 0); | |
remove_action('wp_head', 'parent_post_rel_link', 10, 0); | |
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); | |
// add google analytics to header | |
function add_google_analytics() { | |
echo '<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>'; | |
echo '<script type="text/javascript">'; | |
echo 'var pageTracker = _gat._getTracker("UA-XXXXX-X");'; | |
echo 'pageTracker._trackPageview();'; | |
echo '</script>'; | |
} | |
add_action('wp_head', 'add_google_analytics'); | |
//Remove version number | |
function wpbeginner_remove_version() { | |
return ''; | |
} | |
add_filter('the_generator', 'wpbeginner_remove_version'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment