Created
May 11, 2023 14:31
-
-
Save yxod/e9d8f0f5a4a1893cd0de4fb07fd241e0 to your computer and use it in GitHub Desktop.
remove wp adds
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
//** Speed Up Wordpress **/ | |
remove_action('wp_head','wp_generator'); | |
remove_action('wp_head','wlwmanifest_link'); | |
remove_action('wp_head','wp_resource_hints', 2); | |
remove_action('wp_head','wlwmanifest_link'); | |
remove_action('wp_head','rsd_link'); | |
remove_action('wp_head','rel_canonical'); | |
remove_action('wp_head','wp_site_icon'); | |
remove_action('wp_head','wp_oembed_add_discovery_links' ); | |
remove_action('wp_head','wp_oembed_add_host_js' ); | |
remove_action('wp_head','feed_links_extra', 3 ); | |
remove_action('wp_head','feed_links', 2 ); | |
remove_action('wp_head','print_emoji_detection_script', 7 ); | |
remove_action('wp_head','rest_output_link_wp_head' ); | |
remove_action('wp_head','noindex', 1 ); | |
remove_action('wp_head','wp_shortlink_wp_head', 10, 0); | |
remove_action('wp_head','adjacent_posts_rel_link_wp_head', 10, 0 ); | |
// Disable REST API | |
add_filter( 'rest_enabled', '__return_false' ); | |
remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); | |
remove_action( 'template_redirect', 'rest_output_link_header', 11); | |
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 ); | |
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 ); | |
// Disable RSS | |
function fb_disable_feed() {wp_redirect(get_option('siteurl'));} | |
add_action('do_feed', 'fb_disable_feed', 1); | |
add_action('do_feed_rdf', 'fb_disable_feed', 1); | |
add_action('do_feed_rss', 'fb_disable_feed', 1); | |
add_action('do_feed_rss2', 'fb_disable_feed', 1); | |
add_action('do_feed_atom', 'fb_disable_feed', 1); | |
// Disable Emojii | |
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' ); | |
// Disable srcset | |
add_filter('wp_calculate_image_srcset_meta', '__return_null' ); | |
add_filter('wp_calculate_image_sizes', '__return_false', 99 ); | |
remove_filter('the_content', 'wp_make_content_images_responsive' ); | |
// Disable Gutenberg | |
add_filter( 'use_block_editor_for_post_type', '__return_false', 100 ); | |
add_action( 'admin_init', function(){ | |
remove_action( 'admin_notices', [ 'WP_Privacy_Policy_Content', 'notice' ] ); | |
add_action( 'edit_form_after_title', [ 'WP_Privacy_Policy_Content', 'notice' ] ); | |
}); | |
// Disable XML-RPC | |
add_filter('xmlrpc_enabled', '__return_false'); | |
// Disable Gutenberg Styles | |
function gut_style_disable() {wp_dequeue_style( 'wp-block-library' );} | |
add_action( 'wp_enqueue_scripts', 'gut_style_disable', 100 ); | |
// Remove JQ Migrate | |
function isa_remove_jquery_migrate( &$scripts ) { | |
if( !is_admin() ) { | |
$scripts->remove( 'jquery' ); | |
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4' ); | |
} | |
} | |
add_filter( 'wp_default_scripts', 'isa_remove_jquery_migrate' ); | |
// Remove CSS/JS Version | |
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 ); | |
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 ); | |
function remove_cssjs_ver( $src ) { | |
if( strpos($src,'?ver=')) | |
$src = remove_query_arg( 'ver', $src ); | |
return $src; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment