wordpress移除google字体和emoji表情

由于国内禁止访问google相关网址,导致谷歌字体严重拖慢Wordpress速度,而很多主题,特别是国外的主题,都默认加载了google字体,更要紧的是wordpress 4以后,即使登陆后台时也默认加载google字体,所以在国内使用wordpress最好禁用google字体;禁用WordPress Emoji表情,提高加载速度

下面就是移除的方法:

在主题的functions.php文件中(最好是尾部,免得与其他函数冲突或混淆)添加如下代码,如果您的主题没有这个文件,自己新建一个。

function tc_remove_open_sans_from_wp_core() {
wp_deregister_style( ‘open-sans’ );
wp_register_style( ‘open-sans’, false );
wp_enqueue_style(‘open-sans’,”);
}
add_action( ‘init’, ‘tc_remove_open_sans_from_wp_core’ );
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( ‘wpemoji’ ) );
} else {
return array();
}
}
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’ );