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

Version Description

  • Added: Test Mode, which allows you to test optimizations before releasing them to the public. This option replaces Optimize for Logged-in Administrators/Editors.
  • Fixed: several minor tweaks.
Download this release

Release Info

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

Code changes from version 5.0.6 to 5.1.0

host-webfonts-local.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: OMGF
5
  * Plugin URI: https://ffw.press/wordpress/omgf/
6
  * Description: Increase GDPR compliance, reduce DNS requests and leverage browser cache by automatically downloading Google Fonts to your server.
7
- * Version: 5.0.6
8
  * Author: Daan from FFW.Press
9
  * Author URI: https://ffw.press
10
  * License: GPL2v2 or later
4
  * Plugin Name: OMGF
5
  * Plugin URI: https://ffw.press/wordpress/omgf/
6
  * Description: Increase GDPR compliance, reduce DNS requests and leverage browser cache by automatically downloading Google Fonts to your server.
7
+ * Version: 5.1.0
8
  * Author: Daan from FFW.Press
9
  * Author URI: https://ffw.press
10
  * License: GPL2v2 or later
includes/admin/class-settings.php CHANGED
@@ -120,13 +120,13 @@ class OMGF_Admin_Settings extends OMGF_Admin
120
  /**
121
  * Optimize Fonts
122
  */
123
- const OMGF_OPTIMIZE_SETTING_DISPLAY_OPTION = 'omgf_display_option';
124
- const OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS = 'omgf_optimized_fonts';
125
- const OMGF_OPTIMIZE_SETTING_OPTIMIZE_EDIT_ROLES = 'omgf_optimize_edit_roles';
126
- const OMGF_OPTIMIZE_SETTING_PRELOAD_FONTS = 'omgf_preload_fonts';
127
- const OMGF_OPTIMIZE_SETTING_UNLOAD_FONTS = 'omgf_unload_fonts';
128
- const OMGF_OPTIMIZE_SETTING_UNLOAD_STYLESHEETS = 'omgf_unload_stylesheets';
129
- const OMGF_OPTIMIZE_SETTING_CACHE_KEYS = 'omgf_cache_keys';
130
 
131
  /**
132
  * Advanced Settings
120
  /**
121
  * Optimize Fonts
122
  */
123
+ const OMGF_OPTIMIZE_SETTING_DISPLAY_OPTION = 'omgf_display_option';
124
+ const OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS = 'omgf_optimized_fonts';
125
+ const OMGF_OPTIMIZE_SETTING_PRELOAD_FONTS = 'omgf_preload_fonts';
126
+ const OMGF_OPTIMIZE_SETTING_UNLOAD_FONTS = 'omgf_unload_fonts';
127
+ const OMGF_OPTIMIZE_SETTING_UNLOAD_STYLESHEETS = 'omgf_unload_stylesheets';
128
+ const OMGF_OPTIMIZE_SETTING_CACHE_KEYS = 'omgf_cache_keys';
129
+ const OMGF_OPTIMIZE_SETTING_TEST_MODE = 'omgf_test_mode';
130
 
131
  /**
132
  * Advanced Settings
includes/admin/settings/class-advanced.php CHANGED
@@ -33,9 +33,9 @@ class OMGF_Admin_Settings_Advanced extends OMGF_Admin_Settings_Builder
33
  add_filter('omgf_advanced_settings_content', [$this, 'do_before'], 20);
34
 
35
  // Settings
36
- add_filter('omgf_advanced_settings_content', [$this, 'do_cache_dir'], 70);
37
- add_filter('omgf_advanced_settings_content', [$this, 'do_promo_fonts_source_url'], 80);
38
- add_filter('omgf_advanced_settings_content', [$this, 'do_uninstall'], 110);
39
 
40
  // Close
41
  add_filter('omgf_advanced_settings_content', [$this, 'do_after'], 200);
@@ -90,7 +90,7 @@ class OMGF_Admin_Settings_Advanced extends OMGF_Admin_Settings_Builder
90
  }
91
 
92
  /**
93
- *
94
  */
95
  public function do_uninstall()
96
  {
33
  add_filter('omgf_advanced_settings_content', [$this, 'do_before'], 20);
34
 
35
  // Settings
36
+ add_filter('omgf_advanced_settings_content', [$this, 'do_cache_dir'], 50);
37
+ add_filter('omgf_advanced_settings_content', [$this, 'do_promo_fonts_source_url'], 60);
38
+ add_filter('omgf_advanced_settings_content', [$this, 'do_uninstall'], 100);
39
 
40
  // Close
41
  add_filter('omgf_advanced_settings_content', [$this, 'do_after'], 200);
90
  }
91
 
92
  /**
93
+ * Remove Settings/Files at Uninstall.
94
  */
95
  public function do_uninstall()
96
  {
includes/admin/settings/class-detection.php CHANGED
@@ -88,7 +88,7 @@ class OMGF_Admin_Settings_Detection extends OMGF_Admin_Settings_Builder
88
  <?php endforeach; ?>
89
  </fieldset>
90
  <p class="description">
91
- <?= sprintf(__('By default, OMGF scans each page for mentions of URLs pointing to fonts.googleapis.com. If you need OMGF to "dig deeper", e.g. inside a theme or plugin\'s CSS stylesheets or (Web Font Loader) JS files, <a href="%s" target="_blank">enable these options</a> to increase its level of detection.', $this->plugin_text_domain), 'https://docs.ffw.press/article/21-omgf-pro-google-fonts-processing') . ' ' . $this->promo; ?>
92
  </p>
93
  <ul>
94
  <?php foreach ($this->advanced_processing_pro_options() as $name => $data) : ?>
88
  <?php endforeach; ?>
89
  </fieldset>
90
  <p class="description">
91
+ <?= sprintf(__('By default, OMGF scans each page for mentions of URLs pointing to fonts.googleapis.com. If you need OMGF to "dig deeper", e.g. inside a theme\'s/plugin\'s CSS stylesheets or (Web Font Loader) JS files, <a href="%s" target="_blank">enable these options</a> to increase its level of detection. Best used in combination with a page caching plugin.', $this->plugin_text_domain), 'https://docs.ffw.press/article/21-omgf-pro-google-fonts-processing') . ' ' . $this->promo; ?>
92
  </p>
93
  <ul>
94
  <?php foreach ($this->advanced_processing_pro_options() as $name => $data) : ?>
includes/admin/settings/class-optimize.php CHANGED
@@ -53,7 +53,7 @@ class OMGF_Admin_Settings_Optimize extends OMGF_Admin_Settings_Builder
53
  add_filter('omgf_optimize_settings_content', [$this, 'close_optimize_fonts_container'], 300);
54
 
55
  add_filter('omgf_optimize_settings_content', [$this, 'do_before'], 350);
56
- add_filter('omgf_optimize_settings_content', [$this, 'do_optimize_edit_roles'], 375);
57
  add_filter('omgf_optimize_settings_content', [$this, 'do_after'], 400);
58
  }
59
 
@@ -379,15 +379,15 @@ class OMGF_Admin_Settings_Optimize extends OMGF_Admin_Settings_Builder
379
  }
380
 
381
  /**
382
- *
383
  */
384
- public function do_optimize_edit_roles()
385
  {
386
  $this->do_checkbox(
387
- __('Optimize Fonts For Editors/Administrators?', $this->plugin_text_domain),
388
- OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZE_EDIT_ROLES,
389
- OMGF_OPTIMIZE_EDIT_ROLES,
390
- __('OMGF automatically disables on customizer and page builder previews, etc. Disable this if you want to permanently disable OMGF when you\'re logged in. E.g. when testing/debugging.', $this->plugin_text_domain)
391
  );
392
  }
393
  }
53
  add_filter('omgf_optimize_settings_content', [$this, 'close_optimize_fonts_container'], 300);
54
 
55
  add_filter('omgf_optimize_settings_content', [$this, 'do_before'], 350);
56
+ add_filter('omgf_optimize_settings_content', [$this, 'do_test_mode'], 375);
57
  add_filter('omgf_optimize_settings_content', [$this, 'do_after'], 400);
58
  }
59
 
379
  }
380
 
381
  /**
382
+ * Test Mode
383
  */
384
+ public function do_test_mode()
385
  {
386
  $this->do_checkbox(
387
+ __('Test Mode', $this->plugin_text_domain),
388
+ OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_TEST_MODE,
389
+ OMGF_TEST_MODE,
390
+ __('With this setting enabled, OMGF\'s optimizations will only be visible to logged in administrators or when <code>?omgf=1</code> is added to an URL in the frontend.', $this->plugin_text_domain)
391
  );
392
  }
393
  }
includes/class-omgf.php CHANGED
@@ -58,10 +58,10 @@ class OMGF
58
  define('OMGF_DISPLAY_OPTION', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_DISPLAY_OPTION, 'swap')) ?: 'swap');
59
  define('OMGF_UNLOAD_STYLESHEETS', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_UNLOAD_STYLESHEETS, '')));
60
  define('OMGF_CACHE_KEYS', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_CACHE_KEYS, '')));
61
- define('OMGF_OPTIMIZE_EDIT_ROLES', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZE_EDIT_ROLES, 'on')));
62
  define('OMGF_UNINSTALL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL)));
63
  define('OMGF_UPLOAD_DIR', apply_filters('omgf_upload_dir', WP_CONTENT_DIR . '/uploads/omgf'));
64
- define('OMGF_UPLOAD_URL', apply_filters('omgf_upload_url', WP_CONTENT_URL . '/uploads/omgf'));
65
  }
66
 
67
  /**
58
  define('OMGF_DISPLAY_OPTION', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_DISPLAY_OPTION, 'swap')) ?: 'swap');
59
  define('OMGF_UNLOAD_STYLESHEETS', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_UNLOAD_STYLESHEETS, '')));
60
  define('OMGF_CACHE_KEYS', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_CACHE_KEYS, '')));
61
+ define('OMGF_TEST_MODE', esc_attr(get_option(OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_TEST_MODE)));
62
  define('OMGF_UNINSTALL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL)));
63
  define('OMGF_UPLOAD_DIR', apply_filters('omgf_upload_dir', WP_CONTENT_DIR . '/uploads/omgf'));
64
+ define('OMGF_UPLOAD_URL', apply_filters('omgf_upload_url', content_url('/uploads/omgf')));
65
  }
66
 
67
  /**
includes/class-optimize.php CHANGED
@@ -220,7 +220,7 @@ class OMGF_Optimize
220
  return $current_stylesheet;
221
  break;
222
  default: // 'url'
223
- return str_replace(WP_CONTENT_DIR, content_url(), $local_file);
224
  }
225
  }
226
 
220
  return $current_stylesheet;
221
  break;
222
  default: // 'url'
223
+ return str_replace(OMGF_UPLOAD_DIR, content_url('uploads/omgf'), $local_file);
224
  }
225
  }
226
 
includes/frontend/class-process.php CHANGED
@@ -61,9 +61,16 @@ class OMGF_Frontend_Process
61
  private function init()
62
  {
63
  /**
64
- * Halt if this parameter is set.
 
 
 
65
  */
66
- if (isset($_GET['nomgf'])) {
 
 
 
 
67
  return;
68
  }
69
 
@@ -143,13 +150,6 @@ class OMGF_Frontend_Process
143
  return ob_start([$this, 'return_buffer']);
144
  }
145
 
146
- /**
147
- * Should we optimize for logged in Administrators/Editors?
148
- */
149
- if (!OMGF_OPTIMIZE_EDIT_ROLES && current_user_can('edit_pages')) {
150
- return false;
151
- }
152
-
153
  /**
154
  * Make sure Page Builder previews don't get optimized content.
155
  */
@@ -413,7 +413,7 @@ class OMGF_Frontend_Process
413
  * attribute to prevent it from loading.
414
  */
