Version Description
- Fixed: Use Site Address (URL) to run first optimization scan, instead of WordPress Address (URL), because the WordPress install URL can differ from the frontend URL.
- Fixed: Make sure stylesheet URL is properly decoded and HTML entities, etc. are removed, before attempting to process it. (This would cause parameters, like
subset
ordisplay
, to get lost). - Added: omgf_optimize_query_subset filter to OMGF_Optimize class.
Download this release
Release Info
Developer | DaanvandenBergh |
Plugin | OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy. |
Version | 5.0.2 |
Comparing to | |
See all releases |
Code changes from version 5.0.1 to 5.0.2
- host-webfonts-local.php +1 -1
- includes/frontend/class-process.php +41 -26
- includes/optimize/class-run.php +1 -1
- readme.txt +6 -1
host-webfonts-local.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: OMGF
|
5 |
* Plugin URI: https://ffw.press/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.0.
|
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://ffw.press/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.0.2
|
8 |
* Author: Daan from FFW.Press
|
9 |
* Author URI: https://ffw.press
|
10 |
* License: GPL2v2 or later
|
includes/frontend/class-process.php
CHANGED
@@ -199,6 +199,8 @@ class OMGF_Frontend_Process
|
|
199 |
* @since v5.0.0 Tested with:
|
200 |
* - Cache Enabler v1.8.7
|
201 |
* - Default Settings
|
|
|
|
|
202 |
* - LiteSpeed Cache
|
203 |
* - Don't know (Gal Baras tested it: @see https://wordpress.org/support/topic/completely-broke-wp-rocket-plugin/#post-15377538)
|
204 |
* - W3 Total Cache v2.2.1:
|
@@ -216,7 +218,6 @@ class OMGF_Frontend_Process
|
|
216 |
*
|
217 |
* @todo Not tested (yet):
|
218 |
* - Asset Cleanup Pro
|
219 |
-
* - Kinsta Cache (Same as Cache Enabler?)
|
220 |
* - Swift Performance
|
221 |
*
|
222 |
* @return void
|
@@ -313,6 +314,10 @@ class OMGF_Frontend_Process
|
|
313 |
*/
|
314 |
private function strip_css_tag($handle)
|
315 |
{
|
|
|
|
|
|
|
|
|
316 |
$pos = strrpos($handle, '-css');
|
317 |
|
318 |
if ($pos !== false) {
|
@@ -322,6 +327,27 @@ class OMGF_Frontend_Process
|
|
322 |
return $handle;
|
323 |
}
|
324 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
/**
|
326 |
* Build a Search/Replace array for all found Google Fonts.
|
327 |
*
|
@@ -375,25 +401,16 @@ class OMGF_Frontend_Process
|
|
375 |
continue;
|
376 |
}
|
377 |
|
378 |
-
$
|
379 |
-
$api_params = parse_url($api_url);
|
380 |
-
|
381 |
-
parse_str($api_params['query'], $post_query);
|
382 |
-
|
383 |
-
if (isset($api_params['fragment'])) {
|
384 |
-
parse_str($api_params['fragment'], $additional_query);
|
385 |
-
|
386 |
-
$post_query = array_merge($post_query, $additional_query);
|
387 |
-
}
|
388 |
|
389 |
/**
|
390 |
* Required parameters.
|
391 |
*/
|
392 |
-
if (!isset($
|
393 |
continue;
|
394 |
}
|
395 |
|
396 |
-
$optimize = new OMGF_Optimize($
|
397 |
$cached_url = $optimize->process();
|
398 |
|
399 |
if (!$cached_url) {
|
@@ -416,8 +433,10 @@ class OMGF_Frontend_Process
|
|
416 |
*
|
417 |
* @return string
|
418 |
*/
|
419 |
-
public function
|
420 |
{
|
|
|
|
|
421 |
$parsed_url = parse_url($url);
|
422 |
$query = $parsed_url['query'] ?? '';
|
423 |
|
@@ -433,22 +452,18 @@ class OMGF_Frontend_Process
|
|
433 |
*
|
434 |
* Decode, just to be sure.
|
435 |
*/
|
436 |
-
parse_str(
|
437 |
}
|
438 |
|
439 |
-
$params =
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
]
|
446 |
-
)
|
447 |
);
|
448 |
|
449 |
-
|
450 |
-
|
451 |
-
return apply_filters('omgf_request_url', $request);
|
452 |
}
|
453 |
|
454 |
/**
|
199 |
* @since v5.0.0 Tested with:
|
200 |
* - Cache Enabler v1.8.7
|
201 |
* - Default Settings
|
202 |
+
* - Kinsta Cache (Same as Cache Enabler?)
|
203 |
+
* - Works on ffw.press
|
204 |
* - LiteSpeed Cache
|
205 |
* - Don't know (Gal Baras tested it: @see https://wordpress.org/support/topic/completely-broke-wp-rocket-plugin/#post-15377538)
|
206 |
* - W3 Total Cache v2.2.1:
|
218 |
*
|
219 |
* @todo Not tested (yet):
|
220 |
* - Asset Cleanup Pro
|
|
|
221 |
* - Swift Performance
|
222 |
*
|
223 |
* @return void
|
314 |
*/
|
315 |
private function strip_css_tag($handle)
|
316 |
{
|
317 |
+
if (!$this->ends_with($handle, '-css')) {
|
318 |
+
return $handle;
|
319 |
+
}
|
320 |
+
|
321 |
$pos = strrpos($handle, '-css');
|
322 |
|
323 |
if ($pos !== false) {
|
327 |
return $handle;
|
328 |
}
|
329 |
|
330 |
+
/**
|
331 |
+
* Checks if a $string ends with $end.
|
332 |
+
*
|
333 |
+
* @since v5.0.2
|
334 |
+
*
|
335 |
+
* @param string $string
|
336 |
+
* @param string $end
|
337 |
+
*
|
338 |
+
* @return bool
|
339 |
+
*/
|
340 |
+
private function ends_with($string, $end)
|
341 |
+
{
|
342 |
+
$len = strlen($end);
|
343 |
+
|
344 |
+
if ($len == 0) {
|
345 |
+
return true;
|
346 |
+
}
|
347 |
+
|
348 |
+
return (substr($string, -$len) === $end);
|
349 |
+
}
|
350 |
+
|
351 |
/**
|
352 |
* Build a Search/Replace array for all found Google Fonts.
|
353 |
*
|
401 |
continue;
|
402 |
}
|
403 |
|
404 |
+
$query = $this->build_query($stack['href'], $handle, $stack['id']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
|
406 |
/**
|
407 |
* Required parameters.
|
408 |
*/
|
409 |
+
if (!isset($query['family']) || !isset($query['handle']) || !isset($query['original_handle'])) {
|
410 |
continue;
|
411 |
}
|
412 |
|
413 |
+
$optimize = new OMGF_Optimize($query['family'], $query['handle'], $query['original_handle'], apply_filters('omgf_optimize_query_subset', $query['subset'] ?? ''));
|
414 |
$cached_url = $optimize->process();
|
415 |
|
416 |
if (!$cached_url) {
|
433 |
*
|
434 |
* @return string
|
435 |
*/
|
436 |
+
public function build_query($url, $updated_handle, $handle)
|
437 |
{
|
438 |
+
// Filter out HTML (&, etc) and URL encoded characters, so we can properly parse it.
|
439 |
+
$url = htmlspecialchars_decode(urldecode($url));
|
440 |
$parsed_url = parse_url($url);
|
441 |
$query = $parsed_url['query'] ?? '';
|
442 |
|
452 |
*
|
453 |
* Decode, just to be sure.
|
454 |
*/
|
455 |
+
parse_str($query, $original_query);
|
456 |
}
|
457 |
|
458 |
+
$params = array_merge(
|
459 |
+
$original_query,
|
460 |
+
[
|
461 |
+
'handle' => $updated_handle,
|
462 |
+
'original_handle' => $handle,
|
463 |
+
]
|
|
|
|
|
464 |
);
|
465 |
|
466 |
+
return apply_filters('omgf_request_url', $params);
|
|
|
|
|
467 |
}
|
468 |
|
469 |
/**
|
includes/optimize/class-run.php
CHANGED
@@ -38,7 +38,7 @@ class OMGF_Optimize_Run
|
|
38 |
*/
|
39 |
private function run()
|
40 |
{
|
41 |
-
$front_html = $this->get_front_html(
|
42 |
$error = false;
|
43 |
|
44 |
if (is_wp_error($front_html) || wp_remote_retrieve_response_code($front_html) != 200) {
|
38 |
*/
|
39 |
private function run()
|
40 |
{
|
41 |
+
$front_html = $this->get_front_html(home_url());
|
42 |
$error = false;
|
43 |
|
44 |
if (is_wp_error($front_html) || wp_remote_retrieve_response_code($front_html) != 200) {
|
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.9
|
6 |
-
Stable tag: 5.0.
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -75,6 +75,11 @@ For the FAQ, [click here](https://docs.ffw.press/category/76-omgf-pro---faq).
|
|
75 |
|
76 |
== Changelog ==
|
77 |
|
|
|
|
|
|
|
|
|
|
|
78 |
= 5.0.1 =
|
79 |
* Fixed: Previous versions of OMGF would save stylesheet handles without the appended '-css' string. This is now brought back to guarantee a smooth transition to v5.
|
80 |
* Fixed: If `?nomgf=1` parameter was set, preloads would still be loaded.
|
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.9
|
6 |
+
Stable tag: 5.0.2
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
75 |
|
76 |
== Changelog ==
|
77 |
|
78 |
+
= 5.0.2 =
|
79 |
+
* Fixed: Use Site Address (URL) to run first optimization scan, instead of WordPress Address (URL), because the WordPress install URL can differ from the frontend URL.
|
80 |
+
* Fixed: Make sure stylesheet URL is properly decoded and HTML entities, etc. are removed, before attempting to process it. (This would cause parameters, like `subset` or `display`, to get lost).
|
81 |
+
* Added: omgf_optimize_query_subset filter to OMGF_Optimize class.
|
82 |
+
|
83 |
= 5.0.1 =
|
84 |
* Fixed: Previous versions of OMGF would save stylesheet handles without the appended '-css' string. This is now brought back to guarantee a smooth transition to v5.
|
85 |
* Fixed: If `?nomgf=1` parameter was set, preloads would still be loaded.
|