Version Description
Download this release
Release Info
Developer | everpress |
Plugin | Local Google Fonts |
Version | 0.20.0 |
Comparing to | |
See all releases |
Code changes from version 0.19 to 0.20.0
- README.md +8 -2
- includes/class-local-google-fonts-parser.php +2 -3
- includes/class-local-google-fonts.php +33 -19
- local-google-fonts.php +1 -1
README.md
CHANGED
@@ -4,7 +4,7 @@ Contributors: everpress, xaverb
|
|
4 |
Tags: googlefonts, google, fonts, gdpr, lgf, font, speed
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 6.1
|
7 |
-
Stable tag: 0.
|
8 |
Requires PHP: 5.6+
|
9 |
License: GPLv2 or later
|
10 |
Donate link: https://evp.to/donate
|
@@ -74,7 +74,7 @@ The plugin currently only checks fonts embedded via [`wp_enqueue_style`](https:/
|
|
74 |
|
75 |
### The Divi theme still loads a Google font?
|
76 |
|
77 |
-
The
|
78 |
|
79 |
### Why only the woff2 font format is loaded?
|
80 |
|
@@ -95,6 +95,12 @@ You may have loaded a subset which doesn't included required characters. Check a
|
|
95 |
|
96 |
## Changelog
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
### 0.19
|
99 |
|
100 |
- please reload fonts manually if you encounter problems after the update
|
4 |
Tags: googlefonts, google, fonts, gdpr, lgf, font, speed
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 6.1
|
7 |
+
Stable tag: 0.20.0
|
8 |
Requires PHP: 5.6+
|
9 |
License: GPLv2 or later
|
10 |
Donate link: https://evp.to/donate
|
74 |
|
75 |
### The Divi theme still loads a Google font?
|
76 |
|
77 |
+
The DIVI theme has a custom implementation of Google Fonts. To use LGF with DIVI disable _Improve Google Fonts Loading_ on the Performance Settings page of DIVI.
|
78 |
|
79 |
### Why only the woff2 font format is loaded?
|
80 |
|
95 |
|
96 |
## Changelog
|
97 |
|
98 |
+
### 0.20.0
|
99 |
+
|
100 |
+
- make sure files are loaded via https if requested
|
101 |
+
- new filter `lgf_folder_url`and `lgf_folder`
|
102 |
+
- always append timestamp to prevent caching
|
103 |
+
|
104 |
### 0.19
|
105 |
|
106 |
- please reload fonts manually if you encounter problems after the update
|
includes/class-local-google-fonts-parser.php
CHANGED
@@ -28,9 +28,8 @@ class LGF_Parser {
|
|
28 |
$result = array();
|
29 |
$this->remote_styles = '';
|
30 |
$this->styles = '';
|
31 |
-
$
|
32 |
-
$
|
33 |
-
$folder_url = $upload_dir['error'] ? WP_CONTENT_URL . '/uploads/fonts' : $upload_dir['baseurl'] . '/fonts';
|
34 |
|
35 |
foreach ( $this->format as $format ) {
|
36 |
$remote_styles = $this->get_remote_styleheet( $format );
|
28 |
$result = array();
|
29 |
$this->remote_styles = '';
|
30 |
$this->styles = '';
|
31 |
+
$folder = LGF::get_folder();
|
32 |
+
$folder_url = LGF::get_folder_url();
|
|
|
33 |
|
34 |
foreach ( $this->format as $format ) {
|
35 |
$remote_styles = $this->get_remote_styleheet( $format );
|
includes/class-local-google-fonts.php
CHANGED
@@ -6,8 +6,6 @@ class LGF {
|
|
6 |
|
7 |
private static $instance = null;
|
8 |
|
9 |
-
private $upload_dir;
|
10 |
-
|
11 |
private function __construct() {
|
12 |
|
13 |
register_activation_hook( LGF_PLUGIN_FILE, array( $this, 'activate' ) );
|
@@ -34,6 +32,25 @@ class LGF {
|
|
34 |
return self::$instance;
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
public static function remove_dns_prefetch( $urls, $relation_type ) {
|
38 |
|
39 |
if ( 'dns-prefetch' === $relation_type ) {
|
@@ -91,9 +108,8 @@ class LGF {
|
|
91 |
)
|
92 |
);
|
93 |
|
94 |
-
$
|
95 |
-
$
|
96 |
-
$folder_url = $upload_dir['error'] ? WP_CONTENT_URL . '/uploads/fonts' : $upload_dir['baseurl'] . '/fonts';
|
97 |
|
98 |
$new_src = $folder_url . '/' . $id . '/font.css';
|
99 |
$new_dir = $folder . '/' . $id . '/font.css';
|
@@ -164,16 +180,13 @@ class LGF {
|
|
164 |
|
165 |
$id = md5( $src );
|
166 |
|
167 |
-
$
|
168 |
-
$
|
169 |
-
$folder_url = $upload_dir['error'] ? WP_CONTENT_URL . '/uploads/fonts' : $upload_dir['baseurl'] . '/fonts';
|
170 |
|
171 |
$stylesheet = $folder . '/' . $id . '/font.css';
|
172 |
$stylesheet_url = $folder_url . '/' . $id . '/font.css';
|
173 |
|
174 |
-
if ( file_exists( $stylesheet ) ) {
|
175 |
-
$src = add_query_arg( 'v', filemtime( $stylesheet ), $stylesheet_url );
|
176 |
-
} else {
|
177 |
|
178 |
// do not load on customizer preview.
|
179 |
if ( is_customize_preview() ) {
|
@@ -194,13 +207,16 @@ class LGF {
|
|
194 |
update_option( 'local_google_fonts_buffer', $buffer );
|
195 |
|
196 |
$options = get_option( 'local_google_fonts' );
|
197 |
-
if ( isset( $options['auto_load'] ) ) {
|
198 |
-
|
199 |
-
} else {
|
200 |
-
$src = $org;
|
201 |
}
|
|
|
|
|
|
|
202 |
}
|
203 |
|
|
|
|
|
204 |
return $src;
|
205 |
}
|
206 |
|
@@ -215,8 +231,7 @@ class LGF {
|
|
215 |
|
216 |
|
217 |
public function clear() {
|
218 |
-
$
|
219 |
-
$folder = $upload_dir['error'] ? WP_CONTENT_DIR . '/uploads/fonts' : $upload_dir['basedir'] . '/fonts';
|
220 |
if ( is_dir( $folder ) ) {
|
221 |
$WP_Filesystem = $this->wp_filesystem();
|
222 |
$WP_Filesystem->delete( $folder, true );
|
@@ -230,8 +245,7 @@ class LGF {
|
|
230 |
}
|
231 |
|
232 |
public function remove_set( $id = null ) {
|
233 |
-
$
|
234 |
-
$folder = $upload_dir['error'] ? WP_CONTENT_DIR . '/uploads/fonts' : $upload_dir['basedir'] . '/fonts';
|
235 |
if ( ! is_null( $id ) ) {
|
236 |
$folder .= '/' . basename( $id );
|
237 |
}
|
6 |
|
7 |
private static $instance = null;
|
8 |
|
|
|
|
|
9 |
private function __construct() {
|
10 |
|
11 |
register_activation_hook( LGF_PLUGIN_FILE, array( $this, 'activate' ) );
|
32 |
return self::$instance;
|
33 |
}
|
34 |
|
35 |
+
public static function get_folder() {
|
36 |
+
$upload_dir = wp_get_upload_dir();
|
37 |
+
$folder = $upload_dir['error'] ? WP_CONTENT_DIR . '/uploads/fonts' : $upload_dir['basedir'] . '/fonts';
|
38 |
+
|
39 |
+
return apply_filters( 'lgf_folder', $folder );
|
40 |
+
}
|
41 |
+
|
42 |
+
public static function get_folder_url() {
|
43 |
+
$upload_dir = wp_get_upload_dir();
|
44 |
+
$folder_url = $upload_dir['error'] ? WP_CONTENT_URL . '/uploads/fonts' : $upload_dir['baseurl'] . '/fonts';
|
45 |
+
|
46 |
+
// make sure it's served over https
|
47 |
+
if ( is_ssl() ) {
|
48 |
+
$folder_url = set_url_scheme( $folder_url, 'https' );
|
49 |
+
}
|
50 |
+
|
51 |
+
return apply_filters( 'lgf_folder_url', $folder_url );
|
52 |
+
}
|
53 |
+
|
54 |
public static function remove_dns_prefetch( $urls, $relation_type ) {
|
55 |
|
56 |
if ( 'dns-prefetch' === $relation_type ) {
|
108 |
)
|
109 |
);
|
110 |
|
111 |
+
$folder = self::get_folder();
|
112 |
+
$folder_url = self::get_folder_url();
|
|
|
113 |
|
114 |
$new_src = $folder_url . '/' . $id . '/font.css';
|
115 |
$new_dir = $folder . '/' . $id . '/font.css';
|
180 |
|
181 |
$id = md5( $src );
|
182 |
|
183 |
+
$folder = self::get_folder();
|
184 |
+
$folder_url = self::get_folder_url();
|
|
|
185 |
|
186 |
$stylesheet = $folder . '/' . $id . '/font.css';
|
187 |
$stylesheet_url = $folder_url . '/' . $id . '/font.css';
|
188 |
|
189 |
+
if ( ! file_exists( $stylesheet ) ) {
|
|
|
|
|
190 |
|
191 |
// do not load on customizer preview.
|
192 |
if ( is_customize_preview() ) {
|
207 |
update_option( 'local_google_fonts_buffer', $buffer );
|
208 |
|
209 |
$options = get_option( 'local_google_fonts' );
|
210 |
+
if ( ! isset( $options['auto_load'] ) ) {
|
211 |
+
return $org;
|
|
|
|
|
212 |
}
|
213 |
+
|
214 |
+
$src = $this->process_url( $src, $handle );
|
215 |
+
|
216 |
}
|
217 |
|
218 |
+
$src = add_query_arg( 'v', filemtime( $stylesheet ), $stylesheet_url );
|
219 |
+
|
220 |
return $src;
|
221 |
}
|
222 |
|
231 |
|
232 |
|
233 |
public function clear() {
|
234 |
+
$folder = self::get_folder();
|
|
|
235 |
if ( is_dir( $folder ) ) {
|
236 |
$WP_Filesystem = $this->wp_filesystem();
|
237 |
$WP_Filesystem->delete( $folder, true );
|
245 |
}
|
246 |
|
247 |
public function remove_set( $id = null ) {
|
248 |
+
$folder = self::get_folder();
|
|
|
249 |
if ( ! is_null( $id ) ) {
|
250 |
$folder .= '/' . basename( $id );
|
251 |
}
|
local-google-fonts.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Local Google Fonts
|
4 |
Description: Host your used Google fonts on your server and make your site GDPR compliant.
|
5 |
-
Version: 0.
|
6 |
Author: EverPress
|
7 |
Author URI: https://everpress.co
|
8 |
License: GPLv2 or later
|
2 |
/*
|
3 |
Plugin Name: Local Google Fonts
|
4 |
Description: Host your used Google fonts on your server and make your site GDPR compliant.
|
5 |
+
Version: 0.20.0
|
6 |
Author: EverPress
|
7 |
Author URI: https://everpress.co
|
8 |
License: GPLv2 or later
|