Skip to content

Instantly share code, notes, and snippets.

@dexit
Forked from anthony9981/bloat.php
Created July 25, 2025 10:32
Show Gist options
  • Save dexit/8e46fe83dc86b2b60d96e2fe09b9d70f to your computer and use it in GitHub Desktop.
Save dexit/8e46fe83dc86b2b60d96e2fe09b9d70f to your computer and use it in GitHub Desktop.
Clear WordInstallation
<?php
/* Cleaner WP header
*===============================================================*/
function clean_header() {
// 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' );
// Remove emoji js
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
// Remove EditURI/RSD + wlwmanifest + wp version
remove_action ('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
}
add_action( 'init', 'clean_header' );
/* Remove Link rel=shortlink from http
*===============================================================*/
remove_action('template_redirect', 'wp_shortlink_header', 11);
/* Remove WordPress Version
*===============================================================*/
function remove_version_info() { return '';}
add_filter('the_generator', 'remove_version_info');
/* Remove Dashicons Frontend
*===============================================================*/
add_action('wp_enqueue_scripts', 'disable_dashicons');
function disable_dashicons() {
if(!is_user_logged_in()) {
wp_dequeue_style('dashicons');
wp_deregister_style('dashicons');
}
}
/* Heartbeat API
*===============================================================*/
function heartbeat( $settings ) {
$settings['interval'] = 120; //thay doi thoi gian chay
return $settings;
}
add_filter( 'heartbeat_settings', 'heartbeat' );
/* Disable xmlrpc_methods
*===============================================================*/
add_filter( 'xmlrpc_methods', 'block_xmlrpc_attacks' );
function block_xmlrpc_attacks( $methods ) {
unset( $methods['pingback.ping'] );
unset( $methods['pingback.extensions.getPingbacks'] );
return $methods;
}
add_filter('xmlrpc_enabled', '__return_false');
add_filter('pings_open', '__return_false', 9999);
add_filter('pre_update_option_enable_xmlrpc', '__return_false');
add_filter( 'wp_headers', 'remove_x_pingback_header' );
function remove_x_pingback_header( $headers ) {
unset($headers['X-Pingback'], $headers['x-pingback']);
return $headers;
}
/* Chuyển định dạng Widget về dạng classic
*===============================================================*/
add_filter( 'gutenberg_use_widgets_block_editor', '__return_false' );
add_filter( 'use_widgets_block_editor', '__return_false' );
/* Chuyển định dạng trình soạn thảo về dạng classic
*===============================================================*/
add_filter('use_block_editor_for_post', '__return_false', 10);
/* Tắt auto update của themes, plugins
*===============================================================*/
add_filter( 'auto_update_plugin', '__return_false' );
add_filter( 'auto_update_theme', '__return_false' );
/* Tắt Lazyload trong WP 5.5
*===============================================================*/
add_filter('wp_lazy_loading_enabled', '__return_false');
/* Tắt wp-sitemap.xml WP 5.5
*===============================================================*/
add_filter( 'wp_sitemaps_enabled', '__return_false' );
/* Disable _application_passwords
*===============================================================*/
add_filter( 'wp_is_application_passwords_available', '__return_false' );
/* /* Disable _application_passwords
*===============================================================*/
add_action( 'wp_dashboard_setup', 'remove_dashboard_widgets' );
function remove_dashboard_widgets() {
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); // WordPress.com Blog
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' ); // Plugins
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' ); // Right Now
remove_action( 'welcome_panel', 'wp_welcome_panel' ); // Welcome Panel
remove_action( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' ); // Try Gutenberg
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' ); // Quick Press widget
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' ); // Recent Drafts
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' ); // Other WordPress News
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' ); // Incoming Links
remove_meta_box( 'glsr_dashboard_widget', 'dashboard', 'normal' ); // Gravity Forms
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); // Recent Comments
remove_meta_box( 'pvc_dashboard', 'dashboard', 'normal' ); // Multi Language Plugin
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' ); // Activity
remove_meta_box( 'wpseo-wincher-dashboard-overview', 'dashboard', 'normal' ); // Security Information
remove_meta_box( 'woocommerce_dashboard_recent_reviews', 'dashboard', 'normal' ); // WooCommerce Reviews
remove_meta_box( 'wordfence_activity_report_widget', 'dashboard', 'normal' ); // Wordfence Activity
remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'normal' ); // Yoast SEO Activity
remove_meta_box( 'dashboard_site_health', 'dashboard', 'normal' ); // Site Health
remove_meta_box( 'wc_admin_dashboard_setup', 'dashboard', 'normal' ); // WooCommerce
remove_meta_box( 'e-dashboard-overview', 'dashboard', 'normal' ); // Elementor
remove_meta_box( 'wp_mail_smtp_reports_widget_lite', 'dashboard', 'normal' ); // The Events Calendar
}
/* Ẩn thông báo cập nhật WordPress Core, Themes, Plugins
*===============================================================*/
function disable_update_notifications()
{
global $wp_version;
return (object) array(
'last_checked'=> time(),
'version_checked'=> $wp_version
);
}
add_filter('pre_site_transient_update_core','disable_update_notifications');
add_filter('pre_site_transient_update_plugins','disable_update_notifications');
add_filter('pre_site_transient_update_themes','disable_update_notifications');
/* Remove ?ver=
*===============================================================*/
function wpex_remove_script_version( $src ) {
if ( strpos( $src, 'ver=' ) ) {
$src = remove_query_arg( 'ver', $src );
}
return $src;
}
add_filter( 'script_loader_src', 'wpex_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', 'wpex_remove_script_version', 15, 1 );
/* Disable RSS Feed
*===============================================================*/
function fb_disable_feed() {
wp_die( __('Website này đã tắt chức năng RSS. Vui lòng trở lại <a href="'. get_bloginfo('url') .'">Trang Chủ</a>!') );
}
// 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);
// add_action('do_feed_rss2_comments', 'fb_disable_feed', 1);
// add_action('do_feed_atom_comments', 'fb_disable_feed', 1);
/* Add prefetch dns
*===============================================================*/
function add_prefetch_dns() {
?>
<link rel="dns-prefetch" href="//fonts.googleapis.com">
<link rel="dns-prefetch" href="//www.google-analytics.com">
<link rel="dns-prefetch" href="//www.googletagmanager.com">
<link rel="dns-prefetch" href="//cdnjs.cloudflare.com">
<link rel="dns-prefetch" href="//maps.googleapis.com">
<link rel="dns-prefetch" href="//youtube.com">
<link rel="dns-prefetch" href="//connect.facebook.net">
<link rel="dns-prefetch" href="//www.facebook.com">
<link rel="dns-prefetch" href="//static.xx.fbcdn.net">
<?php
}
add_action('wp_head', 'add_prefetch_dns',100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment