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

Version Description

  • OMGF is now loaded inline with other plugins, not last. And,
  • only Auto Detect is now triggered (if enabled) after all other plugins are loaded.
  • An 'Evil Cache Plugin' warning is now thrown, when OMGF is activated and one of the Evil Cache Plugins are installed, prompting the user to move the webfonts-folder outside of the wp-content/cache folder.
  • Fixed bug where Pre Update functions weren't triggered anymore, e.g. move fonts after cache path change.
  • Minor code optimizations/clean up.
Download this release

Release Info

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

Code changes from version 3.4.3 to 3.4.4

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.4.3
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
@@ -81,4 +81,4 @@ function omgf_init()
81
  return $omgf;
82
  }
83
 
84
- add_action('plugins_loaded', 'omgf_init');
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.4.4
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
81
  return $omgf;
82
  }
83
 
84
+ omgf_init();
includes/admin/class-settings.php CHANGED
@@ -70,6 +70,8 @@ class OMGF_Admin_Settings extends OMGF_Admin
70
  */
71
  public function __construct()
72
  {
 
 
73
  $this->active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'generate-stylesheet';
74
  $this->page = isset($_GET['page']) ? $_GET['page'] : '';
75
 
@@ -89,8 +91,6 @@ class OMGF_Admin_Settings extends OMGF_Admin
89
  add_action('omgf_settings_content', [$this, 'generate_stylesheet_content'], 1);
90
  add_action('omgf_settings_content', [$this, 'advanced_settings_content'], 2);
91
  // @formatter:on
92
-
93
- parent::__construct();
94
  }
95
 
96
  /**
70
  */
71
  public function __construct()
72
  {
73
+ parent::__construct();
74
+
75
  $this->active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'generate-stylesheet';
76
  $this->page = isset($_GET['page']) ? $_GET['page'] : '';
77
 
91
  add_action('omgf_settings_content', [$this, 'generate_stylesheet_content'], 1);
92
  add_action('omgf_settings_content', [$this, 'advanced_settings_content'], 2);
93
  // @formatter:on
 
 
94
  }
95
 
96
  /**
includes/class-omgf.php CHANGED
@@ -18,6 +18,14 @@ defined('ABSPATH') || exit;
18
 
19
  class OMGF
20
  {
 
 
 
 
 
 
 
 
21
  /** @var string */
22
  private $page = '';
23
 
@@ -45,13 +53,10 @@ class OMGF
45
  }
46
 
47
  if (!is_admin()) {
48
- $this->do_frontend();
49
  }
50
 
51
- // @formatter:off
52
- register_activation_hook(OMGF_PLUGIN_FILE, array($this, 'create_cache_dir'));
53
- register_deactivation_hook(OMGF_PLUGIN_FILE, array($this, 'dequeue_css_js'));
54
- // @formatter:on
55
  }
56
 
57
  /**
@@ -103,7 +108,7 @@ class OMGF
103
  /**
104
  * @return OMGF_Admin_AutoDetect
105
  */
106
- private function do_auto_detect()
107
  {
108
  $fonts = json_decode(get_option(OMGF_Admin_Settings::OMGF_SETTING_DETECTED_FONTS));
109
 
@@ -112,14 +117,6 @@ class OMGF
112
  }
113
  }
114
 
115
- /**
116
- * @return OMGF_Frontend_Functions
117
- */
118
- private function do_frontend()
119
- {
120
- return new OMGF_Frontend_Functions();
121
- }
122
-
123
  /**
124
  * @return OMGF_Setup
125
  */
@@ -131,13 +128,29 @@ class OMGF
131
  }
132
 
133
  /**
134
- * Create cache dir upon plugin (re-)activation.
 
 
 
 
 
 
 
 
135
  */
136
- public function create_cache_dir()
137
  {
138
- $uploadDir = OMGF_FONTS_DIR;
139
- if (!is_dir($uploadDir)) {
140
- wp_mkdir_p($uploadDir);
 
 
 
 
 
 
 
 
141
  }
142
  }
143
 
@@ -178,16 +191,6 @@ class OMGF
178
  return $uploadUrl;
179
  }
180
 
181
- /**
182
- * Removes all static files upon plugin deactivation.
183
- */
184
- public function dequeue_css_js()
185
- {
186
- wp_dequeue_script(OMGF_Admin::OMGF_ADMIN_JS_HANDLE);
187
- wp_dequeue_style(OMGF_Admin::OMGF_ADMIN_CSS_HANDLE);
188
- wp_dequeue_style(OMGF_Frontend_Functions::OMGF_STYLE_HANDLE);
189
- }
190
-
191
  /**
192
  * @return OMGF_Uninstall
193
  * @throws ReflectionException
18
 
19
  class OMGF
20
  {
21
+ /**
22
+ * @var array These cache plugins empty the entire cache-folder, instead of just removing
23
+ * its own files.
24
+ */
25
+ const OMGF_EVIL_PLUGINS = [
26
+ 'WP Super Cache' => 'wp-super-cache/wp-cache.php'
27
+ ];
28
+
29
  /** @var string */
30
  private $page = '';
31
 
53
  }
54
 
55
  if (!is_admin()) {
56
+ add_action('plugins_loaded', [$this, 'do_frontend']);
57
  }
58
 
59
+ register_activation_hook(OMGF_PLUGIN_FILE, [$this, 'check_cache_plugins']);
 
 
 
60
  }
61
 
62
  /**
108
  /**
109
  * @return OMGF_Admin_AutoDetect
110
  */
111
+ public function do_auto_detect()
112
  {
113
  $fonts = json_decode(get_option(OMGF_Admin_Settings::OMGF_SETTING_DETECTED_FONTS));
114
 
117
  }
