wordpress不加载Google fonts的几种办法

来源:互联网 发布:js京东购物车代码 编辑:程序博客网 时间:2024/05/11 09:12

下面提供wordpress不加载Google fonts的几种办法,希望能够对站长朋友们有所帮助。

第一种方法:安装Disable Google Font插件,但经过测试之后,没有明显效果。(不推荐)

第二种方法:注释或删除掉style.css和function.php有关加载Google字体的代码fonts.googleapis.com即可。

第三种方法:将以下代码添加到主题目录下的functions.php中,小z博客亲测有效。(推荐)

如果在更改style.css或function.php文件之后,wordpress网站报错,无法打开,或者新建文章时上传图片失败。一定是将wordpress文件的编码保存为非ANSI编码,用记事本打开,保存时选择编码ANSI替换掉原来的文件即可。

class Disable_Google_Fonts {
public function __construct() {
add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 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;

不过为了安全起见小z建议在更改之前对相关文件进行备份,以免出现网站打不开的情况。(极少部分朋友出现此类情况)

文章来源:(http://www.zouxiuping.com/archives/3335) 部分内容来源于:醒妹网(http://www.xingmei.name)


From: http://www.hula8.net/article/3767.html

0 0