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

Version Description

  • Added: Debug Mode with an option to download the log file. Stops logging when file exceeds 1MB for those who forgot to disable it.
  • Fixed: Prevent array to string conversion with new Used Subset(s) option by writing defaults to the database: Latin, Latin Extended.
  • Added: debug logging points in OMGF_Optimize class.
  • Fixed: decode HTML entities in the URL before fetching the stylesheet from the Google Fonts API.
  • Fixed: stricter matching for font-family detection, to prevent similar font names (e.g. Roboto and Roboto Condensed) from getting mixed up in the stylesheet.
  • Fixed: minor performance optimization in OMGF_Optimize class.
Download this release

Release Info

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

Code changes from version 5.3.2 to 5.3.3

assets/css/omgf-admin.css CHANGED
@@ -200,6 +200,10 @@
200
  .tooltip:hover .tooltip-text {
201
  visibility: visible;
202
  }
 
 
 
 
203
  #omgf-help-form .postbox {
204
  padding: 0 15px 5px;
205
  }
200
  .tooltip:hover .tooltip-text {
201
  visibility: visible;
202
  }
203
+ .omgf-warning {
204
+ color: red;
205
+ font-weight: 600;
206
+ }
207
  #omgf-help-form .postbox {
208
  padding: 0 15px 5px;
209
  }
assets/css/omgf-admin.css.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["omgf-admin.less"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAkBA,KACE;EACE,WAAA;EACA,qBAAA;EACA,yBAAA;EACA,gBAAA;EACA,eAAA;EACA,kBAAA;EACA,mBAAA;EACA,4BAAA;;AAEA,KAVF,eAUG;EACC,eAAA;EACA,mBAAA;EACA,WAAA;EACA,qBAAA;;;;;AAQN;EACE,oBAAA;;AADF,SAGE;EACE,eAAA;;AAJJ,SAOE,kBAAiB;EACf,oBAAA;EACA,mBAAA;;AAIJ,KAAM;EACJ,iBAAA;;AADF,KAAM,KAGJ;EACE,iBAAA;;AAJJ,KAAM,KAQJ,mBACE;EACE,eAAA;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253
  }
254
  }
255
 
 
 
 
 
 
256
  #omgf-help-form {
257
  .postbox {
258
  padding: 0 15px 5px;
253
  }
254
  }
255
 
256
+ .omgf-warning {
257
+ color: red;
258
+ font-weight: 600;
259
+ }
260
+
261
  #omgf-help-form {
