Version Description
Added error handling for API-calls.
Download this release
Release Info
Developer | DaanvandenBergh |
Plugin | OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy. |
Version | 3.3.3 |
Comparing to | |
See all releases |
Code changes from version 3.3.2 to 3.3.3
- host-webfonts-local.php +1 -1
- includes/admin/class-settings.php +14 -1
- includes/class-api.php +13 -4
- readme.txt +9 -3
host-webfonts-local.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: OMGF
|
5 |
* Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
|
6 |
* Description: Minimize DNS requests and leverage browser cache by easily saving Google Fonts to your server and removing the external Google Fonts.
|
7 |
-
* Version: 3.3.
|
8 |
* Author: Daan van den Bergh
|
9 |
* Author URI: https://daan.dev
|
10 |
* License: GPL2v2 or later
|
4 |
* Plugin Name: OMGF
|
5 |
* Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
|
6 |
* Description: Minimize DNS requests and leverage browser cache by easily saving Google Fonts to your server and removing the external Google Fonts.
|
7 |
+
* Version: 3.3.3
|
8 |
* Author: Daan van den Bergh
|
9 |
* Author URI: https://daan.dev
|
10 |
* License: GPL2v2 or later
|
includes/admin/class-settings.php
CHANGED
@@ -61,20 +61,32 @@ class OMGF_Admin_Settings extends OMGF_Admin
|
|
61 |
/** @var string $active_tab */
|
62 |
private $active_tab;
|
63 |
|
|
|
|
|
|
|
64 |
/**
|
65 |
* OMGF_Admin_Settings constructor.
|
66 |
*/
|
67 |
public function __construct()
|
68 |
{
|
69 |
$this->active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'generate-stylesheet';
|
|
|
70 |
|
71 |
// @formatter:off
|
72 |
add_action('admin_menu', [$this, 'create_menu']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
add_action('omgf_settings_tab', [$this, 'generate_stylesheet_tab'], 1);
|
74 |
add_action('omgf_settings_tab', [$this, 'advanced_settings_tab'], 2);
|
|
|
|
|
75 |
add_action('omgf_settings_content', [$this, 'generate_stylesheet_content'], 1);
|
76 |
add_action('omgf_settings_content', [$this, 'advanced_settings_content'], 2);
|
77 |
-
add_filter('plugin_action_links_' . plugin_basename(OMGF_PLUGIN_FILE), [$this, 'create_settings_link']);
|
78 |
// @formatter:on
|
79 |
|
80 |
parent::__construct();
|
@@ -95,6 +107,7 @@ class OMGF_Admin_Settings extends OMGF_Admin
|
|
95 |
'create_settings_page'
|
96 |
)
|
97 |
);
|
|
|
98 |
// @formatter:off
|
99 |
add_action('admin_init', array($this, 'register_settings'));
|
100 |
// @formatter:on
|
61 |
/** @var string $active_tab */
|
62 |
private $active_tab;
|
63 |
|
64 |
+
/** @var string $page */
|
65 |
+
private $page;
|
66 |
+
|
67 |
/**
|
68 |
* OMGF_Admin_Settings constructor.
|
69 |
*/
|
70 |
public function __construct()
|
71 |
{
|
72 |
$this->active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'generate-stylesheet';
|
73 |
+
$this->page = isset($_GET['page']) ? $_GET['page'] : '';
|
74 |
|
75 |
// @formatter:off
|
76 |
add_action('admin_menu', [$this, 'create_menu']);
|
77 |
+
add_filter('plugin_action_links_' . plugin_basename(OMGF_PLUGIN_FILE), [$this, 'create_settings_link']);
|
78 |
+
|
79 |
+
if (!$this->page == 'optimize-webfonts') {
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
|
83 |
+
// Tabs
|
84 |
add_action('omgf_settings_tab', [$this, 'generate_stylesheet_tab'], 1);
|
85 |
add_action('omgf_settings_tab', [$this, 'advanced_settings_tab'], 2);
|
86 |
+
|
87 |
+
// Content
|
88 |
add_action('omgf_settings_content', [$this, 'generate_stylesheet_content'], 1);
|
89 |
add_action('omgf_settings_content', [$this, 'advanced_settings_content'], 2);
|
|
|
90 |
// @formatter:on
|
91 |
|
92 |
parent::__construct();
|
107 |
'create_settings_page'
|
108 |
)
|
109 |
);
|
110 |
+
|
111 |
// @formatter:off
|
112 |
add_action('admin_init', array($this, 'register_settings'));
|
113 |
// @formatter:on
|
includes/class-api.php
CHANGED
@@ -25,13 +25,17 @@ class OMGF_API
|
|
25 |
*/
|
26 |
public function get_subsets($query)
|
27 |
{
|
28 |
-
$request
|
|
|
|
|
|
|
|
|
29 |
|
30 |
if ($request == 'Not found') {
|
31 |
return [];
|
32 |
}
|
33 |
|
34 |
-
$result
|
35 |
|
36 |
return [
|
37 |
'subset_family' => $result->family,
|
@@ -49,8 +53,13 @@ class OMGF_API
|
|
49 |
*/
|
50 |
public function get_font_styles($font_family, $selected_subsets)
|
51 |
{
|
52 |
-
$request
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
foreach ($result->variants as $variant) {
|
56 |
$fonts[] = [
|
25 |
*/
|
26 |
public function get_subsets($query)
|
27 |
{
|
28 |
+
$request = wp_remote_get(OMGF_HELPER_URL . $query);
|
29 |
+
|
30 |
+
if (is_wp_error($request)) {
|
31 |
+
OMGF_Admin_Notice::set_notice($request->get_error_message(), true, 'error', $request->get_error_code());
|
32 |
+
}
|
33 |
|
34 |
if ($request == 'Not found') {
|
35 |
return [];
|
36 |
}
|
37 |
|
38 |
+
$result = json_decode($request['body']);
|
39 |
|
40 |
return [
|
41 |
'subset_family' => $result->family,
|
53 |
*/
|
54 |
public function get_font_styles($font_family, $selected_subsets)
|
55 |
{
|
56 |
+
$request = wp_remote_get(OMGF_HELPER_URL . $font_family . '?subsets=' . $selected_subsets);
|
57 |
+
|
58 |
+
if (is_wp_error($request)) {
|
59 |
+
OMGF_Admin_Notice::set_notice($request->get_error_message(), true, 'error', $request->get_error_code());
|
60 |
+
}
|
61 |
+
|
62 |
+
$result = json_decode($request['body']);
|
63 |
|
64 |
foreach ($result->variants as $variant) {
|
65 |
$fonts[] = [
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== OMGF | Host Google Fonts Locally ===
|
2 |
Contributors: DaanvandenBergh
|
3 |
-
Tags: google, fonts, preload, font-display, webfonts, subsets, remove, minimize, external, requests
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 5.4
|
6 |
-
Stable tag: 3.3.
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -12,7 +12,10 @@ With only 2 clicks of a button, OMGF automagically downloads your Google Fonts y
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
OMGF is written with performance and user-friendliness in mind. It uses the Google Fonts Helper API to automagically download the fonts you want to WordPress' contents folder and generate a stylesheet for it. The stylesheet is automatically included to your site's header and 100% compatible with CSS and JS optimizing/minification plugins like Autoptimize or W3 Total Cache. OMGF can efficiently remove any requests to external Google Fonts (loaded from fonts.gstatic.com or fonts.googleapies.com).
|
18 |
|
@@ -105,6 +108,9 @@ N/A
|
|
105 |
|
106 |
== Changelog ==
|
107 |
|
|
|
|
|
|
|
108 |
= 3.3.2 =
|
109 |
* Auto Detect is now compatible with Newspaper theme.
|
110 |
|
1 |
=== OMGF | Host Google Fonts Locally ===
|
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.4
|
6 |
+
Stable tag: 3.3.3
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
> How could using fonts via Google's service possibly run afoul of GDPR? The fact of the matter is that, when a font is requested by the user's browser, their IP is logged by Google and used for analytics.
|
16 |
+
> — Lifehacker
|
17 |
+
|
18 |
+
Leverage Browser Cache, Minimize DNS requests and serve your Google Fonts in a 100% GDPR compliant way with OMGF!
|
19 |
|
20 |
OMGF is written with performance and user-friendliness in mind. It uses the Google Fonts Helper API to automagically download the fonts you want to WordPress' contents folder and generate a stylesheet for it. The stylesheet is automatically included to your site's header and 100% compatible with CSS and JS optimizing/minification plugins like Autoptimize or W3 Total Cache. OMGF can efficiently remove any requests to external Google Fonts (loaded from fonts.gstatic.com or fonts.googleapies.com).
|
21 |
|
108 |
|
109 |
== Changelog ==
|
110 |
|
111 |
+
= 3.3.3 =
|
112 |
+
Added error handling for API-calls.
|
113 |
+
|
114 |
= 3.3.2 =
|
115 |
* Auto Detect is now compatible with Newspaper theme.
|
116 |
|