415
  if (OMGF::unloaded_stylesheets() && in_array($handle, OMGF::unloaded_stylesheets())) {
416
- $search[$key] = $stack['href'];
417
  $replace[$key] = '';
418
 
419
  continue;
61
  private function init()
62
  {
63
  /**
64
+ * Halt execution if:
65
+ * * `nomgf` GET-parameter is set.
66
+ * * Test Mode is enabled and current user is not an admin.
67
+ * * Test Mode is enabled and `omgf` GET-parameter is not set.
68
  */
69
+ if (
70
+ isset($_GET['nomgf'])
71
+ || ((OMGF_TEST_MODE == 'on' && !current_user_can('manage_options') && !isset($_GET['omgf_optimize']))
72
+ && (OMGF_TEST_MODE == 'on' && !current_user_can('manage_options') && !isset($_GET['omgf_optimize']) && !isset($_GET['omgf'])))
73
+ ) {
74
  return;
75
  }
76
 
150
  return ob_start([$this, 'return_buffer']);
151
  }
152
 
 
 
 
 
 
 
 
153
  /**
154
  * Make sure Page Builder previews don't get optimized content.
155
  */
413
  * attribute to prevent it from loading.
414
  */
415
  if (OMGF::unloaded_stylesheets() && in_array($handle, OMGF::unloaded_stylesheets())) {
416
+ $search[$key] = $stack['href'];
417
  $replace[$key] = '';
418
 
419
  continue;
readme.md CHANGED
@@ -42,7 +42,6 @@ All Google Fonts are listed in the **Manage Optimized Fonts** section of OMGF's
42
  - To serve fonts from an alternative path (e.g. when you're using Security through Obscurity plugins like WP Hide, etc.), or
43
  - Set a relative path to easily migrate from development/staging areas to production/live, or
44
  - Anything you like!
45
- - Proper handling for AMP pages (Fallback to or remove Google Fonts).
46
 
47
  *[Purchase OMGF Pro](https://ffw.press/wordpress/omgf-pro/) | [Documentation](https://docs.ffw.press/category/4-omgf-pro/) | [Tested Plugins & Themes](https://docs.ffw.press/article/40-list-of-compatible-themes-and-plugins-omgf-pro)*
48
 
42
  - To serve fonts from an alternative path (e.g. when you're using Security through Obscurity plugins like WP Hide, etc.), or
43
  - Set a relative path to easily migrate from development/staging areas to production/live, or
44
  - Anything you like!
 
45
 
46
  *[Purchase OMGF Pro](https://ffw.press/wordpress/omgf-pro/) | [Documentation](https://docs.ffw.press/category/4-omgf-pro/) | [Tested Plugins & Themes](https://docs.ffw.press/article/40-list-of-compatible-themes-and-plugins-omgf-pro)*
47
 
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.9
6
- Stable tag: 5.0.6
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -50,7 +50,6 @@ All Google Fonts are listed in the **Manage Optimized Fonts** section of OMGF's
50
  - To serve fonts from an alternative path (e.g. when you're using Security through Obscurity plugins like WP Hide, etc.), or
51
  - Set a relative path to easily migrate from development/staging areas to production/live, or
52
  - Anything you like!
53
- - Proper handling for AMP pages (Fallback to or remove Google Fonts).
54
 
55
  *[Purchase OMGF Pro](https://ffw.press/wordpress/omgf-pro/) | [Documentation](https://docs.ffw.press/category/4-omgf-pro/) | [Tested Plugins & Themes](https://docs.ffw.press/article/40-list-of-compatible-themes-and-plugins-omgf-pro)*
56
 
@@ -76,6 +75,11 @@ For the FAQ, [click here](https://docs.ffw.press/category/76-omgf-pro---faq).
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
79
  = 5.0.6 =
80
  * Added: Removed Cache Directory in favor of an automatic approach to improve UX, because most people didn't change the default value anyway.
81
  - I.e. all files generated by OMGF are stored in a subdirectory of the Uploads folder (default `wp-content/uploads`), called `omgf`.
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.9
6
+ Stable tag: 5.1.0
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
50
  - To serve fonts from an alternative path (e.g. when you're using Security through Obscurity plugins like WP Hide, etc.), or
51
  - Set a relative path to easily migrate from development/staging areas to production/live, or
52
  - Anything you like!
 
53
 
54
  *[Purchase OMGF Pro](https://ffw.press/wordpress/omgf-pro/) | [Documentation](https://docs.ffw.press/category/4-omgf-pro/) | [Tested Plugins & Themes](https://docs.ffw.press/article/40-list-of-compatible-themes-and-plugins-omgf-pro)*
55
 
75
 
76
  == Changelog ==
77
 
78
+ = 5.1.0 =
79
+ * Added: Test Mode, which allows you to test optimizations before releasing them to the public.
80
+ This option replaces Optimize for Logged-in Administrators/Editors.
81
+ * Fixed: several minor tweaks.
82
+
83
  = 5.0.6 =
84
  * Added: Removed Cache Directory in favor of an automatic approach to improve UX, because most people didn't change the default value anyway.
85
  - I.e. all files generated by OMGF are stored in a subdirectory of the Uploads folder (default `wp-content/uploads`), called `omgf`.