262
  .postbox {
263
  padding: 0 15px 5px;
assets/js/omgf-admin.js CHANGED
@@ -21,7 +21,9 @@ jQuery(document).ready(function ($) {
21
  optimize_xhr: false,
22
  cache_prefix: '-mod-',
23
  flush_action_init: $('.omgf-empty').data('init'),
24
- nonce: $('.omgf-empty').data('nonce'),
 
 
25
 
26
  /**
27
  * Initialize all on click events.
@@ -42,6 +44,7 @@ jQuery(document).ready(function ($) {
42
  $('#omgf-cache-refresh').on('click', this.refresh_cache);
43
  $('.omgf-empty, #omgf-cache-flush').on('click', this.empty_cache_directory);
44
  $('#omgf-optimize-settings-form').on('submit', this.show_loader_before_submit);
 
45
 
46
  // Ticker
47
  setInterval(this.loop_ticker_items, 4000);
@@ -75,7 +78,7 @@ jQuery(document).ready(function ($) {
75
  data: {
76
  action: 'omgf_remove_stylesheet_from_db',
77
  handle: handle,
78
- nonce: omgf_admin.nonce,
79
  },
80
  beforeSend: function () {
81
  omgf_admin.show_loader();
@@ -95,7 +98,7 @@ jQuery(document).ready(function ($) {
95
  url: ajaxurl,
96
  data: {
97
  action: 'omgf_refresh_cache',
98
- nonce: omgf_admin.nonce,
99
  },
100
  beforeSend: function () {
101
  $('.omgf-optimize-fonts-manage table tbody').each(function (key, elem) {
@@ -290,7 +293,7 @@ jQuery(document).ready(function ($) {
290
  url: ajaxurl,
291
  data: {
292
  action: 'omgf_empty_dir',
293
- nonce: omgf_admin.nonce,
294
  init: omgf_admin.flush_action_init
295
  },
296
  beforeSend: function () {
@@ -302,6 +305,27 @@ jQuery(document).ready(function ($) {
302
  });
303
  },
304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  show_loader_before_submit: function () {
306
  omgf_admin.show_loader();
307
  },
21
  optimize_xhr: false,
22
  cache_prefix: '-mod-',
23
  flush_action_init: $('.omgf-empty').data('init'),
24
+ empty_action_nonce: $('.omgf-empty').data('nonce'),
25
+ delete_log_xhr: false,
26
+ delete_action_nonce: $('#omgf-delete-log').data('nonce'),
27
 
28
  /**
29
  * Initialize all on click events.
44
  $('#omgf-cache-refresh').on('click', this.refresh_cache);
45
  $('.omgf-empty, #omgf-cache-flush').on('click', this.empty_cache_directory);
46
  $('#omgf-optimize-settings-form').on('submit', this.show_loader_before_submit);
47
+ $('#omgf-delete-log').on('click', this.delete_log);
48
 
49
  // Ticker
50
  setInterval(this.loop_ticker_items, 4000);
78
  data: {
79
  action: 'omgf_remove_stylesheet_from_db',
80
  handle: handle,
81
+ nonce: omgf_admin.empty_action_nonce,
82
  },
83
  beforeSend: function () {
84
  omgf_admin.show_loader();
98
  url: ajaxurl,
99
  data: {
100
  action: 'omgf_refresh_cache',
101
+ nonce: omgf_admin.empty_action_nonce,
102
  },
103
  beforeSend: function () {
104
  $('.omgf-optimize-fonts-manage table tbody').each(function (key, elem) {
293
  url: ajaxurl,
294
  data: {
295
  action: 'omgf_empty_dir',
296
+ nonce: omgf_admin.empty_action_nonce,
297
  init: omgf_admin.flush_action_init
298
  },
299
  beforeSend: function () {
305
  });
306
  },
307
 
308
+ delete_log: function () {
309
+ if (omgf_admin.delete_log_xhr) {
310
+ omgf_admin.delete_log_xhr.abort();
311
+ }
312
+
313
+ omgf_admin.delete_log_xhr = $.ajax({
314
+ type: 'POST',
315
+ url: ajaxurl,
316
+ data: {
317
+ action: 'omgf_delete_log',
318
+ nonce: omgf_admin.delete_action_nonce,
319
+ },
320
+ beforeSend: function () {
321
+ omgf_admin.show_loader();
322
+ },
323
+ complete: function () {
324
+ location.reload();
325
+ }
326
+ });
327
+ },
328
+
329
  show_loader_before_submit: function () {
330
  omgf_admin.show_loader();
331
  },
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 compliance, reduce DNS requests and leverage browser cache by automatically downloading Google Fonts to your server.
7
- * Version: 5.3.2
8
  * Author: Daan from Daan.dev
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
@@ -19,8 +19,8 @@ defined('ABSPATH') || exit;
19
  define('OMGF_PLUGIN_DIR', plugin_dir_path(__FILE__));
20
  define('OMGF_PLUGIN_FILE', __FILE__);
21
  define('OMGF_PLUGIN_BASENAME', plugin_basename(OMGF_PLUGIN_FILE));
22
- define('OMGF_STATIC_VERSION', '5.3.2');
23
- define('OMGF_DB_VERSION', '5.0.0');
24
 
25
  /**
26
  * Takes care of loading classes on demand.
4
  * Plugin Name: OMGF
5
  * Plugin URI: https://daan.dev/wordpress/omgf/
6
  * Description: Increase GDPR compliance, reduce DNS requests and leverage browser cache by automatically downloading Google Fonts to your server.
7
+ * Version: 5.3.3
8
  * Author: Daan from Daan.dev
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
19
  define('OMGF_PLUGIN_DIR', plugin_dir_path(__FILE__));
20
  define('OMGF_PLUGIN_FILE', __FILE__);
21
  define('OMGF_PLUGIN_BASENAME', plugin_basename(OMGF_PLUGIN_FILE));
22
+ define('OMGF_STATIC_VERSION', '5.3.3');
23
+ define('OMGF_DB_VERSION', '5.3.3');
24
 
25
  /**
26
  * Takes care of loading classes on demand.
includes/admin/class-settings.php CHANGED
@@ -126,6 +126,7 @@ class OMGF_Admin_Settings extends OMGF_Admin
126
  * Advanced Settings
127
  */
128
  const OMGF_ADV_SETTING_COMPATIBILITY = 'omgf_compatibility';
 
129
  const OMGF_ADV_SETTING_UNINSTALL = 'omgf_uninstall';
130
 
131
  /**
126
  * Advanced Settings
127
  */
128
  const OMGF_ADV_SETTING_COMPATIBILITY = 'omgf_compatibility';
129
+ const OMGF_ADV_SETTING_DEBUG_MODE = 'omgf_debug';
130
  const OMGF_ADV_SETTING_UNINSTALL = 'omgf_uninstall';
131
 
132
  /**
includes/admin/settings/class-advanced.php CHANGED
@@ -36,6 +36,8 @@ class OMGF_Admin_Settings_Advanced extends OMGF_Admin_Settings_Builder
36
  add_filter('omgf_advanced_settings_content', [$this, 'do_cache_dir'], 50);
37
  add_filter('omgf_advanced_settings_content', [$this, 'do_promo_fonts_source_url'], 60);
38
  add_filter('omgf_advanced_settings_content', [$this, 'do_compatibility'], 70);
 
 
39
  add_filter('omgf_advanced_settings_content', [$this, 'do_uninstall'], 100);
40
 
41
  // Close
@@ -68,7 +70,7 @@ class OMGF_Admin_Settings_Advanced extends OMGF_Admin_Settings_Builder
68
  </p>
69
  </td>
70
  </tr>
71
- <?php
72
  }
73
 
74
  /**
@@ -102,6 +104,43 @@ class OMGF_Admin_Settings_Advanced extends OMGF_Admin_Settings_Builder
102
  );
103
  }
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  /**
106
  * Remove Settings/Files at Uninstall.
107
  */
36
  add_filter('omgf_advanced_settings_content', [$this, 'do_cache_dir'], 50);
37
  add_filter('omgf_advanced_settings_content', [$this, 'do_promo_fonts_source_url'], 60);
38
  add_filter('omgf_advanced_settings_content', [$this, 'do_compatibility'], 70);
39
+ add_filter('omgf_advanced_settings_content', [$this, 'do_debug_mode'], 80);
40
+ add_filter('omgf_advanced_settings_content', [$this, 'do_download_log'], 90);
41
  add_filter('omgf_advanced_settings_content', [$this, 'do_uninstall'], 100);
42
 
43
  // Close
70
  </p>
71
  </td>
72
  </tr>
73
+ <?php
74
  }
75
 
76
  /**
104
  );
105
  }
106
 
107
+ public function do_debug_mode()
108
+ {
109
+ $this->do_checkbox(
110
+ __('Debug Mode', $this->plugin_text_domain),
111
+ OMGF_Admin_Settings::OMGF_ADV_SETTING_DEBUG_MODE,
112
+ OMGF_DEBUG_MODE,
113
+ __('Don\'t enable this option, unless when asked by me (Daan) or, if you know what you\'re doing.')
114
+ );
115
+ }
116
+
117
+ /**
118
+ * Show Download Log button if debug mode is on and debug file exists.
119
+ */
120
+ public function do_download_log()
121
+ {
122
+ ?>
123
+ <tr>
124
+ <th></th>
125
+ <td>
126
+ <?php if (OMGF_DEBUG_MODE === 'on' && file_exists(OMGF::$log_file)) : ?>
127
+ <?php
128
+ clearstatcache();
129
+ $nonce = wp_create_nonce(OMGF_Admin_Settings::OMGF_ADMIN_PAGE);
130
+ ?>
131
+ <a class="button button-secondary" href="<?php echo admin_url("admin-ajax.php?action=omgf_download_log&nonce=$nonce"); ?>"><?php _e('Download Log', $this->plugin_text_domain); ?></a>
132
+ <?php if (filesize(OMGF::$log_file) > MB_IN_BYTES) : ?>
133
+ <a id="omgf-delete-log" class="button button-cancel" data-nonce="<?php echo $nonce; ?>"><?php _e('Delete log', $this->plugin_text_domain); ?></a>
134
+ <p class="omgf-warning"><?php _e('Your log file is currently larger than 1MB. To protect your filesystem logging has stopped. Delete the log file to enable logging again.', $this->plugin_text_domain); ?></p>
135
+ <?php endif; ?>
136
+ <?php else : ?>
137
+ <p class="description"><?php _e('No log file available for download.', $this->plugin_text_domain); ?></p>
138
+ <?php endif; ?>
139
+ </td>
140
+ </tr>
141
+ <?php
142
+ }
143
+
144
  /**
145
  * Remove Settings/Files at Uninstall.
146
  */
includes/admin/settings/class-optimize.php CHANGED
@@ -200,7 +200,7 @@ class OMGF_Admin_Settings_Optimize extends OMGF_Admin_Settings_Builder
200
  __('Remove Async Google Fonts (Pro)', $this->plugin_text_domain),
201
  'omgf_pro_remove_async_fonts',
202
  defined('OMGF_PRO_REMOVE_ASYNC_FONTS') ? OMGF_PRO_REMOVE_ASYNC_FONTS : false,
203
- sprintf(__('Remove Google Fonts loaded (asynchronously) by (3rd party) JavaScript libraries used by some themes/plugins. This won\'t work with embedded content (i.e. <code>iframe</code>). <strong>Warning!</strong> Make sure you load the Google Fonts, <a href="%s">either manually</a> or by using a plugin (like <a href="%s" target="_blank">Additional Fonts</a>) to prevent styling breaks.', $this->plugin_text_domain), 'https://daan.dev/docs/omgf-pro/remove-async-google-fonts/', 'https://daan.dev/wordpress/omgf-additional-fonts/'),
204
  !defined('OMGF_PRO_REMOVE_ASYNC_FONTS')
205
  );
206
  }
