OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy. - Version 3.6.1

Version Description

  • Fixed bug in Auto Detect where duplicate fonts would override the earlier detected font styles. Newer styles are now appended to the list.
  • Added multiple filters and action hooks to prepare OMGF for the release of OMGF Pro.
  • Removed the code to detect incompatible themes/plugins, because an upgrade to OMGF Pro will solve all of your problems :)
    • OMGF Pro is able to detect, replace and remove all Google Fonts (incl. WebFont Loader) regardless of how they are added by the theme or plugin, incl. dns prefetch, preconnect and preload resource hint headers.
Download this release

Release Info

Developer DaanvandenBergh
Plugin Icon 128x128 OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy.
Version 3.6.1
Comparing to
See all releases

Code changes from version 3.6.0 to 3.6.1

host-webfonts-local.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: OMGF
5
  * Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
6
  * Description: Minimize DNS requests and leverage browser cache by easily saving Google Fonts to your server and removing the external Google Fonts.
7
- * Version: 3.6.0
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
4
  * Plugin Name: OMGF
5
  * Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
6
  * Description: Minimize DNS requests and leverage browser cache by easily saving Google Fonts to your server and removing the external Google Fonts.
7
+ * Version: 3.6.1
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
includes/admin/class-auto-detect.php CHANGED
@@ -54,7 +54,13 @@ class OMGF_Admin_AutoDetect
54
 
55
  $font_styles[$font['subset_font']] = $this->api->get_font_styles($font['subset_font'], implode(',', $font['selected_subsets']));
56
 
57
- $subsets[$font['subset_font']] = $font;
 
 
 
 
 
 
58
  unset($subsets[$index]);
59
  }
60
 
@@ -78,7 +84,7 @@ class OMGF_Admin_AutoDetect
78
  if (empty($subsets)) {
79
  OMGF_Admin_Notice::set_notice(__('Auto Detect completed successfully, but no Google Fonts were found.', 'host-webfonts-local'), false, 'warning');
80
 
81
- OMGF_Admin_Notice::set_notice(sprintf(__('Your theme (or plugin) might be using unconventional methods (or Web Font Loader) to load Google Fonts. For a custom integration to load your Google Fonts locally, <a href="%s" target="_blank">hire me</a> or <a href="%s" target="_blank">contact me</a> when in doubt.', 'host-webfonts-local'), 'https://woosh.dev/wordpress-services/omgf-expert-configuration/', OMGF_SITE_URL . '/contact'), false, 'info');
82
  } else {
83
  $count_fonts = count($subsets);
84
  $count_subsets = 0;
54
 
55
  $font_styles[$font['subset_font']] = $this->api->get_font_styles($font['subset_font'], implode(',', $font['selected_subsets']));
56
 
57
+ // If subset was already detected, replace styles instead of overwriting them.
58
+ if (isset($subsets[$font['subset_font']])) {
59
+ $subsets[$font['subset_font']] = array_replace_recursive($subsets[$font['subset_font']], $font);
60
+ } else {
61
+ $subsets[$font['subset_font']] = $font;
62
+ }
63
+
64
  unset($subsets[$index]);
65
  }
66
 
84
  if (empty($subsets)) {
85
  OMGF_Admin_Notice::set_notice(__('Auto Detect completed successfully, but no Google Fonts were found.', 'host-webfonts-local'), false, 'warning');
86
 
87
+ OMGF_Admin_Notice::set_notice(sprintf(__('Your theme and/or plugins are using unconventional methods (or Web Font Loader) to load Google Fonts. <strong>Upgrade to OMGF Pro</strong> (<em>starting at € 39, -</em>) to automatically detect and replace Google Fonts for your theme and plugins. <a href="%s" target="_blank">Purchase OMGF Pro</a>.', 'host-webfonts-local'), 'https://woosh.dev/wordpress-plugins/host-google-fonts-pro'), false, 'info');
88
  } else {
89
  $count_fonts = count($subsets);
90
  $count_subsets = 0;
includes/ajax/class-generate.php CHANGED
@@ -62,10 +62,10 @@ class OMGF_AJAX_Generate extends OMGF_AJAX
62
  OMGF_Admin_Notice::set_notice(__('Congratulations! Your stylesheet was generated successfully and added to your theme\'s header.', 'host-webfonts-local'), false);
63
 
64
  $count = count($selectedFonts);
65
- $review = 'https://wordpress.org/support/plugin/host-webfonts-local/reviews/?rate=5#new-post';
66
- $tweet = "https://twitter.com/intent/tweet?text=I+just+optimized+$count+Google+Fonts+with+OMGF+for+@WordPress!+Try+it+for+yourself:&via=Dan0sz&hashtags=GoogleFonts,WordPress,Pagespeed,Insights&url=https://wordpress.org/plugins/host-webfonts-local/";
67
 
68
- OMGF_Admin_Notice::set_notice(sprintf(__('OMGF has optimized %s fonts. Enjoy your performance boost! Would you be willing to <a href="%s" target="_blank">leave a review</a> or <a href="%s" target="_blank">tweet about it</a>?', 'host-webfonts-local'), $count, $review, $tweet), true, 'info');
69
  } catch (Exception $e) {
70
  OMGF_Admin_Notice::set_notice(__("Stylesheet could not be generated:", 'host-webfonts-local') . " $e", true, 'error', $e->getCode());
71
  }
