Local Google Fonts - Version 0.16

Version Description

Download this release

Release Info

Developer everpress
Plugin Icon 128x128 Local Google Fonts
Version 0.16
Comparing to
See all releases

Code changes from version 0.15 to 0.16

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.0
7
- Stable tag: 0.15
8
  Requires PHP: 5.6+
9
  License: GPLv2 or later
10
  Author: EverPress
@@ -84,6 +84,10 @@ You may have loaded a subset which doesn't included required characters. Check a
84
 
85
  ## Changelog
86
 
 
 
 
 
87
  ### 0.15
88
 
89
  - using custom mirror to prevent down times
4
  Tags: googlefonts, google, fonts, gdpr, lgf, font, speed
5
  Requires at least: 4.6
6
  Tested up to: 6.0
7
+ Stable tag: 0.16
8
  Requires PHP: 5.6+
9
  License: GPLv2 or later
10
  Author: EverPress
84
 
85
  ## Changelog
86
 
87
+ ### 0.16
88
+
89
+ - using absolute path to support Google Fonts in [Mailster](https://mailster.co/?utm_campaign=wporg&utm_source=Local+Google+Fonts&utm_medium=readme).
90
+
91
  ### 0.15
92
 
93
  - using custom mirror to prevent down times
includes/class-local-google-fonts-admin.php CHANGED
@@ -125,136 +125,8 @@ class LGF_Admin {
125
  return;
126
  }
127
 
128
- $buffer = get_option( 'local_google_fonts_buffer', array() );
129
-
130
- $folder = WP_CONTENT_DIR . '/uploads/fonts';
131
- $folder_url = WP_CONTENT_URL . '/uploads/fonts';
132
- $count = count( $buffer );
133
 
134
- if ( ! $count ) :
135
- add_settings_error( 'local_google_fonts_messages', 'local_google_fonts_message', __( 'You have currently no Google fonts in use on your site.', 'local-google-fonts' ) );
136
- endif;
137
- settings_errors( 'local_google_fonts_messages' );
138
- ?>
139
- <div class="wrap">
140
- <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
141
-
142
- <form action="options.php" method="post">
143
- <?php
144
- settings_fields( 'local_google_fonts_settings_page' );
145
- do_settings_sections( 'local_google_fonts_settings_page' );
146
-
147
- ?>
148
- <?php submit_button(); ?>
149
-
150
- <hr>
151
- <h2><?php printf( esc_html__( _n( '%d Google font source found on your site.', '%d Google font sources found on your site.', $count, 'local-google-fonts' ) ), $count ); ?></h2>
152
-
153
- <p><?php esc_html_e( 'This page shows all discovered Google Fonts over time. If you miss a font start browsing your front end so they end up showing here.', 'local-google-fonts' ); ?></p>
154
-
155
- <?php foreach ( $buffer as $id => $data ) : ?>
156
-
157
- <h3><?php esc_html_e( 'Handle', 'local-google-fonts' ); ?>: <code><?php esc_html_e( $data['handle'] ); ?></code></h3>
158
- <p><?php esc_html_e( 'Original URL', 'local-google-fonts' ); ?>: <code><?php echo rawurldecode( $data['src'] ); ?></code> <a href="<?php echo esc_url( $data['src'] ); ?>" class="dashicons dashicons-external" target="_blank" title="<?php esc_attr_e( 'show original URL', 'local-google-fonts' ); ?>"></a></p>
159
-
160
- <?php $fontinfo = $this->get_font_info( $data['src'], $data['handle'] ); ?>
161
-
162
- <?php if ( is_wp_error( $fontinfo ) ) : ?>
163
- <div class="notice inline error">
164
- <p><strong><?php echo esc_html( $fontinfo->get_error_message() ); ?></strong></p>
165
- </div>
166
- <?php else : ?>
167
-
168
- <table class="wp-list-table widefat fixed striped table-view-list ">
169
- <thead>
170
- <tr>
171
- <th scope="col" id="name" class="manage-column column-name column-primary" style="width: 150px"><?php esc_html_e( 'Name', 'local-google-fonts' ); ?></th>
172
- <th scope="col" id="description" class="manage-column column-description"><?php esc_html_e( 'Variants', 'local-google-fonts' ); ?></th>
173
- <th scope="col" id="auto-updates" class="manage-column column-auto-updates" style="width: 250px"><?php esc_html_e( 'Status', 'local-google-fonts' ); ?></th>
174
- </tr>
175
- </thead>
176
- <tbody>
177
- <?php foreach ( $fontinfo as $i => $font ) : ?>
178
-
179
- <?php $filename = $font->id . '-' . $font->version . '-' . $font->defSubset; ?>
180
- <tr>
181
- <td><strong><?php echo esc_html( $font->family ); ?></strong><br>
182
- <?php if ( $font->id != $font->original ) : ?>
183
- <span class="font-alternative" title="<?php esc_attr_e( 'This is the best alternative for a font no longer supported.', 'local-google-fonts' ); ?>"><?php esc_html_e( 'alternative', 'local-google-fonts' ); ?></span>
184
- <?php endif; ?>
185
- </td>
186
- <td>
187
- <p class="code">
188
- <?php foreach ( $font->variants as $variant ) : ?>
189
- <span class="variant"><?php printf( '%s %s', $variant->fontStyle, $variant->fontWeight ); ?></span>
190
- <?php endforeach ?>
191
- </p>
192
- <?php $active_subsets = isset( $data['subsets'] ) ? $data['subsets'][ $font->id ] : array_keys( array_filter( (array) $font->subsetMap ) ); ?>
193
- <p><strong><?php esc_html_e( 'Subsets', 'local-google-fonts' ); ?></strong><br>
194
- <?php foreach ( $font->subsetMap as $subset => $is_active ) : ?>
195
- <label title="<?php printf( esc_attr__( 'Load %s subset with this font', 'local-google-fonts' ), $subset ); ?>" class="subset"><input type="checkbox" name="subsets[<?php echo esc_attr( $data['handle'] ); ?>][<?php echo esc_attr( $font->id ); ?>][]" value="<?php echo esc_attr( $subset ); ?>" <?php checked( in_array( $subset, $active_subsets ) ); ?>> <?php echo esc_html( $subset ); ?> </label>
196
- <?php endforeach ?>
197
- </p>
198
- <details>
199
- <summary><strong><?php printf( esc_html__( '%1$d of %2$d files loaded.', 'local-google-fonts' ), $font->loaded, $font->total ); ?></strong></summary>
200
- <div style="max-height: 280px; overflow: scroll;font-size: small;white-space: nowrap; overflow: hidden; overflow-y: auto;" class="code">
201
- <?php foreach ( $font->variants as $variant ) : ?>
202
- <div>
203
- <h4><?php printf( '%s %s', $variant->fontStyle, $variant->fontWeight ); ?></h4>
204
- <?php foreach ( array( 'woff', 'svg', 'woff2', 'ttf', 'eot' ) as $ext ) : ?>
205
- <ul>
206
- <li>
207
- <?php $file = $data['id'] . '/' . $filename . '-' . $variant->id . '.' . $ext; ?>
208
- <?php if ( file_exists( $folder . '/' . $file ) ) : ?>
209
- <code><?php esc_html_e( 'Local', 'local-google-fonts' ); ?>: <a href="<?php echo esc_url( $folder_url . '/' . $file ); ?>" download><?php echo esc_html( basename( $file ) ); ?></a></code>
210
- <strong title="<?php esc_attr_e( 'loaded, served from your server', 'local-google-fonts' ); ?>">✔</strong>
211
- <?php else : ?>
212
- <code><?php esc_html_e( 'Local', 'local-google-fonts' ); ?>: <?php echo esc_html( basename( $file ) ); ?></code>
213
- <strong class="wp-ui-text-notification" title="<?php esc_attr_e( 'not loaded, served from Google servers', 'local-google-fonts' ); ?>">✕</strong>
214
- <?php endif; ?>
215
- </li>
216
- <li><code><?php esc_html_e( 'Remote', 'local-google-fonts' ); ?>: <?php echo esc_url( $variant->{$ext} ); ?></code></li>
217
- </ul>
218
- <?php endforeach; ?>
219
- </div>
220
- <?php endforeach ?>
221
- </div>
222
- </details>
223
- </td>
224
- <td>
225
- <?php if ( is_dir( $folder . '/' . $data['id'] ) ) : ?>
226
- <?php printf( '%s %s', '<strong>✔</strong>', esc_html__( 'loaded, served from your server', 'local-google-fonts' ) ); ?>
227
- <?php else : ?>
228
- <?php printf( '%s %s', '<strong class="wp-ui-text-notification">✕</strong>', esc_html__( 'not loaded, served from Google servers', 'local-google-fonts' ) ); ?>
229
- <?php endif; ?>
230
-
231
- </td>
232
-
233
- </tr>
234
- <?php endforeach ?>
235
- </tbody>
236
- </table>
237
- <p>
238
- <?php if ( is_dir( $folder . '/' . $data['id'] ) ) : ?>
239
- <button class="host-locally button button-primary" name="hostlocal" value="<?php echo esc_attr( $data['handle'] ); ?>"><?php esc_html_e( 'Reload Fonts', 'local-google-fonts' ); ?></button>
240
- <button class="host-locally button button-link-delete" name="removelocal" value="<?php echo esc_attr( $data['handle'] ); ?>"><?php esc_html_e( 'Remove hosted files', 'local-google-fonts' ); ?></button>
241
- <?php else : ?>
242
- <button class="host-locally button button-primary" name="hostlocal" value="<?php echo esc_attr( $data['handle'] ); ?>"><?php esc_html_e( 'Host locally', 'local-google-fonts' ); ?></button>
243
- <?php endif; ?>
244
- </p>
245
- <?php endif; ?>
246
-
247
- <?php endforeach ?>
248
- <hr>
249
- <p class="textright">
250
- <button class="host-locally button button-link-delete" name="flush" value="1"><?php esc_html_e( 'Remove all stored data', 'local-google-fonts' ); ?></button>
251
- </p>
252
- <?php submit_button(); ?>
253
-
254
- </form>
255
- </div>
256
-
257
- <?php
258
  }