200
  __('Remove Async Google Fonts (Pro)', $this->plugin_text_domain),
201
  'omgf_pro_remove_async_fonts',
202
  defined('OMGF_PRO_REMOVE_ASYNC_FONTS') ? OMGF_PRO_REMOVE_ASYNC_FONTS : false,
203
+ sprintf(__('Remove Google Fonts loaded (asynchronously) by (3rd party) JavaScript libraries used by some themes/plugins. This won\'t work with embedded content (i.e. <code>iframe</code>). <strong>Warning!</strong> Make sure you load the Google Fonts, either <a href="%s">manually</a> or by using a plugin (like <a href="%s" target="_blank">Additional Fonts</a>) to prevent styling breaks.', $this->plugin_text_domain), 'https://daan.dev/docs/omgf-pro/remove-async-google-fonts/', 'https://daan.dev/wordpress/omgf-additional-fonts/'),
204
  !defined('OMGF_PRO_REMOVE_ASYNC_FONTS')
205
  );
206
  }
includes/class-ajax.php CHANGED
@@ -29,6 +29,8 @@ class OMGF_AJAX
29
  add_action('wp_ajax_omgf_remove_stylesheet_from_db', [$this, 'remove_stylesheet_from_db']);
30
  add_action('wp_ajax_omgf_refresh_cache', [$this, 'refresh_cache']);
