Disable Google Fonts - Version 1.3

Version Description

  • Released on 12th December 2016
  • Remove fonts used in Twenty Seventeen.
Download this release

Release Info

Developer dimadin
Plugin Icon wp plugin Disable Google Fonts
Version 1.3
Comparing to
See all releases

Code changes from version 1.2 to 1.3

Files changed (2) hide show
  1. disable-google-fonts.php +32 -26
  2. readme.txt +11 -6
disable-google-fonts.php CHANGED
@@ -11,11 +11,11 @@
11
 
12
  /**
13
  * Plugin Name: Disable Google Fonts
14
- * Plugin URI: http://blog.milandinic.com/wordpress/plugins/disable-google-fonts/
15
  * Description: Disable enqueuing of Open Sans and other fonts used by WordPress from Google.
16
  * Author: Milan Dinić
17
- * Author URI: http://blog.milandinic.com/
18
- * Version: 1.2
19
  * Text Domain: disable-google-fonts
20
  * Domain Path: /languages/
21
  * License: GPL
@@ -27,45 +27,28 @@ if ( ! defined( 'ABSPATH' ) ) exit;
27
  class Disable_Google_Fonts {
28
  /**
29
  * Hook actions and filters.
30
- *
31
  * @since 1.0
32
  * @access public
33
  */
34
  public function __construct() {
35
  add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 4 );
36
  add_action( 'after_setup_theme', array( $this, 'register_theme_fonts_disabler' ), 1 );
37
-
38
- // Register plugins action links filter
39
- add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 );
40
- add_filter( 'network_admin_plugin_action_links', array( $this, 'action_links' ), 10, 2 );
41
  }
42
 
43
  /**
44
  * Add action links to plugins page.
45
  *
46
  * @since 1.2
 
47
  * @access public
48
  *
49
- * @param array $links Existing plugin's action links.
50
  * @param string $plugin_file Path to the plugin file.
51
- * @return array $links New plugin's action links.
52
  */
53
  public function action_links( $links, $plugin_file ) {
54
- // Set basename
55
- $basename = plugin_basename( __FILE__ );
56
-
57
- // Check if it is for this plugin
58
- if ( $basename != $plugin_file ) {
59
- return $links;
60
- }
61
-
62
- // Load translations
63
- load_plugin_textdomain( 'disable-google-fonts', false, dirname( $basename ) . '/languages' );
64
-
65
- // Add new links
66
- $links['donate'] = '<a href="http://blog.milandinic.com/donate/">' . __( 'Donate', 'disable-google-fonts' ) . '</a>';
67
- $links['wpdev'] = '<a href="http://blog.milandinic.com/wordpress/custom-development/">' . __( 'WordPress Developer', 'disable-google-fonts' ) . '</a>';
68
- $links['premiums'] = '<strong><a href="https://shop.milandinic.com/">' . __( 'Premium WordPress Plugins', 'disable-google-fonts' ) . '</a></strong>';
69
 
70
  return $links;
71
  }
@@ -250,6 +233,26 @@ class Disable_Google_Fonts {
250
  return $translations;
251
  }
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  /**
254
  * Register filters that disable fonts for bundled themes.
255
  *
@@ -273,6 +276,9 @@ class Disable_Google_Fonts {
273
  $template = get_template();
274
 
275
  switch ( $template ) {
 
 
 
276
  case 'twentysixteen' :
277
  add_filter( 'gettext_with_context', array( $this, 'disable_merriweather' ), 888, 4 );
278
  add_filter( 'gettext_with_context', array( $this, 'disable_montserrat' ), 888, 4 );
@@ -297,4 +303,4 @@ class Disable_Google_Fonts {
297
  /* Although it would be preferred to do this on hook,
298
  * load early to make sure Open Sans is removed
299
  */
300
- $disable_google_fonts = new Disable_Google_Fonts;
11
 
12
  /**
13
  * Plugin Name: Disable Google Fonts
14
+ * Plugin URI: https://milandinic.com/wordpress/plugins/disable-google-fonts/
15
  * Description: Disable enqueuing of Open Sans and other fonts used by WordPress from Google.
16
  * Author: Milan Dinić
17
+ * Author URI: https://milandinic.com/
18
+ * Version: 1.3
19
  * Text Domain: disable-google-fonts
20
  * Domain Path: /languages/
21
  * License: GPL
27
  class Disable_Google_Fonts {
28
  /**
29
  * Hook actions and filters.
30
+ *
31
  * @since 1.0
32
  * @access public
33
  */
34
  public function __construct() {
35
  add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 4 );
