最近越来越多朋友询问,为什么 WordPress 后台突然变慢了很多。究其原因,还是国内“网络长城”这道墙搞的鬼 —— 屏蔽了N多Google的IP——导致WordPress后台无法正常加载 Google Open Sans 字体。
截止本文,Google搜索仍然无法正常使用,实在郁闷!不仅仅 Google 字体,就连 Google 地图也是无法加载的(公司网站调用的谷歌地图已无法显示)。
从Wordpress3.8开始,wordpress后台界面进行了重新的设计,并且引入了Google的第三方字体Open Sans。也就是说每一个wordpress后台打开都会自动加载Google Open Sans 字体。国外估计是没有问题的。但是大陆的“墙”现在已经容不下Google的自由和分享了。这个,你懂得!
我测试了一下,禁用Google Open Sans字体后,后台加载速度明显提升好几倍!
当然,如果你想了解更多wordpress加速技巧也可以去看看下面这几个方法:
现提供两种禁用Google字体办法:
第一:非插件插入代码解决:
把下面代码插入主题中的functions.php中:
代码1:
// Remove Open Sans that WP adds from frontend if (!function_exists('remove_wp_open_sans')) : function remove_wp_open_sans() { wp_deregister_style( 'open-sans' ); wp_register_style( 'open-sans', false ); } // 前台删除Google字体CSS //add_action('wp_enqueue_scripts', 'remove_wp_open_sans'); // 后台删除Google字体CSS add_action('admin_enqueue_scripts', 'remove_wp_open_sans'); endif;
代码2
function remove_open_sans() { wp_deregister_style( 'open-sans' ); wp_register_style( 'open-sans', false ); wp_enqueue_style('open-sans',''); } add_action( 'init', 'remove_open_sans' );
2种代码选一种即可解决访问后台慢的问题了!
第二:使用插件解决:
解决方法很简单,进入后台插件页面搜索Disable Google Fonts
或者Remove Open Sans font Link from WP core
其中之一安装启用即可。
第三:使用墙内公共库加载Google字体
哎呀,不懂,最近也没有时间研究,慢就让它慢吧,无奈。。。。等有时间了再说。
在学习代码之中,感谢分享