31
  add_action('wp_ajax_omgf_empty_dir', [$this, 'empty_directory']);
 
 
32
  }
33
 
34
  /**
@@ -176,4 +178,58 @@ class OMGF_AJAX
176
  delete_option($option);
177
  }
178
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  }
29
  add_action('wp_ajax_omgf_remove_stylesheet_from_db', [$this, 'remove_stylesheet_from_db']);
30
  add_action('wp_ajax_omgf_refresh_cache', [$this, 'refresh_cache']);
31
  add_action('wp_ajax_omgf_empty_dir', [$this, 'empty_directory']);
32
+ add_action('wp_ajax_omgf_download_log', [$this, 'download_log']);
33
+ add_action('wp_ajax_omgf_delete_log', [$this, 'delete_log']);
34
  }
35
 
36
  /**
178
  delete_option($option);
179
  }
180
  }
181
+
182
+ public function download_log()
183
+ {
184
+ check_ajax_referer(OMGF_Admin_Settings::OMGF_ADMIN_PAGE, 'nonce');
185
+
186
+ if (!current_user_can('manage_options')) {
187
+ wp_die(__("Hmmm, you're not supposed to be here.", $this->plugin_text_domain));
188
+ }
189
+
190
+ $filename = OMGF::$log_file;
191
+
192
+ /**
193
+ * Shouldn't happen, but you never know.
194
+ */
195
+ if (!file_exists($filename)) {
196
+ wp_die();
197
+ }
198
+
199
+ $basename = basename($filename);
200
+ $filesize = filesize($filename);
201
+
202
+ header('Content-Description: File Transfer');
203
+ header('Content-Type: text/plain');
204
+ header("Cache-Control: no-cache, must-revalidate");
205
+ header("Expires: 0");
206
+ header("Content-Disposition: attachment; filename=$basename");
207
+ header("Content-Length: $filesize");
208
+ header('Pragma: public');
209
+
210
+ flush();
211
+
212
+ readfile($filename);
213
+
214
+ wp_die();
215
+ }
216
+
217
+ public function delete_log()
218
+ {
219
+ check_ajax_referer(OMGF_Admin_Settings::OMGF_ADMIN_PAGE, 'nonce');
220
+
221
+ if (!current_user_can('manage_options')) {
222
+ wp_die(__("Hmmm, you're not supposed to be here.", $this->plugin_text_domain));
223
+ }
224
+
225
+ $filename = OMGF::$log_file;
226
+
227
+ if (file_exists($filename)) {
228
+ unlink($filename);
229
+
230
+ add_settings_error('general', 'omgf-log-file-deleted', __('Log file successfully deleted', $this->plugin_text_domain), 'success');
231
+ }
232
+
233
+ wp_die();
234
+ }
235
  }
includes/class-omgf.php CHANGED
@@ -18,6 +18,11 @@ defined('ABSPATH') || exit;
18
 
19
  class OMGF
20
  {
 
 
 
 
 
21
  /**
22
  * OMGF constructor.
23
  */
@@ -25,6 +30,12 @@ class OMGF
25
  {
26
  $this->define_constants();
27
 
 
 
 
 
 
 
28
  if (is_admin()) {
29
  add_action('_admin_menu', [$this, 'init_admin']);
30
 
@@ -35,6 +46,7 @@ class OMGF
35
  add_action('init', [$this, 'init_frontend'], 50);
36
  }
37
 
 
38
  add_action('admin_init', [$this, 'do_optimize']);
39
  add_filter('content_url', [$this, 'force_ssl'], 1000, 2);
40
  add_filter('pre_update_option_omgf_optimized_fonts', [$this, 'base64_decode_optimized_fonts']);
@@ -61,11 +73,22 @@ class OMGF
61
  define('OMGF_CACHE_KEYS', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_CACHE_KEYS, '')));
62
  define('OMGF_TEST_MODE', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_TEST_MODE)));
63
  define('OMGF_COMPATIBILITY', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_COMPATIBILITY, 'on')));
 