259
 
260
 
125
  return;
126
  }
127
 
128
+ include_once dirname( LGF_PLUGIN_FILE ).'/views/settings.php';
 
 
 
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
131
 
132
 
includes/class-local-google-fonts.php CHANGED
@@ -122,21 +122,21 @@ class LGF {
122
  $style .= "\tfont-display: " . $args['display'] . ";\n";
123
  }
124
 
125
- $style .= "\tsrc: url('" . $file . ".eot?v=$time');\n";
126
  $style .= "\tsrc: local(''),\n";
127
- $style .= "\t\turl('" . $file . ".eot?v=$time?#iefix') format('embedded-opentype'),\n";
128
 
129
  if ( $v->woff2 ) {
130
- $style .= "\t\turl('" . $file . ".woff2?v=$time') format('woff2'),\n";
131
  }
132
  if ( $v->woff ) {
133
- $style .= "\t\turl('" . $file . ".woff?v=$time') format('woff'),\n";
134
  }
135
  if ( $v->ttf ) {
136
- $style .= "\t\turl('" . $file . ".ttf?v=$time') format('truetype'),\n";
137
  }
138
  if ( $v->svg ) {
139
- $style .= "\t\turl('" . $file . ".svg?v=$time" . strrchr( $v->svg, '#' ) . "') format('svg');\n";
140
  }
141
  $style .= "}\n\n";
142
 
122
  $style .= "\tfont-display: " . $args['display'] . ";\n";
123
  }
124
 
125
+ $style .= "\tsrc: url('" . $folder_url . '/' . $id . '/' . $file . ".eot?v=$time');\n";
126
  $style .= "\tsrc: local(''),\n";
127
+ $style .= "\t\turl('" . $folder_url . '/' . $id . '/' . $file . ".eot?v=$time#iefix') format('embedded-opentype'),\n";
128
 
129
  if ( $v->woff2 ) {
130
+ $style .= "\t\turl('" . $folder_url . '/' . $id . '/' . $file . ".woff2?v=$time') format('woff2'),\n";
131
  }
132
  if ( $v->woff ) {
133
+ $style .= "\t\turl('" . $folder_url . '/' . $id . '/' . $file . ".woff?v=$time') format('woff'),\n";
134
  }
135
  if ( $v->ttf ) {
136
+ $style .= "\t\turl('" . $folder_url . '/' . $id . '/' . $file . ".ttf?v=$time') format('truetype'),\n";
137
  }
138
  if ( $v->svg ) {
139
+ $style .= "\t\turl('" . $folder_url . '/' . $id . '/' . $file . ".svg?v=$time" . strrchr( $v->svg, '#' ) . "') format('svg');\n";
140
  }
141
  $style .= "}\n\n";
142
 
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.15
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.16
6
  Author: EverPress
7
  Author URI: https://everpress.co
8
  License: GPLv2 or later
