<?php 

// WordPress cleanup function
function cleanup_head() {
    
    // EditURI link
    remove_action( 'wp_head', 'rsd_link' );

    // Category feed links
    remove_action( 'wp_head', 'feed_links_extra', 3 );
    
    // Post and comment feed links
    remove_action( 'wp_head', 'feed_links', 2 );
        
    // Windows Live Writer
    remove_action( 'wp_head', 'wlwmanifest_link' );
    
    // Index link
    remove_action( 'wp_head', 'index_rel_link' );
    
    // Previous link
    remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
    
    // Start link
    remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
    
    // Canonical
    remove_action('wp_head', 'rel_canonical', 10, 0 );
    
    // Shortlink
    remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
    
    // Links for adjacent posts
    remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
    
    // WP version
    remove_action( 'wp_head', 'wp_generator' );
    
    // Remove api.w.org relation link
    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 query strings from all static resources
    function wp_cleanup_query_string( $src ){ 
      $output = preg_split("/(&ver|\?ver)/", $src);
      return $output[0]; 
    } 
    add_filter( 'script_loader_src', 'wp_cleanup_query_string', 15, 1 ); 
    add_filter( 'style_loader_src', 'wp_cleanup_query_string', 15, 1 );

    // Disable XML-RPC
    add_filter( 'xmlrpc_enabled', '__return_false' );

}


function start_cleanup() {
  // Initialize the cleanup
  add_action('init', 'cleanup_head');
} 
add_action('after_setup_theme','start_cleanup');


 