64
  define('OMGF_UNINSTALL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL)));
65
  define('OMGF_UPLOAD_DIR', apply_filters('omgf_upload_dir', WP_CONTENT_DIR . '/uploads/omgf'));
66
  define('OMGF_UPLOAD_URL', apply_filters('omgf_upload_url', WP_CONTENT_URL . '/uploads/omgf'));
67
  }
68
 
 
 
 
 
 
 
 
 
 
 
69
  /**
70
  * Escape each value of an option array.
71
  */
@@ -110,6 +133,20 @@ class OMGF
110
  return new OMGF_Frontend_Process();
111
  }
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  /**
114
  * @return OMGF_Admin_Optimize
115
  */
@@ -386,10 +423,10 @@ class OMGF
386
  */
387
  public static function debug($message)
388
  {
389
- if (!defined('OMGF_DEBUG_MODE') || !OMGF_DEBUG_MODE) {
390
  return;
391
  }
392
 
393
- error_log(current_time('Y-m-d H:i:s') . ' ' . microtime() . ": $message\n", 3, trailingslashit(WP_CONTENT_DIR) . 'omgf-pro-debug.log');
394
  }
395
  }
18
 
19
  class OMGF
20
  {
21
+ /**
22
+ * @var string $log_file Path where log file is located.
23
+ */
24
+ public static $log_file;
25
+
26
  /**
27
  * OMGF constructor.
28
  */
30
  {
31
  $this->define_constants();
32
 
33
+ self::$log_file = trailingslashit(WP_CONTENT_DIR) . 'omgf-debug.log';
34
+
35
+ if (version_compare(OMGF_CURRENT_DB_VERSION, OMGF_DB_VERSION) < 0) {
36
+ add_action('plugins_loaded', [$this, 'do_migrate_db']);
37
+ }
38
+
39
  if (is_admin()) {
40
  add_action('_admin_menu', [$this, 'init_admin']);
41
 
46
  add_action('init', [$this, 'init_frontend'], 50);
47
  }
48
 
49
+ add_filter('omgf_optimize_url', [$this, 'decode_url']);
50
  add_action('admin_init', [$this, 'do_optimize']);
51
  add_filter('content_url', [$this, 'force_ssl'], 1000, 2);
52
  add_filter('pre_update_option_omgf_optimized_fonts', [$this, 'base64_decode_optimized_fonts']);
73
  define('OMGF_CACHE_KEYS', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_CACHE_KEYS, '')));
74
  define('OMGF_TEST_MODE', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_TEST_MODE)));
75
  define('OMGF_COMPATIBILITY', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_COMPATIBILITY, 'on')));
76
+ define('OMGF_DEBUG_MODE', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_DEBUG_MODE)));
77
  define('OMGF_UNINSTALL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL)));
78
  define('OMGF_UPLOAD_DIR', apply_filters('omgf_upload_dir', WP_CONTENT_DIR . '/uploads/omgf'));
79
  define('OMGF_UPLOAD_URL', apply_filters('omgf_upload_url', WP_CONTENT_URL . '/uploads/omgf'));
80
  }
81
 
82
+ /**
83
+ * Run any DB migration scripts if needed.
84
+ *
85
+ * @return void
86
+ */
87
+ public function do_migrate_db()
88
+ {
89
+ new OMGF_DB_Migrate();
90
+ }
91
+
92
  /**
93
  * Escape each value of an option array.
94
  */
133
  return new OMGF_Frontend_Process();
134
  }
135
 
136
+ /**
137
+ * @since v5.3.3 Decode HTML entities to prevent URL decoding issues on some systems.
138
+ *
139
+ * @filter omgf_optimize_url
140
+ *
141
+ * @param mixed $url
142
+ *
143
+ * @return string
144
+ */
145
+ public function decode_url($url)
146
+ {
147
+ return html_entity_decode($url);
148
+ }
149
+
150
  /**
151
  * @return OMGF_Admin_Optimize
152
  */
423
  */
424
  public static function debug($message)
425
  {
426
+ if (OMGF_DEBUG_MODE !== 'on' || filesize(self::$log_file > MB_IN_BYTES)) {
427
  return;
428
  }
429
 
430
+ error_log(current_time('Y-m-d H:i:s') . ' ' . microtime() . ": $message\n", 3, self::$log_file);
431
  }
432
  }
includes/class-optimize.php CHANGED
@@ -124,6 +124,8 @@ class OMGF_Optimize
124
  */
125
  $font->family = rawurlencode($font->family);
126
 
 
 
