OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy. - Version 1.8.3

Version Description

Extended support for local source attribute.

Download this release

Release Info

Developer DaanvandenBergh
Plugin Icon 128x128 OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy.
Version 1.8.3
Comparing to
See all releases

Code changes from version 1.7.9 to 1.8.3

host-webfonts-local.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: CAOS for Webfonts
5
  * Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
6
  * Description: Automagically save the fonts you want to use inside your content-folder, generate a stylesheet for them and enqueue it in your theme's header.
7
- * Version: 1.7.9
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
@@ -21,7 +21,7 @@ global $wpdb;
21
  /**
22
  * Define constants.
23
  */
24
- define('CAOS_WEBFONTS_DB_VERSION', '1.7.0');
25
  define('CAOS_WEBFONTS_STATIC_VERSION', '1.7.6');
26
  define('CAOS_WEBFONTS_SITE_URL', 'https://daan.dev');
27
  define('CAOS_WEBFONTS_DB_TABLENAME', $wpdb->prefix . 'caos_webfonts');
@@ -82,7 +82,7 @@ add_action('admin_menu', 'hwlCreateMenu');
82
  */
83
  function hwlGetContentDirName() {
84
  preg_match('/[^\/]+$/u', WP_CONTENT_DIR, $match);
85
-
86
  return $match[0];
87
  }
88
 
@@ -95,12 +95,12 @@ function hwlGetUploadUrl() {
95
  } else {
96
  $uploadUrl = get_site_url(CAOS_WEBFONTS_CURRENT_BLOG_ID, hwlGetContentDirName() . CAOS_WEBFONTS_CACHE_DIR);
97
  }
98
-
99
  return $uploadUrl;
100
  }
101
 
102
  /**
103
- * Create table to store downloaded fonts in.
104
  */
105
  function hwlCreateWebfontsTable() {
106
  global $wpdb;
@@ -117,12 +117,12 @@ function hwlCreateWebfontsTable() {
117
  UNIQUE KEY (font_id)
118
  ) " . CAOS_WEBFONTS_DB_CHARSET . ";";
119
  $wpdb->query($sql);
120
-
121
  add_option('caos_webfonts_db_version', '1.6.1');
122
  }
123
 
124
  /**
125
- * Create table to store selected subsets in.
126
  */
