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

Version Description

| August 16th, 2021

Download this release

Release Info

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

Code changes from version 4.5.1 to 4.5.2

assets/js/omgf-admin.js CHANGED
@@ -19,7 +19,7 @@ jQuery(document).ready(function ($) {
19
  ticker_index: 0,
20
  empty_cache_directory_xhr: false,
21
  optimize_xhr: false,
22
- cache_prefix: '-ul-',
23
  cache_section: $('.omgf-empty').data('cache-section'),
24
 
25
  /**
@@ -139,9 +139,8 @@ jQuery(document).ready(function ($) {
139
  * Generate a unique cache key if some of this stylesheet's fonts are unloaded.
140
  */
141
  if (cache_key_index !== -1) {
142
- var current_cache_key = cache_keys[cache_key_index];
143
-
144
- var cache_key = omgf_admin.cache_prefix + Math.random().toString(36).substring(2, 7);
145
 
146
  if (current_cache_key.indexOf(omgf_admin.cache_prefix) !== -1) {
147
  var parts = current_cache_key.split(omgf_admin.cache_prefix),
@@ -282,12 +281,4 @@ jQuery(document).ready(function ($) {
282
  };
283
 
284
  omgf_admin.init();
285
-
286
- $('#omgf_relative_url').click(function () {
287
- if (this.checked === true) {
288
- $('#omgf_cdn_url').prop('disabled', true);
289
- } else {
290
- $('#omgf_cdn_url').prop('disabled', false);
291
- }
292
- });
293
  });
19
  ticker_index: 0,
20
  empty_cache_directory_xhr: false,
21
  optimize_xhr: false,
22
+ cache_prefix: '-mod-',
23
  cache_section: $('.omgf-empty').data('cache-section'),
24
 
25
  /**
139
  * Generate a unique cache key if some of this stylesheet's fonts are unloaded.
140
  */
141
  if (cache_key_index !== -1) {
142
+ var current_cache_key = cache_keys[cache_key_index],
143
+ cache_key = omgf_admin.cache_prefix + Math.random().toString(36).substring(2, 7);
 
144
 
145
  if (current_cache_key.indexOf(omgf_admin.cache_prefix) !== -1) {
146
  var parts = current_cache_key.split(omgf_admin.cache_prefix),
281
  };
282
 
283
  omgf_admin.init();
 
 
 
 
 
 
 
 
284
  });
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, leverage browser cache and speed up WordPress by saving Google Fonts to your server and removing external Google Fonts requests.
7
- * Version: 4.5.1
8
  * Author: Daan from FFW.Press
9
  * Author URI: https://ffw.press
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, leverage browser cache and speed up WordPress by saving Google Fonts to your server and removing external Google Fonts requests.
7
+ * Version: 4.5.2
8
  * Author: Daan from FFW.Press
9
  * Author URI: https://ffw.press
10
  * License: GPL2v2 or later
includes/admin/class-settings.php CHANGED
@@ -90,23 +90,23 @@ class OMGF_Admin_Settings extends OMGF_Admin
90
  'vietnamese' => 'Vietnamese'
91
  ];
92
  const OMGF_FALLBACK_FONT_STACKS_OPTIONS = [
93
- 'arial' => 'Arial',
94
- 'baskerville' => 'Baskerville',
95
- 'bodoni-mt' => 'Bodoni MT',
96
- 'calibri' => 'Calibri',
97
- 'calisto-mt' => 'Calisto MT',
98
- 'cambria' => 'Cambria',
99
- 'candara' => 'Candara',
100
- 'century-gothic' => 'Century Gothic',
101
- 'consolas' => 'Consolas',
102
- 'copperplate' => 'Copperplate Gothic',
103
- 'courier-new' => 'Courier New',
104
- 'dejavu-sans' => 'Dejavu Sans',
105
- 'didot' => 'Didot',
106
- 'franklin-gothic' => 'Franklin Gothic',
107
- 'garamond' => 'Garamond',
108
- 'georgia' => 'Georgia',
109
- 'gill-sans' => 'Gill Sans',
110
  'goudy-old-style' => 'Goudy Old Style',
111
  'helvetica' => 'Helvetica',
112
  'impact' => 'Impact',
90
  'vietnamese' => 'Vietnamese'
91
  ];
92
  const OMGF_FALLBACK_FONT_STACKS_OPTIONS = [
93
+ 'arial' => 'Arial',
94
+ 'baskerville' => 'Baskerville',
95
+ 'bodoni-mt' => 'Bodoni MT',
96
+ 'calibri' => 'Calibri',
97
+ 'calisto-mt' => 'Calisto MT',
98
+ 'cambria' => 'Cambria',
99
+ 'candara' => 'Candara',
100
+ 'century-gothic' => 'Century Gothic',
101
+ 'consolas' => 'Consolas',
102
+ 'copperplate-gothic' => 'Copperplate Gothic',
103
+ 'courier-new' => 'Courier New',
104
+ 'dejavu-sans' => 'Dejavu Sans',
105
+ 'didot' => 'Didot',
106
+ 'franklin-gothic' => 'Franklin Gothic',
107
+ 'garamond' => 'Garamond',
108
+ 'georgia' => 'Georgia',
109
+ 'gill-sans' => 'Gill Sans',
110
  'goudy-old-style' => 'Goudy Old Style',
111
  'helvetica' => 'Helvetica',
112
  'impact' => 'Impact',
includes/admin/settings/class-detection.php CHANGED
@@ -100,6 +100,10 @@ class OMGF_Admin_Settings_Detection extends OMGF_Admin_Settings_Builder
100
  'label' => __('Process Stylesheet Imports', $this->plugin_text_domain),
101
  'description' => __('Scan stylesheets loaded by your theme and plugins for <code>@import</code> statements loading Google Fonts and process them.', $this->plugin_text_domain)
102
  ],
 
 
 
 
103
  'omgf_pro_process_inline_styles' => [
104
  'label' => __('Process Inline Styles', $this->plugin_text_domain),
105
  'description' => __('Process all inline <code>@font-face</code> and <code>@import</code> rules loading Google Fonts.', $this->plugin_text_domain)
100
  'label' => __('Process Stylesheet Imports', $this->plugin_text_domain),
101
  'description' => __('Scan stylesheets loaded by your theme and plugins for <code>@import</code> statements loading Google Fonts and process them.', $this->plugin_text_domain)
102
  ],
103
+ 'omgf_pro_process_stylesheet_font_faces' => [
104
+ 'label' => __('Process Stylesheet Font Faces', $this->plugin_text_domain),
105
+ 'description' => __('Scan stylesheets loaded by your theme and plugins for <code>@font-face</code> statements loading Google Fonts and process them.', $this->plugin_text_domain)
106
+ ],
107
  'omgf_pro_process_inline_styles' => [
108
  'label' => __('Process Inline Styles', $this->plugin_text_domain),
109
  'description' => __('Process all inline <code>@font-face</code> and <code>@import</code> rules loading Google Fonts.', $this->plugin_text_domain)
includes/api/class-download.php CHANGED
@@ -117,25 +117,25 @@ class OMGF_API_Download extends WP_REST_Controller
117
  $fonts_request = $this->build_fonts_request($font_families, $font);
118
 
119
  if (strpos($fonts_request, ':') != false) {
120
- list($family, $variants) = explode(':', $fonts_request);
121
  } else {
122
  $family = $fonts_request;
123
- $variants = '';
124
  }
125
 
126
- $variants = $this->parse_requested_variants($variants, $font);
127
 
128
  if ($unloaded_fonts = omgf_init()::unloaded_fonts()) {
129
  $font_id = $font->id;
130
 
131
- // Now we're sure we got 'em all. We can safely unload those we don't want.
132
  if (isset($unloaded_fonts[$original_handle][$font_id])) {
133
- $variants = $this->dequeue_unloaded_variants($variants, $unloaded_fonts[$original_handle], $font->id);
134
- $fonts_request = $family . ':' . implode(',', $variants);
135
  }
136
  }
137
 
138
- $font->variants = $this->filter_variants($font->id, $font->variants, $fonts_request, $original_handle);
139
  }
140
 
141
  /**
@@ -164,18 +164,18 @@ class OMGF_API_Download extends WP_REST_Controller
164
 
165
  file_put_contents($local_file, $stylesheet);
166
 
167
- $current_font = [$original_handle => $fonts];
168
- $optimized_fonts = omgf_init()::optimized_fonts();
169
 
170
  // At first run, simply override the optimized_fonts array.
171
  if (empty($optimized_fonts)) {
172
- $optimized_fonts = $current_font;
173
  // When a new font is detected, add it to the list.
174
  } elseif (!isset($optimized_fonts[$original_handle])) {
175
- $optimized_fonts = $optimized_fonts + $current_font;
176
  // Unload is probably used. Let's rewrite the variants still in use.
177
  } else {
178
- $optimized_fonts = $this->rewrite_variants($optimized_fonts, $current_font);
179
  }
180
 
181
  update_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS, $optimized_fonts);
@@ -397,7 +397,7 @@ class OMGF_API_Download extends WP_REST_Controller
397
  * @param mixed $stylesheet_handle
398
  * @return mixed
399
  */
400
- private function filter_variants($font_id, $available, $wanted, $stylesheet_handle)
401
  {
402
  if (strpos($wanted, ':') !== false) {
403
  // We don't need the first variable.
117
  $fonts_request = $this->build_fonts_request($font_families, $font);
118
 
119
  if (strpos($fonts_request, ':') != false) {
120
+ list($family, $requested_variants) = explode(':', $fonts_request);
121
  } else {
122
  $family = $fonts_request;
123
+ $requested_variants = '';
124
  }
125
 
126
+ $requested_variants = $this->parse_requested_variants($requested_variants, $font);
127
 
128
  if ($unloaded_fonts = omgf_init()::unloaded_fonts()) {
129
  $font_id = $font->id;
130
 
131
+ // Now we're sure we got 'em all. We can safely dequeue those we don't want.
132
  if (isset($unloaded_fonts[$original_handle][$font_id])) {
133
+ $requested_variants = $this->dequeue_unloaded_variants($requested_variants, $unloaded_fonts[$original_handle], $font->id);
134
+ $fonts_request = $family . ':' . implode(',', $requested_variants);
135
  }
136
  }
137
 
138
+ $font->variants = $this->process_unload_queue($font->id, $font->variants, $fonts_request, $original_handle);
139
  }
140
 
141
  /**
164
 
165
  file_put_contents($local_file, $stylesheet);
166
 
167
+ $current_fonts = [$original_handle => $fonts];
168
+ $optimized_fonts = OMGF::optimized_fonts();
169
 
170
  // At first run, simply override the optimized_fonts array.
171
  if (empty($optimized_fonts)) {
172
+ $optimized_fonts = $current_fonts;
173
  // When a new font is detected, add it to the list.
174
  } elseif (!isset($optimized_fonts[$original_handle])) {
175
+ $optimized_fonts = $optimized_fonts + $current_fonts;
176
  // Unload is probably used. Let's rewrite the variants still in use.
177
  } else {
178
+ $optimized_fonts = $this->rewrite_variants($optimized_fonts, $current_fonts);
179
  }
180
 
181
  update_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS, $optimized_fonts);
397
  * @param mixed $stylesheet_handle
398
  * @return mixed
399
  */
400
+ private function process_unload_queue($font_id, $available, $wanted, $stylesheet_handle)
401
  {
402
  if (strpos($wanted, ':') !== false) {
403
  // We don't need the first variable.
includes/class-admin.php CHANGED
@@ -203,7 +203,7 @@ class OMGF_Admin
203
  $wp_settings_errors = [];
204
  }
205
 
206
- add_settings_error('general', 'omgf_settings_changed', __('Settings changed. <a href="#" class="omgf-empty">Click here</a> to empty OMGF\'s cache.', $this->plugin_text_domain), 'success');
207
  }
208
 
209
  return $value;
203
  $wp_settings_errors = [];
204
  }
205
 
206
+ add_settings_error('general', 'omgf_settings_changed', __('Settings changed. <a href="#" data-cache-section="/*" class="omgf-empty">Click here</a> to empty OMGF\'s cache.', $this->plugin_text_domain), 'success');
207
  }
