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

Version Description

  • Fixed bug in Web Font Loader.
  • Fixed bug where sometimes stylesheet would still be enqueued, even though the file didn't exist.
Download this release

Release Info

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

Code changes from version 3.1.0 to 3.1.1

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.1.0
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.1.1
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
includes/class-db.php CHANGED
@@ -32,9 +32,11 @@ class OMGF_DB
32
  }
33
 
34
  /**
35
- * @return array|\Exception
 
 
36
  */
37
- public function get_downloaded_fonts()
38
  {
39
  try {
40
  $fonts = $this->get_total_fonts();
@@ -43,6 +45,12 @@ class OMGF_DB
43
  return $font['downloaded'] == 1;
44
  });
45
 
 
 
 
 
 
 
46
  return $downloaded;
47
  } catch (\Exception $e) {
48
  return $e;
@@ -50,7 +58,7 @@ class OMGF_DB
50
  }
51
 
52
  /**
53
- * @return array|Exception|object|null
54
  */
55
  public function get_preload_fonts()
56
  {
32
  }
33
 
34
  /**
35
+ * @param bool $clean
36
+ *
37
+ * @return array|Exception
38
  */
39
+ public function get_downloaded_fonts($clean = false)
40
  {
41
  try {
42
  $fonts = $this->get_total_fonts();
45
  return $font['downloaded'] == 1;
46
  });
47
 
48
+ if ($clean) {
49
+ foreach ($downloaded as &$download) {
50
+ $download['font_family'] = str_replace('\'', '', $download['font_family']);
51
+ }
52
+ }
53
+
54
  return $downloaded;
55
  } catch (\Exception $e) {
56
  return $e;
58
  }
59
 
60
  /**
61
+ * @return array|Exception
62
  */
63
  public function get_preload_fonts()
64
  {
includes/frontend/class-functions.php CHANGED
@@ -23,14 +23,26 @@ class OMGF_Frontend_Functions
23
  /** @var OMGF_DB */
24
  private $db;
25
 
 
 
 
 
 
 
26
  /**
27
  * OMGF_Frontend_Functions constructor.
28
  */
29
  public function __construct()
30
  {
 
 
 
31
  // @formatter:off
32
  add_action('wp_print_styles', array($this, 'is_remove_google_fonts_enabled'), PHP_INT_MAX - 1000);
33
- add_action('wp_enqueue_scripts', array($this, 'enqueue_stylesheet'), OMGF_ENQUEUE_ORDER);
 
 
 
34
 
35
  if (OMGF_AUTO_DETECT_ENABLED) {
36
  add_action('wp_print_styles', array($this, 'auto_detect_fonts'), PHP_INT_MAX - 10000);
23
  /** @var OMGF_DB */
24
  private $db;
25
 
26
+ /** @var string */
27
+ private $stylesheet_file;
28
+
29
+ /** @var string */
30
+ private $stylesheet_url;
31
+
32
  /**
33
  * OMGF_Frontend_Functions constructor.
34
  */
35
  public function __construct()
36
  {
37
+ $this->stylesheet_file = OMGF_FONTS_DIR . '/' . OMGF_FILENAME;
38
+ $this->stylesheet_url = OMGF_FONTS_URL . '/' . OMGF_FILENAME;
39
+
40
  // @formatter:off
41
  add_action('wp_print_styles', array($this, 'is_remove_google_fonts_enabled'), PHP_INT_MAX - 1000);
42
+
43
+ if (file_exists($this->stylesheet_file)) {
44
+ add_action('wp_enqueue_scripts', array($this, 'enqueue_stylesheet'), OMGF_ENQUEUE_ORDER);
45
+ }
46
 
47
  if (OMGF_AUTO_DETECT_ENABLED) {
48
  add_action('wp_print_styles', array($this, 'auto_detect_fonts'), PHP_INT_MAX - 10000);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: DaanvandenBergh
3
  Tags: google, fonts, preload, font-display, webfonts, subsets, remove, minimize, external, requests, leverage, browser, cache
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
- Stable tag: 3.1.0
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -105,8 +105,12 @@ N/A
105
 
106
  == Changelog ==
107
 
 
 
 
 
108
  = 3.1.0 =
109
- * OMGF can now rewrite the URI from where fonts are served using the 'Serve webfonts from...' setting. This is particularly useful when using seurity through obscurity (e.g. WP Hide)
110
  * Fixed bug where clicking 'save changes' would remove listed fonts and subsets.
111
  * Gave some settings more accurate descriptions.
112
 
3
  Tags: google, fonts, preload, font-display, webfonts, subsets, remove, minimize, external, requests, leverage, browser, cache
4
  Requires at least: 4.6
5
  Tested up to: 5.4
6
+ Stable tag: 3.1.1
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
105
 
106
  == Changelog ==
107
 
108
+ = 3.1.1 =
109
+ * Fixed bug in Web Font Loader.
110
+ * Fixed bug where sometimes stylesheet would still be enqueued, even though the file didn't exist.
111
+
112
  = 3.1.0 =
113
+ * OMGF can now rewrite the URI from where fonts are served using the 'Serve webfonts from...' setting. This is particularly useful when using seurity through obscurity plugins (e.g. WP Hide.)
114
  * Fixed bug where clicking 'save changes' would remove listed fonts and subsets.
115
  * Gave some settings more accurate descriptions.
116
 
templates/frontend-web-font-loader.phtml CHANGED
@@ -17,7 +17,7 @@
17
  defined('ABSPATH') || exit;
18
 
19
  $db = new OMGF_DB();
20
- $fonts = $db->get_downloaded_fonts();
21
  $families = array_unique(
22
  array_map(
23
  function ($i) {
@@ -30,8 +30,8 @@ $omgfStaticVersion = '?ver=' . OMGF_STATIC_VERSION;
30
  $omgfSrcUrl = OMGF_FONTS_URL . '/' . OMGF_FILENAME . (OMGF_REMOVE_VERSION ? null : $omgfStaticVersion);
31
  $wflVersion = '?ver=' . OMGF_WEB_FONT_LOADER_VERSION;
32
  $wflSrcUrl = plugin_dir_url(OMGF_PLUGIN_FILE) . 'js/libraries/webfont.js' . (OMGF_REMOVE_VERSION ? null : $wflVersion);
33
- ?>
34
- <?php if ($fonts && $families): ?>
35
  <script type="text/javascript">
36
  /**
37
  * Using Typekit's Web Font Loader to load OMGF's fonts asynchronously.
17
  defined('ABSPATH') || exit;
18
 
19
  $db = new OMGF_DB();
20
+ $fonts = $db->get_downloaded_fonts(true);
21
  $families = array_unique(
22
  array_map(
23
  function ($i) {
30
  $omgfSrcUrl = OMGF_FONTS_URL . '/' . OMGF_FILENAME . (OMGF_REMOVE_VERSION ? null : $omgfStaticVersion);
31
  $wflVersion = '?ver=' . OMGF_WEB_FONT_LOADER_VERSION;
32
  $wflSrcUrl = plugin_dir_url(OMGF_PLUGIN_FILE) . 'js/libraries/webfont.js' . (OMGF_REMOVE_VERSION ? null : $wflVersion);
33
+
34
+ if ($fonts && $families): ?>
35
  <script type="text/javascript">
36
  /**
37
  * Using Typekit's Web Font Loader to load OMGF's fonts asynchronously.