127
  function hwlCreateSubsetsTable() {
128
  global $wpdb;
@@ -134,10 +134,23 @@ function hwlCreateSubsetsTable() {
134
  UNIQUE KEY (subset_font)
135
  ) " . CAOS_WEBFONTS_DB_CHARSET . ";";
136
  $wpdb->query($sql);
137
-
138
  update_option('caos_webfonts_db_version', '1.7.0');
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  /**
142
  * Check current version and execute required db updates.
143
  */
@@ -146,9 +159,12 @@ function hwlRunDbUpdates() {
146
  if (version_compare($currentVersion, '1.6.1') < 0) {
147
  hwlCreateWebfontsTable();
148
  }
149
- if (version_compare($currentVersion, CAOS_WEBFONTS_DB_VERSION) < 0) {
150
  hwlCreateSubsetsTable();
151
  }
 
 
 
152
  }
153
  add_action('plugins_loaded', 'hwlRunDbUpdates');
154
 
@@ -161,7 +177,7 @@ function hwlSettingsLink($links) {
161
  $adminUrl = admin_url() . 'options-general.php?page=optimize-webfonts';
162
  $settingsLink = "<a href='$adminUrl'>" . __('Settings') . "</a>";
163
  array_push($links, $settingsLink);
164
-
165
  return $links;
166
  }
167
  $caosLink = plugin_basename(__FILE__);
@@ -185,15 +201,15 @@ function hwlSettingsPage() {
185
  </p>
186
 
187
  <div id="hwl-admin-notices"></div>
188
-
189
  <?php require_once(plugin_dir_path(__FILE__) . 'includes/welcome-panel.php'); ?>
190
 
191
  <form id="hwl-options-form" name="hwl-options-form" method="post" style="float: left; width: 60%;">
192
  <div class="">
193
  <?php
194
-
195
  include(plugin_dir_path(__FILE__) . 'includes/caos-webfonts-style-generation.php');
196
-
197
  ?>
198
  </div>
199
  </form>
@@ -202,11 +218,11 @@ function hwlSettingsPage() {
202
  <?php
203
  settings_fields('caos-webfonts-basic-settings');
204
  do_settings_sections('caos-webfonts-basic-settings');
205
-
206
  include(plugin_dir_path(__FILE__) . 'includes/caos-webfonts-basic-settings.php');
207
-
208
  do_action('hwl_after_settings_form_settings');
209
-
210
  submit_button();
211
  ?>
212
  </form>
@@ -219,7 +235,7 @@ function hwlSettingsPage() {
219
  */
220
  function hwlGetTotalFonts() {
221
  global $wpdb;
222
-
223
  try {
224
  return $wpdb->get_results("SELECT * FROM " . CAOS_WEBFONTS_DB_TABLENAME);
225
  } catch (\Exception $e) {
@@ -232,7 +248,7 @@ function hwlGetTotalFonts() {
232
  */
233
  function hwlGetDownloadedFonts() {
234
  global $wpdb;
235
-
236
  try {
237
  return $wpdb->get_results("SELECT * FROM " . CAOS_WEBFONTS_DB_TABLENAME . " WHERE downloaded = 1");
238
  } catch (\Exception $e) {
@@ -255,7 +271,7 @@ function hwlGetDownloadStatus() {
255
  */
256
  function hwlGetSubsets() {
257
  global $wpdb;
258
-
259
  try {
260
  return $wpdb->get_results("SELECT * FROM " . CAOS_WEBFONTS_DB_TABLENAME . "_subsets");
261
  } catch(\Exception $e) {
@@ -265,7 +281,7 @@ function hwlGetSubsets() {
265
 
266
  function hwlGetFontsByFamily($family) {
267
  global $wpdb;
268
-
269
  try {
270
  return $wpdb->get_results("SELECT * FROM " . CAOS_WEBFONTS_DB_TABLENAME . " WHERE font_family = '$family'");
271
  } catch(\Exception $e) {
@@ -278,7 +294,7 @@ function hwlGetFontsByFamily($family) {
278
  */
279
  function hwlCleanQueue() {
280
  global $wpdb;
281
-
282
  try {
283
  $wpdb->query("TRUNCATE TABLE " . CAOS_WEBFONTS_DB_TABLENAME);
284
  $wpdb->query("TRUNCATE TABLE " . CAOS_WEBFONTS_DB_TABLENAME . "_subsets");
@@ -323,14 +339,14 @@ add_action('wp_ajax_hwlAjaxEmptyDir', 'hwlAjaxEmptyDir');
323
  function hwlAjaxSearchFontSubsets() {
324
  try {
325
  $searchQueries = explode(',', sanitize_text_field($_POST['search_query']));
326
-
327
  foreach ($searchQueries as $searchQuery) {
328
  $request = curl_init();
329
  curl_setopt($request, CURLOPT_URL, CAOS_WEBFONTS_HELPER_URL . $searchQuery);
330
  curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
331
  $result = curl_exec($request);
332
  curl_close($request);
333
-
334
  $result = json_decode($result);
335
  $response[] = array(
336
  'family' => $result->family,
@@ -353,12 +369,12 @@ function hwlAjaxSearchGoogleFonts() {
353
  $request = curl_init();
354
  $searchQuery = sanitize_text_field($_POST['search_query']);
355
  $subsets = implode($_POST['search_subsets'], ',');
356
-
357
  curl_setopt($request, CURLOPT_URL, CAOS_WEBFONTS_HELPER_URL . $searchQuery . '?subsets=' . $subsets);
358
  curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
359
-
360
  $result = curl_exec($request);
361
-
362
  curl_close($request);
363
  wp_die($result);
364
  } catch (\Exception $e) {
@@ -389,7 +405,7 @@ function hwlFontDisplayOptions() {
389
  'Fallback' => 'fallback',
390
  'Optional' => 'optional'
391
  );
392
-
393
  return $fontDisplay;
394
  }
395
 
@@ -443,10 +459,10 @@ register_deactivation_hook(__FILE__, 'hwlDequeueJsCss');
443
  */
444
  function hwlAddLinkPreload() {
445
  global $wp_styles;
446
-
447
  $handle = 'hwl-style';
448
  $sstyle = $wp_styles->registered[$handle];
449
-
450
  $source = $sstyle->src . ($sstyle->ver ? "?ver={$sstyle->ver}" : "");
451
  echo "<link rel='preload' href='{$source}' as='style' />\n";
452
  }
4
  * Plugin Name: CAOS for Webfonts
5
  * Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
6
  * Description: Automagically save the fonts you want to use inside your content-folder, generate a stylesheet for them and enqueue it in your theme's header.
7
+ * Version: 1.8.3
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
21
  /**
22
  * Define constants.
23
  */
24
+ define('CAOS_WEBFONTS_DB_VERSION', '1.8.3');
25
  define('CAOS_WEBFONTS_STATIC_VERSION', '1.7.6');
26
  define('CAOS_WEBFONTS_SITE_URL', 'https://daan.dev');
27
  define('CAOS_WEBFONTS_DB_TABLENAME', $wpdb->prefix . 'caos_webfonts');
82
  */
83
  function hwlGetContentDirName() {
84
  preg_match('/[^\/]+$/u', WP_CONTENT_DIR, $match);
85
+
86
  return $match[0];
87
  }
88
 
95
  } else {
96
  $uploadUrl = get_site_url(CAOS_WEBFONTS_CURRENT_BLOG_ID, hwlGetContentDirName() . CAOS_WEBFONTS_CACHE_DIR);
97
  }
98
+
99
  return $uploadUrl;
100
  }
101
 
102
  /**
103
+ * Create table to store downloaded fonts in version 1.6.1.
104
  */
105
  function hwlCreateWebfontsTable() {
106
  global $wpdb;
117
  UNIQUE KEY (font_id)
118
  ) " . CAOS_WEBFONTS_DB_CHARSET . ";";
119
  $wpdb->query($sql);
120
+
121
  add_option('caos_webfonts_db_version', '1.6.1');
122
  }
123
 
124
  /**
125
+ * Create table to store selected subsets in version 1.7.0.
126
  */
127
  function hwlCreateSubsetsTable() {
128
  global $wpdb;
134
  UNIQUE KEY (subset_font)
135
  ) " . CAOS_WEBFONTS_DB_CHARSET . ";";
136
  $wpdb->query($sql);
137
+
138
  update_option('caos_webfonts_db_version', '1.7.0');
139
  }
140
 
141
+ /**
142
+ * Adds the 'local' column in version 1.8.3
143
+ */
144
+ function hwlAddLocalColumn() {
145
+ global $wpdb;
146
+
147
+ $sql = "ALTER TABLE " . CAOS_WEBFONTS_DB_TABLENAME . " " .
148
+ "ADD COLUMN local varchar(128) AFTER font_style;";
149
+ $wpdb->query($sql);
150
+
151
+ update_option('caos_webfonts_db_version', '1.8.3');
152
+ }
153
+
154
  /**
155
  * Check current version and execute required db updates.
156
  */
159
  if (version_compare($currentVersion, '1.6.1') < 0) {
160
  hwlCreateWebfontsTable();
161
  }
162
+ if (version_compare($currentVersion, '1.7.0') < 0) {
163
  hwlCreateSubsetsTable();
164
  }
165
+ if (version_compare($currentVersion, CAOS_WEBFONTS_DB_VERSION) < 0) {
166
+ hwlAddLocalColumn();
167
+ }
168
  }
169
  add_action('plugins_loaded', 'hwlRunDbUpdates');
170
 
177
  $adminUrl = admin_url() . 'options-general.php?page=optimize-webfonts';
178
  $settingsLink = "<a href='$adminUrl'>" . __('Settings') . "</a>";
179
  array_push($links, $settingsLink);
180
+
181
  return $links;
182
  }
183
  $caosLink = plugin_basename(__FILE__);
201
  </p>
202
 
203
  <div id="hwl-admin-notices"></div>
204
+
205
  <?php require_once(plugin_dir_path(__FILE__) . 'includes/welcome-panel.php'); ?>
206
 
207
  <form id="hwl-options-form" name="hwl-options-form" method="post" style="float: left; width: 60%;">
208
  <div class="">
209
  <?php
210
+
211
  include(plugin_dir_path(__FILE__) . 'includes/caos-webfonts-style-generation.php');
212
+
213
  ?>
214
  </div>
215
  </form>
218
  <?php
219
  settings_fields('caos-webfonts-basic-settings');
220
  do_settings_sections('caos-webfonts-basic-settings');
221
+
222
  include(plugin_dir_path(__FILE__) . 'includes/caos-webfonts-basic-settings.php');
223
+
224
  do_action('hwl_after_settings_form_settings');
225
+
226
  submit_button();
227
  ?>
228
  </form>
235
  */
236
  function hwlGetTotalFonts() {
237
  global $wpdb;
238
+
239
  try {
240
  return $wpdb->get_results("SELECT * FROM " . CAOS_WEBFONTS_DB_TABLENAME);
241
  } catch (\Exception $e) {
248
  */
249
  function hwlGetDownloadedFonts() {
250
  global $wpdb;
251
+
252
  try {
253
  return $wpdb->get_results("SELECT * FROM " . CAOS_WEBFONTS_DB_TABLENAME . " WHERE downloaded = 1");
254
  } catch (\Exception $e) {
271
  */
272
  function hwlGetSubsets() {
273
  global $wpdb;
274
+
275
  try {
276
  return $wpdb->get_results("SELECT * FROM " . CAOS_WEBFONTS_DB_TABLENAME . "_subsets");
277
  } catch(\Exception $e) {
281
 
282
  function hwlGetFontsByFamily($family) {
283
  global $wpdb;
284
+
285
  try {
286
  return $wpdb->get_results("SELECT * FROM " . CAOS_WEBFONTS_DB_TABLENAME . " WHERE font_family = '$family'");
287
  } catch(\Exception $e) {
294
  */
295
  function hwlCleanQueue() {
296
  global $wpdb;
297
+
298
  try {
299
  $wpdb->query("TRUNCATE TABLE " . CAOS_WEBFONTS_DB_TABLENAME);
300
  $wpdb->query("TRUNCATE TABLE " . CAOS_WEBFONTS_DB_TABLENAME . "_subsets");
339
  function hwlAjaxSearchFontSubsets() {
340
  try {
341
  $searchQueries = explode(',', sanitize_text_field($_POST['search_query']));
342
+
343
  foreach ($searchQueries as $searchQuery) {
344
  $request = curl_init();
345
  curl_setopt($request, CURLOPT_URL, CAOS_WEBFONTS_HELPER_URL . $searchQuery);
346
  curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
347
  $result = curl_exec($request);
348
  curl_close($request);
349
+
350
  $result = json_decode($result);
351
  $response[] = array(
352
  'family' => $result->family,
369
  $request = curl_init();
370
  $searchQuery = sanitize_text_field($_POST['search_query']);
371
  $subsets = implode($_POST['search_subsets'], ',');
372
+
373
  curl_setopt($request, CURLOPT_URL, CAOS_WEBFONTS_HELPER_URL . $searchQuery . '?subsets=' . $subsets);
374
  curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
375
+
376
  $result = curl_exec($request);
377
+
378
  curl_close($request);
379
  wp_die($result);
380
  } catch (\Exception $e) {
405
  'Fallback' => 'fallback',
406
  'Optional' => 'optional'
407
  );
408
+
409
  return $fontDisplay;
410
  }
411
 
459
  */
460
  function hwlAddLinkPreload() {
461
  global $wp_styles;
462
+
463
  $handle = 'hwl-style';
464
  $sstyle = $wp_styles->registered[$handle];
465
+
466
  $source = $sstyle->src . ($sstyle->ver ? "?ver={$sstyle->ver}" : "");
467
  echo "<link rel='preload' href='{$source}' as='style' />\n";
468
  }
includes/ajax/download-fonts.php CHANGED
@@ -54,7 +54,7 @@ foreach ($subsets as $id => $subset)
54
  {
55
  $availableSubsets = implode($subset['available'], ',');
56
  $selectedSubsets = implode($subset['selected'], ',');
57
-
58
  $wpdb->insert(
59
  CAOS_WEBFONTS_DB_TABLENAME . '_subsets',
60
  array(
@@ -79,6 +79,7 @@ foreach ($selectedFonts as $id => $font)
79
  'font_family' => sanitize_text_field($font['font-family']),
80
  'font_weight' => sanitize_text_field($font['font-weight']),
81
  'font_style' => sanitize_text_field($font['font-style']),
 
82
  'downloaded' => 0,
83
  'url_ttf' => esc_url_raw($font['url']['ttf']),
84
  'url_woff' => esc_url_raw($font['url']['woff']),
54
  {
55
  $availableSubsets = implode($subset['available'], ',');
56
  $selectedSubsets = implode($subset['selected'], ',');
57
+
58
  $wpdb->insert(
59
  CAOS_WEBFONTS_DB_TABLENAME . '_subsets',
60
  array(
79
  'font_family' => sanitize_text_field($font['font-family']),
80
  'font_weight' => sanitize_text_field($font['font-weight']),
81
  'font_style' => sanitize_text_field($font['font-style']),
82
+ 'local' => sanitize_text_field($font['local']),
83
  'downloaded' => 0,
84
  'url_ttf' => esc_url_raw($font['url']['ttf']),
85
  'url_woff' => esc_url_raw($font['url']['woff']),
includes/ajax/generate-stylesheet.php CHANGED
@@ -50,6 +50,9 @@ foreach ($selectedFonts as $font) {
50
  $fontUrlWoffTwo = esc_url_raw($font->url_woff2);
51
  $fontUrlWoff = esc_url_raw($font->url_woff);
52
  $fontUrlTtf = esc_url_raw($font->url_ttf);
 
 
 
53
 
54
  $fonts[] =
55
  "@font-face {
@@ -57,10 +60,11 @@ foreach ($selectedFonts as $font) {
57
  font-display: $fontDisplay;
58
  font-style: $fontStyle;
59
  font-weight: $fontWeight;
60
- src: url('$fontUrlWoffTwo') format('woff2'), /* Super Modern Browsers */
 
 
61
  url('$fontUrlWoff') format('woff'), /* Modern Browsers */
62
- url('$fontUrlTtf') format('truetype'), /* Safari, Android, iOS */
63
- url('$fontUrlEot'); /* IE9 Compatible */
64
  }";
65
  }
66
 
50
  $fontUrlWoffTwo = esc_url_raw($font->url_woff2);
51
  $fontUrlWoff = esc_url_raw($font->url_woff);
52
  $fontUrlTtf = esc_url_raw($font->url_ttf);
53
+ $locals = explode(',', sanitize_text_field($font->local));
54
+ $fontLocal = isset($locals[0]) ? $locals[0] : $fontFamily . " " . ucfirst($fontStyle);
55
+ $fontLocalDash = isset($locals[1]) ? $locals[1] : $fontFamily . "-" . ucfirst($fontStyle);
56
 
57
  $fonts[] =
58
  "@font-face {
60
  font-display: $fontDisplay;
61
  font-style: $fontStyle;
62
  font-weight: $fontWeight;
63
+ src: url('$fontUrlEot'); /* IE9 Compatible */
64
+ src: local('$fontLocal'), local('$fontLocalDash'),
65
+ url('$fontUrlWoffTwo') format('woff2'), /* Super Modern Browsers */
66
  url('$fontUrlWoff') format('woff'), /* Modern Browsers */
67
+ url('$fontUrlTtf') format('truetype'); /* Safari, Android, iOS */
 
68
  }";
69
  }
70
 
includes/caos-webfonts-style-generation.php CHANGED
@@ -36,18 +36,18 @@ if (!defined('ABSPATH')) {
36
  $availableSubsets = explode(',', $subsetFont->available_subsets);
37
  $selectedSubsets = explode(',', $subsetFont->selected_subsets);
38
  ?>
39
- <tr valign="top" id="<?php echo $subsetFont->subset_font; ?>">
40
  <td>
41
  <label>
42
- <input readonly type="text" class="hwl-subset-font-family" value="<?php echo $subsetFont->subset_family; ?>"/>
43
  </label>
44
  </td>
45
  <?php foreach ($availableSubsets as $availableSubset): ?>
46
  <td>
47
  <label>
48
  <?php $checked = in_array($availableSubset, $selectedSubsets) ? 'checked="checked"' : ''; ?>
49
- <input name="<?php echo $subsetFont->subset_font; ?>" value="<?php echo $availableSubset; ?>" type="checkbox" onclick="hwlGenerateSearchQuery('<?php echo $subsetFont->subset_font; ?>')" <?php echo $checked; ?>/>
50
- <?php echo $availableSubset; ?>
51
  </label>
52
  </td>
53
  <?php endforeach; ?>
@@ -67,7 +67,7 @@ if (!defined('ABSPATH')) {
67
  ?>
68
  <?php if ($savedFonts && $subsetFonts): ?>
69
  <?php foreach ($subsetFonts as $subsetFont): ?>
70
- <tbody id="hwl-section-<?php echo $subsetFont->subset_font; ?>">
71
  <?php
72
  $fonts = hwlGetFontsByFamily($subsetFont->subset_family);
73
  ?>
@@ -75,24 +75,25 @@ if (!defined('ABSPATH')) {
75
  $fontId = $font->font_id;
76
  $arrayPath = "caos_webfonts_array][$fontId]";
77
  ?>
78
- <tr id="row-<?php echo $fontId; ?>" valign="top">
79
  <td>
80
- <input readonly type="text" value="<?php echo $font->font_family; ?>" name="<?php echo $arrayPath; ?>[font-family]"/>
81
  </td>
82
  <td>
83
- <input readonly type="text" value="<?php echo $font->font_style; ?>" name="<?php echo $arrayPath; ?>[font-style]"/>
84
  </td>
85
  <td>
86
- <input readonly type="text" value="<?php echo $font->font_weight; ?>" name="<?php echo $arrayPath; ?>[font-weight]"/>
87
  </td>
88
  <td>
89
- <input type="hidden" value="<?php echo $fontId; ?>" name="<?php echo $arrayPath; ?>[id]"/>
90
- <input type="hidden" value="<?php echo $font->url_ttf; ?>" name="<?php echo $arrayPath; ?>[url][ttf]"/>
91
- <input type="hidden" value="<?php echo $font->url_woff; ?>" name="<?php echo $arrayPath; ?>[url][woff]"/>
92
- <input type="hidden" value="<?php echo $font->url_woff2; ?>" name="<?php echo $arrayPath; ?>[url][woff2]"/>
93
- <input type="hidden" value="<?php echo $font->url_eot; ?>" name="<?php echo $arrayPath; ?>[url][eot]"/>
 
94
  <div class="hwl-remove">
95
- <a onclick="hwlRemoveRow('row-<?php echo $fontId; ?>')">
96
  <small>remove</small>
97
  </a>
98
  </div>
@@ -143,8 +144,8 @@ if (!defined('ABSPATH')) {
143
  ?>
144
  <td colspan="5">
145
  <div class="caos-status-total-bar" style="">
146
- <div id="caos-status-progress-bar" style="width: <?php echo $width; ?>%;">
147
- <span class="caos-status-progress-percentage"><?php echo $width . '%'; ?></span>
148
  </div>
149
  </div>
150
  </td>
36
  $availableSubsets = explode(',', $subsetFont->available_subsets);
37
  $selectedSubsets = explode(',', $subsetFont->selected_subsets);
38
  ?>
39
+ <tr valign="top" id="<?= $subsetFont->subset_font; ?>">
40
  <td>
41
  <label>
42
+ <input readonly type="text" class="hwl-subset-font-family" value="<?= $subsetFont->subset_family; ?>"/>
43
  </label>
44
  </td>
45
  <?php foreach ($availableSubsets as $availableSubset): ?>
46
  <td>
47
  <label>
48
  <?php $checked = in_array($availableSubset, $selectedSubsets) ? 'checked="checked"' : ''; ?>
49
+ <input name="<?= $subsetFont->subset_font; ?>" value="<?= $availableSubset; ?>" type="checkbox" onclick="hwlGenerateSearchQuery('<?= $subsetFont->subset_font; ?>')" <?= $checked; ?>/>
50
+ <?= $availableSubset; ?>
51
  </label>
52
  </td>
53
  <?php endforeach; ?>
67
  ?>
68
  <?php if ($savedFonts && $subsetFonts): ?>
69
  <?php foreach ($subsetFonts as $subsetFont): ?>
70
+ <tbody id="hwl-section-<?= $subsetFont->subset_font; ?>">
71
  <?php
72
  $fonts = hwlGetFontsByFamily($subsetFont->subset_family);
73
  ?>
75
  $fontId = $font->font_id;
76
  $arrayPath = "caos_webfonts_array][$fontId]";
77
  ?>
78
+ <tr id="row-<?= $fontId; ?>" valign="top">
79
  <td>
80
+ <input readonly type="text" value="<?= $font->font_family; ?>" name="<?= $arrayPath; ?>[font-family]"/>
81
  </td>
82
  <td>
83
+ <input readonly type="text" value="<?= $font->font_style; ?>" name="<?= $arrayPath; ?>[font-style]"/>
84
  </td>
85
  <td>
86
+ <input readonly type="text" value="<?= $font->font_weight; ?>" name="<?= $arrayPath; ?>[font-weight]"/>
87
  </td>
88
  <td>
89
+ <input type="hidden" value="<?= $fontId; ?>" name="<?= $arrayPath; ?>[id]"/>
90
+ <input type="hidden" value="<?= $font->local; ?>" name="<?= $arrayPath; ?>[local]"/>
91
+ <input type="hidden" value="<?= $font->url_ttf; ?>" name="<?= $arrayPath; ?>[url][ttf]"/>
92
+ <input type="hidden" value="<?= $font->url_woff; ?>" name="<?= $arrayPath; ?>[url][woff]"/>
93
+ <input type="hidden" value="<?= $font->url_woff2; ?>" name="<?= $arrayPath; ?>[url][woff2]"/>
94
+ <input type="hidden" value="<?= $font->url_eot; ?>" name="<?= $arrayPath; ?>[url][eot]"/>
95
  <div class="hwl-remove">
96
+ <a onclick="hwlRemoveRow('row-<?= $fontId; ?>')">
97
  <small>remove</small>
98
  </a>
99
  </div>
144
  ?>
145
  <td colspan="5">
146
  <div class="caos-status-total-bar" style="">
147
+ <div id="caos-status-progress-bar" style="width: <?= $width; ?>%;">
148
+ <span class="caos-status-progress-percentage"><?= $width . '%'; ?></span>
149
  </div>
150
  </div>
151
  </td>
js/hwl-admin.js CHANGED
@@ -142,6 +142,7 @@ function hwlRenderAvailableFonts(results)
142
  font = fontFamily.replace(/\s+/g, '-').toLowerCase() + '-' + variants[iii].id
143
  fontWeight = variants[iii].fontWeight
144
  fontStyle = variants[iii].fontStyle
 
145
  renderedFonts[iii] = `<tr id="row-${font}" valign="top">
146
  <td>
147
  <input readonly type="text" value="${fontFamily}" name="caos_webfonts_array][${font}][font-family]" />
@@ -154,6 +155,7 @@ function hwlRenderAvailableFonts(results)
154
  </td>
155
  <td>
156
  <input type="hidden" value="${fontId}" name="caos_webfonts_array][${font}][id]" />
 
157
  <input type="hidden" value="${variants[iii].ttf}" name="caos_webfonts_array][${font}][url][ttf]" />
158
  <input type="hidden" value="${variants[iii].woff}" name="caos_webfonts_array][${font}][url][woff]" />
159
  <input type="hidden" value="${variants[iii].woff2}" name="caos_webfonts_array][${font}][url][woff2]" />
142
  font = fontFamily.replace(/\s+/g, '-').toLowerCase() + '-' + variants[iii].id
143
  fontWeight = variants[iii].fontWeight
144
  fontStyle = variants[iii].fontStyle
145
+ fontLocal = variants[iii].local
146
  renderedFonts[iii] = `<tr id="row-${font}" valign="top">
147
  <td>
148
  <input readonly type="text" value="${fontFamily}" name="caos_webfonts_array][${font}][font-family]" />
155
  </td>
156
  <td>
157
  <input type="hidden" value="${fontId}" name="caos_webfonts_array][${font}][id]" />
158
+ <input type="hidden" value="${fontLocal}" name="caos_webfonts_array][${font}][local]" />
159
  <input type="hidden" value="${variants[iii].ttf}" name="caos_webfonts_array][${font}][url][ttf]" />
160
  <input type="hidden" value="${variants[iii].woff}" name="caos_webfonts_array][${font}][url][woff]" />
161
  <input type="hidden" value="${variants[iii].woff2}" name="caos_webfonts_array][${font}][url][woff2]" />
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: DaanvandenBergh
3
  Donate link: https://daan.dev/donate/
4
  Tags: update, host, save, local, locally, google, fonts, webfonts, minimize, external, requests, leverage, browser, cache
5
  Requires at least: 4.5
6
- Tested up to: 5.1
7
- Stable tag: 1.7.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -23,6 +23,7 @@ This will *decrease your pageload times*, *leverage browser cache*, *minimize DN
23
  - Generate a stylesheet, which is automatically added to your header using WordPress' wp_head()-function,
24
  - Change the caching path (where the fonts and stylesheet are saved) for increased compatibility with Caching- and Security-plugins, such as WP Super Cache, Autoptimize and WordFence,
25
  - Control font performance by adding font-display property,
 
26
  - Prioritize fonts with rel='preload'.
27
 
28
  == Installation ==
@@ -59,7 +60,9 @@ No, it does not. It creates a CSS Stylesheet which will be automatically added t
59
 
60
  = My fonts aren't being downloaded! What's going on? =
61
 
62
- First check your database if the table {prefix}_caos_webfonts exists. If you're using any caching plugins, such as Autoptimize, W3TC or WP Super Cache, empty their caches. After that empty your browser's cache and reload the page. Try again.
 
 
63
 
64
  = The stylesheet isn't loaded? What's going on? =
65
 
@@ -79,6 +82,19 @@ N/A
79
 
80
  == Changelog ==
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  = 1.7.9 =
83
  Cleared up instructions in Welcome Panel.
84
  Added option to remove version parameter from stylesheet request.
3
  Donate link: https://daan.dev/donate/
4
  Tags: update, host, save, local, locally, google, fonts, webfonts, minimize, external, requests, leverage, browser, cache
5
  Requires at least: 4.5
6
+ Tested up to: 5.2
7
+ Stable tag: 1.8.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
23
  - Generate a stylesheet, which is automatically added to your header using WordPress' wp_head()-function,
24
  - Change the caching path (where the fonts and stylesheet are saved) for increased compatibility with Caching- and Security-plugins, such as WP Super Cache, Autoptimize and WordFence,
25
  - Control font performance by adding font-display property,
26
+ - Auto-generates the local source for webfonts,
27
  - Prioritize fonts with rel='preload'.
28
 
29
  == Installation ==
60
 
61
  = My fonts aren't being downloaded! What's going on? =
62
 
63
+ First check your database if the table {prefix}_caos_webfonts exists. If it doesn't, remove the `caos_webfonts_db_version` from the `wp_options` table and reload the page. The table should be created and the issue should be resolved.
64
+
65
+ If the issue still persists and you're using any caching plugins, such as Autoptimize, W3TC or WP Super Cache? Empty their caches. After that empty your browser's cache and reload the page. Try again.
66
 
67
  = The stylesheet isn't loaded? What's going on? =
68
 
82
 
83
  == Changelog ==
84
 
85
+ = 1.8.3 =
86
+ Extended support for local source attribute.
87
+
88
+ = 1.8.2 =
89
+ Correct support for Legacy IE browsers (EOT).
90
+ Added 'local'-attribute to stylesheet.
91
+
92
+ = 1.8.1 =
93
+ Load EOT-files first in stylesheet.
94
+
95
+ = 1.8.0 =
96
+ Minor code optimizations.
97
+
98
  = 1.7.9 =
99
  Cleared up instructions in Welcome Panel.
100
  Added option to remove version parameter from stylesheet request.