62
  OMGF_Admin_Notice::set_notice(__('Congratulations! Your stylesheet was generated successfully and added to your theme\'s header.', 'host-webfonts-local'), false);
63
 
64
  $count = count($selectedFonts);
65
+ $review = apply_filters('omgf_generate_stylesheet_review_link', 'https://wordpress.org/support/plugin/host-webfonts-local/reviews/?rate=5#new-post');
66
+ $tweet = apply_filters('omgf_generate_stylesheet_tweet_link', "https://twitter.com/intent/tweet?text=I+just+optimized+$count+Google+Fonts+with+OMGF+for+@WordPress!+Try+it+for+yourself:&via=Dan0sz&hashtags=GoogleFonts,WordPress,Pagespeed,Insights&url=https://wordpress.org/plugins/host-webfonts-local/", $count);
67
 
68
+ OMGF_Admin_Notice::set_notice(sprintf(__('OMGF has optimized %s fonts. Enjoy your performance boost! Would you like to <a href="%s" target="_blank">write a review</a> or <a href="%s" target="_blank">tweet about it</a>?', 'host-webfonts-local'), $count, $review, $tweet), true, 'info');
69
  } catch (Exception $e) {
70
  OMGF_Admin_Notice::set_notice(__("Stylesheet could not be generated:", 'host-webfonts-local') . " $e", true, 'error', $e->getCode());
71
  }
includes/class-ajax.php CHANGED
@@ -18,29 +18,6 @@ defined('ABSPATH') || exit;
18
 
19
  class OMGF_AJAX
