你在訪問自己的站點後台的時候,你有沒有發現自己的站點圖標一直在轉圈,一直在加載的問題呢。這是因為 google fonts 的問題。從 WordPress 3.8 開始使用自動加載 Open Sans 字體,並引用 Google 上面的 CSS 樣式。 Open Sans 字體主要用於 WordPress 站點管理員登陸後頂部以及左邊功能條的字體樣式。

下面説解決方案:

方案 1:安裝插件

插件 (1):Disable Google Fonts

http://WordPress.org/plugins/disable-google-fonts/

插件 (2):Remove Open Sans font Link from WP core

http://WordPress.org/plugins/remove-open-sans-font-from-wp-core/

以上兩個插件安裝任意一款即可。

 

方案 2:在主題 functions.php 中添加代碼即可,這裏三種方法,理論都可用的。

代碼 (1):

1

2

3

4

5

6

7
//禁用 google fonts

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):

1

2

3

4

5

6

7

8

9

10

11

12
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;

代碼 (3):

1

2

3

4

5

6

7

8

9

10
// 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 );

    }

    add_action('wp_enqueue_scripts', 'remove_wp_open_sans');

    // Uncomment below to remove from admin

    // add_action('admin_enqueue_scripts', 'remove_wp_open_sans');

endif;

當你使用上面任一方案的時候,你在搜索,你會發現,已經找不到如上圖所示的 googlefonts.admincdn.com 了

2015-07-09T11:11:37+08:00發表於:2015-07-09|WordPress|