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

Version Description

  • Fixed invalid preload header,
  • Fixed warning: array_keys() expects parameter 1 to be array, null given when multiple stylesheets are loaded, but preloads are only enabled for one of them.
Download this release

Release Info

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

Code changes from version 4.2.2 to 4.2.3

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.2.2
8
  * Author: Daan (from Fast FW Press)
9
  * Author URI: https://ffwp.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, leverage browser cache and speed up WordPress by saving Google Fonts to your server and removing external Google Fonts requests.
7
+ * Version: 4.2.3
8
  * Author: Daan (from Fast FW Press)
9
  * Author URI: https://ffwp.dev
10
  * License: GPL2v2 or later
includes/frontend/class-functions.php CHANGED
@@ -95,13 +95,14 @@ class OMGF_Frontend_Functions
95
 
96
  foreach ( $stylesheets as $stylesheet => $fonts ) {
97
  foreach ( $fonts as $font ) {
98
- if ( ! in_array( $font->id, array_keys( $preloaded_fonts [ $stylesheet ] ) ) ) {
 
 
99
  continue;
100
  }
101
 
102
- $font_id = $font->id;
103
- $preloads_stylesheet = $preloaded_fonts [ $stylesheet ];
104
- $preload_variants = array_filter(
105
  $font->variants,
106
  function ( $variant ) use ( $preloads_stylesheet, $font_id ) {
107
  return in_array( $variant->id, $preloads_stylesheet[ $font_id ] );
@@ -110,7 +111,7 @@ class OMGF_Frontend_Functions
110
 
111
  foreach ( $preload_variants as $variant ) {
112
  $url = $variant->woff2;
113
- echo "<link id='omgf-preload' rel='preload' href='$url' />\n";
114
  }
115
  }
116
  }
95
 
96
  foreach ( $stylesheets as $stylesheet => $fonts ) {
97
  foreach ( $fonts as $font ) {
98
+ $preloads_stylesheet = $preloaded_fonts [ $stylesheet ] ?? [];
99
+
100
+ if ( ! in_array( $font->id, array_keys( $preloads_stylesheet ) ) ) {
101
  continue;
102
  }
103
 
104
+ $font_id = $font->id;
105
+ $preload_variants = array_filter(
 
106
  $font->variants,
107
  function ( $variant ) use ( $preloads_stylesheet, $font_id ) {
108
  return in_array( $variant->id, $preloads_stylesheet[ $font_id ] );
111
 
112
  foreach ( $preload_variants as $variant ) {
113
  $url = $variant->woff2;
114
+ echo "<link id='omgf-preload' rel='preload' href='$url' as='font' type='font/woff2' crossorigin />\n";
115
  }
116
  }
117
  }
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.5
6
- Stable tag: 4.2.2
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -122,6 +122,10 @@ No, not yet. But I will definitely try to make it compatible in the future!
122
 
123
  == Changelog ==
124
 
 
 
 
 
125
  = 4.2.2 =
126
  * Small fix for themes/page builders which requests Google Fonts with protocol relative URI i.e. '//fonts.googleapis.com' instead of 'https://fonts.googleapis.com'.
127
  * Tested with Elementor. Works.
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.5
6
+ Stable tag: 4.2.3
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
122
 
123
  == Changelog ==
124
 
125
+ = 4.2.3 =
126
+ * Fixed invalid preload header,
127
+ * Fixed warning: `array_keys() expects parameter 1 to be array, null given` when multiple stylesheets are loaded, but preloads are only enabled for one of them.
128
+
129
  = 4.2.2 =
130
  * Small fix for themes/page builders which requests Google Fonts with protocol relative URI i.e. '//fonts.googleapis.com' instead of 'https://fonts.googleapis.com'.
131
  * Tested with Elementor. Works.