20
  {
21
- /**
22
- * A list of themes which use unconventional methods to load Google Fonts.
23
- */
24
- const OMGF_INCOMPATIBLE_THEMES = [
25
- 'thrive-theme'
26
- ];
27
-
28
- /**
29
- * A list of frameworks (plugins) for themes which use unconventional methods to load Google Fonts.
30
- */
31
- const OMGF_INCOMPATIBLE_FRAMEWORKS = [
32
- 'redux-framework' => [
33
- 'title' => 'Redux Framework',
34
- 'basename' => 'redux-framework/redux-framework.php'
35
- ]
36
- ];
37
-
38
- /** @var string $addon_url */
39
- private $addon_url = 'https://woosh.dev/wordpress-plugins/omgf-%s-compatibility/';
40
-
41
- /** @var string $addon_slug */
42
- private $addon_slug = 'omgf-%s-compatibility';
43
-
44
  /** @var OMGF_DB $db */
45
  protected $db;
46
 
@@ -110,10 +87,6 @@ class OMGF_AJAX
110
  */
111
  public function enable_auto_detect()
112
  {
113
- $this->check_theme_compatibility();
114
-
115
- $this->check_framework_compatibility();
116
-
117
  update_option(OMGF_Admin_Settings::OMGF_SETTING_AUTO_DETECTION_ENABLED, true);
118
 
119
  $url = get_permalink(get_posts()[0]->ID);
@@ -121,42 +94,6 @@ class OMGF_AJAX
121
  OMGF_Admin_Notice::set_notice(__("Auto Detect enabled. Open any page on your frontend (e.g. your <a href='$url' target='_blank'>latest post</a>). After the page is fully loaded, return here and <a href='javascript:location.reload()'>click here</a> to refresh this page.", $this->plugin_text_domain));
122
  }
123
 
124
- /**
125
- * Throw a warning if an incompatible theme is used.
126
- */
127
- private function check_theme_compatibility()
128
- {
129
- $theme = wp_get_theme();
130
- $template = $theme->get_template();
131
-
132
- $this->plugin_text_domain = 'host-webfonts-local';
133
- $compatibility_addon = sprintf($this->addon_slug, $template) . '/' . sprintf($this->addon_slug, $template) . '.php';
134
-
135
- if (in_array($template, self::OMGF_INCOMPATIBLE_THEMES) && !is_plugin_active($compatibility_addon)) {
136
- $name = $theme->get('Name');
137
- $url = sprintf($this->addon_url, $template);
138
-
139
- OMGF_Admin_Notice::set_notice(sprintf(__("Your theme, <strong>$name</strong>, uses unconventional methods to load Google Fonts. For OMGF to work properly with $name, a premium add-on <em>(starting at € 39, -)</em> is required. Click <a href='%s' target='_blank'>here</a> for more information.", $this->plugin_text_domain), $url), true, 'warning');
140
- }
141
- }
142
-
143
- /**
144
- * Throw a warning if an incompatible framework is used.
145
- */
146
- private function check_framework_compatibility()
147
- {
148
- foreach (self::OMGF_INCOMPATIBLE_FRAMEWORKS as $slug => $info) {
149
- $compatibility_addon = sprintf($this->addon_slug, $slug) . '/' . sprintf($this->addon_slug, $slug) . '.php';
150
-
151
- if (is_plugin_active($info['basename']) && !is_plugin_active($compatibility_addon)) {
152
- $name = $info['title'];
153
- $url = sprintf($this->addon_url, $slug);
154
-
155
- OMGF_Admin_Notice::set_notice(sprintf(__("Your theme's framework, <strong>$name</strong>, uses unconventional methods to load Google Fonts. For OMGF to work properly with $name, a premium add-on <em>(starting at € 39, -)</em> is required. Click <a href='%s' target='_blank'>here</a> for more information.", $this->plugin_text_domain), $url), true, 'warning');
156
- }
157
- }
158
- }
159
-
160
  /**
161
  * Return the available fonts for the selected subset(s) from the API.
162
  */
18
 
19
  class OMGF_AJAX
20
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  /** @var OMGF_DB $db */
22
  protected $db;
23
 
87
  */
88
  public function enable_auto_detect()
89
  {
 
 
 
 
90
  update_option(OMGF_Admin_Settings::OMGF_SETTING_AUTO_DETECTION_ENABLED, true);
91
 
92
  $url = get_permalink(get_posts()[0]->ID);
94
  OMGF_Admin_Notice::set_notice(__("Auto Detect enabled. Open any page on your frontend (e.g. your <a href='$url' target='_blank'>latest post</a>). After the page is fully loaded, return here and <a href='javascript:location.reload()'>click here</a> to refresh this page.", $this->plugin_text_domain));
95
  }
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  /**
98
  * Return the available fonts for the selected subset(s) from the API.
99
  */
includes/frontend/class-functions.php CHANGED
@@ -203,6 +203,10 @@ class OMGF_Frontend_Functions
203
  */
204
  public function auto_detect_fonts()
205
  {
 
 
 
 
206
  global $wp_styles;
207
 
208
  $registered = $wp_styles->registered;
203
  */
204
  public function auto_detect_fonts()
205
  {
206
+ if (apply_filters('omgf_pro_auto_detect_enabled', false)) {
207
+ return;
208
+ }
209
+
210
  global $wp_styles;
211
 
212
  $registered = $wp_styles->registered;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: DaanvandenBergh
3
  Tags: google, fonts, gdpr, cache, speed, preload, font-display, webfonts, subsets, remove, minimize, external, requests
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
- Stable tag: 3.6.0
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -61,6 +61,10 @@ This could be for several reasons:
61
  1. Have you checked if your font is available on Google Fonts?
62
  1. Is your font listed as an open source font, or is it a premium font? For obvious reasons, OMGF only has access to open source fonts.
63
 
 
 
 
 
64
  = Can I serve the fonts from my CDN? =
65
 
66
  Yes, you can. Enter the url of your CDN and re-download and re-generate the stylesheet. Then the fonts will be saved to and served from your CDN.
@@ -75,7 +79,7 @@ This must be, because you're still loading the externally hosted Google Fonts, b
75
 
76
  = I have 'Remove Google Fonts' enabled, but the fonts from fonts.gstatic.com|fonts.googleapis.com are still loaded. What's going on? =
77
 
78
- The option in OMGF removes any fonts that are loaded in the conventional way. However, if it doesn't work for you and you're using a popular theme, I'd love to help and make OMGF compatible. So don't hesitate to [contact](https://daan.dev/contact/) me.
79
 
80
  = Does this plugin edit template files? =
81
 
@@ -83,7 +87,7 @@ No, it does not. It creates a CSS Stylesheet which will be automatically added t
83
 
84
  = The stylesheet isn't loaded? What's going on? =
85
 
86
- OMGF enqueues the stylesheet into WordPress' head. If the stylesheet isn't loaded, this probably means your theme isn't implementing the wp_head() function into it's header section.
87
 
88
  = Does this plugin support Multi Site? I'm getting CORS errors! =
89
 
@@ -108,6 +112,12 @@ N/A
108
 
109
  == Changelog ==
110
 
 
 
 
 
 
 
111
  = 3.6.0 =
112
  * OMGF now supports add-ons to extend its Auto Detect and Auto Removal feature.
113
  * From now on, a notice containing a link to the required add-on will be thrown for known themes and frameworks which follow unconventional methods to include Google Fonts.
3
  Tags: google, fonts, gdpr, cache, speed, preload, font-display, webfonts, subsets, remove, minimize, external, requests
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
+ Stable tag: 3.6.1
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
61
  1. Have you checked if your font is available on Google Fonts?
62
  1. Is your font listed as an open source font, or is it a premium font? For obvious reasons, OMGF only has access to open source fonts.
63
 
64
+ = Does this plugin remove resource hints, e.g. preconnect, preload or dns-prefetch? =
65
+
66
+ No, to automatically remove resource hints pointing to fonts.googleapis.com or fonts.gstatic.com, [upgrade to OMGF Pro](https://woosh.dev/wordpress-plugins/host-google-fonts-pro/).
67
+
68
  = Can I serve the fonts from my CDN? =
69
 
70
  Yes, you can. Enter the url of your CDN and re-download and re-generate the stylesheet. Then the fonts will be saved to and served from your CDN.
79
 
80
  = I have 'Remove Google Fonts' enabled, but the fonts from fonts.gstatic.com|fonts.googleapis.com are still loaded. What's going on? =
81
 
82
+ The option in OMGF removes any fonts that are loaded in the conventional way. However, if it doesn't work for you you're theme is either using an unconventional method or WebFont Loader to add Google Fonts. [Upgrade to OMGF Pro](https://woosh.dev/wordpress-plugins/host-google-fonts-pro/) to automatically replace these fonts with a locally hosted version.
83
 
84
  = Does this plugin edit template files? =
85
 
87
 
88
  = The stylesheet isn't loaded? What's going on? =
89
 
90
+ OMGF enqueues the stylesheet into WordPress' head. If the stylesheet isn't loaded, this probably means your theme isn't implementing the wp_head() function correctly in its header section.
91
 
92
  = Does this plugin support Multi Site? I'm getting CORS errors! =
93
 
112
 
113
  == Changelog ==
114
 
115
+ = 3.6.1 =
116
+ * Fixed bug in Auto Detect where duplicate fonts would override the earlier detected font styles. Newer styles are now appended to the list.
117
+ * Added multiple filters and action hooks to prepare OMGF for the release of OMGF Pro.
118
+ * Removed the code to detect incompatible themes/plugins, because an upgrade to OMGF Pro will solve all of your problems :)
119
+ * *OMGF Pro is able to detect, replace and remove all Google Fonts (incl. WebFont Loader) regardless of how they are added by the theme or plugin, incl. dns prefetch, preconnect and preload resource hint headers.*
120
+
121
  = 3.6.0 =
122
  * OMGF now supports add-ons to extend its Auto Detect and Auto Removal feature.
123
  * From now on, a notice containing a link to the required add-on will be thrown for known themes and frameworks which follow unconventional methods to include Google Fonts.
templates/admin/block-advanced-settings.phtml CHANGED
@@ -28,13 +28,13 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
28
  <tr valign="top">
29
  <th scope="row">
30
  <label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>">
31
- <?php _e('Remove Google Fonts (experimental)', 'host-webfonts-local'); ?>
32
  </label>
33
  </th>
34
  <td>
35
  <input class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>" id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>" <?= OMGF_REMOVE_GFONTS == 'on' ? 'checked = "checked"' : ''; ?> />
36
  <p class="description">
37
- <?= sprintf(__('Enabling this option will attempt to remove any externally hosted Google Fonts-stylesheets from your WordPress-blog. If it doesn\'t work for you, your theme and/or plugin(s) are using unconventional methods (or Web Font Loader) to load Google Fonts. <a href="%s" target="_blank">Hire me</a> for a custom integration or <a href="%s" target="_blank">contact me</a> when in doubt.', 'host-webfonts-local'), 'https://woosh.dev/wordpress-services/omgf-expert-configuration/' . $utmTags, OMGF_SITE_URL . '/contact/' . $utmTags); ?>
38
  </p>
39
  </td>
40
  </tr>
@@ -52,7 +52,7 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
52
  </select>
53
  <br/>
54
  <p class="description">
55
- <?php _e('Select which font-display strategy to use. Defaults to \'Auto\'.', 'host-webfonts-local'); ?>
56
  <a target="_blank" href="https://developers.google.com/web/updates/2016/02/font-display"><?php _e('Read more', 'host-webfonts-local'); ?></a>
57
  </p>
58
  </td>
@@ -92,7 +92,7 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
92
  <td>
93
  <input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>" <?= OMGF_FORCE_SSL ? "checked ='checked'" : ''; ?> />
94
  <p class="description">
95
- <?php _e('Some plugins mess up WordPress\' URL structure, which can cause OMGF to generate incorrect URLs in the stylesheet. If OMGF is generating non-SSL (<code>http://...</code>) URLs in the stylesheet, and you have the <strong>Site</strong> and <strong>WordPress Address</strong> (in <strong>Settings</strong> > <strong>General</strong>) set to SSL (<code>https://...</code>), then enable this option.', 'host-webfonts-local'); ?>
96
  </p>
97
  </td>
98
  </tr>
28
  <tr valign="top">
29
  <th scope="row">
30
  <label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>">
31
+ <?php _e('Remove Google Fonts', 'host-webfonts-local'); ?>
32
  </label>
33
  </th>
34
  <td>
35
  <input class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>" id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>" <?= OMGF_REMOVE_GFONTS == 'on' ? 'checked = "checked"' : ''; ?> />
36
  <p class="description">
37
+ <?= sprintf(__('Remove any externally hosted Google Fonts-stylesheets from your WordPress-blog. If it doesn\'t work, your theme and/or plugin(s) are using unconventional methods or Web Font Loader to load Google Fonts. <a href="%s" target="_blank">Upgrade to OMGF Pro</a> to automatically remove Google Fonts incl. resource hints (e.g. <code>dns-prefetch</code>, <code>preconnect</code> and <code>preload</code>).', 'host-webfonts-local'), 'https://woosh.dev/wordpress-plugins/host-google-fonts-pro/' . $utmTags); ?>
38
  </p>
39
  </td>
40
  </tr>
52
  </select>
53
  <br/>
54
  <p class="description">
55
+ <?php _e('Select which font-display strategy to use. Defaults to \'Auto\'. \'Swap\' is recommended.', 'host-webfonts-local'); ?>
56
  <a target="_blank" href="https://developers.google.com/web/updates/2016/02/font-display"><?php _e('Read more', 'host-webfonts-local'); ?></a>
57
  </p>
58
  </td>
92
  <td>
93
  <input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>" <?= OMGF_FORCE_SSL ? "checked ='checked'" : ''; ?> />
94
  <p class="description">
95
+ <?php _e('Some plugins mess up WordPress\' URL structure, which can cause OMGF to generate incorrect URLs in the stylesheet. If OMGF is generating non-SSL (<code>http://...</code>) URLs in the stylesheet, and you have the <strong>Site</strong> and <strong>WordPress Address</strong> (in <strong>Settings</strong> > <strong>General</strong>) set to SSL (<code>https://</code>), then enable this option.', 'host-webfonts-local'); ?>
96
  </p>
97
  </td>
98
  </tr>