你现在是否被WordPress主题缓慢的加载速度而差点劝退?如果你正在忍受,不妨跟我学几个简单的WordPress主题提速小技巧,复制粘贴即可提升网站100%的速度!为你节省近2000元的网站速度优化费用。
准备开始第一步
优化步骤:
登录后台 – [ 外观 ] – [主题编辑器] 找到 functions.php,
复制你需要的功能到文件内保存即可,如下图
一.关闭emoji表情
/**
* 关闭emoji表情
*/
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_action('init', 'disable_emojis');
function disable_emojis_tinymce($plugins){
if (is_array($plugins)) {
return array_diff($plugins, array(
'wpemoji'
));
} else {
return array();
}
}
二、WordPress 自动更新和后台更新检查\
/**
* 彻底关闭 WordPress 自动更新和后台更新检查
*/
// 彻底关闭自动更新
add_filter('automatic_updater_disabled', '__return_true');
// 关闭更新检查定时作业
remove_action('init', 'wp_schedule_update_checks');
// 移除已有的版本检查定时作业
wp_clear_scheduled_hook('wp_version_check');
// 移除已有的插件更新定时作业
wp_clear_scheduled_hook('wp_update_plugins');
// 移除已有的主题更新定时作业
wp_clear_scheduled_hook('wp_update_themes');
// 移除已有的自动更新定时作业
wp_clear_scheduled_hook('wp_maybe_auto_update');
// 移除后台内核更新检查
remove_action( 'admin_init', '_maybe_update_core' );
// 移除后台插件更新检查
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-update.php', 'wp_update_plugins' );
remove_action( 'load-update-core.php', 'wp_update_plugins' );
remove_action( 'admin_init', '_maybe_update_plugins' );
// 移除后台主题更新检查
remove_action( 'load-themes.php', 'wp_update_themes' );
remove_action(