Remove WP Header Bloat

<?php // Disable Gutenberg // disable for posts add_filter('use_block_editor_for_post', '__return_false', 10); // disable for post types add_filter('use_block_editor_for_post_type', '__return_false', 10); // remove some meta tags from WordPress remove_action('wp_head', 'wp_generator'); remove_action( 'wp_head', array( visual_composer(), 'addMetaData' ) ); function remove_dns_prefetch( $hints, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { return array_diff( wp_dependencies_unique_hosts(), $hints ); } return $hints; } remove_action ('wp_head', 'rsd_link'); remove_action( 'wp_head', 'wlwmanifest_link'); remove_action( 'wp_head', 'wp_shortlink_wp_head'); //remove json api capabilities function remove_json_api () { // Remove the REST API lines from the HTML Header remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 ); // Remove the REST API endpoint. remove_action( 'rest_api_init', 'wp_oembed_register_route' ); // Turn off oEmbed auto discovery. add_filter( 'embed_oembed_discover', '__return_false' ); // Don't filter oEmbed results. remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); // Remove oEmbed discovery links. remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); // Remove oEmbed-specific JavaScript from the front-end and back-end. remove_action( 'wp_head', 'wp_oembed_add_host_js' ); } add_action( 'after_setup_theme', 'remove_json_api' ); //completely disable json api function disable_json_api () { // Filters for WP-API version 1.x add_filter('json_enabled', '__return_false'); add_filter('json_jsonp_enabled', '__return_false'); // Filters for WP-API version 2.x add_filter('rest_enabled', '__return_false'); add_filter('rest_jsonp_enabled', '__return_false'); } add_action( 'after_setup_theme', 'disable_json_api' ); // Remove auto generated feed links function my_remove_feeds() { remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'feed_links', 2 ); } add_action( 'after_setup_theme', 'my_remove_feeds' ); add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 ); //remove emoji scripts from head remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); ?>

Posted 14/06/2019 in PHP , WordPress by Denis Tags:

Posted 14/06/2019 in PHP , WordPress by Denis

Posted 14/06/2019 in PHP , WordPress

Recommended articles