127
  foreach ($font->variants as $variant_id => &$variant) {
128
  /**
129
  * @since v5.3.0 Variable fonts use one filename for all font weights/styles. That's why we drop the weight from the filename.
@@ -141,19 +143,18 @@ class OMGF_Optimize
141
  */
142
  $variant->fontFamily = rawurlencode($variant->fontFamily);
143
 
144
- /**
145
- * @since v5.3.0 No need to keep this if this variant belongs to a subset we don't need.
146
- */
147
- if (isset($variant->subset) && !in_array($variant->subset, apply_filters('omgf_used_subsets', OMGF_SUBSETS))) {
148
- unset($font->variants[$variant_id]);
149
-
150
- continue;
151
- }
152
 
153
  if (isset($variant->woff2)) {
 
 
 
 
 
154
  $variant->woff2 = OMGF::download($variant->woff2, $filename, 'woff2', $this->path);
155
  }
156
  }
 
 
157
  }
158
 
159
  $stylesheet = OMGF::generate_stylesheet($fonts);
@@ -197,6 +198,8 @@ class OMGF_Optimize
197
  */
198
  private function grab_fonts_object($url)
199
  {
 
 
200
  $response = wp_remote_get($url, [
201
  'user-agent' => self::USER_AGENT['woff2']
202
  ]);
@@ -209,6 +212,8 @@ class OMGF_Optimize
209
 
210
  $stylesheet = wp_remote_retrieve_body($response);
211
 
 
 
212
  preg_match_all('/font-family:\s\'(.*?)\';/', $stylesheet, $font_families);
213
 
214
  if (!isset($font_families[1]) || empty($font_families[1])) {
@@ -217,6 +222,8 @@ class OMGF_Optimize
217
 
218
  $font_families = array_unique($font_families[1]);
219
 
 
 
220
  foreach ($font_families as $font_family) {
221
  $id = strtolower(str_replace(' ', '-', $font_family));
222
  $object[$id] = (object) [
@@ -227,6 +234,8 @@ class OMGF_Optimize
227
  ];
228
  }
229
 
 
 
230
  return $object;
231
  }
232
 
@@ -240,6 +249,8 @@ class OMGF_Optimize
240
  */
241
  private function parse_variants($stylesheet, $font_family)
242
  {
 
 
243
  /**
244
  * This also captures the commented Subset name.
245
  */
@@ -249,8 +260,13 @@ class OMGF_Optimize
249
  return [];
250
  }
251
 
 
 
252
  foreach ($font_faces[0] as $key => $font_face) {
253
- if (strpos($font_face, $font_family) === false) {
 
 
 
254
  continue;
255
  }
256
 
@@ -260,8 +276,14 @@ class OMGF_Optimize
260
  preg_match('/\/\*\s([a-z\-]+?)\s\*\//', $font_face, $subset);
261
  preg_match('/unicode-range:\s(.*?);/', $font_face, $range);
262
 
263
- $key = $subset[1] . '-' . $font_weight[1] . ($font_style[1] == 'normal' ? '' : '-' . $font_style[1]);
 
 
 
 
 
264
 
 
265
  $font_object[$key] = new stdClass();
266
  $font_object[$key]->id = $font_weight[1] . ($font_style[1] == 'normal' ? '' : $font_style[1]);
267
  $font_object[$key]->fontFamily = $font_family;
@@ -277,14 +299,22 @@ class OMGF_Optimize
277
  $font_object[$key]->range = $range[1];
278
  }
279
 
 
 
280
  /**
281
  * @since v5.3.0 Is this a variable font i.e. one font file for multiple font weights/styles?
282
  */
283
- if (substr_count($stylesheet, $font_src[1]) > 1) {
284
- $this->variable_fonts[strtolower(str_replace(' ', '-', $font_family))] = true;
 
 
285
  }
286
  }
287
 
 
 
 
 
288
  return $font_object;
289
  }
290
 
@@ -294,13 +324,19 @@ class OMGF_Optimize
294
  */
295
  private function parse_subsets($stylesheet)
296
  {
 
 
297
  preg_match_all('/\/\*\s([a-z\-]+?)\s\*\//', $stylesheet, $subsets);
298
 
299
  if (!isset($subsets[1]) || empty($subsets[1])) {
300
  return [];
301
  }
302
 
303
- return array_unique($subsets[1]);
 
 
 
 
304
  }
305
 
306
  /**
@@ -317,6 +353,8 @@ class OMGF_Optimize
317
 
318
  $url = urldecode($url);
319
 
 
 
320
  if (strpos($url, '/css2') !== false) {
321
  $url = $this->unload_css2($url);
322
  } else {
@@ -471,13 +509,6 @@ class OMGF_Optimize
471
  }
472
 
473
  foreach ($properties->variants as $id => &$variant) {
474
- /**
475
- * @since v5.3.0 Get rid of any subsets that aren't in use.
476
- */
477
- if (isset($variant->subset) && !in_array($variant->subset, apply_filters('omgf_used_subsets', OMGF_SUBSETS))) {
478
- unset($properties->variants[$id]);
479
- }
480
-
481
  $replacement_variant = $replacement[$font_family]->variants[$id] ?? '';
482
 
