Version Description
- Released on 23rd December 2018
- Change logic when disabling font via string translation filter.
- Change plugin description to better explain in which situations it works.
- Add support for WordPress 5.0, latest version of Gutenberg plugin, and most of the themes in WordPress.org Themes Repository.
Download this release
Release Info
Developer | dimadin |
Plugin | Disable Google Fonts |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.4 to 2.0
- disable-google-fonts.php +123 -6
- readme.txt +10 -4
disable-google-fonts.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* The Disable Google Fonts Plugin
|
5 |
*
|
6 |
-
* Disable enqueuing of
|
7 |
*
|
8 |
* @package Disable_Google_Fonts
|
9 |
* @subpackage Main
|
@@ -12,10 +12,10 @@
|
|
12 |
/**
|
13 |
* Plugin Name: Disable Google Fonts
|
14 |
* Plugin URI: https://milandinic.com/wordpress/plugins/disable-google-fonts/
|
15 |
-
* Description: Disable enqueuing of
|
16 |
* Author: Milan Dinić
|
17 |
* Author URI: https://milandinic.com/
|
18 |
-
* Version:
|
19 |
* Text Domain: disable-google-fonts
|
20 |
* Domain Path: /languages/
|
21 |
* License: GPL
|
@@ -32,9 +32,7 @@ class Disable_Google_Fonts {
|
|
32 |
* @access public
|
33 |
*/
|
34 |
public function __construct() {
|
35 |
-
add_filter( 'gettext_with_context', array( $this, '
|
36 |
-
add_filter( 'gettext_with_context', array( $this, 'disable_noto_serif' ), 888, 4 );
|
37 |
-
add_action( 'after_setup_theme', array( $this, 'register_theme_fonts_disabler' ), 1 );
|
38 |
}
|
39 |
|
40 |
/**
|
@@ -54,6 +52,125 @@ class Disable_Google_Fonts {
|
|
54 |
return $links;
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
/**
|
58 |
* Force 'off' as a result of Open Sans font toggler string translation.
|
59 |
*
|
3 |
/**
|
4 |
* The Disable Google Fonts Plugin
|
5 |
*
|
6 |
+
* Disable enqueuing of fonts from Google used by WordPress core, default themes, Gutenberg, and many more
|
7 |
*
|
8 |
* @package Disable_Google_Fonts
|
9 |
* @subpackage Main
|
12 |
/**
|
13 |
* Plugin Name: Disable Google Fonts
|
14 |
* Plugin URI: https://milandinic.com/wordpress/plugins/disable-google-fonts/
|
15 |
+
* Description: Disable enqueuing of fonts from Google used by WordPress core, default themes, Gutenberg, and many more.
|
16 |
* Author: Milan Dinić
|
17 |
* Author URI: https://milandinic.com/
|
18 |
+
* Version: 2.0
|
19 |
* Text Domain: disable-google-fonts
|
20 |
* Domain Path: /languages/
|
21 |
* License: GPL
|
32 |
* @access public
|
33 |
*/
|
34 |
public function __construct() {
|
35 |
+
add_filter( 'gettext_with_context', array( $this, 'disable_google_fonts' ), 888, 4 );
|
|
|
|
|
36 |
}
|
37 |
|
38 |
/**
|
52 |
return $links;
|
53 |
}
|
54 |
|
55 |
+
/**
|
56 |
+
* Force 'off' as a result of font toggler string translation.
|
57 |
+
*
|
58 |
+
* @since 2.0
|
59 |
+
* @access public
|
60 |
+
*
|
61 |
+
* @param string $translations Translated text.
|
62 |
+
* @param string $text Text to translate.
|
63 |
+
* @param string $context Context information for the translators.
|
64 |
+
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
|
65 |
+
* @return string $translations Translated text.
|
66 |
+
*/
|
67 |
+
public function disable_google_fonts( $translations, $text, $context, $domain ) {
|
68 |
+
switch ( $text ) {
|
69 |
+
case 'on':
|
70 |
+
// Pass for most cases.
|
71 |
+
if ( $this->is_ending_with_font_toggler( $context ) || in_array( $context, $this->get_font_toggler_variants() ) ) {
|
72 |
+
$translations = 'off';
|
73 |
+
}
|
74 |
+
break;
|
75 |
+
case 'Noto Serif:400,400i,700,700i':
|
76 |
+
if ( 'Google Font Name and Variants' === $context ) {
|
77 |
+
$translations = 'off';
|
78 |
+
}
|
79 |
+
break;
|
80 |
+
}
|
81 |
+
|
82 |
+
return $translations;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Check if text is ending with variation of 'font(s):( )on or off'.
|
87 |
+
*
|
88 |
+
* For most strings that are used as font togglers, context is ending
|
89 |
+
* with this text. This method checks if that is the case.
|
90 |
+
*
|
91 |
+
* @since 2.0
|
92 |
+
* @access public
|
93 |
+
*
|
94 |
+
* @param string $text Text to check.
|
95 |
+
* @return bool Whether text is ending with phrase or not.
|
96 |
+
*/
|
97 |
+
public function is_ending_with_font_toggler( $text ) {
|
98 |
+
if ( preg_match( '/font[s]?:\s?on or off$/i', $text ) ) {
|
99 |
+
return true;
|
100 |
+
} else {
|
101 |
+
return false;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Get context variants that cannot be detected with string font toggler checker.
|
107 |
+
*
|
108 |
+
* @since 2.0
|
109 |
+
*
|
110 |
+
* @return array
|
111 |
+
*/
|
112 |
+
public function get_font_toggler_variants() {
|
113 |
+
return array(
|
114 |
+
'arimo:on or off',
|
115 |
+
'Assistant:on or off',
|
116 |
+
'Atma: on or off',
|
117 |
+
'Crimson Text: on or off',
|
118 |
+
'Dancing Script: on or off',
|
119 |
+
'Droid sans: on or off',
|
120 |
+
'Google font: on',
|
121 |
+
'Google Font for body text: on or off',
|
122 |
+
'Google Font for heading text: on or off',
|
123 |
+
'Google Font for menu text: on or off',
|
124 |
+
'Google fonts: "on" or "off"',
|
125 |
+
'Great Vibes:on or off',
|
126 |
+
'greatvibes:on or off',
|
127 |
+
'Hind: on or off',
|
128 |
+
'Indie Flower: on or off',
|
129 |
+
'Josefin Sans: on or off',
|
130 |
+
'Lato: on or off',
|
131 |
+
'Lato:on or off',
|
132 |
+
'Lato : on or off',
|
133 |
+
'Lobster:on or off',
|
134 |
+
'Lora: on or off',
|
135 |
+
'Merriweather: on or off',
|
136 |
+
'Merriweather:on or off',
|
137 |
+
'montserrat:on or off',
|
138 |
+
'Muli: on or off',
|
139 |
+
'Nunito Sans: on or off',
|
140 |
+
'Open Sans',
|
141 |
+
'Open Sans:on or off',
|
142 |
+
'Open Sans: on or off',
|
143 |
+
'opensans:on or off',
|
144 |
+
'Open Sans : on or off',
|
145 |
+
'Oswald:on or off',
|
146 |
+
'oswald:on or off',
|
147 |
+
'Oxygen: on or off',
|
148 |
+
'Pacifico: on or off',
|
149 |
+
'Pacifico:on or off',
|
150 |
+
'pacifico:on or off',
|
151 |
+
'Poppins: on or off',
|
152 |
+
'playball:on or off',
|
153 |
+
'Playfair Display: on or off',
|
154 |
+
'Product Sans: on or off',
|
155 |
+
'pt_sans:on or off',
|
156 |
+
'Raleway: on or off',
|
157 |
+
'Roboto',
|
158 |
+
'Roboto: on or off',
|
159 |
+
'roboto:on or off',
|
160 |
+
'Roboto:on or off',
|
161 |
+
'Roboto : on or off',
|
162 |
+
'Roboto Condensed',
|
163 |
+
'Roboto Condensed:on or off',
|
164 |
+
'roboto_condensed:on or off',
|
165 |
+
'robotocondensed:on or off',
|
166 |
+
'Roboto Slab:on or off',
|
167 |
+
'Sail:on or off',
|
168 |
+
'Scada:on or off',
|
169 |
+
'scada:on or off',
|
170 |
+
'Shadows Into Light: on or off',
|
171 |
+
);
|
172 |
+
}
|
173 |
+
|
174 |
/**
|
175 |
* Force 'off' as a result of Open Sans font toggler string translation.
|
176 |
*
|
readme.txt
CHANGED
@@ -3,17 +3,17 @@ Contributors: dimadin
|
|
3 |
Donate link: https://milandinic.com/donate/
|
4 |
Tags: Open Sans, Google Fonts, Google Web Fonts
|
5 |
Requires at least: 3.5
|
6 |
-
Tested up to:
|
7 |
Requires PHP: 5.2.4
|
8 |
-
Stable tag:
|
9 |
|
10 |
-
Disable enqueuing of
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
[Plugin homepage](https://milandinic.com/wordpress/plugins/disable-google-fonts/) | [Plugin author](https://milandinic.com/) | [Donate](https://milandinic.com/donate/)
|
15 |
|
16 |
-
This plugin stops loading of
|
17 |
|
18 |
Reasons for not using Google Fonts might be privacy and security, local development or production, blocking of Google's servers, characters not supported by font, performance.
|
19 |
|
@@ -28,6 +28,12 @@ And it's on [GitHub](https://github.com/dimadin/disable-google-fonts).
|
|
28 |
|
29 |
== Changelog ==
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
= 1.4 =
|
32 |
* Released on 28th September 2018
|
33 |
* Remove fonts used in Gutenberg.
|
3 |
Donate link: https://milandinic.com/donate/
|
4 |
Tags: Open Sans, Google Fonts, Google Web Fonts
|
5 |
Requires at least: 3.5
|
6 |
+
Tested up to: 5.0.2
|
7 |
Requires PHP: 5.2.4
|
8 |
+
Stable tag: 2.0
|
9 |
|
10 |
+
Disable enqueuing of fonts from Google used by WordPress core, default themes, Gutenberg, and many more.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
[Plugin homepage](https://milandinic.com/wordpress/plugins/disable-google-fonts/) | [Plugin author](https://milandinic.com/) | [Donate](https://milandinic.com/donate/)
|
15 |
|
16 |
+
This plugin stops loading of fonts from Google Fonts used by WordPress core, Gutenberg plugin, bundled themes (Twenty Twelve, Twenty Thirteen, Twenty Fourteen, Twenty Fifteen, Twenty Sixteen, Twenty Seventeen), and most other themes. If theme or plugin (whose name is not listed here) uses fonts from Google Fonts, those fonts still might be loaded if that theme or plugin loads fonts from Google in a way that is incompatible with this plugin.
|
17 |
|
18 |
Reasons for not using Google Fonts might be privacy and security, local development or production, blocking of Google's servers, characters not supported by font, performance.
|
19 |
|
28 |
|
29 |
== Changelog ==
|
30 |
|
31 |
+
= 2.0 =
|
32 |
+
* Released on 23rd December 2018
|
33 |
+
* Change logic when disabling font via string translation filter.
|
34 |
+
* Change plugin description to better explain in which situations it works.
|
35 |
+
* Add support for WordPress 5.0, latest version of Gutenberg plugin, and most of the themes in WordPress.org Themes Repository.
|
36 |
+
|
37 |
= 1.4 =
|
38 |
* Released on 28th September 2018
|
39 |
* Remove fonts used in Gutenberg.
|