由于Googlefonts以及Gravatar头像服务在国内访问很不稳定,经常出现载入很慢的问题,严重影响了wp后台的操作,所以引用一下两段代码去除这2个默认的服务,只需把以下代码copy到主题目录下的function.php中就可以。
/********在 WordPress 中如何替换 Gravatar 头像的服务器地址*******/ function dmeng_get_https_avatar($avatar) { //~ 替换为 https 的域名 $avatar = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com"), "secure.gravatar.com", $avatar); //~ 替换为 https 协议 $avatar = str_replace("http", "https", $avatar); return $avatar; } add_filter('get_avatar', 'dmeng_get_https_avatar'); /*******替换google字体*******/ function devework_replace_open_sans() { wp_deregister_style('open-sans'); wp_register_style( 'open-sans', '//fonts.useso.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600' ); wp_enqueue_style( 'open-sans'); } add_action( 'wp_enqueue_scripts', 'devework_replace_open_sans' ); add_action('admin_enqueue_scripts', 'devework_replace_open_sans');