483
  if ($replacement_variant && $replacement_variant != $variant) {
124
  */
125
  $font->family = rawurlencode($font->family);
126
 
127
+ OMGF::debug(__('Processing downloads for', $this->plugin_text_domain) . ' ' . $font->family . '...');
128
+
129
  foreach ($font->variants as $variant_id => &$variant) {
130
  /**
131
  * @since v5.3.0 Variable fonts use one filename for all font weights/styles. That's why we drop the weight from the filename.
143
  */
144
  $variant->fontFamily = rawurlencode($variant->fontFamily);
145
 
 
 
 
 
 
 
 
 
146
 
147
  if (isset($variant->woff2)) {
148
+ OMGF::debug(sprintf(__('Downloading %s to %s from %s.'), $filename, $this->path, $variant->woff2));
149
+
150
+ /**
151
+ * If file already exists the OMGF_Download class bails early.
152
+ */
153
  $variant->woff2 = OMGF::download($variant->woff2, $filename, 'woff2', $this->path);
154
  }
155
  }
156
+
157
+ OMGF::debug(__('Finished downloading for', $this->plugin_text_domain) . ' ' . $font->family);
158
  }
159
 
160
  $stylesheet = OMGF::generate_stylesheet($fonts);
198
  */
199
  private function grab_fonts_object($url)
200
  {
201
+ OMGF::debug(__('Fetching stylesheet from: ', $this->plugin_text_domain) . $url);
202
+
203
  $response = wp_remote_get($url, [
204
  'user-agent' => self::USER_AGENT['woff2']
205
  ]);
212
 
213
  $stylesheet = wp_remote_retrieve_body($response);
214
 
215
+ OMGF::debug(__('Stylesheet fetched. Parsing for font-families...', $this->plugin_text_domain));
216
+
217
  preg_match_all('/font-family:\s\'(.*?)\';/', $stylesheet, $font_families);
218
 
219
  if (!isset($font_families[1]) || empty($font_families[1])) {
222
 
223
  $font_families = array_unique($font_families[1]);
224
 
225
+ OMGF::debug(__('Font-families found: ', $this->plugin_text_domain) . print_r($font_families, true));
226
+
227
  foreach ($font_families as $font_family) {
228
  $id = strtolower(str_replace(' ', '-', $font_family));
229
  $object[$id] = (object) [
234
  ];
235
  }
236
 
237
+ OMGF::debug(__('Stylesheet successfully converted to object.', $this->plugin_text_domain));
238
+
239
  return $object;
240
  }
241
 
249
  */
250
  private function parse_variants($stylesheet, $font_family)
251
  {
252
+ OMGF::debug(__('Parsing variants.', $this->plugin_text_domain));
253
+
254
  /**
255
  * This also captures the commented Subset name.
256
  */
260
  return [];
261
  }
262
 
263
+ OMGF::debug(sprintf(__('Found %s @font-face statements.', $this->plugin_text_domain), count($font_faces[0])));
264
+
265
  foreach ($font_faces[0] as $key => $font_face) {
266
+ /**
267
+ * @since v5.3.3 Exact match for font-family attribute, to prevent similar font names from falling thru, e.g. Roboto and Roboto Slab.
268
+ */
269
+ if (!preg_match('/font-family:[\s\'"]*?' . $font_family . '[\'"]?;/', $font_face)) {
270
  continue;
271
  }
272
 
276
  preg_match('/\/\*\s([a-z\-]+?)\s\*\//', $font_face, $subset);
277
  preg_match('/unicode-range:\s(.*?);/', $font_face, $range);
278
 
279
+ /**
280
+ * @since v5.3.0 No need to keep this if this variant belongs to a subset we don't need.
281
+ */
282
+ if (!empty($subset) && isset($subset[1]) && !in_array($subset[1], apply_filters('omgf_used_subsets', OMGF_SUBSETS))) {
283
+ continue;
284
+ }
285
 
286
+ $key = $subset[1] . '-' . $font_weight[1] . ($font_style[1] == 'normal' ? '' : '-' . $font_style[1]);
287
  $font_object[$key] = new stdClass();
288
  $font_object[$key]->id = $font_weight[1] . ($font_style[1] == 'normal' ? '' : $font_style[1]);
289
  $font_object[$key]->fontFamily = $font_family;
299
  $font_object[$key]->range = $range[1];
300
  }
301
 
302
+ $id = strtolower(str_replace(' ', '-', $font_family));
303
+
304
  /**
305
  * @since v5.3.0 Is this a variable font i.e. one font file for multiple font weights/styles?
306
  */
307
+ if (substr_count($stylesheet, $font_src[1]) > 1 && !in_array($id, $this->variable_fonts)) {
308
+ $this->variable_fonts[$id] = $id;
309
+
310
+ OMGF::debug(__('Same file used for multiple @font-face statements. This is a variable font: ', $this->plugin_text_domain) . $font_family);
311
  }
312
  }
313
 
314
+ OMGF::debug(__('Generated the following @font-face objects: ', $this->plugin_text_domain) . print_r($font_object, true));
315
+
316
+ OMGF::debug(__('All @font-face statements processed.', $this->plugin_text_domain));
317
+
318
  return $font_object;