208
 
209
  return $value;
includes/frontend/class-functions.php CHANGED
@@ -65,20 +65,19 @@ class OMGF_Frontend_Functions
65
  */
66
  public function add_preloads()
67
  {
68
- $preloaded_fonts = apply_filters('omgf_frontend_preloaded_fonts', omgf_init()::preloaded_fonts());
69
 
70
  if (!$preloaded_fonts) {
71
  return;
72
  }
73
 
74
- $optimized_fonts = apply_filters('omgf_frontend_optimized_fonts', omgf_init()::optimized_fonts());
75
 
76
  /**
77
  * When OMGF Pro is enabled and set to Automatic mode, the merged handle is used to only load selected
78
  * preloads for the currently used stylesheet.
79
  */
80
- $id = get_queried_object_id();
81
- $pro_handle = apply_filters('omgf_pro_merged_handle', '', $id);
82
 
83
  $i = 0;
84
 
65
  */
66
  public function add_preloads()
67
  {
68
+ $preloaded_fonts = apply_filters('omgf_frontend_preloaded_fonts', OMGF::preloaded_fonts());
69
 
70
  if (!$preloaded_fonts) {
71
  return;
72
  }
73
 
74
+ $optimized_fonts = apply_filters('omgf_frontend_optimized_fonts', OMGF::optimized_fonts());
75
 
76
  /**
77
  * When OMGF Pro is enabled and set to Automatic mode, the merged handle is used to only load selected
78
  * preloads for the currently used stylesheet.
79
  */
80
+ $pro_handle = apply_filters('omgf_pro_merged_handle', '');
 
81
 
82
  $i = 0;
83
 
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.8
6
- Stable tag: 4.5.1
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -45,7 +45,7 @@ Everything in the free version, plus:
45
 
46
  - Specify a Fallback Font Stack for every Google Font, to reduce Cumulative Layout Shift,
47
  - Automatically remove/replace all Google Fonts throughout the entire document/page,
48
- - Also supports WebFont Loader (webfont.js), Early Access Google Fonts and requests in stylesheets using @import (@font-face coming soon...).
49
  - Automatically generate different stylesheets for pages with another configuration of Google Fonts.
50
  - Combine all Google Fonts stylesheets (requested by your theme and/or plugins) into one file,
51
  - Deduplicate Google Fonts stylesheets,
@@ -132,6 +132,10 @@ No, not yet. But I will definitely try to make it compatible in the future!
132
 
133
  == Changelog ==
134
 
 
 
 
 
135
  = 4.5.1 | August 2nd, 2021 =
136
  * Enhancement: Added post update notice to inform user of the plugin's database changes. The current notice you were viewed was simply, because the current DB version wasn't logged yet on your system. So if you're reading this: Ha! Made you look! ;)
137
  * Pro Feature: Added promo material for Fallback Font Stack (Pro) feature.
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.8
6
+ Stable tag: 4.5.2
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
45
 
46
  - Specify a Fallback Font Stack for every Google Font, to reduce Cumulative Layout Shift,
47
  - Automatically remove/replace all Google Fonts throughout the entire document/page,
48
+ - Also supports WebFont Loader (webfont.js), Early Access Google Fonts and requests in stylesheets using @import and @font-face statements.
49
  - Automatically generate different stylesheets for pages with another configuration of Google Fonts.
50
  - Combine all Google Fonts stylesheets (requested by your theme and/or plugins) into one file,
51
  - Deduplicate Google Fonts stylesheets,
132
 
133
  == Changelog ==
134
 
135
+ = 4.5.2 | August 16th, 2021 =
136
+ * Pro Feature: Added promo material for @font-face detection in local stylesheets.
137
+ * Fix: Fixed several warnings and notices.
138
+
139
  = 4.5.1 | August 2nd, 2021 =
140
  * Enhancement: Added post update notice to inform user of the plugin's database changes. The current notice you were viewed was simply, because the current DB version wasn't logged yet on your system. So if you're reading this: Ha! Made you look! ;)
141
  * Pro Feature: Added promo material for Fallback Font Stack (Pro) feature.