wp_head() Clean & Optimize & Secure WordPress

edit /wp-content/themes/namexyz/functions.php
// disable post revisions
define('WP_POST_REVISIONS', 0);

// removes the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'rsd_link' );

// removes the link to the Windows Live Writer manifest file.
remove_action( 'wp_head', 'wlwmanifest_link' );

// remove WP version on the XHTML generator that is generated on the wp_head hook
remove_action( 'wp_head', 'wp_generator' ); //only web
add_filter( 'the_generator', '__return_false' ); //all switch($type){ (wp-includes/general-template.php)

// remove admin bar
add_filter( 'show_admin_bar', '__return_false' );

// removes all extra rss comment feed links(%postname%/comment/feed/)
add_filter( 'feed_links_show_comments_feed', '__return_false' );

// removes the links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'feed_links', 2 );

// removes all extra rss feed links(%postname%/feed/)
remove_action( 'wp_head', 'feed_links_extra', 3 );

// remove emoji js & css
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

// remove link
remove_action( 'wp_head', 'wp_shortlink_wp_head' ); //short link (domain.ltd/?p=$post-id)
remove_action( 'wp_head', 'index_rel_link' ); // index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link' ); // Display relational links for the posts adjacent to the current post.

// Remove WP Version From Styles
add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999 );
// Remove WP Version From Scripts
add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999 );
// Function to remove version numbers
function sdt_remove_ver_css_js( $src ) {
// if ( strpos( $src, 'ver='. get_bloginfo( 'version' ) ) ) // Remove only the "ver" parameter which have WordPress version
if ( strpos( $src, 'ver=' ) ) // Remove the "ver" parameter from all enqueued CSS and JS files
$src = remove_query_arg( 'ver', $src );
return $src;
}

// move script form wp_head() to wp_footer()
remove_action('wp_head', 'wp_enqueue_scripts', 1); // remove all .css & .js from wp_head()
add_action('wp_footer', 'wp_enqueue_scripts', 5); // add all .css & .js to wp_footer()

// Disable REST API link tag
remove_action('wp_head', 'rest_output_link_wp_head', 10);

// Disable oEmbed Discovery Links
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);

// Disable REST API link in HTTP headers
remove_action('template_redirect', 'rest_output_link_header', 11, 0);


define('WP_POST_REVISIONS', 0);
remove_action('wp_head', 'wp_enqueue_scripts', 1);
add_action('wp_footer', 'wp_enqueue_scripts', 5);
remove_action('wp_head', 'rest_output_link_wp_head', 10);
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
add_filter('the_generator', '__return_false');
add_filter('show_admin_bar', '__return_false');
add_filter('feed_links_show_comments_feed', '__return_false');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
add_filter('style_loader_src', 'sdt_remove_ver_css_js', 9999);
add_filter('script_loader_src', 'sdt_remove_ver_css_js', 9999);
function sdt_remove_ver_css_js( $src ) {
if (strpos($src, 'ver=')) // Remove the "ver" parameter from all enqueued CSS and JS files
$src = remove_query_arg('ver', $src);
return $src;
}

Blog |
» Line it!

#Subscribe \ newsletter.

รับข้อมูลข่าวสารก่อนใคร กรอก email ได้เลย ไม่พลาดทุกบทความดีๆ จากเรา
เหมือนโพสนี้ "wp_head() Clean & Optimize & Secure WordPress"

Delivered by FeedBurner(Google)
 Subscribe taxze.com
*รบกวนยืนยันรับข่าวสารที่อีเมล์อีกรอบด้วยนะครับ **ไม่มีการแสปมใดๆ ทั้งสิ้น และคุณสามารถยกเลิกรับข่าวสารได้ตลอดเวลา +1