Version Description
| March 6th, 2021 = * Tested with WP 5.7 * [FIX] All fonts would be loaded, when all fonts of one font-family were checked for unloading. * [FIX] Fixed some notices and warnings. * Added compatibility for OMGF Pro's Early Access compatibility. * OMGF's admin JS is now only loaded on OMGF's settings screens. * [FIX] Fixed bug where Italic 400 fonts couldn't be unloaded.
Download this release
Release Info
Developer | DaanvandenBergh |
Plugin | OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy. |
Version | 4.2.6 |
Comparing to | |
See all releases |
Code changes from version 4.2.5 to 4.2.6
host-webfonts-local.php
CHANGED
@@ -5,8 +5,8 @@
|
|
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.2.
|
9 |
-
* Author: Daan
|
10 |
* Author URI: https://ffw.press
|
11 |
* License: GPL2v2 or later
|
12 |
* Text Domain: host-webfonts-local
|
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.2.6
|
9 |
+
* Author: Daan from FFW.Press
|
10 |
* Author URI: https://ffw.press
|
11 |
* License: GPL2v2 or later
|
12 |
* Text Domain: host-webfonts-local
|
includes/admin/settings/class-detection.php
CHANGED
@@ -32,8 +32,8 @@ class OMGF_Admin_Settings_Detection extends OMGF_Admin_Settings_Builder
|
|
32 |
// Settings
|
33 |
add_filter('omgf_detection_settings_content', [$this, 'do_process_google_fonts'], 30);
|
34 |
add_filter('omgf_detection_settings_content', [$this, 'do_promo_advanced_processing'], 40);
|
35 |
-
add_filter('omgf_detection_settings_content', [$this, 'do_promo_fonts_processing'],
|
36 |
-
add_filter('omgf_detection_settings_content', [$this, 'do_promo_process_resource_hints'],
|
37 |
|
38 |
// Close
|
39 |
add_filter('omgf_detection_settings_content', [$this, 'do_after'], 100);
|
@@ -105,6 +105,10 @@ class OMGF_Admin_Settings_Detection extends OMGF_Admin_Settings_Builder
|
|
105 |
'omgf_pro_process_webfont_loader' => [
|
106 |
'label' => __('Process Webfont Loader', $this->plugin_text_domain),
|
107 |
'description' => __('Process <code>webfont.js</code> libraries and the corresponding configuration defining which Google Fonts to load.', $this->plugin_text_domain)
|
|
|
|
|
|
|
|
|
108 |
]
|
109 |
];
|
110 |
}
|
@@ -118,7 +122,7 @@ class OMGF_Admin_Settings_Detection extends OMGF_Admin_Settings_Builder
|
|
118 |
__('Advanced Processing (Pro)', $this->plugin_text_domain),
|
119 |
'omgf_pro_advanced_processing',
|
120 |
defined('OMGF_PRO_ADVANCED_PROCESSING') ? OMGF_PRO_ADVANCED_PROCESSING : false,
|
121 |
-
__('By default, OMGF scans for Google Fonts which are registered/enqueued
|
122 |
true
|
123 |
);
|
124 |
}
|
32 |
// Settings
|
33 |
add_filter('omgf_detection_settings_content', [$this, 'do_process_google_fonts'], 30);
|
34 |
add_filter('omgf_detection_settings_content', [$this, 'do_promo_advanced_processing'], 40);
|
35 |
+
add_filter('omgf_detection_settings_content', [$this, 'do_promo_fonts_processing'], 60);
|
36 |
+
add_filter('omgf_detection_settings_content', [$this, 'do_promo_process_resource_hints'], 70);
|
37 |
|
38 |
// Close
|
39 |
add_filter('omgf_detection_settings_content', [$this, 'do_after'], 100);
|
105 |
'omgf_pro_process_webfont_loader' => [
|
106 |
'label' => __('Process Webfont Loader', $this->plugin_text_domain),
|
107 |
'description' => __('Process <code>webfont.js</code> libraries and the corresponding configuration defining which Google Fonts to load.', $this->plugin_text_domain)
|
108 |
+
],
|
109 |
+
'omgf_pro_process_early_access' => [
|
110 |
+
'label' => __('Process Early Access', $this->plugin_text_domain),
|
111 |
+
'description' => __('Process stylesheets loaded from <code>fonts.googleapis.com/earlyaccess</code> or <code>fonts.gstatic.com/ea</code>.', $this->plugin_text_domain)
|
112 |
]
|
113 |
];
|
114 |
}
|
122 |
__('Advanced Processing (Pro)', $this->plugin_text_domain),
|
123 |
'omgf_pro_advanced_processing',
|
124 |
defined('OMGF_PRO_ADVANCED_PROCESSING') ? OMGF_PRO_ADVANCED_PROCESSING : false,
|
125 |
+
__('By default, OMGF scans for Google Fonts which are registered/enqueued using the <code>wp_enqueue_scripts()</code> action in WordPress\' header (<code>wp_head()</code>). Enabling this option will process all Google Fonts throughout the entire document. This setting can be fine-tuned using the settings below.', $this->plugin_text_domain) . ' ' . $this->promo,
|
126 |
true
|
127 |
);
|
128 |
}
|
includes/admin/settings/class-optimize.php
CHANGED
@@ -177,7 +177,7 @@ class OMGF_Admin_Settings_Optimize extends OMGF_Admin_Settings_Builder
|
|
177 |
?>
|
178 |
<tbody class="stylesheet" id="<?= $handle; ?>">
|
179 |
<?php foreach ($fonts as $font) : ?>
|
180 |
-
<?php if (count($font->variants) <= 0) continue; ?>
|
181 |
<th><?= $font->family; ?> <span class="handle">(<?= $handle; ?>)</span></th>
|
182 |
<?php foreach ($font->variants as $variant) : ?>
|
183 |
<tr>
|
177 |
?>
|
178 |
<tbody class="stylesheet" id="<?= $handle; ?>">
|
179 |
<?php foreach ($fonts as $font) : ?>
|
180 |
+
<?php if (count((array) $font->variants) <= 0) continue; ?>
|
181 |
<th><?= $font->family; ?> <span class="handle">(<?= $handle; ?>)</span></th>
|
182 |
<?php foreach ($font->variants as $variant) : ?>
|
183 |
<tr>
|
includes/api/class-download.php
CHANGED
@@ -37,6 +37,9 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
37 |
/** @var string */
|
38 |
private $path = '';
|
39 |
|
|
|
|
|
|
|
40 |
public function register_routes()
|
41 |
{
|
42 |
foreach ($this->endpoints as $endpoint) {
|
@@ -77,11 +80,10 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
77 |
$original_handle = $request->get_param('original_handle');
|
78 |
|
79 |
if (!$this->handle || !$original_handle) {
|
80 |
-
|
81 |
}
|
82 |
|
83 |
$this->path = WP_CONTENT_DIR . OMGF_CACHE_PATH . '/' . $this->handle;
|
84 |
-
$url = self::OMGF_GOOGLE_FONTS_API_URL . '/api/fonts/%s';
|
85 |
$font_families = explode('|', $params['family']);
|
86 |
|
87 |
if (defined('OMGF_PRO_FORCE_SUBSETS') && !empty(OMGF_PRO_FORCE_SUBSETS)) {
|
@@ -93,30 +95,30 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
93 |
$fonts = [];
|
94 |
|
95 |
foreach ($font_families as $font_family) {
|
96 |
-
$fonts[] = $this->grab_font_family($font_family, $
|
97 |
}
|
98 |
|
99 |
-
// Filter out empty
|
100 |
$fonts = array_filter($fonts);
|
101 |
|
102 |
foreach ($fonts as $font_key => &$font) {
|
103 |
-
$
|
104 |
|
105 |
-
list($family, $variants) = explode(':', $
|
106 |
|
107 |
-
$variants = $this->
|
108 |
|
109 |
if ($unloaded_fonts = omgf_init()::unloaded_fonts()) {
|
110 |
$font_id = $font->id;
|
111 |
|
112 |
// Now we're sure we got 'em all. We can safely unload those we don't want.
|
113 |
if (isset($unloaded_fonts[$original_handle][$font_id])) {
|
114 |
-
$variants
|
115 |
-
$
|
116 |
}
|
117 |
}
|
118 |
|
119 |
-
$font->variants = $this->filter_variants($font->variants, $
|
120 |
}
|
121 |
|
122 |
foreach ($fonts as &$font) {
|
@@ -151,13 +153,12 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
151 |
|
152 |
update_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS, $optimized_fonts);
|
153 |
|
154 |
-
// After
|
155 |
header('Content-Type: text/css');
|
156 |
-
header('Content-Transfer-Encoding: Binary');
|
157 |
header('Content-Length: ' . filesize($local_file));
|
158 |
flush();
|
159 |
readfile($local_file);
|
160 |
-
|
161 |
}
|
162 |
|
163 |
/**
|
@@ -167,7 +168,7 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
167 |
*
|
168 |
* @return array
|
169 |
*/
|
170 |
-
private function
|
171 |
{
|
172 |
return array_filter(
|
173 |
$variants,
|
@@ -177,6 +178,11 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
177 |
return !in_array('regular', $unloaded_fonts[$font_id]) && !in_array($value, $unloaded_fonts[$font_id]);
|
178 |
}
|
179 |
|
|
|
|
|
|
|
|
|
|
|
180 |
return !in_array($value, $unloaded_fonts[$font_id]);
|
181 |
}
|
182 |
);
|
@@ -235,13 +241,33 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
235 |
*
|
236 |
* @return mixed|void
|
237 |
*/
|
238 |
-
private function grab_font_family($font_family, $
|
239 |
{
|
|
|
|
|
240 |
list($family, $variants) = explode(':', $font_family);
|
241 |
$family = strtolower(str_replace(' ', '-', $family));
|
242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
$response = wp_remote_get(
|
244 |
-
sprintf($url, $family) .
|
245 |
);
|
246 |
|
247 |
$response_code = $response['response']['code'] ?? '';
|
@@ -270,11 +296,15 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
270 |
*
|
271 |
* @return mixed
|
272 |
*/
|
273 |
-
private function
|
274 |
{
|
275 |
$font_request = array_filter(
|
276 |
$font_families,
|
277 |
function ($value) use ($font) {
|
|
|
|
|
|
|
|
|
278 |
return strpos($value, $font->family) !== false;
|
279 |
}
|
280 |
);
|
@@ -283,43 +313,54 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
283 |
}
|
284 |
|
285 |
/**
|
286 |
-
* @param $
|
287 |
* @param $font
|
288 |
*
|
289 |
* @return array
|
290 |
*/
|
291 |
-
private function
|
292 |
{
|
293 |
-
$
|
294 |
|
295 |
-
|
296 |
-
|
|
|
|
|
297 |
foreach ($font->variants as $variant) {
|
298 |
-
$
|
299 |
}
|
300 |
}
|
301 |
|
302 |
-
return $
|
303 |
}
|
304 |
|
305 |
/**
|
306 |
-
*
|
307 |
-
* @param $
|
308 |
-
*
|
309 |
-
* @
|
|
|
|
|
310 |
*/
|
311 |
-
private function filter_variants($
|
312 |
{
|
313 |
list($family, $variants) = explode(':', $wanted);
|
314 |
|
315 |
-
|
316 |
-
|
317 |
-
|
|
|
318 |
|
319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
return array_filter(
|
322 |
-
$
|
323 |
function ($font) use ($variants) {
|
324 |
$id = $font->id;
|
325 |
|
@@ -357,6 +398,10 @@ class OMGF_API_Download extends WP_REST_Controller
|
|
357 |
return content_url($file_uri);
|
358 |
}
|
359 |
|
|
|
|
|
|
|
|
|
360 |
$tmp = download_url($url);
|
361 |
copy($tmp, $file);
|
362 |
@unlink($tmp);
|
37 |
/** @var string */
|
38 |
private $path = '';
|
39 |
|
40 |
+
/**
|
41 |
+
* @return void
|
42 |
+
*/
|
43 |
public function register_routes()
|
44 |
{
|
45 |
foreach ($this->endpoints as $endpoint) {
|
80 |
$original_handle = $request->get_param('original_handle');
|
81 |
|
82 |
if (!$this->handle || !$original_handle) {
|
83 |
+
wp_die(__('Handle not provided.', $this->plugin_text_domain), 406);
|
84 |
}
|
85 |
|
86 |
$this->path = WP_CONTENT_DIR . OMGF_CACHE_PATH . '/' . $this->handle;
|
|
|
87 |
$font_families = explode('|', $params['family']);
|
88 |
|
89 |
if (defined('OMGF_PRO_FORCE_SUBSETS') && !empty(OMGF_PRO_FORCE_SUBSETS)) {
|
95 |
$fonts = [];
|
96 |
|
97 |
foreach ($font_families as $font_family) {
|
98 |
+
$fonts[] = $this->grab_font_family($font_family, $query);
|
99 |
}
|
100 |
|
101 |
+
// Filter out empty elements, i.e. failed requests.
|
102 |
$fonts = array_filter($fonts);
|
103 |
|
104 |
foreach ($fonts as $font_key => &$font) {
|
105 |
+
$fonts_request = $this->build_fonts_request($font_families, $font);
|
106 |
|
107 |
+
list($family, $variants) = explode(':', $fonts_request);
|
108 |
|
109 |
+
$variants = $this->parse_requested_variants($variants, $font);
|
110 |
|
111 |
if ($unloaded_fonts = omgf_init()::unloaded_fonts()) {
|
112 |
$font_id = $font->id;
|
113 |
|
114 |
// Now we're sure we got 'em all. We can safely unload those we don't want.
|
115 |
if (isset($unloaded_fonts[$original_handle][$font_id])) {
|
116 |
+
$variants = $this->dequeue_unloaded_variants($variants, $unloaded_fonts[$original_handle], $font->id);
|
117 |
+
$fonts_request = $family . ':' . implode(',', $variants);
|
118 |
}
|
119 |
}
|
120 |
|
121 |
+
$font->variants = $this->filter_variants($font->id, $font->variants, $fonts_request, $original_handle);
|
122 |
}
|
123 |
|
124 |
foreach ($fonts as &$font) {
|
153 |
|
154 |
update_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS, $optimized_fonts);
|
155 |
|
156 |
+
// After generating it, serve it.
|
157 |
header('Content-Type: text/css');
|
|
|
158 |
header('Content-Length: ' . filesize($local_file));
|
159 |
flush();
|
160 |
readfile($local_file);
|
161 |
+
exit();
|
162 |
}
|
163 |
|
164 |
/**
|
168 |
*
|
169 |
* @return array
|
170 |
*/
|
171 |
+
private function dequeue_unloaded_variants($variants, $unloaded_fonts, $font_id)
|
172 |
{
|
173 |
return array_filter(
|
174 |
$variants,
|
178 |
return !in_array('regular', $unloaded_fonts[$font_id]) && !in_array($value, $unloaded_fonts[$font_id]);
|
179 |
}
|
180 |
|
181 |
+
if ($value == '400italic') {
|
182 |
+
// Sometimes the font is defined as 'italic', so we need to check both.
|
183 |
+
return !in_array('italic', $unloaded_fonts[$font_id]) && !in_array($value, $unloaded_fonts[$font_id]);
|
184 |
+
}
|
185 |
+
|
186 |
return !in_array($value, $unloaded_fonts[$font_id]);
|
187 |
}
|
188 |
);
|
241 |
*
|
242 |
* @return mixed|void
|
243 |
*/
|
244 |
+
private function grab_font_family($font_family, $query)
|
245 |
{
|
246 |
+
$url = self::OMGF_GOOGLE_FONTS_API_URL . '/api/fonts/%s';
|
247 |
+
|
248 |
list($family, $variants) = explode(':', $font_family);
|
249 |
$family = strtolower(str_replace(' ', '-', $family));
|
250 |
|
251 |
+
/**
|
252 |
+
* Add fonts to the request's $_GET 'family' parameter. Then pass an array to 'omgf_alternate_fonts'
|
253 |
+
* filter. Then pass an alternate API url to the 'omgf_alternate_api_url' filter to fetch fonts from
|
254 |
+
* an alternate API.
|
255 |
+
*/
|
256 |
+
$alternate_fonts = apply_filters('omgf_alternate_fonts', []);
|
257 |
+
|
258 |
+
if (in_array($family, array_keys($alternate_fonts))) {
|
259 |
+
$url = apply_filters('omgf_alternate_api_url', $url);
|
260 |
+
unset($query);
|
261 |
+
}
|
262 |
+
|
263 |
+
$query_string = '';
|
264 |
+
|
265 |
+
if ($query) {
|
266 |
+
$query_string = '?' . http_build_query($query);
|
267 |
+
}
|
268 |
+
|
269 |
$response = wp_remote_get(
|
270 |
+
sprintf($url, $family) . $query_string
|
271 |
);
|
272 |
|
273 |
$response_code = $response['response']['code'] ?? '';
|
296 |
*
|
297 |
* @return mixed
|
298 |
*/
|
299 |
+
private function build_fonts_request($font_families, $font)
|
300 |
{
|
301 |
$font_request = array_filter(
|
302 |
$font_families,
|
303 |
function ($value) use ($font) {
|
304 |
+
if (isset($font->early_access)) {
|
305 |
+
return strpos($value, strtolower(str_replace(' ', '', $font->family))) !== false;
|
306 |
+
}
|
307 |
+
|
308 |
return strpos($value, $font->family) !== false;
|
309 |
}
|
310 |
);
|
313 |
}
|
314 |
|
315 |
/**
|
316 |
+
* @param $request
|
317 |
* @param $font
|
318 |
*
|
319 |
* @return array
|
320 |
*/
|
321 |
+
private function parse_requested_variants($request, $font)
|
322 |
{
|
323 |
+
$requested_variants = array_filter(explode(',', $request));
|
324 |
|
325 |
+
/**
|
326 |
+
* This means by default all fonts are requested, so we need to fill up the queue, before unloading the unwanted variants.
|
327 |
+
*/
|
328 |
+
if (count($requested_variants) == 0) {
|
329 |
foreach ($font->variants as $variant) {
|
330 |
+
$requested_variants[] = $variant->id;
|
331 |
}
|
332 |
}
|
333 |
|
334 |
+
return $requested_variants;
|
335 |
}
|
336 |
|
337 |
/**
|
338 |
+
*
|
339 |
+
* @param mixed $font_id
|
340 |
+
* @param mixed $available
|
341 |
+
* @param mixed $wanted
|
342 |
+
* @param mixed $stylesheet_handle
|
343 |
+
* @return mixed
|
344 |
*/
|
345 |
+
private function filter_variants($font_id, $available, $wanted, $stylesheet_handle)
|
346 |
{
|
347 |
list($family, $variants) = explode(':', $wanted);
|
348 |
|
349 |
+
/**
|
350 |
+
* Build array and filter out empty elements.
|
351 |
+
*/
|
352 |
+
$variants = array_filter(explode(',', $variants));
|
353 |
|
354 |
+
/**
|
355 |
+
* If $variants is empty and this is the first run, i.e. there are no unloaded fonts (yet)
|
356 |
+
* return all available variants.
|
357 |
+
*/
|
358 |
+
if (empty($variants) && !isset(omgf::unloaded_fonts()[$stylesheet_handle][$font_id])) {
|
359 |
+
return $available;
|
360 |
+
}
|
361 |
|
362 |
return array_filter(
|
363 |
+
$available,
|
364 |
function ($font) use ($variants) {
|
365 |
$id = $font->id;
|
366 |
|
398 |
return content_url($file_uri);
|
399 |
}
|
400 |
|
401 |
+
if (strpos($url, '//') == 0) {
|
402 |
+
$url = 'https:' . $url;
|
403 |
+
}
|
404 |
+
|
405 |
$tmp = download_url($url);
|
406 |
copy($tmp, $file);
|
407 |
@unlink($tmp);
|
includes/class-admin.php
CHANGED
@@ -64,8 +64,10 @@ class OMGF_Admin
|
|
64 |
*/
|
65 |
public function enqueue_admin_scripts($hook)
|
66 |
{
|
67 |
-
|
68 |
-
|
|
|
|
|
69 |
}
|
70 |
|
71 |
/**
|
64 |
*/
|
65 |
public function enqueue_admin_scripts($hook)
|
66 |
{
|
67 |
+
if ($hook == 'settings_page_optimize-webfonts') {
|
68 |
+
wp_enqueue_script(self::OMGF_ADMIN_JS_HANDLE, plugin_dir_url(OMGF_PLUGIN_FILE) . 'assets/js/omgf-admin.js', ['jquery'], OMGF_STATIC_VERSION, true);
|
69 |
+
wp_enqueue_style(self::OMGF_ADMIN_CSS_HANDLE, plugin_dir_url(OMGF_PLUGIN_FILE) . 'assets/css/omgf-admin.css', [], OMGF_STATIC_VERSION);
|
70 |
+
}
|
71 |
}
|
72 |
|
73 |
/**
|
includes/class-omgf.php
CHANGED
@@ -68,7 +68,7 @@ class OMGF
|
|
68 |
static $optimized_fonts = [];
|
69 |
|
70 |
if (empty($optimized_fonts)) {
|
71 |
-
$optimized_fonts = get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS, []);
|
72 |
}
|
73 |
|
74 |
return $optimized_fonts;
|
@@ -82,7 +82,7 @@ class OMGF
|
|
82 |
static $preloaded_fonts = [];
|
83 |
|
84 |
if (empty($preloaded_fonts)) {
|
85 |
-
$preloaded_fonts = get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_PRELOAD_FONTS, []);
|
86 |
}
|
87 |
|
88 |
return $preloaded_fonts;
|
@@ -96,7 +96,7 @@ class OMGF
|
|
96 |
static $unloaded_fonts = [];
|
97 |
|
98 |
if (empty($unloaded_fonts)) {
|
99 |
-
$unloaded_fonts = get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_UNLOAD_FONTS, []);
|
100 |
}
|
101 |
|
102 |
return $unloaded_fonts;
|
68 |
static $optimized_fonts = [];
|
69 |
|
70 |
if (empty($optimized_fonts)) {
|
71 |
+
$optimized_fonts = get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS, []) ?: [];
|
72 |
}
|
73 |
|
74 |
return $optimized_fonts;
|
82 |
static $preloaded_fonts = [];
|
83 |
|
84 |
if (empty($preloaded_fonts)) {
|
85 |
+
$preloaded_fonts = get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_PRELOAD_FONTS, []) ?: [];
|
86 |
}
|
87 |
|
88 |
return $preloaded_fonts;
|
96 |
static $unloaded_fonts = [];
|
97 |
|
98 |
if (empty($unloaded_fonts)) {
|
99 |
+
$unloaded_fonts = get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_UNLOAD_FONTS, []) ?: [];
|
100 |
}
|
101 |
|
102 |
return $unloaded_fonts;
|
includes/frontend/class-functions.php
CHANGED
@@ -74,7 +74,7 @@ class OMGF_Frontend_Functions
|
|
74 |
|
75 |
$font_id = $font->id;
|
76 |
$preload_variants = array_filter(
|
77 |
-
$font->variants,
|
78 |
function ($variant) use ($preloads_stylesheet, $font_id) {
|
79 |
return in_array($variant->id, $preloads_stylesheet[$font_id]);
|
80 |
}
|
74 |
|
75 |
$font_id = $font->id;
|
76 |
$preload_variants = array_filter(
|
77 |
+
(array) $font->variants,
|
78 |
function ($variant) use ($preloads_stylesheet, $font_id) {
|
79 |
return in_array($variant->id, $preloads_stylesheet[$font_id]);
|
80 |
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
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.
|
6 |
-
Stable tag: 4.2.
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -44,8 +44,9 @@ Please keep in mind that, although I try to make the configuration of this plugi
|
|
44 |
= Features in the PRO version =
|
45 |
Everything in the free version, plus:
|
46 |
- Automatically remove/replace all Google Fonts throughout the entire document/page,
|
47 |
-
-
|
48 |
-
-
|
|
|
49 |
- Reduce loading time and page size, by forcing the used subset(s) for all Google Fonts requests,
|
50 |
- Remove Resource Hints (preload, preconnect, dns-prefetch) pointing to fonts.googleapis.com or fonts.gstatic.com.
|
51 |
|
@@ -122,6 +123,14 @@ No, not yet. But I will definitely try to make it compatible in the future!
|
|
122 |
|
123 |
== Changelog ==
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
= 4.2.5 | January 27th, 2021 =
|
126 |
* Improved compatibility with WordPress subdirectory installs.
|
127 |
* Implemented some actions/filters needed for upcoming release of OMGF Additional Fonts.
|
2 |
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.2.6
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
44 |
= Features in the PRO version =
|
45 |
Everything in the free version, plus:
|
46 |
- Automatically remove/replace all Google Fonts throughout the entire document/page,
|
47 |
+
- Also supports WebFont Loader (webfont.js) and Early Access Google Fonts.
|
48 |
+
- Combine all Google Fonts (made by your theme and/or plugins) stylesheets into one file,
|
49 |
+
- Deduplicate Google Fonts stylesheets,
|
50 |
- Reduce loading time and page size, by forcing the used subset(s) for all Google Fonts requests,
|
51 |
- Remove Resource Hints (preload, preconnect, dns-prefetch) pointing to fonts.googleapis.com or fonts.gstatic.com.
|
52 |
|
123 |
|
124 |
== Changelog ==
|
125 |
|
126 |
+
= 4.2.6 | March 6th, 2021 =
|
127 |
+
* Tested with WP 5.7
|
128 |
+
* [FIX] All fonts would be loaded, when all fonts of one font-family were checked for unloading.
|
129 |
+
* [FIX] Fixed some notices and warnings.
|
130 |
+
* Added compatibility for OMGF Pro's Early Access compatibility.
|
131 |
+
* OMGF's admin JS is now only loaded on OMGF's settings screens.
|
132 |
+
* [FIX] Fixed bug where Italic 400 fonts couldn't be unloaded.
|
133 |
+
|
134 |
= 4.2.5 | January 27th, 2021 =
|
135 |
* Improved compatibility with WordPress subdirectory installs.
|
136 |
* Implemented some actions/filters needed for upcoming release of OMGF Additional Fonts.
|