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

Version Description

  • Fixed logo for Safari compatibility.
  • Added updaten notices for future important updates.
Download this release

Release Info

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

Code changes from version 4.4.3 to 4.4.4

assets/images/ffw-press-logo.png CHANGED
Binary file
host-webfonts-local.php CHANGED
@@ -1,16 +1,14 @@
1
  <?php
2
 
3
  /**
4
- * @formatter:off
5
  * Plugin Name: OMGF
6
  * Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
7
  * Description: Minimize DNS requests, leverage browser cache and speed up WordPress by saving Google Fonts to your server and removing external Google Fonts requests.
8
- * Version: 4.4.3
9
  * Author: Daan from FFW.Press
10
  * Author URI: https://ffw.press
11
  * License: GPL2v2 or later
12
  * Text Domain: host-webfonts-local
13
- * @formatter:on
14
  */
15
 
16
  defined('ABSPATH') || exit;
1
  <?php
2
 
3
  /**
 
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.4.4
8
  * Author: Daan from FFW.Press
9
  * Author URI: https://ffw.press
10
  * License: GPL2v2 or later
11
  * Text Domain: host-webfonts-local
 
12
  */
13
 
14
  defined('ABSPATH') || exit;
includes/class-omgf.php CHANGED
@@ -34,9 +34,19 @@ class OMGF
34
  $this->do_frontend();
35
  }
36
 
37
- add_action('rest_api_init', [$this, 'register_routes']);
38
  add_action('admin_init', [$this, 'do_optimize']);
 
 
 
 
 
39
  add_filter('content_url', [$this, 'rewrite_url'], 10, 2);
 
 
 
 
 
 
40
  }
41
 
42
  /**
@@ -190,6 +200,33 @@ class OMGF
190
  return new OMGF_Optimize();
191
  }
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  /**
194
  * @param $url
195
  * @param $path
@@ -209,13 +246,13 @@ class OMGF
209
  * If Relative URLs is enabled, overwrite URL with Path and continue execution.
210
  */
211
  if (OMGF_RELATIVE_URL) {
212
- $content_dir = str_replace(site_url(), '', content_url());
213
 
214
  $url = $content_dir . $path;
215
  }
216
 
217
  if (OMGF_CDN_URL) {
218
- $url = str_replace(site_url(), OMGF_CDN_URL, $url);
219
  }
220
 
221
  if (OMGF_CACHE_URI) {
@@ -225,6 +262,35 @@ class OMGF
225
  return $url;
226
  }
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  /**
229
  * @return OMGF_Uninstall
230
  * @throws ReflectionException
34
  $this->do_frontend();
35
  }
36
 
 
37
  add_action('admin_init', [$this, 'do_optimize']);
38
+ add_action('rest_api_init', [$this, 'register_routes']);
39
+
40
+ /**
41
+ * Proper rewrite URLs
42
+ */
43
  add_filter('content_url', [$this, 'rewrite_url'], 10, 2);
44
+ add_filter('content_url', [$this, 'force_ssl'], 1000, 2);
45
+
46
+ /**
47
+ * Render plugin update messages.
48
+ */
49
+ add_action('in_plugin_update_message-' . OMGF_PLUGIN_BASENAME, [$this, 'render_update_notice'], 11, 2);
50
  }
51
 
52
  /**
200
  return new OMGF_Optimize();
201
  }
202
 
203
+ /**
204
+ * Render update notices if available.
205
+ *
206
+ * @param mixed $plugin
207
+ * @param mixed $response
208
+ * @return void
209
+ */
210
+ public function render_update_notice($plugin, $response)
211
+ {
212
+ $current_version = $plugin['Version'];
213
+ $new_version = $plugin['new_version'];
214
+
215
+ if (version_compare($current_version, $new_version, '<')) {
216
+ $response = wp_remote_get('https://daan.dev/omgf-update-notices.json');
217
+ $update_notices = (array) json_decode(wp_remote_retrieve_body($response));
218
+
219
+ if (!isset($update_notices[$new_version])) {
220
+ return;
221
+ }
222
+
223
+ printf(
224
+ ' <strong>' . __('This update includes major changes, please <a href="%s" target="_blank">read this</a> before continuing.') . '</strong>',
225
+ $update_notices[$new_version]->url
226
+ );
227
+ }
228
+ }
229
+
230
  /**
231
  * @param $url
232
  * @param $path
246
  * If Relative URLs is enabled, overwrite URL with Path and continue execution.
247
  */
248
  if (OMGF_RELATIVE_URL) {
249
+ $content_dir = str_replace(home_url(), '', content_url());
250
 
251
  $url = $content_dir . $path;
252
  }
253
 
254
  if (OMGF_CDN_URL) {
255
+ $url = str_replace(home_url(), OMGF_CDN_URL, $url);
256
  }
257
 
258
  if (OMGF_CACHE_URI) {
262
  return $url;
263
  }
264
 
265
+ /**
266
+ * content_url() uses is_ssl() to detect whether SSL is used. This fails for servers behind
267
+ * load balancers and/or reverse proxies. So, we double check with this filter.
268
+ *
269
+ * @since v4.4.4
270
+ *
271
+ * @param mixed $url
272
+ * @param mixed $path
273
+ * @return mixed
274
+ */
275
+ public function force_ssl($url, $path)
276
+ {
277
+ /**
278
+ * Only rewrite URLs requested by this plugin. We don't want to interfere with other plugins.
279
+ */
280
+ if (strpos($url, OMGF_CACHE_PATH) === false) {
281
+ return $url;
282
+ }
283
+
284
+ /**
285
+ * If the user entered https:// in the Home URL option, it's safe to assume that SSL is used.
286
+ */
287
+ if (!is_ssl() && strpos(home_url(), 'https://') !== false) {
288
+ $url = str_replace('http://', 'https://', $url);
289
+ }
290
+
291
+ return $url;
292
+ }
293
+
294
  /**
295
  * @return OMGF_Uninstall
296
  * @throws ReflectionException
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.7
6
- Stable tag: 4.4.3
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -123,6 +123,10 @@ No, not yet. But I will definitely try to make it compatible in the future!
123
 
124
  == Changelog ==
125
 
 
 
 
 
126
  = 4.4.3 =
127
  * Fixed a few warnings/notices.
128
  * Re-worded some options and option descriptions.
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.7
6
+ Stable tag: 4.4.4
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
123
 
124
  == Changelog ==
125
 
126
+ = 4.4.4 =
127
+ * Fixed logo for Safari compatibility.
128
+ * Added updaten notices for future important updates.
129
+
130
  = 4.4.3 =
131
  * Fixed a few warnings/notices.
132
  * Re-worded some options and option descriptions.