Last active
October 30, 2017 08:34
-
-
Save Shumaher/f46400c5d3b44a80d0065b0e7f872a2f to your computer and use it in GitHub Desktop.
Some optimizations for WordPress, see http://blog.alexz.me/wp-opengraph for more info
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 | |
function disable_emojis() { | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); | |
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); | |
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); | |
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); | |
add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 ); | |
} | |
add_action( 'init', 'disable_emojis' ); | |
function disable_emojis_tinymce( $plugins ) { | |
if ( is_array( $plugins ) ) { | |
return array_diff( $plugins, array( 'wpemoji' ) ); | |
} else { | |
return array(); | |
} | |
} | |
function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) { | |
if ( 'dns-prefetch' == $relation_type ) { | |
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' ); | |
$urls = array_diff( $urls, array( $emoji_svg_url ) ); | |
} | |
return $urls; | |
} | |
function remove_script_version( $src ){ | |
$parts = explode( '?ver=', $src ); | |
return $parts[0]; | |
} | |
add_filter('script_loader_src', 'remove_script_version', 15, 1); | |
add_filter('style_loader_src', 'remove_script_version', 15, 1); | |
function remove_wp_embed() { | |
if (!is_admin()) { | |
wp_deregister_script('wp-embed'); | |
} | |
} | |
add_action('init', 'remove_wp_embed'); | |
add_filter('rest_enabled', '__return_false'); | |
remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); | |
remove_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 ); | |
remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); | |
remove_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' ); | |
remove_action( 'auth_cookie_expired', 'rest_cookie_collect_status' ); | |
remove_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' ); | |
remove_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); | |
remove_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); | |
remove_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); | |
remove_action( 'init', 'rest_api_init' ); | |
remove_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 ); | |
remove_action( 'parse_request', 'rest_api_loaded' ); | |
remove_action( 'rest_api_init', 'wp_oembed_register_route'); | |
remove_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); | |
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); | |
remove_action( 'wp_head', 'wp_oembed_add_host_js' ); | |
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 ); | |
add_filter( 'embed_oembed_discover', '__return_false' ); | |
add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' ); | |
remove_action('rss_head', 'wp_generator'); | |
//remove_action('rss2_head', 'the_generator'); | |
//remove_action('commentsrss2_head', 'wp_generator'); | |
remove_action('atom_head', 'wp_generator'); | |
remove_action('wp_head', 'wp_generator'); | |
remove_action('wp_head', 'rsd_link'); | |
//remove_action('wp_head', 'feed_links', 2); | |
//remove_action('wp_head', 'feed_links_extra', 3 ); | |
remove_action('wp_head', 'wlwmanifest_link'); | |
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 ); | |
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); | |
/* | |
add_filter( 'xmlrpc_methods', 'sar_block_xmlrpc_attacks' ); | |
function sar_block_xmlrpc_attacks( $methods ) { | |
unset( $methods['pingback.ping'] ); | |
unset( $methods['pingback.extensions.getPingbacks'] ); | |
return $methods; | |
} | |
add_filter( 'wp_headers', 'sar_remove_x_pingback_header' ); | |
function sar_remove_x_pingback_header( $headers ) { | |
unset( $headers['X-Pingback'] ); | |
return $headers; | |
} | |
add_action('wp', function() { | |
header_remove('X-Pingback'); | |
}, 1000); | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment