WordPress禁止google字体的方法

Wordpress 7 浏览 1 分钟阅读

我的Wordpress之前装了Disable Google Fonts这个插件来禁止google字体,可是没有用。在后来经常可以看到“连接到font.googlexx.com”的提示信息,今天通过代码彻底解决了。代码如下:

/**
 * WordPress 后台禁用Google Open Sans字体,加速网站
 * https://www.wpdaxue.com/disable-google-fonts.html
 */
add_filter( 'gettext_with_context', 'wpdx_disable_open_sans', 888, 4 );
function wpdx_disable_open_sans( $translations, $text, $context, $domain ) {
  if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
    $translations = 'off';
  }
  return $translations;
}

0

  1. This post has no comment yet

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

相关文章