How to prohibit WordPress from using Google font

Recently, Google seems to be completely blocked in China. Not only the search service is completely unavailable, but also other services are affected. One of the things involved is that when using WordPress recently, the page loading is extremely slow. A simple page needs to wait for a long time. Using firebug to view it, it is found that the browser has been waiting for the embedded Google Web font (go) in the page Ogle fonts) link fonts.googleapis.com Until the timeout occurs. This shows that fonts.googleapis.com The site is blocked, too.

I once said in the article “Chinese usage of Web font (1)” that it is very difficult for Chinese to use web font, let alone the English Web font provided by Google – it is basically useless. So it’s strange why Google fonts are used in the Chinese version of WordPress.

Since it is inevitable that Google will be banned, we can only ban the use of WordPress fonts.googleapis.com This is the address. How do you remove embedded fonts.googleapis.com What about reference links?

There are two places in the WordPress system that use Google font, one is the theme, the other is the administrator interface. The Google font in the theme is easy to remove, just delete it directly, but the Google font in the administrator’s admin interface is not so easy, because we can’t modify the WordPress system file (the modified system file may be covered in the next upgrade). )

In WP includes / script- loader.php You can see the following code:

if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) {
		$subsets = 'latin,latin-ext';

		/* translators: To add an additional Open Sans character subset specific to your language,
		 * translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language.
		 */
		$subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' );

		if ( 'cyrillic' == $subset ) {
			$subsets .= ',cyrillic,cyrillic-ext';
		} elseif ( 'greek' == $subset ) {
			$subsets .= ',greek,greek-ext';
		} elseif ( 'vietnamese' == $subset ) {
			$subsets .= ',vietnamese';
		}

		// Hotlink Open Sans, for now
		$open_sans_font_url = "//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";
	}

Obviously, just set if (‘off ‘! = = 0_ X (‘on ‘,’open sans font: on or off’) {this judgment statement does not pass, that is to say, as long as the language file zh located in the WP content / Languages directory is saved_ cn.mo Just modify it.

First, open zh_ cn.po , find the line msgctxt “open sans font: on or off” in it, change msgstr “on” below it to msgstr “off”, save it, and finally delete the modified zh_ cn.po Compile to zh_ cn.mo ——You can use online compilation tools http://tools.konstruktors.com/ Or use the official tool recommended by WordPress: poedit.

The compiled zh_ cn.mo Replace the original zh_ cn.mo .

Before revision:

#. translators: If there are characters in your language that are not supported
#. * by Open Sans, translate this to 'off'. Do not translate into your own
#. language.
#: wp-includes/script-loader.php:564
msgctxt "Open Sans font: on or off"
msgid "on"
msgstr "on"
	

After modification:

#. translators: If there are characters in your language that are not supported
#. * by Open Sans, translate this to 'off'. Do not translate into your own
#. language.
#: wp-includes/script-loader.php:564
msgctxt "Open Sans font: on or off"
msgid "on"
msgstr "off"
	

If you think the method of removing Google Fonts is still complicated, you can try the WordPress plugin disable Google fonts.

Related Article
WordPress automatically intercepts part of the content of the article as a summary

In the daily release of articles, not every article may have an article summary, so the summary function of WordPress Read more

How to add user defined upload avatar function in WordPress

Friends who use WordPress to build a website should know that WordPress itself does not have the function of uploading Read more

How to get the number of articles and comments of the current logined user in WordPress

When developing WordPress Theme user center, I want to get the number of articles and comments of current logged in Read more

WordPress tips: get statistics of the number of pictures in the article

As far as I know, WordPress has no function to count the number of pictures in the article, so to Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image