WordPress最近加载缓慢的原因及解决方案

由于最近,ZF关闭了谷歌在国内的所有产品,包括CDN服务,字体服务在内,对于开发者来说,造成一定的困扰,如果使用了谷歌字体,和谷歌的JqueryCDN服务,打开会非常慢,直到这两者超时,由于新版的Wordpress已经内置默认使用了谷歌的Jqu http:// eryCDN,和Open Sans字体,

在WP的functions.php文件中加入过滤器来屏蔽字体以及更换成国内的CDN,

class Disable_Google_Fonts {
    public function __construct() {
        add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 666, 4 );
    }
    public function disable_open_sans( $translations, $text, $context, $domain ) {
        if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
        $translations = 'off';
       }
    return $translations;
    }
}
$disable_google_fonts = new Disable_Google_Fonts;
function add_scripts() { 
    wp_deregister_script( 'jquery' ); 
    wp_register_script( 'jquery', 'http://libs.baidu.com/jquery/1.7.1/jquery.min.js'); 
    wp_enqueue_script( 'jquery' ); 

 
add_action('wp_enqueue_scripts', 'add_scripts');

相关链接

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值