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

Version Description

| December 14th, 2022 = * Fixed: ArgumentCountError: array_intersect() expects at least 1 argument, 0 given. * Improved: don't show "optimization success" message if Auto-configure Subsets needs to run again.

Download this release

Release Info

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

Code changes from version 5.5.0 to 5.5.1

host-webfonts-local.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: OMGF
5
  * Plugin URI: https://daan.dev/wordpress/omgf/
6
  * Description: Increase GDPR/DSGVO compliance, reduce DNS requests and leverage browser cache by automatically downloading Google Fonts to your server.
7
- * Version: 5.5.0
8
  * Author: Daan from Daan.dev
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
4
  * Plugin Name: OMGF
5
  * Plugin URI: https://daan.dev/wordpress/omgf/
6
  * Description: Increase GDPR/DSGVO compliance, reduce DNS requests and leverage browser cache by automatically downloading Google Fonts to your server.
7
+ * Version: 5.5.1
8
  * Author: Daan from Daan.dev
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
includes/class-admin.php CHANGED
@@ -192,6 +192,13 @@ class OMGF_Admin
192
  */
193
  public function settings_changed($value, $option_name, $old_value)
194
  {
 
 
 
 
 
 
 
195
  if (!in_array($option_name, $this->stale_cache_options)) {
196
  return $value;
197
  }
192
  */
193
  public function settings_changed($value, $option_name, $old_value)
194
  {
195
+ /**
196
+ * Don't show this message on the Main tab.
197
+ */
198
+ if (array_key_exists('tab', $_GET) && $_GET['tab'] == OMGF_Admin_Settings::OMGF_SETTINGS_FIELD_OPTIMIZE) {
199
+ return $value;
200
+ }
201
+
202
  if (!in_array($option_name, $this->stale_cache_options)) {
203
  return $value;
204
  }
includes/class-omgf.php CHANGED
@@ -491,9 +491,16 @@ class OMGF
491
  */
492
  if ($intersect) {
493
  /**
494
- * We can't always control what's in $subsets and empty arrays could occur, throwing warnings.
 
495
  */
496
- return @call_user_func_array('array_intersect', array_values(array_filter($subsets)));
 
 
 
 
 
 
497
  }
498
 
499
  return $subsets;
491
  */
492
  if ($intersect) {
493
  /**
494
+ * @var array $filtered_subsets Contains an array of Font Families along with the available selected subsets, e.g.
495
+ * { 'Lato' => { 'latin', 'latin-ext' } }
496
  */
497
+ $filtered_subsets = array_values(array_filter($subsets));
498
+
499
+ if (!empty($filtered_subsets)) {
500
+ return call_user_func_array('array_intersect', $filtered_subsets);
501
+ }
502
+
503
+ return $filtered_subsets;
504
  }
505
 
506
  return $subsets;
includes/class-optimize.php CHANGED
@@ -141,6 +141,10 @@ class OMGF_Optimize
141
 
142
  OMGF::debug(__('Processing downloads for', $this->plugin_text_domain) . ' ' . $font->family . '...');
143
 
 
 
 
 
144
  foreach ($font->variants as $variant_id => &$variant) {
145
  /**
146
  * @since v5.3.0 Variable fonts use one filename for all font weights/styles. That's why we drop the weight from the filename.
@@ -288,6 +292,8 @@ class OMGF_Optimize
288
 
289
  OMGF::debug(sprintf(__('Found %s @font-face statements.', $this->plugin_text_domain), count($font_faces[0])));
290
 
 
 
291
  foreach ($font_faces[0] as $key => $font_face) {
292
  /**
293
  * @since v5.3.3 Exact match for font-family attribute, to prevent similar font names from falling thru, e.g. Roboto and Roboto Slab.
141
 
142
  OMGF::debug(__('Processing downloads for', $this->plugin_text_domain) . ' ' . $font->family . '...');
143
 
144
+ if (!isset($font->variants) || empty($font->variants)) {
145
+ continue;
146
+ }
147
+
148
  foreach ($font->variants as $variant_id => &$variant) {
149
  /**
150
  * @since v5.3.0 Variable fonts use one filename for all font weights/styles. That's why we drop the weight from the filename.
292
 
293
  OMGF::debug(sprintf(__('Found %s @font-face statements.', $this->plugin_text_domain), count($font_faces[0])));
294
 
295
+ $font_object = [];
296
+
297
  foreach ($font_faces[0] as $key => $font_face) {
298
  /**
299
  * @since v5.3.3 Exact match for font-family attribute, to prevent similar font names from falling thru, e.g. Roboto and Roboto Slab.
includes/class-stylesheet-generator.php CHANGED
@@ -46,6 +46,10 @@ class OMGF_StylesheetGenerator
46
  $stylesheet = "/**\n * Auto Generated by $this->plugin\n * @author: Daan van den Bergh\n * @url: https://daan.dev\n */\n\n";
47
 
48
  foreach ($this->fonts as $font) {
 
 
 
 
49
  foreach ($font->variants as $variant) {
50
  /**
51
  * Filter font_family name.
46
  $stylesheet = "/**\n * Auto Generated by $this->plugin\n * @author: Daan van den Bergh\n * @url: https://daan.dev\n */\n\n";
47
 
48
  foreach ($this->fonts as $font) {
49
+ if (!isset($font->variants) || empty($font->variants)) {
50
+ continue;
51
+ }
52
+
53
  foreach ($font->variants as $variant) {
54
  /**
55
  * Filter font_family name.
includes/optimize/class-run.php CHANGED
@@ -96,14 +96,6 @@ class OMGF_Optimize_Run
96
  $wp_settings_errors = [];
97
  }
98
 
99
- add_settings_error('general', 'omgf_optimization_success', __('Optimization completed successfully.', $this->plugin_text_domain) . ' ' . sprintf('<a target="_blank" href="%s">', self::DOCS_TEST_URL) . __('How can I verify it\'s working?', $this->plugin_text_domain) . '</a>', 'success');
100
-
101
- OMGF_Admin_Notice::set_notice(
102
- sprintf(__('Make sure you flush any caches of 3rd party plugins you\'re using (e.g. Revolution Slider, WP Rocket, Autoptimize, W3 Total Cache, etc.) to allow %s\'s optimizations to take effect. ', $this->plugin_text_domain), apply_filters('omgf_settings_page_title', 'OMGF')),
103
- 'omgf-cache-notice',
104
- 'warning'
105
- );
106
-
107
  /**
108
  * @since v5.4.4 Check if selected Used Subset(s) are actually available in all detected font families,
109
  * and update the Used Subset(s) option if not.
@@ -112,7 +104,8 @@ class OMGF_Optimize_Run
112
 
113
  if (OMGF_AUTO_SUBSETS == 'on') {
114
  /**
115
- * Show a notice
 
116
  */
117
  if ($available_used_subsets && !empty($diff = array_diff(OMGF_SUBSETS, $available_used_subsets))) {
118
  OMGF_Admin_Notice::set_notice(
@@ -128,18 +121,25 @@ class OMGF_Optimize_Run
128
  'omgf-used-subsets-removed',
129
  'info'
130
  );
131
- }
132
 
133
- if ($available_used_subsets) {
134
  update_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_SUBSETS, $available_used_subsets);
135
- } elseif (!empty($diff = array_diff(OMGF_SUBSETS, ['latin']))) {
 
 
 
 
136
  /**
137
  * If detected fonts aren't available in any of the subsets that were selected, just set Used Subsets to Latin
138
  * to make sure nothing breaks.
139
  */
140
  OMGF_Admin_Notice::set_notice(
141
  sprintf(
142
- __('Used Subset(s) is set to Latin, since all detected font-families aren\'t available in %s. <a href="#" id="omgf-optimize-again">Run optimization again</a> to process these changes.', 'host-webfonts-local'),
 
 
 
 
 
143
  $this->fluent_implode($diff)
144
  ),
145
  'omgf-used-subsets-defaults',
@@ -147,8 +147,18 @@ class OMGF_Optimize_Run
147
  );
148
 
149
  update_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_SUBSETS, ['latin']);
 
 
150
  }
151
  }
 
 
 
 
 
 
 
 
152
  }
153
 
154
  /**
96
  $wp_settings_errors = [];
97
  }
98
 
 
 
 
 
 
 
 
 
99
  /**
100
  * @since v5.4.4 Check if selected Used Subset(s) are actually available in all detected font families,
101
  * and update the Used Subset(s) option if not.
104
 
105
  if (OMGF_AUTO_SUBSETS == 'on') {
106
  /**
107
+ * If $diff is empty, this means that the detected fonts are available in all selected subsets of the
108
+ * Used Subset(s) option and no further action is required.
109
  */
110
  if ($available_used_subsets && !empty($diff = array_diff(OMGF_SUBSETS, $available_used_subsets))) {
111
  OMGF_Admin_Notice::set_notice(
121
  'omgf-used-subsets-removed',
122
  'info'
123
  );
 
124
 
 
125
  update_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_SUBSETS, $available_used_subsets);
126
+
127
+ return;
128
+ }
129
+
130
+ if (!empty($diff = array_diff(OMGF_SUBSETS, ['latin']))) {
131
  /**
132
  * If detected fonts aren't available in any of the subsets that were selected, just set Used Subsets to Latin
133
  * to make sure nothing breaks.
134
  */
135
  OMGF_Admin_Notice::set_notice(
136
  sprintf(
137
+ _n(
138
+ 'Used Subset(s) is set to Latin, since %s isn\'t available in all detected font-families. <a href="#" id="omgf-optimize-again">Run optimization again</a> to process these changes.',
139
+ 'Used Subset(s) is set to Latin, since %s aren\'t available in all detected font-families. <a href="#" id="omgf-optimize-again">Run optimization again</a> to process these changes.',
140
+ count($diff),
141
+ 'host-webfonts-local',
142
+ ),
143
  $this->fluent_implode($diff)
144
  ),
145
  'omgf-used-subsets-defaults',
147
  );
148
 
149
  update_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_SUBSETS, ['latin']);
150
+
151
+ return;
152
  }
153
  }