319
  }
320
 
324
  */
325
  private function parse_subsets($stylesheet)
326
  {
327
+ OMGF::debug(__('Parsing subsets.', $this->plugin_text_domain));
328
+
329
  preg_match_all('/\/\*\s([a-z\-]+?)\s\*\//', $stylesheet, $subsets);
330
 
331
  if (!isset($subsets[1]) || empty($subsets[1])) {
332
  return [];
333
  }
334
 
335
+ $subsets = array_unique($subsets[1]);
336
+
337
+ OMGF::debug(__('This stylesheet contains @font-face statements for the following subsets: ', $this->plugin_text_domain) . print_r($subsets, true));
338
+
339
+ return $subsets;
340
  }
341
 
342
  /**
353
 
354
  $url = urldecode($url);
355
 
356
+ OMGF::debug(__('Looking for unloads for: ', $this->plugin_text_domain) . $url);
357
+
358
  if (strpos($url, '/css2') !== false) {
359
  $url = $this->unload_css2($url);
360
  } else {
509
  }
510
 
511
  foreach ($properties->variants as $id => &$variant) {
 
 
 
 
 
 
 
512
  $replacement_variant = $replacement[$font_family]->variants[$id] ?? '';
513
 
514
  if ($replacement_variant && $replacement_variant != $variant) {
includes/db/class-migrate.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('ABSPATH') || exit;
3
+
4
+ /**
5
+ * @package OMGF Pro
6
+ * @author Daan van den Bergh
7
+ * https://daan.dev
8
+ * @copyright © 2022 Daan van den Bergh. All Rights Reserved.
9
+ */
10
+ class OMGF_DB_Migrate
11
+ {
12
+ /** @var string */
13
+ private $current_version = '';
14
+
15
+ /**
16
+ * DB Migration constructor.
17
+ */
18
+ public function __construct()
19
+ {
20
+ /**
21
+ * Can be used to block migration scripts that shouldn't be run on a fresh install.
22
+ */
23
+ $this->current_version = get_option(OMGF_Admin_Settings::OMGF_CURRENT_DB_VERSION);
24
+
25
+ if ($this->should_run_migration('5.3.3')) {
26
+ new OMGF_DB_Migrate_V533();
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Checks whether migration script has been run.
32
+ *
33
+ * @param mixed $version
34
+ * @return bool
35
+ */
36
+ private function should_run_migration($version)
37
+ {
38
+ return version_compare($this->current_version, $version) < 0;
39
+ }
40
+ }
includes/db/migrate/class-v533.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('ABSPATH') || exit;
3
+
4
+ /**
5
+ * @package OMGF Pro
6
+ * @author Daan van den Bergh
7
+ * https://daan.dev
8
+ * @copyright © 2022 Daan van den Bergh. All Rights Reserved.
9
+ * @since v3.6.0
10
+ */
11
+ class OMGF_DB_Migrate_V533
12
+ {
13
+ /** @var $version string The version number this migration script was introduced with. */
14
+ private $version = '5.3.3';
15
+
16
+ /**
17
+ * Buid
18
+ *
19
+ * @return void
20
+ */
21
+ public function __construct()
22
+ {
23
+ $this->init();
24
+ }
25
+
26
+ /**
27
+ * Initialize
28
+ *
29
+ * @return void
30
+ */
31
+ private function init()
32
+ {
33
+ $subsets = get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_SUBSETS);
34
+
35
+ if (!$subsets) {
36
+ update_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_SUBSETS, ['latin', 'latin-ext']);
37
+ }
38
+
39
+ /**
40
+ * Update stored version number.
41
+ */
42
+ update_option(OMGF_Admin_Settings::OMGF_CURRENT_DB_VERSION, $this->version);
43
+ }
44
+ }
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: 6.0
6
- Stable tag: 5.3.2
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,14 @@ For the FAQ, [click here](https://daan.dev/docs/omgf-pro-faq/).
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
 
 
79
  = 5.3.2 =
80
  * Fixed: updated static version to force a browser cache refresh of admin JS files.
81
 
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: 6.0
6
+ Stable tag: 5.3.3
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.3.3 =
80
+ * Added: Debug Mode with an option to download the log file. Stops logging when file exceeds 1MB for those who forgot to disable it.
81
+ * Fixed: Prevent array to string conversion with new Used Subset(s) option by writing defaults to the database: Latin, Latin Extended.
82
+ * Added: debug logging points in OMGF_Optimize class.
83
+ * Fixed: decode HTML entities in the URL before fetching the stylesheet from the Google Fonts API.
84
+ * Fixed: stricter matching for font-family detection, to prevent similar font names (e.g. Roboto and Roboto Condensed) from getting mixed up in the stylesheet.
85
+ * Fixed: minor performance optimization in OMGF_Optimize class.
86
+
87
  = 5.3.2 =
88
  * Fixed: updated static version to force a browser cache refresh of admin JS files.
89