views/settings.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ $buffer = get_option( 'local_google_fonts_buffer', array() );
5
+
6
+ $folder = WP_CONTENT_DIR . '/uploads/fonts';
7
+ $folder_url = WP_CONTENT_URL . '/uploads/fonts';
8
+ $count = count( $buffer );
9
+
10
+ if ( ! $count ) :
11
+ add_settings_error( 'local_google_fonts_messages', 'local_google_fonts_message', __( 'You have currently no Google fonts in use on your site.', 'local-google-fonts' ) );
12
+ endif;
13
+ settings_errors( 'local_google_fonts_messages' );
14
+ ?>
15
+ <div class="wrap">
16
+ <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
17
+
18
+ <form action="options.php" method="post">
19
+ <?php
20
+ settings_fields( 'local_google_fonts_settings_page' );
21
+ do_settings_sections( 'local_google_fonts_settings_page' );
22
+
23
+ ?>
24
+ <?php submit_button(); ?>
25
+
26
+ <hr>
27
+ <h2><?php printf( esc_html__( _n( '%d Google font source found on your site.', '%d Google font sources found on your site.', $count, 'local-google-fonts' ) ), $count ); ?></h2>
28
+
29
+ <p><?php esc_html_e( 'This page shows all discovered Google Fonts over time. If you miss a font start browsing your front end so they end up showing here.', 'local-google-fonts' ); ?></p>
30
+
31
+ <?php foreach ( $buffer as $id => $data ) : ?>
32
+
33
+ <h3><?php esc_html_e( 'Handle', 'local-google-fonts' ); ?>: <code><?php esc_html_e( $data['handle'] ); ?></code></h3>
34
+ <p><?php esc_html_e( 'Original URL', 'local-google-fonts' ); ?>: <code><?php echo rawurldecode( $data['src'] ); ?></code> <a href="<?php echo esc_url( $data['src'] ); ?>" class="dashicons dashicons-external" target="_blank" title="<?php esc_attr_e( 'show original URL', 'local-google-fonts' ); ?>"></a></p>
35
+
36
+ <?php $fontinfo = $this->get_font_info( $data['src'], $data['handle'] ); ?>
37
+
38
+ <?php if ( is_wp_error( $fontinfo ) ) : ?>
39
+ <div class="notice inline error">
40
+ <p><strong><?php echo esc_html( $fontinfo->get_error_message() ); ?></strong></p>
41
+ </div>
42
+ <?php else : ?>
43
+
44
+ <table class="wp-list-table widefat fixed striped table-view-list ">
45
+ <thead>
46
+ <tr>
47
+ <th scope="col" id="name" class="manage-column column-name column-primary" style="width: 150px"><?php esc_html_e( 'Name', 'local-google-fonts' ); ?></th>
48
+ <th scope="col" id="description" class="manage-column column-description"><?php esc_html_e( 'Variants', 'local-google-fonts' ); ?></th>
49
+ <th scope="col" id="auto-updates" class="manage-column column-auto-updates" style="width: 250px"><?php esc_html_e( 'Status', 'local-google-fonts' ); ?></th>
50
+ </tr>
51
+ </thead>
52
+ <tbody>
53
+ <?php foreach ( $fontinfo as $i => $font ) : ?>
54
+
55
+ <?php $filename = $font->id . '-' . $font->version . '-' . $font->defSubset; ?>
56
+ <tr>
57
+ <td><strong><?php echo esc_html( $font->family ); ?></strong><br>
58
+ <?php if ( $font->id != $font->original ) : ?>
59
+ <span class="font-alternative" title="<?php esc_attr_e( 'This is the best alternative for a font no longer supported.', 'local-google-fonts' ); ?>"><?php esc_html_e( 'alternative', 'local-google-fonts' ); ?></span>
60
+ <?php endif; ?>
61
+ </td>
62
+ <td>
63
+ <p class="code">
64
+ <?php foreach ( $font->variants as $variant ) : ?>
65
+ <span class="variant"><?php printf( '%s %s', $variant->fontStyle, $variant->fontWeight ); ?></span>
66
+ <?php endforeach ?>
67
+ </p>
68
+ <?php $active_subsets = isset( $data['subsets'] ) ? $data['subsets'][ $font->id ] : array_keys( array_filter( (array) $font->subsetMap ) ); ?>
69
+ <p><strong><?php esc_html_e( 'Subsets', 'local-google-fonts' ); ?></strong><br>
70
+ <?php foreach ( $font->subsetMap as $subset => $is_active ) : ?>
71
+ <label title="<?php printf( esc_attr__( 'Load %s subset with this font', 'local-google-fonts' ), $subset ); ?>" class="subset"><input type="checkbox" name="subsets[<?php echo esc_attr( $data['handle'] ); ?>][<?php echo esc_attr( $font->id ); ?>][]" value="<?php echo esc_attr( $subset ); ?>" <?php checked( in_array( $subset, $active_subsets ) ); ?>> <?php echo esc_html( $subset ); ?> </label>
72
+ <?php endforeach ?>
73
+ </p>
74
+ <details>
75
+ <summary><strong><?php printf( esc_html__( '%1$d of %2$d files loaded.', 'local-google-fonts' ), $font->loaded, $font->total ); ?></strong></summary>
76
+ <div style="max-height: 280px; overflow: scroll;font-size: small;white-space: nowrap; overflow: hidden; overflow-y: auto;" class="code">
77
+ <?php foreach ( $font->variants as $variant ) : ?>
78
+ <div>
79
+ <h4><?php printf( '%s %s', $variant->fontStyle, $variant->fontWeight ); ?></h4>
80
+ <?php foreach ( array( 'woff', 'svg', 'woff2', 'ttf', 'eot' ) as $ext ) : ?>
81
+ <ul>
82
+ <li>
83
+ <?php $file = $data['id'] . '/' . $filename . '-' . $variant->id . '.' . $ext; ?>
84
+ <?php if ( file_exists( $folder . '/' . $file ) ) : ?>
85
+ <code><?php esc_html_e( 'Local', 'local-google-fonts' ); ?>: <a href="<?php echo esc_url( $folder_url . '/' . $file ); ?>" download><?php echo esc_html( basename( $file ) ); ?></a></code>
86
+ <strong title="<?php esc_attr_e( 'loaded, served from your server', 'local-google-fonts' ); ?>">✔</strong>
87
+ <?php else : ?>
88
+ <code><?php esc_html_e( 'Local', 'local-google-fonts' ); ?>: <?php echo esc_html( basename( $file ) ); ?></code>
89
+ <strong class="wp-ui-text-notification" title="<?php esc_attr_e( 'not loaded, served from Google servers', 'local-google-fonts' ); ?>">✕</strong>
90
+ <?php endif; ?>
91
+ </li>
92
+ <li><code><?php esc_html_e( 'Remote', 'local-google-fonts' ); ?>: <?php echo esc_url( $variant->{$ext} ); ?></code></li>
93
+ </ul>
94
+ <?php endforeach; ?>
95
+ </div>
96
+ <?php endforeach ?>
97
+ </div>
98
+ </details>
99
+ </td>
100
+ <td>
101
+ <?php if ( is_dir( $folder . '/' . $data['id'] ) ) : ?>
102
+ <?php printf( '%s %s', '<strong>✔</strong>', esc_html__( 'loaded, served from your server', 'local-google-fonts' ) ); ?>
103
+ <?php else : ?>
104
+ <?php printf( '%s %s', '<strong class="wp-ui-text-notification">✕</strong>', esc_html__( 'not loaded, served from Google servers', 'local-google-fonts' ) ); ?>
105
+ <?php endif; ?>
106
+
107
+ </td>
108
+
109
+ </tr>
110
+ <?php endforeach ?>
111
+ </tbody>
112
+ </table>
113
+ <p>
114
+ <?php if ( is_dir( $folder . '/' . $data['id'] ) ) : ?>
115
+ <button class="host-locally button button-primary" name="hostlocal" value="<?php echo esc_attr( $data['handle'] ); ?>"><?php esc_html_e( 'Reload Fonts', 'local-google-fonts' ); ?></button>
116
+ <button class="host-locally button button-link-delete" name="removelocal" value="<?php echo esc_attr( $data['handle'] ); ?>"><?php esc_html_e( 'Remove hosted files', 'local-google-fonts' ); ?></button>
117
+ <?php else : ?>
118
+ <button class="host-locally button button-primary" name="hostlocal" value="<?php echo esc_attr( $data['handle'] ); ?>"><?php esc_html_e( 'Host locally', 'local-google-fonts' ); ?></button>
119
+ <?php endif; ?>
120
+ </p>
121
+ <?php endif; ?>
122
+
123
+ <?php endforeach ?>
124
+ <hr>
125
+ <p class="textright">
126
+ <button class="host-locally button button-link-delete" name="flush" value="1"><?php esc_html_e( 'Remove all stored data', 'local-google-fonts' ); ?></button>
127
+ </p>
128
+ <?php submit_button(); ?>
129
+
130
+ </form>
131
+ </div>