154
+
155
+ add_settings_error('general', 'omgf_optimization_success', __('Optimization completed successfully.', $this->plugin_text_domain) . ' ' . sprintf('<a target="_blank" href="%s">', self::DOCS_TEST_URL) . __('How can I verify it\'s working?', $this->plugin_text_domain) . '</a>', 'success');
156
+
157
+ OMGF_Admin_Notice::set_notice(
158
+ sprintf(__('Make sure you flush any caches of 3rd party plugins you\'re using (e.g. Revolution Slider, WP Rocket, Autoptimize, W3 Total Cache, etc.) to allow %s\'s optimizations to take effect. ', $this->plugin_text_domain), apply_filters('omgf_settings_page_title', 'OMGF')),
159
+ 'omgf-cache-notice',
160
+ 'warning'
161
+ );
162
  }
163
 
164
  /**
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: DaanvandenBergh
3
  Tags: google, fonts, gdpr, dsgvo, cache, speed, preload, font-display, webfonts, subsets, remove, minimize, external, requests
4
  Requires at least: 4.6
5
  Tested up to: 6.1
6
- Stable tag: 5.5.0
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -76,6 +76,10 @@ For the FAQ, [click here](https://daan.dev/docs/omgf-pro-faq/).
76
 
77
  == Changelog ==
78
 
 
 
 
 
79
  = 5.5.0 | December 5th, 2022 =
80
  * Added: 'omgf_optimize_run_args' filter to allow adding attional GET-parameters before running optimization.
81
  * Improved: always use protocol relative ('//' instead of 'https://') URLs when generating and loading stylesheets to avoid SSL- and permalinks related quirks in WordPress.
3
  Tags: google, fonts, gdpr, dsgvo, cache, speed, preload, font-display, webfonts, subsets, remove, minimize, external, requests
4
  Requires at least: 4.6
5
  Tested up to: 6.1
6
+ Stable tag: 5.5.1
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
76
 
77
  == Changelog ==
78
 
79
+ = 5.5.1 | December 14th, 2022 =
80
+ * Fixed: ArgumentCountError: array_intersect() expects at least 1 argument, 0 given.
81
+ * Improved: don't show "optimization success" message if Auto-configure Subsets needs to run again.
82
+
83
  = 5.5.0 | December 5th, 2022 =
84
  * Added: 'omgf_optimize_run_args' filter to allow adding attional GET-parameters before running optimization.
85
  * Improved: always use protocol relative ('//' instead of 'https://') URLs when generating and loading stylesheets to avoid SSL- and permalinks related quirks in WordPress.