36
  add_action( 'after_setup_theme', array( $this, 'register_theme_fonts_disabler' ), 1 );
 
 
 
 
37
  }
38
 
39
  /**
40
  * Add action links to plugins page.
41
  *
42
  * @since 1.2
43
+ * @deprecated 1.3
44
  * @access public
45
  *
46
+ * @param array $links Plugin's action links.
47
  * @param string $plugin_file Path to the plugin file.
48
+ * @return array $links Plugin's action links.
49
  */
50
  public function action_links( $links, $plugin_file ) {
51
+ _deprecated_function( __METHOD__, '1.3' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  return $links;
54
  }
233
  return $translations;
234
  }
235
 
236
+ /**
237
+ * Force 'off' as a result of Libre Franklin font toggler string translation.
238
+ *
239
+ * @since 1.3
240
+ * @access public
241
+ *
242
+ * @param string $translations Translated text.
243
+ * @param string $text Text to translate.
244
+ * @param string $context Context information for the translators.
245
+ * @param string $domain Text domain. Unique identifier for retrieving translated strings.
246
+ * @return string $translations Translated text.
247
+ */
248
+ public function disable_libre_franklin( $translations, $text, $context, $domain ) {
249
+ if ( 'Libre Franklin font: on or off' == $context && 'on' == $text ) {
250
+ $translations = 'off';
251
+ }
252
+
253
+ return $translations;
254
+ }
255
+
256
  /**
257
  * Register filters that disable fonts for bundled themes.
258
  *
276
  $template = get_template();
277
 
278
  switch ( $template ) {
279
+ case 'twentyseventeen' :
280
+ add_filter( 'gettext_with_context', array( $this, 'disable_libre_franklin' ), 888, 4 );
281
+ break;
282
  case 'twentysixteen' :
283
  add_filter( 'gettext_with_context', array( $this, 'disable_merriweather' ), 888, 4 );
284
  add_filter( 'gettext_with_context', array( $this, 'disable_montserrat' ), 888, 4 );
303
  /* Although it would be preferred to do this on hook,
304
  * load early to make sure Open Sans is removed
305
  */
306
+ $disable_google_fonts = new Disable_Google_Fonts;
readme.txt CHANGED
@@ -1,18 +1,19 @@
1
  === Disable Google Fonts ===
2
  Contributors: dimadin
3
- Donate link: http://blog.milandinic.com/donate/
4
  Tags: Open Sans, Google Fonts, Google Web Fonts
5
  Requires at least: 3.5
6
- Tested up to: 4.5
7
- Stable tag: 1.2
 
8
 
9
  Disable enqueuing of Open Sans and other fonts used by WordPress from Google.
10
 
11
  == Description ==
12
 
13
- [Plugin homepage](http://blog.milandinic.com/wordpress/plugins/disable-google-fonts/) | [Plugin author](http://blog.milandinic.com/) | [Donate](http://blog.milandinic.com/donate/)
14
 
15
- This plugin stops loading of Open Sans and other fonts used by WordPress and bundled themes (Twenty Twelve, Twenty Thirteen, Twenty Fourteen, Twenty Fifteen, Twenty Sixteen) from Google Fonts.
16
 
17
  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.
18
 
@@ -27,10 +28,14 @@ And it's on [GitHub](https://github.com/dimadin/disable-google-fonts).
27
 
28
  == Changelog ==
29
 
 
 
 
 
30
  = 1.2 =
31
  * Released on 9th December 2015
32
  * Remove fonts used in Twenty Sixteen.
33
 
34
  = 1.1 =
35
  * Released on 29th December 2014
36
- * Remove fonts used in Twenty Fifteen.
1
  === Disable Google Fonts ===
2
  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: 4.9.6
7
+ Requires PHP: 5.2.4
8
+ Stable tag: 1.3
9
 
10
  Disable enqueuing of Open Sans and other fonts used by WordPress from Google.
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 Open Sans and other fonts used by WordPress core or bundled themes (Twenty Twelve, Twenty Thirteen, Twenty Fourteen, Twenty Fifteen, Twenty Sixteen, Twenty Seventeen) from Google Fonts. If another theme or plugin uses fonts from Google Fonts, those fonts still might be loaded.
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
+ = 1.3 =
32
+ * Released on 12th December 2016
33
+ * Remove fonts used in Twenty Seventeen.
34
+
35
  = 1.2 =
36
  * Released on 9th December 2015
37
  * Remove fonts used in Twenty Sixteen.
38
 
39
  = 1.1 =
40
  * Released on 29th December 2014
41
+ * Remove fonts used in Twenty Fifteen.