近期很多WordPress網(wǎng)站用戶反映,在訪問WordPress網(wǎng)站后臺(tái)的時(shí)候,加載速度變的非常的慢,尤其會(huì)出現(xiàn)WordPress后臺(tái)框架加載完畢,而字體卻仍沒有出現(xiàn)的情況。從?WordPress 3.8?開始使用自動(dòng)加載Open Sans字體,并引用Google上面的CSS樣式。Open Sans字體主要用于WordPress站點(diǎn)管理員登陸后頂部以及左邊功能條的字體樣式。
最近由于Google的一些應(yīng)用和相關(guān)地址被國內(nèi)屏蔽,所以導(dǎo)致加載相關(guān)字體和樣式會(huì)出現(xiàn)打不開或者訪問速度過慢的情況,所以會(huì)拖延站點(diǎn)的打開速度。 現(xiàn)在,我們整理了幾種禁用 Google Fonts?字體的方法,來解決后臺(tái)管理變慢的問題。

1.?Useso take over Google (國人開發(fā)更適合)
Useso take over Google 插件是國人開發(fā)的一款去除WordPress程序中Google資源引用的插件,它通過使用國內(nèi)的360前端公共庫替換Google資源調(diào)用。
Useso take over Google?插件插件會(huì)自動(dòng)把所有頁面中出現(xiàn)的對(duì)Google字體、Google公共庫的引用,換成對(duì)useso的引用,保證國內(nèi)能正常訪問資源。
Useso take over Google?插件下載:點(diǎn)擊下載
Useso take over Google?插件作者網(wǎng)站下載:點(diǎn)擊進(jìn)入
2. 安裝啟用Disable Google Fonts 或Remove Open Sans font Link from WP core
Disable Google Fonts?和?Remove Open Sans font Link from WP core?插件都可以禁用WordPress網(wǎng)站后臺(tái)的Google Fonts?字體調(diào)用。
在網(wǎng)站后臺(tái)的 插件里 搜索2個(gè)插件中的一個(gè),在線安裝啟用即可。
Disable Google Fonts 插件不需要沒有任何額外設(shè)置,安裝啟用就可以生效了。插件主要應(yīng)用于以下場合:
- 基于隱私和安全的考慮(使用Google字體,會(huì)讓Google了解你網(wǎng)站的每一次頁面瀏覽的情況)
- 本地開發(fā)或者本地產(chǎn)品(無法訪問互聯(lián)網(wǎng),或者訪問互聯(lián)網(wǎng)受限)
- 無法訪問Google服務(wù)器(有些地方屏蔽了Google的服務(wù))
- 語言不支持(Google Fonts字體僅支持少數(shù)幾種語言)
- 性能(每次頁面瀏覽都要訪問 Google 的服務(wù)器)
Disable Google Fonts WordPress插件很簡單好用。不過它僅能關(guān)閉 WordPress 控制臺(tái)(儀表盤)中的 Google Fonts,以及 WordPress 自帶幾個(gè)主題中的 Google Fonts 。
3. 添加代碼禁用
在主題中的 functions.php?文件中添加以下代碼:
//DisableGoogleFonts
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;
或者在主題中的 functions.php?文件中添加下面的代碼也可以解決:
//RemoveOpenSans
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' );
禁用了相關(guān)字體后,WordPress的網(wǎng)站后臺(tái)就恢復(fù)正常狀態(tài)了,不會(huì)因?yàn)橐虞d的字體無法顯示而導(dǎo)致后臺(tái)功能變慢的問題了。


