118
  }
119
 
 
 
 
 
 
 
 
 
120
  /**
121
  * @return OMGF_Setup
122
  */
128
  }
129
 
130
  /**
131
+ * @return OMGF_Frontend_Functions
132
+ */
133
+ public function do_frontend()
134
+ {
135
+ return new OMGF_Frontend_Functions();
136
+ }
137
+
138
+ /**
139
+ * Throw a warning if any of the Evil Cache Plugins are used.
140
  */
141
+ public function check_cache_plugins()
142
  {
143
+ if (strpos(OMGF_CACHE_PATH, '/cache/') === false) {
144
+ return;
145
+ }
146
+
147
+ $cache_path = OMGF_CACHE_PATH;
148
+ $admin_url = admin_url('options-general.php?page=optimize-webfonts&tab=advanced-settings');
149
+
150
+ foreach (self::OMGF_EVIL_PLUGINS as $name => $basename) {
151
+ if (is_plugin_active($basename)) {
152
+ OMGF_Admin_Notice::set_notice(sprintf(__("It looks like <strong>you're using %s</strong>. This plugin empties the entire <code>wp-content/cache</code> folder after a cache flush. To prevent this, <strong>move OMGF's fonts</strong> by changing the <em>Save font files to...</em> option under OMGF's <a href='%s'>Advanced Settings</a> from <code>%s</code> to something else, e.g. <code>/omgf-cache</code>.", 'host-webfonts-local'), $name, $admin_url, $cache_path), false, 'warning');
153
+ }
154
  }
155
  }
156
 
191
  return $uploadUrl;
192
  }
193
 
 
 
 
 
 
 
 
 
 
 
194
  /**
195
  * @return OMGF_Uninstall
196
  * @throws ReflectionException
includes/class-setup.php CHANGED
@@ -57,6 +57,9 @@ class OMGF_Setup
57
  $this->drop_tables();
58
  }
59
 
 
 
 
60
  private function migrate_db()
61
  {
62
  $current_fonts = $this->wpdb->get_results("SELECT * FROM " . OMGF_DB_TABLENAME);
57
  $this->drop_tables();
58
  }
59
 
60
+ /**
61
+ *
62
+ */
63
  private function migrate_db()
64
  {
65
  $current_fonts = $this->wpdb->get_results("SELECT * FROM " . OMGF_DB_TABLENAME);
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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.4.3
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -108,6 +108,13 @@ N/A
108
 
109
  == Changelog ==
110
 
 
 
 
 
 
 
 
111
  = 3.4.3 =
112
  * Better error handling for Auto Detect.
113
  * Increased performance in admin area.
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.4.4
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
108
 
109
  == Changelog ==
110
 
111
+ = 3.4.4 =
112
+ * OMGF is now loaded inline with other plugins, not last. And,
113
+ * only Auto Detect is now triggered (if enabled) after all other plugins are loaded.
114
+ * An 'Evil Cache Plugin' warning is now thrown, when OMGF is activated and one of the Evil Cache Plugins are installed, prompting the user to move the webfonts-folder **outside** of the `wp-content/cache` folder.
115
+ * Fixed bug where Pre Update functions weren't triggered anymore, e.g. move fonts after cache path change.
116
+ * Minor code optimizations/clean up.
117
+
118
  = 3.4.3 =
119
  * Better error handling for Auto Detect.
120
  * Increased performance in admin area.
templates/admin/block-advanced-settings.phtml CHANGED
@@ -66,7 +66,7 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
66
  <td>
67
  <input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>" placeholder="<?= __('e.g. /cache/omgf-webfonts', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_PATH; ?>"/>
68
  <p class="description">
69
- <?php _e("The folder (inside <code>wp-content</code>) where font files should be stored. Give each site a unique value if you're using Multisite. Defaults to <code>/cache/omgf-webfonts</code>. After changing this setting, the folder will be created if it doesn't exist and existing files will be moved automatically.", 'host-webfonts-local'); ?>
70
  </p>
71
  </td>
72
  </tr>
@@ -105,7 +105,7 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
105
  <td>
106
  <input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>" placeholder="<?= __('e.g. cdn.mydomain.com', 'host-webfonts-local'); ?>" value="<?= OMGF_CDN_URL; ?>" <?= OMGF_RELATIVE_URL ? 'disabled' : ''; ?> />
107
  <p class="description">
108
- <?php _e("Are you using a CDN? Then enter the URL here.", 'host-webfonts-local'); ?>
109
  </p>
110
  </td>
111
  </tr>
66
  <td>
67
  <input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>" placeholder="<?= __('e.g. /cache/omgf-webfonts', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_PATH; ?>"/>
68
  <p class="description">
69
+ <?php _e("The folder (inside <code>wp-content</code>) where font files should be stored. Some caching plugins (e.g. WP Super Cache) empty the entire <code>wp-content/cache</code> folder when the cache if flushed. Change this value if you're using such a plugin. Give each site a unique value if you're using Multisite. Defaults to <code>/cache/omgf-webfonts</code>. After changing this setting, the folder will be created if it doesn't exist and existing files will be moved automatically.", 'host-webfonts-local'); ?>
70
  </p>
71
  </td>
72
  </tr>
105
  <td>
106
  <input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>" placeholder="<?= __('e.g. cdn.mydomain.com', 'host-webfonts-local'); ?>" value="<?= OMGF_CDN_URL; ?>" <?= OMGF_RELATIVE_URL ? 'disabled' : ''; ?> />
107
  <p class="description">
108
+ <?php _e("Are you using a CDN? Then enter the URL here. Leave empty when using CloudFlare.", 'host-webfonts-local'); ?>
109
  </p>
110
  </td>
111
  </tr>