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

Version Description

| August 16th, 2020 = * Tested with WP 5.5. * Cleaned up the sidebar. * Improved re-enqueueing of stylesheets, if a stylesheet depends on the removed Google Font stylesheet. * Pressing Enter in the Search Bar triggers search now. * Developers can now easily add functionalities to OMGF's brand new Extensions tab, using several new filters and actions. * If OMGF is used along with other WoOSH! plugins (e.g. CAOS, OMGF Pro, etc.) the same class loader is used, significantly increasing performance. * Added dates to changelog :)

Download this release

Release Info

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

Code changes from version 3.7.0 to 3.8.0

assets/js/omgf-admin.js CHANGED
@@ -33,6 +33,8 @@ jQuery(document).ready(function ($) {
33
  font_style_list: [],
34
 
35
  // Selectors
 
 
36
  $loader: $('.omgf-loading'),
37
  $font_families: $('.omgf-subset-font-family'),
38
  $subsets: $('.omgf-subset'),
@@ -51,6 +53,14 @@ jQuery(document).ready(function ($) {
51
  this.$subsets.on('click', this.manage_subset_queue);
52
  this.$manage_font_styles.on('click', this.manage_font_styles_queues);
53
 
 
 
 
 
 
 
 
 
54
  // Buttons
55
  $('#omgf-search-subsets').on('click', this.click_search);
56
  $('#omgf-auto-detect, .help.auto-detect').on('click', this.enable_auto_detect);
33
  font_style_list: [],
34
 
35
  // Selectors
36
+ $search_box: $('#omgf-search'),
37
+ $search_button: $('#omgf-search-subsets'),
38
  $loader: $('.omgf-loading'),
39
  $font_families: $('.omgf-subset-font-family'),
40
  $subsets: $('.omgf-subset'),
53
  this.$subsets.on('click', this.manage_subset_queue);
54
  this.$manage_font_styles.on('click', this.manage_font_styles_queues);
55
 
56
+ // Pressing enter in the search box redirects to WordPress' General Options? Let's NOT.
57
+ this.$search_box.on('keyup, keydown', function(event) {
58
+ if (event.keyCode === 13) {
59
+ event.preventDefault();
60
+ omgf_admin.$search_button.click();
61
+ }
62
+ });
63
+
64
  // Buttons
65
  $('#omgf-search-subsets').on('click', this.click_search);
66
  $('#omgf-auto-detect, .help.auto-detect').on('click', this.enable_auto_detect);
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.7.0
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
@@ -38,29 +38,13 @@ function omgf_autoload($class)
38
  return;
39
  }
40
 
41
- $filename = '';
42
-
43
- if (count($path) == 1) {
44
- $filename = 'class-' . strtolower(str_replace('_', '-', $class)) . '.php';
45
- } elseif (count($path) == 2) {
46
- array_shift($path);
47
- $filename = 'class-' . strtolower($path[0]) . '.php';
48
- } else {
49
- array_shift($path);
50
- end($path);
51
- $i = 0;
52
-
53
- while ($i < key($path)) {
54
- $filename .= strtolower($path[$i]) . '/';
55
- $i++;
56
- }
57
-
58
- $pieces = preg_split('/(?=[A-Z])/', lcfirst($path[$i]));
59
-
60
- $filename .= 'class-' . strtolower(implode('-', $pieces)) . '.php';
61
  }
62
 
63
- return include OMGF_PLUGIN_DIR . 'includes/' . $filename;
 
 
64
  }
65
 
66
  spl_autoload_register('omgf_autoload');
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.8.0
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
38
  return;
39
  }
40
 
41
+ if (!class_exists('Woosh_Autoloader')) {
42
+ require_once(OMGF_PLUGIN_DIR . 'woosh-autoload.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
+ $autoload = new Woosh_Autoloader($class);
46
+
47
+ return include OMGF_PLUGIN_DIR . 'includes/' . $autoload->load();
48
  }
49
 
50
  spl_autoload_register('omgf_autoload');
includes/admin/class-auto-detect.php CHANGED
@@ -84,7 +84,7 @@ class OMGF_Admin_AutoDetect
84
  if (empty($subsets)) {
85
  OMGF_Admin_Notice::set_notice(__('Auto Detect completed successfully, but no Google Fonts were found.', 'host-webfonts-local'), false, 'warning');
86
 
87
- OMGF_Admin_Notice::set_notice(sprintf(__('Your theme and/or plugins are using unconventional methods (or Web Font Loader) to load Google Fonts. <strong>Upgrade to OMGF Pro</strong> (<em>starting at € 39, -</em>) to automatically detect and replace Google Fonts for your theme and plugins. <a href="%s" target="_blank">Purchase OMGF Pro</a>.', 'host-webfonts-local'), 'https://woosh.dev/wordpress-plugins/host-google-fonts-pro'), false, 'info');
88
  } else {
89
  $count_fonts = count($subsets);
90
  $count_subsets = 0;
84
  if (empty($subsets)) {
85
  OMGF_Admin_Notice::set_notice(__('Auto Detect completed successfully, but no Google Fonts were found.', 'host-webfonts-local'), false, 'warning');
86
 
87
+ OMGF_Admin_Notice::set_notice(sprintf(__('Your theme and/or plugins are using unconventional methods (or Web Font Loader) to load Google Fonts. <strong>Upgrade to OMGF Pro</strong> (<em>starting at € 29, -</em>) to automatically detect and replace Google Fonts for your theme and plugins. <a href="%s" target="_blank">Purchase OMGF Pro</a>.', 'host-webfonts-local'), OMGF_Admin_Settings_Builder::WOOSH_WORDPRESS_PLUGINS_HOST_GOOGLE_FONTS_PRO), false, 'info');
88
  } else {
89
  $count_fonts = count($subsets);
90
  $count_subsets = 0;
includes/admin/class-settings.php CHANGED
@@ -21,7 +21,9 @@ class OMGF_Admin_Settings extends OMGF_Admin
21
  /**
22
  * Settings Fields
23
  */
24
- const OMGF_SETTINGS_FIELD_ADVANCED = 'omgf-advanced-settings';
 
 
25
 
26
  /**
27
  * Option Values
@@ -65,6 +67,9 @@ class OMGF_Admin_Settings extends OMGF_Admin
65
  /** @var string $page */
66
  private $page;
67
 
 
 
 
68
  /**
69
  * OMGF_Admin_Settings constructor.
70
  */
@@ -72,24 +77,26 @@ class OMGF_Admin_Settings extends OMGF_Admin
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
 
78
  // @formatter:off
79
  add_action('admin_menu', [$this, 'create_menu']);
80
  add_filter('plugin_action_links_' . plugin_basename(OMGF_PLUGIN_FILE), [$this, 'create_settings_link']);
81
 
82
- if (!$this->page == 'optimize-webfonts') {
83
  return;
84
  }
85
 
86
  // Tabs
87
  add_action('omgf_settings_tab', [$this, 'generate_stylesheet_tab'], 1);
88
  add_action('omgf_settings_tab', [$this, 'advanced_settings_tab'], 2);
 
89
 
90
  // Content
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
 
@@ -103,10 +110,7 @@ class OMGF_Admin_Settings extends OMGF_Admin
103
  'Optimize Google Fonts',
104
  'manage_options',
105
  'optimize-webfonts',
106
- array(
107
- $this,
108
- 'create_settings_page'
109
- )
110
  );
111
 
112
  // @formatter:off
@@ -120,11 +124,11 @@ class OMGF_Admin_Settings extends OMGF_Admin
120
  public function create_settings_page()
121
  {
122
  if (!current_user_can('manage_options')) {
123
- wp_die(__("You're not cool enough to access this page.", 'host-webfonts-local'));
124
  }
125
  ?>
126
  <div class="wrap">
127
- <h1><?= apply_filters('omgf_settings_page_title', __('OMGF | Optimize My Google Fonts', 'host-webfonts-local')); ?></h1>
128
 
129
  <p>
130
  <?= get_plugin_data(OMGF_PLUGIN_FILE)['Description']; ?>
@@ -154,10 +158,16 @@ class OMGF_Admin_Settings extends OMGF_Admin
154
  */
155
  public function register_settings()
156
  {
 
 
 
 
 
 
157
  foreach ($this->get_settings() as $constant => $value)
158
  {
159
  register_setting(
160
- OMGF_Admin_Settings::OMGF_SETTINGS_FIELD_ADVANCED,
161
  $value
162
  );
163
  }
@@ -171,13 +181,22 @@ class OMGF_Admin_Settings extends OMGF_Admin
171
  */
172
  public function get_settings()
173
  {
174
- $reflection = new ReflectionClass($this);
175
- $constants = $reflection->getConstants();
 
 
 
 
 
 
 
 
 
176
 
177
  return array_filter(
178
  $constants,
179
- function ($key) {
180
- return strpos($key, 'OMGF_ADV_SETTING') !== false;
181
  },
182
  ARRAY_FILTER_USE_KEY
183
  );
@@ -188,7 +207,7 @@ class OMGF_Admin_Settings extends OMGF_Admin
188
  */
189
  public function generate_stylesheet_tab()
190
  {
191
- $this->generate_tab('generate-stylesheet', 'dashicons-admin-appearance', __('Generate Stylesheet', 'host-webfonts-local'));
192
  }
193
 
194
  /**
@@ -196,7 +215,15 @@ class OMGF_Admin_Settings extends OMGF_Admin
196
  */
197
  public function advanced_settings_tab()
198
  {
199
- $this->generate_tab('advanced-settings', 'dashicons-admin-settings', __('Advanced Settings', 'host-webfonts-local'));
 
 
 
 
 
 
 
 
200
  }
201
 
202
  /**
@@ -228,7 +255,7 @@ class OMGF_Admin_Settings extends OMGF_Admin
228
  */
229
  public function generate_stylesheet_content()
230
  {
231
- if ($this->active_tab != 'generate-stylesheet') {
232
  return;
233
  }
234
  ?>
@@ -241,22 +268,39 @@ class OMGF_Admin_Settings extends OMGF_Admin
241
  }
242
 
243
  /**
244
- * Render Advanced Settings
245
  */
246
  public function advanced_settings_content()
247
  {
248
- if ($this->active_tab != 'advanced-settings') {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  return;
250
  }
251
  ?>
252
- <form id="omgf-advanced-settings-form" name="omgf-settings-form" method="post" action="options.php">
253
  <?php
254
- settings_fields(OMGF_Admin_Settings::OMGF_SETTINGS_FIELD_ADVANCED);
255
- do_settings_sections(OMGF_Admin_Settings::OMGF_SETTINGS_FIELD_ADVANCED);
256
 
257
  do_action('omgf_before_settings_form_settings');
258
 
259
- echo apply_filters('omgf_' . str_replace('-', '_', $this->active_tab) . '_content', '');
260
 
261
  do_action('omgf_after_settings_form_settings');
262
 
21
  /**
22
  * Settings Fields
23
  */
24
+ const OMGF_SETTINGS_FIELD_GENERATE_STYLESHEET = 'omgf-generate-stylesheet';
25
+ const OMGF_SETTINGS_FIELD_ADVANCED = 'omgf-advanced-settings';
26
+ const OMGF_SETTINGS_FIELD_EXTENSIONS = 'omgf-extensions-settings';
27
 
28
  /**
29
  * Option Values
67
  /** @var string $page */
68
  private $page;
69
 
70
+ /** @var string $plugin_text_domain */
71
+ private $plugin_text_domain = 'host-webfonts-local';
72
+
73
  /**
74
  * OMGF_Admin_Settings constructor.
75
  */
77
  {
78
  parent::__construct();
79
 
80
+ $this->active_tab = isset($_GET['tab']) ? $_GET['tab'] : self::OMGF_SETTINGS_FIELD_GENERATE_STYLESHEET;
81
  $this->page = isset($_GET['page']) ? $_GET['page'] : '';
82
 
83
  // @formatter:off
84
  add_action('admin_menu', [$this, 'create_menu']);
85
  add_filter('plugin_action_links_' . plugin_basename(OMGF_PLUGIN_FILE), [$this, 'create_settings_link']);
86
 
87
+ if ($this->page !== 'optimize-webfonts') {
88
  return;
89
  }
90
 
91
  // Tabs
92
  add_action('omgf_settings_tab', [$this, 'generate_stylesheet_tab'], 1);
93
  add_action('omgf_settings_tab', [$this, 'advanced_settings_tab'], 2);
94
+ add_action('omgf_settings_tab', [$this, 'extensions_settings_tab'], 3);
95
 
96
  // Content
97
  add_action('omgf_settings_content', [$this, 'generate_stylesheet_content'], 1);
98
  add_action('omgf_settings_content', [$this, 'advanced_settings_content'], 2);
99
+ add_action('omgf_settings_content', [$this, 'extensions_settings_content'], 3);
100
  // @formatter:on
101
  }
102
 
110
  'Optimize Google Fonts',
111
  'manage_options',
112
  'optimize-webfonts',
113
+ [$this, 'create_settings_page']
 
 
 
114
  );
115
 
116
  // @formatter:off
124
  public function create_settings_page()
125
  {
126
  if (!current_user_can('manage_options')) {
127
+ wp_die(__("You're not cool enough to access this page.", $this->plugin_text_domain));
128
  }
129
  ?>
130
  <div class="wrap">
131
+ <h1><?= apply_filters('omgf_settings_page_title', __('OMGF | Optimize My Google Fonts', $this->plugin_text_domain)); ?></h1>
132
 
133
  <p>
134
  <?= get_plugin_data(OMGF_PLUGIN_FILE)['Description']; ?>
158
  */
159
  public function register_settings()
160
  {
161
+ if ($this->active_tab !== self::OMGF_SETTINGS_FIELD_GENERATE_STYLESHEET
162
+ && $this->active_tab !== self::OMGF_SETTINGS_FIELD_ADVANCED
163
+ && $this->active_tab !== self::OMGF_SETTINGS_FIELD_EXTENSIONS) {
164
+ $this->active_tab = self::OMGF_SETTINGS_FIELD_GENERATE_STYLESHEET;
165
+ }
166
+
167
  foreach ($this->get_settings() as $constant => $value)
168
  {
169
  register_setting(
170
+ $this->active_tab,
171
  $value
172
  );
173
  }
181
  */
182
  public function get_settings()
183
  {
184
+ if ($this->active_tab == self::OMGF_SETTINGS_FIELD_GENERATE_STYLESHEET) {
185
+ return [];
186
+ }
187
+
188
+ $reflection = new ReflectionClass($this);
189
+ $constants = apply_filters('omgf_settings_constants', $reflection->getConstants());
190
+ $needle = 'OMGF_ADV_SETTING';
191
+
192
+ if ($this->active_tab == self::OMGF_SETTINGS_FIELD_EXTENSIONS) {
193
+ $needle = 'OMGF_EXT_SETTING';
194
+ }
195
 
196
  return array_filter(
197
  $constants,
198
+ function ($key) use ($needle) {
199
+ return strpos($key, $needle) !== false;
200
  },
201
  ARRAY_FILTER_USE_KEY
202
  );
207
  */
208
  public function generate_stylesheet_tab()
209
  {
210
+ $this->generate_tab(self::OMGF_SETTINGS_FIELD_GENERATE_STYLESHEET, 'dashicons-admin-appearance', __('Generate Stylesheet', $this->plugin_text_domain));
211
  }
212
 
213
  /**
215
  */
216
  public function advanced_settings_tab()
217
  {
218
+ $this->generate_tab(self::OMGF_SETTINGS_FIELD_ADVANCED, 'dashicons-admin-settings', __('Advanced Settings', $this->plugin_text_domain));
219
+ }
220
+
221
+ /**
222
+ * Add Extensions tab to Settings Screen.
223
+ */
224
+ public function extensions_settings_tab()
225
+ {
226
+ $this->generate_tab(self::OMGF_SETTINGS_FIELD_EXTENSIONS, 'dashicons-admin-plugins', __('Extensions', $this->plugin_text_domain));
227
  }
228
 
229
  /**
255
  */
256
  public function generate_stylesheet_content()
257
  {
258
+ if ($this->active_tab != self::OMGF_SETTINGS_FIELD_GENERATE_STYLESHEET) {
259
  return;
260
  }
261
  ?>
268
  }
269
 
270
  /**
271
+ * Render Advanced Settings content
272
  */
273
  public function advanced_settings_content()
274
  {
275
+ $this->do_settings_content(self::OMGF_SETTINGS_FIELD_ADVANCED);
276
+ }
277
+
278
+ /**
279
+ * Render Extensions content
280
+ */
281
+ public function extensions_settings_content()
282
+ {
283
+ $this->do_settings_content(self::OMGF_SETTINGS_FIELD_EXTENSIONS);
284
+ }
285
+
286
+ /**
287
+ * @param $id
288
+ * @param $field
289
+ */
290
+ private function do_settings_content($field)
291
+ {
292
+ if ($this->active_tab != $field) {
293
  return;
294
  }
295
  ?>
296
+ <form id="<?= $field; ?>-form" name="omgf-settings-form" method="post" action="options.php?tab=<?= $this->active_tab; ?>">
297
  <?php
298
+ settings_fields($field);
299
+ do_settings_sections($field);
300
 
301
  do_action('omgf_before_settings_form_settings');
302
 
303
+ echo apply_filters(str_replace('-', '_', $field) . '_content', '');
304
 
305
  do_action('omgf_after_settings_form_settings');
306
 
includes/admin/settings/class-advanced.php CHANGED
@@ -76,7 +76,7 @@ class OMGF_Admin_Settings_Advanced extends OMGF_Admin_Settings_Builder
76
  __('Auto Remove', $this->plugin_text_domain),
77
  OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS,
78
  OMGF_REMOVE_GFONTS,
79
- sprintf(__('Remove any requests to externally hosted Google Fonts-stylesheets from your WordPress-blog. If it doesn\'t work, your theme and/or plugin(s) are using unconventional methods or Web Font Loader to load Google Fonts. <a href="%s" target="_blank">Upgrade to OMGF Pro</a> to automatically remove Google Fonts incl. resource hints (e.g. <code>dns-prefetch</code>, <code>preconnect</code> and <code>preload</code>).', $this->plugin_text_domain), 'https://woosh.dev/wordpress-plugins/host-google-fonts-pro/' . $this->utmTags)
80
  );
81
  }
82
 
76
  __('Auto Remove', $this->plugin_text_domain),
77
  OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS,
78
  OMGF_REMOVE_GFONTS,
79
+ sprintf(__('Remove any requests to externally hosted Google Fonts-stylesheets from your WordPress-blog. If it doesn\'t work, your theme and/or plugin(s) are using unconventional methods or Web Font Loader to load Google Fonts. <a href="%s" target="_blank">Upgrade to OMGF Pro</a> to automatically remove Google Fonts incl. resource hints (e.g. <code>dns-prefetch</code>, <code>preconnect</code> and <code>preload</code>).', $this->plugin_text_domain), self::WOOSH_WORDPRESS_PLUGINS_HOST_GOOGLE_FONTS_PRO . $this->utmTags)
80
  );
81
  }
82
 
includes/admin/settings/class-builder.php CHANGED
@@ -18,6 +18,8 @@ defined('ABSPATH') || exit;
18
 
19
  class OMGF_Admin_Settings_Builder
20
  {
 
 
21
  /** @var string $plugin_text_domain */
22
  protected $plugin_text_domain = 'host-webfonts-local';
23
 
@@ -144,13 +146,13 @@ class OMGF_Admin_Settings_Builder
144
  * @param $checked
145
  * @param $description
146
  */
147
- public function do_checkbox($label, $name, $checked, $description, $update_required = false)
148
  {
149
  ?>
150
  <tr>
151
  <th scope="row"><?= apply_filters($name . '_setting_label', $label); ?> <?= $update_required ?: ''; ?></th>
152
  <td>
153
- <input type="checkbox" class="<?= str_replace('_' , '-' , $name); ?>" name="<?= $name; ?>"
154
  <?= $checked == "on" ? 'checked = "checked"' : ''; ?> />
155
  <p class="description">
156
  <?= apply_filters($name . '_setting_description', $description); ?>
18
 
19
  class OMGF_Admin_Settings_Builder
20
  {
21
+ const WOOSH_WORDPRESS_PLUGINS_HOST_GOOGLE_FONTS_PRO = 'https://woosh.dev/wordpress-plugins/host-google-fonts-pro/#get-omgf-pro';
22
+
23
  /** @var string $plugin_text_domain */
24
  protected $plugin_text_domain = 'host-webfonts-local';
25
 
146
  * @param $checked
147
  * @param $description
148
  */
149
+ public function do_checkbox($label, $name, $checked, $description, $update_required = false, $disabled = false)
150
  {
151
  ?>
152
  <tr>
153
  <th scope="row"><?= apply_filters($name . '_setting_label', $label); ?> <?= $update_required ?: ''; ?></th>
154
  <td>
155
+ <input type="checkbox" <?= apply_filters($name . '_setting_disabled', $disabled) ? 'disabled' : ''; ?> class="<?= str_replace('_' , '-' , $name); ?>" name="<?= $name; ?>"
156
  <?= $checked == "on" ? 'checked = "checked"' : ''; ?> />
157
  <p class="description">
158
  <?= apply_filters($name . '_setting_description', $description); ?>
includes/admin/settings/class-extensions.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
+ * @package : OMGF
12
+ * @author : Daan van den Bergh
13
+ * @copyright: (c) 2020 Daan van den Bergh
14
+ * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
+
17
+ defined('ABSPATH') || exit;
18
+
19
+ class OMGF_Admin_Settings_Extensions extends OMGF_Admin_Settings_Builder
20
+ {
21
+ /**
22
+ * OMGF_Admin_Settings_Advanced constructor.
23
+ */
24
+ public function __construct()
25
+ {
26
+ $this->title = __('Extensions', $this->plugin_text_domain);
27
+
28
+ // Open
29
+ // @formatter:off
30
+ add_filter('omgf_extensions_settings_content', [$this, 'do_title'], 10);
31
+ add_filter('omgf_extensions_settings_content', [$this, 'do_description'], 15);
32
+ add_filter('omgf_extensions_settings_content', [$this, 'do_before'], 20);
33
+
34
+ // Settings
35
+ add_filter('omgf_extensions_settings_content', [$this, 'do_promo_remove_stylesheets'], 30);
36
+ add_filter('omgf_extensions_settings_content', [$this, 'do_promo_remove_inline_styles'], 40);
37
+ add_filter('omgf_extensions_settings_content', [$this, 'do_promo_remove_webfont_loader'], 50);
38
+ add_filter('omgf_extensions_settings_content', [$this, 'do_promo_remove_resource_hints'], 60);
39
+
40
+ // Close
41
+ add_filter('omgf_extensions_settings_content', [$this, 'do_after'], 100);
42
+ // @formatter:on
43
+ }
44
+
45
+ /**
46
+ * Description
47
+ */
48
+ public function do_description()
49
+ {
50
+ ?>
51
+ <p>
52
+ <?= __('Fine tune and enhance the functionality of OMGF using extensions.', $this->plugin_text_domain); ?>
53
+ </p>
54
+ <p>
55
+ <?= sprintf(__('For a list of available plugins, click <a target="_blank" href="%s">here</a>.', $this->plugin_text_domain), 'https://woosh.dev/wordpress-plugins/'); ?>
56
+ </p>
57
+ <?php
58
+ }
59
+
60
+ /**
61
+ * Add (overridable) promo options for Remove Stylesheets Pro.
62
+ */
63
+ public function do_promo_remove_stylesheets()
64
+ {
65
+ $this->do_checkbox(
66
+ __('Remove Stylesheets (Pro)', $this->plugin_text_domain),
67
+ 'omgf_pro_remove_stylesheets',
68
+ defined('OMGF_PRO_REMOVE_STYLESHEETS') ? OMGF_PRO_REMOVE_STYLESHEETS : false,
69
+ sprintf(__('Remove all stylesheets loaded from <code>fonts.googleapis.com</code> or <code>fonts.gstatic.com</code>. <a href="%s" target="_blank">Purchase OMGF Pro</a> to enable this option.', $this->plugin_text_domain), OMGF_Admin_Settings_Builder::WOOSH_WORDPRESS_PLUGINS_HOST_GOOGLE_FONTS_PRO),
70
+ false,
71
+ true
72
+ );
73
+ }
74
+
75
+ /**
76
+ *
77
+ */
78
+ public function do_promo_remove_inline_styles()
79
+ {
80
+ $this->do_checkbox(
81
+ __('Remove Inline Styles (Pro)', $this->plugin_text_domain),
82
+ 'omgf_pro_remove_inline_styles',
83
+ defined('OMGF_PRO_REMOVE_INLINE_STYLES') ? OMGF_PRO_REMOVE_INLINE_STYLES : false,
84
+ sprintf(__('Remove all <code>@font-face</code> and <code>@import</code> rules loading Google Fonts. <a href="%s" target="_blank">Purchase OMGF Pro</a> to enable this option.', $this->plugin_text_domain), OMGF_Admin_Settings_Builder::WOOSH_WORDPRESS_PLUGINS_HOST_GOOGLE_FONTS_PRO),
85
+ false,
86
+ true
87
+ );
88
+ }
89
+
90
+ /**
91
+ *
92
+ */
93
+ public function do_promo_remove_webfont_loader()
94
+ {
95
+ $this->do_checkbox(
96
+ __('Remove WebFont Loader (Pro)', $this->plugin_text_domain),
97
+ 'omgf_pro_remove_webfont_loader',
98
+ defined('OMGF_PRO_REMOVE_WEBFONT_LOADER') ? OMGF_PRO_REMOVE_WEBFONT_LOADER : false,
99
+ sprintf(__('Remove any WebFont Loader (<code>webfont.js</code>) libraries and the corresponding configuration defining which Google Fonts to load (WebFont Config). <a href="%s" target="_blank">Purchase OMGF Pro</a> to enable this option.', $this->plugin_text_domain), OMGF_Admin_Settings_Builder::WOOSH_WORDPRESS_PLUGINS_HOST_GOOGLE_FONTS_PRO),
100
+ false,
101
+ true
102
+ );
103
+ }
104
+
105
+ /**
106
+ *
107
+ */
108
+ public function do_promo_remove_resource_hints()
109
+ {
110
+ $this->do_checkbox(
111
+ __('Remove Resource Hints (Pro)', $this->plugin_text_domain),
112
+ 'omgf_pro_remove_resource_hints',
113
+ defined('OMGF_PRO_REMOVE_RESOURCE_HINTS') ? OMGF_PRO_REMOVE_RESOURCE_HINTS : false,
114
+ sprintf(__('Remove all <code>link</code> elements with a <code>rel</code> attribute value of <code>dns-prefetch</code>, <code>preload</code> or <code>preconnect</code>. <a href="%s" target="_blank">Purchase OMGF Pro</a> to enable this option.', $this->plugin_text_domain), OMGF_Admin_Settings_Builder::WOOSH_WORDPRESS_PLUGINS_HOST_GOOGLE_FONTS_PRO),
115
+ false,
116
+ true
117
+ );
118
+ }
119
+ }
includes/class-admin.php CHANGED
@@ -36,6 +36,7 @@ class OMGF_Admin
36
  add_action('admin_notices', [$this, 'add_notice']);
37
 
38
  $this->do_advanced_settings();
 
39
 
40
  add_filter('pre_update_option_omgf_cache_dir', [$this, 'cache_dir_changed'], 10, 2);
41
  add_filter('pre_update_option_omgf_cache_uri', [$this, 'serve_uri_changed'], 10, 2);
@@ -82,11 +83,22 @@ class OMGF_Admin
82
  OMGF_Admin_Notice::print_notice();
83
  }
84
 
 
 
 
85
  private function do_advanced_settings()
86
  {
87
  return new OMGF_Admin_Settings_Advanced();
88
  }
89
 
 
 
 
 
 
 
 
 
90
  /**
91
  * When the cache path is changed, OMGF moves the entire fonts folder to its new destination and throws a notice to
92
  * regenerate the stylesheet.
36
  add_action('admin_notices', [$this, 'add_notice']);
37
 
38
  $this->do_advanced_settings();
39
+ $this->do_extensions_settings();
40
 
41
  add_filter('pre_update_option_omgf_cache_dir', [$this, 'cache_dir_changed'], 10, 2);
42
  add_filter('pre_update_option_omgf_cache_uri', [$this, 'serve_uri_changed'], 10, 2);
83
  OMGF_Admin_Notice::print_notice();
84
  }
85
 
86
+ /**
87
+ * @return OMGF_Admin_Settings_Advanced
88
+ */
89
  private function do_advanced_settings()
90
  {
91
  return new OMGF_Admin_Settings_Advanced();
92
  }
93
 
94
+ /**
95
+ * @return OMGF_Admin_Settings_Extensions
96
+ */
97
+ private function do_extensions_settings()
98
+ {
99
+ return new OMGF_Admin_Settings_Extensions();
100
+ }
101
+
102
  /**
103
  * When the cache path is changed, OMGF moves the entire fonts folder to its new destination and throws a notice to
104
  * regenerate the stylesheet.
includes/frontend/class-functions.php CHANGED
@@ -29,6 +29,7 @@ class OMGF_Frontend_Functions
29
  /** @var string */
30
  private $stylesheet_url;
31
 
 
32
  private $do_optimize;
33
 
34
  /**
@@ -41,19 +42,19 @@ class OMGF_Frontend_Functions
41
  $this->do_optimize = $this->maybe_optimize_fonts();
42
 
43
  // @formatter:off
44
- add_action('wp_print_styles', array($this, 'is_remove_google_fonts_enabled'), PHP_INT_MAX - 1000);
45
 
46
  if (file_exists($this->stylesheet_file)) {
47
- add_action('wp_enqueue_scripts', array($this, 'enqueue_stylesheet'), OMGF_ENQUEUE_ORDER);
48
  }
49
 
50
  if (OMGF_AUTO_DETECT_ENABLED) {
51
- add_action('wp_print_styles', array($this, 'auto_detect_fonts'), PHP_INT_MAX - 10000);
52
  }
53
 
54
  $this->db = new OMGF_DB();
55
  // Needs to be loaded before stylesheet.
56
- add_action('wp_enqueue_scripts', array($this, 'preload_fonts'), 0);
57
  // @formatter:on
58
  }
59
 
@@ -68,7 +69,7 @@ class OMGF_Frontend_Functions
68
 
69
  if (OMGF_REMOVE_GFONTS == 'on' && !is_admin()) {
70
  // @formatter:off
71
- add_action('wp_print_styles', array($this, 'remove_google_fonts'), PHP_INT_MAX - 500);
72
  // Theme: Enfold
73
  add_filter('avf_output_google_webfonts_script', function() { return false; });
74
  // @formatter:on
@@ -110,7 +111,7 @@ class OMGF_Frontend_Functions
110
  $registered, function ($contents) use ($fonts) {
111
  return !empty(array_intersect(array_keys($fonts), $contents->deps))
112
  && $contents->handle !== 'wp-block-editor';
113
- }
114
  );
115
 
116
  foreach ($fonts as $font) {
@@ -119,8 +120,12 @@ class OMGF_Frontend_Functions
119
  }
120
 
121
  foreach ($dependencies as $dependency) {
122
- wp_register_style('omgf-dep-' . $dependency->handle, $dependency->src);
123
- wp_enqueue_style('omgf-dep-' . $dependency->handle, $dependency->src);
 
 
 
 
124
  }
125
  }
126
 
29
  /** @var string */
30
  private $stylesheet_url;
31
 
32
+ /** @var bool $do_optimize */
33
  private $do_optimize;
34
 
35
  /**
42
  $this->do_optimize = $this->maybe_optimize_fonts();
43
 
44
  // @formatter:off
45
+ add_action('wp_print_styles', [$this, 'is_remove_google_fonts_enabled'], PHP_INT_MAX - 1000);
46
 
47
  if (file_exists($this->stylesheet_file)) {
48
+ add_action('wp_enqueue_scripts', [$this, 'enqueue_stylesheet'], OMGF_ENQUEUE_ORDER);
49
  }
50
 
51
  if (OMGF_AUTO_DETECT_ENABLED) {
52
+ add_action('wp_print_styles', [$this, 'auto_detect_fonts'], PHP_INT_MAX - 10000);
53
  }
54
 
55
  $this->db = new OMGF_DB();
56
  // Needs to be loaded before stylesheet.
57
+ add_action('wp_head', [$this, 'preload_fonts'], 1);
58
  // @formatter:on
59
  }
60
 
69
 
70
  if (OMGF_REMOVE_GFONTS == 'on' && !is_admin()) {
71
  // @formatter:off
72
+ add_action('wp_print_styles', [$this, 'remove_google_fonts'], PHP_INT_MAX - 500);
73
  // Theme: Enfold
74
  add_filter('avf_output_google_webfonts_script', function() { return false; });
75
  // @formatter:on
111
  $registered, function ($contents) use ($fonts) {
112
  return !empty(array_intersect(array_keys($fonts), $contents->deps))
113
  && $contents->handle !== 'wp-block-editor';
114
+ }
115
  );
116
 
117
  foreach ($fonts as $font) {
120
  }
121
 
122
  foreach ($dependencies as $dependency) {
123
+ $deps = array_diff($dependency->deps, array_keys($fonts));
124
+ wp_deregister_style($dependency->handle);
125
+ wp_dequeue_style($dependency->handle);
126
+
127
+ wp_register_style($dependency->handle, $dependency->src, $deps + [ 'omgf-fonts' ]);
128
+ wp_enqueue_style($dependency->handle, $dependency->src, $deps + [ 'omgf-fonts' ]);
129
  }
130
  }
131
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  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.7.0
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -112,11 +112,20 @@ N/A
112
 
113
  == Changelog ==
114
 
115
- = 3.7.0 =
 
 
 
 
 
 
 
 
 
116
  * OMGF settings screen is now easily extendable: added filters, actions, etc.
117
  * Overall performance improvements and reduced code footprint.
118
 
119
- = 3.6.2 =
120
  * Added filter so Auto Remove can be disabled by other plugins (OMGF Pro, in this case.)
121
 
122
  = 3.6.1 =
@@ -125,17 +134,17 @@ N/A
125
  * Removed the code to detect incompatible themes/plugins, because an upgrade to OMGF Pro will solve all of your problems :)
126
  * *OMGF Pro is able to detect, replace and remove all Google Fonts (incl. WebFont Loader) regardless of how they are added by the theme or plugin, incl. dns prefetch, preconnect and preload resource hint headers.*
127
 
128
- = 3.6.0 =
129
  * OMGF now supports add-ons to extend its Auto Detect and Auto Removal feature.
130
  * From now on, a notice containing a link to the required add-on will be thrown for known themes and frameworks which follow unconventional methods to include Google Fonts.
131
  * This list now contains Thrive Themes and Redux Framework, but other themes (I'm researching Avada) will be added in the near future.
132
  * Generated stylesheets and downloaded fonts are now be saved to the 'uploads/omgf' folder by default.
133
 
134
- = 3.5.0 =
135
  * Added Force SSL option, to force the usage of SSL while generating the stylesheet.
136
  * Added WP Rocket to list of Evil Plugins, because it empties the entire wp-content/cache folder instead of just its own files.
137
 
138
- = 3.4.5 =
139
  * Preload path should include absolute url, instead of relative, to prevent issues with CDN usage.
140
 
141
  = 3.4.4 =
@@ -157,7 +166,7 @@ N/A
157
  * 'Optimize fonts for logged in users?' should be on by default, cause it causes to much confusion.
158
  * Fixed bug where Auto Detect would fail if no font styles were specified in the Google Font URL.
159
 
160
- = 3.4.0 =
161
  * Added 'Downloaded' indicator in 'Generate Stylesheet' tab.
162
  * Added 'Also optimize fonts for logged in users?' option. This means that all users with editor
163
  capabilities will (from now on) only view the optimizations when this option is checked, or when
@@ -184,7 +193,7 @@ N/A
184
  * Replaced separate apply buttons with one apply button, which handles the entire queue for removal as well as preload at once.
185
  * Known bug: 'Apply' button isn't clickable when sticky. Available workaround: scroll to the bottom of the list and click 'Apply'.
186
 
187
- = 3.3.0 =
188
  * Introduced a queueing system for font-styles search, preload and remove for easier management. The 'Apply' buttons now process all your changes at once.
189
  * The 'Apply' buttons are sticky, so they're visible for long lists.
190
 
@@ -192,7 +201,7 @@ N/A
192
  * Fixes in responsiveness of admin screen.
193
  * Fixed links in Quick Start and Support block.
194
 
195
- = 3.2.0 =
196
  * Fonts are now automatically updated and font files and stylesheet are automatically moved after the 'Serve fonts from...' or 'Save fonts to...' options are changed.
197
  * Added several reminder notices to improve UX and reduce the level of complexity.
198
  * Notices/warnings/errors are now grouped.
@@ -209,7 +218,7 @@ N/A
209
  * Fixed bug in Web Font Loader.
210
  * Fixed bug where sometimes stylesheet would still be enqueued, even though the file didn't exist.
211
 
212
- = 3.1.0 =
213
  * 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.)
214
  * Fixed bug where clicking 'save changes' would remove listed fonts and subsets.
215
  * Gave some settings more accurate descriptions.
@@ -230,7 +239,7 @@ N/A
230
  * Search now works bug free.
231
  * WordPress' default admin fonts no longer show up as results.
232
 
233
- = 2.5.0 =
234
  Updated Welcome-panel with WoOSH!-services.
235
  Preload can now be used for certain fonts only (also combined with Web Font Loader).
236
 
2
  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.5
6
+ Stable tag: 3.8.0
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
112
 
113
  == Changelog ==
114
 
115
+ = 3.8.0 | August 16th, 2020 =
116
+ * Tested with WP 5.5.
117
+ * Cleaned up the sidebar.
118
+ * Improved re-enqueueing of stylesheets, if a stylesheet depends on the removed Google Font stylesheet.
119
+ * Pressing Enter in the Search Bar triggers search now.
120
+ * Developers can now easily add functionalities to OMGF's brand new Extensions tab, using several new filters and actions.
121
+ * If OMGF is used along with other WoOSH! plugins (e.g. CAOS, OMGF Pro, etc.) the same class loader is used, significantly increasing performance.
122
+ * Added dates to changelog :)
123
+
124
+ = 3.7.0 | June 10th, 2020 =
125
  * OMGF settings screen is now easily extendable: added filters, actions, etc.
126
  * Overall performance improvements and reduced code footprint.
127
 
128
+ = 3.6.2 | June 7th, 2020 =
129
  * Added filter so Auto Remove can be disabled by other plugins (OMGF Pro, in this case.)
130
 
131
  = 3.6.1 =
134
  * Removed the code to detect incompatible themes/plugins, because an upgrade to OMGF Pro will solve all of your problems :)
135
  * *OMGF Pro is able to detect, replace and remove all Google Fonts (incl. WebFont Loader) regardless of how they are added by the theme or plugin, incl. dns prefetch, preconnect and preload resource hint headers.*
136
 
137
+ = 3.6.0 | May 30th, 2020 =
138
  * OMGF now supports add-ons to extend its Auto Detect and Auto Removal feature.
139
  * From now on, a notice containing a link to the required add-on will be thrown for known themes and frameworks which follow unconventional methods to include Google Fonts.
140
  * This list now contains Thrive Themes and Redux Framework, but other themes (I'm researching Avada) will be added in the near future.
141
  * Generated stylesheets and downloaded fonts are now be saved to the 'uploads/omgf' folder by default.
142
 
143
+ = 3.5.0 | May 24th, 2020 =
144
  * Added Force SSL option, to force the usage of SSL while generating the stylesheet.
145
  * Added WP Rocket to list of Evil Plugins, because it empties the entire wp-content/cache folder instead of just its own files.
146
 
147
+ = 3.4.5 | May 21st, 2020 =
148
  * Preload path should include absolute url, instead of relative, to prevent issues with CDN usage.
149
 
150
  = 3.4.4 =
166
  * 'Optimize fonts for logged in users?' should be on by default, cause it causes to much confusion.
167
  * Fixed bug where Auto Detect would fail if no font styles were specified in the Google Font URL.
168
 
169
+ = 3.4.0 | May 4th, 2020 =
170
  * Added 'Downloaded' indicator in 'Generate Stylesheet' tab.
171
  * Added 'Also optimize fonts for logged in users?' option. This means that all users with editor
172
  capabilities will (from now on) only view the optimizations when this option is checked, or when
193
  * Replaced separate apply buttons with one apply button, which handles the entire queue for removal as well as preload at once.
194
  * Known bug: 'Apply' button isn't clickable when sticky. Available workaround: scroll to the bottom of the list and click 'Apply'.
195
 
196
+ = 3.3.0 | March 25th, 2020 =
197
  * Introduced a queueing system for font-styles search, preload and remove for easier management. The 'Apply' buttons now process all your changes at once.
198
  * The 'Apply' buttons are sticky, so they're visible for long lists.
199
 
201
  * Fixes in responsiveness of admin screen.
202
  * Fixed links in Quick Start and Support block.
203
 
204
+ = 3.2.0 | March 24th, 2020 =
205
  * Fonts are now automatically updated and font files and stylesheet are automatically moved after the 'Serve fonts from...' or 'Save fonts to...' options are changed.
206
  * Added several reminder notices to improve UX and reduce the level of complexity.
207
  * Notices/warnings/errors are now grouped.
218
  * Fixed bug in Web Font Loader.
219
  * Fixed bug where sometimes stylesheet would still be enqueued, even though the file didn't exist.
220
 
221
+ = 3.1.0 | March 21st, 2020 =
222
  * 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.)
223
  * Fixed bug where clicking 'save changes' would remove listed fonts and subsets.
224
  * Gave some settings more accurate descriptions.
239
  * Search now works bug free.
240
  * WordPress' default admin fonts no longer show up as results.
241
 
242
+ = 2.5.0 | January 30st, 2020 =
243
  Updated Welcome-panel with WoOSH!-services.
244
  Preload can now be used for certain fonts only (also combined with Web Font Loader).
245
 
templates/admin/block-welcome.phtml CHANGED
@@ -16,68 +16,52 @@
16
 
17
  defined('ABSPATH') || exit;
18
 
19
- $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=support_tab';
20
- $tweetUrl = 'https://twitter.com/intent/tweet?text=I+just+optimized+my+Google+Fonts+with+OMGF+for+@WordPress!+Try+it+for+yourself:&via=Dan0sz&hashtags=GoogleFonts,WordPress,Pagespeed,Insights&url=https://wordpress.org/plugins/host-webfonts-local/';
 
21
  ?>
22
  <div class="welcome-panel-content">
23
  <div class="welcome-panel-column-container">
24
  <div class="welcome-panel-column" style="width: 100%; margin-right: 15px;">
25
- <h2><?php _e('Quickstart', 'host-webfonts-local'); ?></h2>
26
  <ul>
27
  <li class="welcome-icon dashicons-before dashicons-admin-settings">
28
- <?= sprintf(__('Click %sAuto-detect%s and wait for the on-screen instructions', 'host-webfonts-local'), '<a class="help auto-detect" href="#">', '</a>'); ?>
29
  </li>
30
  <li class="welcome-icon dashicons-before dashicons-update">
31
- <?= sprintf(__('Click %sDownload Fonts%s and wait for the download to complete', 'host-webfonts-local'), '<a class="help download-fonts" href="#">', '</a>'); ?>
32
  </li>
33
  <li class="welcome-icon dashicons-before dashicons-art">
34
- <?= sprintf(__('Click %sGenerate Stylesheet%s and wait for the process to complete', 'host-webfonts-local'), '<a class="help generate-stylesheet" href="#">', '</a>'); ?>
35
  </li>
36
- <li class="welcome-icon dashicons-before dashicons-editor-removeformatting"><?php _e('Check \'Remove Google Fonts\' and save your changes', 'host-webfonts-local'); ?></li>
37
- <li class="welcome-icon dashicons-before dashicons-smiley"><?php _e('Done!', 'host-webfonts-local'); ?></li>
38
  </ul>
39
  <p>
40
- <?= sprintf(__('%sClick here%s for a more comprehensive guide.', 'host-webfonts-local'), '<a target="_blank" href="' . OMGF_SITE_URL . '/wordpress/host-google-fonts-locally/' . $utmTags . '">', '</a>'); ?>
41
- </p>
42
- <hr/>
43
- </div>
44
- <div class="welcome-panel-column" style="width: 100%; margin-right: 15px;">
45
- <h3>
46
- <span class="dashicons dashicons-dashboard"></span> <?php _e('Make WordPress <em>Faster</em> Than Superman', 'host-webfonts-local'); ?>
47
- </h3>
48
- <p>
49
- <?= __('Superman can reach the other side of the world in <strong>3 seconds</strong>. Google wants your website to do it <strong>faster</strong>. Let\'s give Google a run for its money.', 'host-webfonts-local'); ?>
50
- </p>
51
- <p>
52
- <a target="_blank" class="button button-primary button-hero" href="https://woosh.dev/wordpress-services/<?= $utmTags; ?>"><span class="dashicons dashicons-thumbs-up"></span> <?= __('Hire me', 'host-webfonts-local'); ?>
53
- </a>
54
- <span><em>(<?= __('Starting at € 99,-', 'host-analyticsjs-local'); ?>)</em></span>
55
  </p>
56
  <hr/>
57
  </div>
58
  <div class="welcome-panel-column welcome-panel-last" style="width: 100%;">
59
  <h3>
60
- <?php _e('Support OMGF by Spreading the Word!', 'host-webfonts-local'); ?>
61
  </h3>
62
  <p>
63
- <?= sprintf(__('Knowledge should be free. That\'s why I will never charge you for the plugins I create and I will help you to succeed in your projects through the %stutorials%s on my blog.', 'host-webfonts-local'), '<a href="' . OMGF_SITE_URL . '/how-to/' . $utmTags . '" target="_blank">', '</a>'); ?>
64
- </p>
65
- <p>
66
- <?= __('But that doesn\'t mean there\'s nothing you can do to support me! :)', 'host-webfonts-local'); ?>
67
  </p>
68
  <p>
69
- <?= sprintf(__('Please help me spread the word by leaving a %s5-star review%s on Wordpress.org or sending a %sTweet%s about OMGF.', 'host-webfonts-local'), '<a target="_blank" href="https://wordpress.org/support/plugin/host-webfonts-local/reviews/?rate=5#new-post">', '</a>', "<a href='$tweetUrl'>", '</a>'); ?>
70
  </p>
71
  <p>
72
- <a target="_blank" class="button button-secondary button-hero" href="https://wordpress.org/support/plugin/host-webfonts-local/reviews/?rate=5#new-post"><span class="dashicons-before dashicons-star-filled"> <?php _e('Review', 'host-webfonts-local'); ?></span></a>
73
- <a target="_blank" class="button button-secondary button-hero" href="<?= $tweetUrl; ?>"><span class="dashicons-before dashicons-twitter"> <?php _e('Tweet', 'host-webfonts-local'); ?></span></a>
74
  </p>
75
  <hr/>
76
  <h3>
77
- <?php _e('Need Help?', 'host-webfonts-local'); ?>
78
  </h3>
79
  <p>
80
- <?= sprintf(__('Visit the %sFAQ%s and %sSupport Forum%s to see if your question has already been answered. If not, ask a question on the Support Forum.', 'host-webfonts-local'), '<a href="https://wordpress.org/plugins/host-webfonts-local/#description" target="_blank">', '</a>', '<a href="https://wordpress.org/support/plugin/host-webfonts-local">', '</a>'); ?>
81
  </p>
82
  </div>
83
  </div>
16
 
17
  defined('ABSPATH') || exit;
18
 
19
+ $plugin_text_domain = 'host-webfonts-local';
20
+ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=support_tab';
21
+ $tweetUrl = 'https://twitter.com/intent/tweet?text=I+just+optimized+my+Google+Fonts+with+OMGF+for+@WordPress!+Try+it+for+yourself:&via=Dan0sz&hashtags=GoogleFonts,WordPress,Pagespeed,Insights&url=https://wordpress.org/plugins/host-webfonts-local/';
22
  ?>
23
  <div class="welcome-panel-content">
24
  <div class="welcome-panel-column-container">
25
  <div class="welcome-panel-column" style="width: 100%; margin-right: 15px;">
26
+ <h2><?php _e('Quickstart', $plugin_text_domain); ?></h2>
27
  <ul>
28
  <li class="welcome-icon dashicons-before dashicons-admin-settings">
29
+ <?= sprintf(__('Click %sAuto-detect%s and wait for the on-screen instructions', $plugin_text_domain), '<a class="help auto-detect" href="#">', '</a>'); ?>
30
  </li>
31
  <li class="welcome-icon dashicons-before dashicons-update">
32
+ <?= sprintf(__('Click %sDownload Fonts%s and wait for the download to complete', $plugin_text_domain), '<a class="help download-fonts" href="#">', '</a>'); ?>
33
  </li>
34
  <li class="welcome-icon dashicons-before dashicons-art">
35
+ <?= sprintf(__('Click %sGenerate Stylesheet%s and wait for the process to complete', $plugin_text_domain), '<a class="help generate-stylesheet" href="#">', '</a>'); ?>
36
  </li>
37
+ <li class="welcome-icon dashicons-before dashicons-editor-removeformatting"><?= sprintf(__('Check <em>Auto Remove</em> in <a href="%s">Advanced Settings</a> and save your changes', $plugin_text_domain), admin_url('options-general.php?page=optimize-webfonts&tab=omgf-advanced-settings')); ?></li>
38
+ <li class="welcome-icon dashicons-before dashicons-smiley"><?php _e('Done!', $plugin_text_domain); ?></li>
39
  </ul>
40
  <p>
41
+ <?= sprintf(__('%sClick here%s for a more comprehensive guide.', $plugin_text_domain), '<a target="_blank" href="' . OMGF_SITE_URL . '/wordpress/host-google-fonts-locally/' . $utmTags . '">', '</a>'); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  </p>
43
  <hr/>
44
  </div>
45
  <div class="welcome-panel-column welcome-panel-last" style="width: 100%;">
46
  <h3>
47
+ <?php _e('Support OMGF by Spreading the Word!', $plugin_text_domain); ?>
48
  </h3>
49
  <p>
50
+ <?= __('Just because this plugin\'s free, doesn\'t mean there\'s nothing you can do to support me! :)', $plugin_text_domain); ?>
 
 
 
51
  </p>
52
  <p>
53
+ <?= sprintf(__('Please help me spread the word by leaving a %s5-star review%s on Wordpress.org or sending a %sTweet%s about OMGF.', $plugin_text_domain), '<a target="_blank" href="https://wordpress.org/support/plugin/host-webfonts-local/reviews/?rate=5#new-post">', '</a>', "<a href='$tweetUrl'>", '</a>'); ?>
54
  </p>
55
  <p>
56
+ <a target="_blank" class="button button-secondary button-hero" href="https://wordpress.org/support/plugin/host-webfonts-local/reviews/?rate=5#new-post"><span class="dashicons-before dashicons-star-filled"> <?php _e('Review', $plugin_text_domain); ?></span></a>
57
+ <a target="_blank" class="button button-secondary button-hero" href="<?= $tweetUrl; ?>"><span class="dashicons-before dashicons-twitter"> <?php _e('Tweet', $plugin_text_domain); ?></span></a>
58
  </p>
59
  <hr/>
60
  <h3>
61
+ <?php _e('Need Help?', $plugin_text_domain); ?>
62
  </h3>
63
  <p>
64
+ <?= sprintf(__('Visit the %sFAQ%s and %sSupport Forum%s to see if your question has already been answered. If not, ask a question on the Support Forum.', $plugin_text_domain), '<a href="https://wordpress.org/plugins/host-webfonts-local/#description" target="_blank">', '</a>', '<a href="https://wordpress.org/support/plugin/host-webfonts-local">', '</a>'); ?>
65
  </p>
66
  </div>
67
  </div>
woosh-autoload.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* * * * * * * * * * * * * * * * * * * * * *
3
+ * _ __ ____ _____ __ ____
4
+ * | | / /___ / __ \/ ___// / / / /
5
+ * | | /| / / __ \/ / / /\__ \/ /_/ / /
6
+ * | |/ |/ / /_/ / /_/ /___/ / __ /_/
7
+ * |__/|__/\____/\____//____/_/ /_(_)
8
+ *
9
+ * @author : Daan van den Bergh
10
+ * @url : https://woosh.dev/wordpress-plugins/
11
+ * @copyright: (c) 2020 Daan van den Bergh
12
+ * @license : GPL2v2 or later
13
+ * * * * * * * * * * * * * * * * * * * * * */
14
+
15
+ class Woosh_Autoloader
16
+ {
17
+ /** @var string $class */
18
+ private $class;
19
+
20
+ /** @var string $file */
21
+ private $file;
22
+
23
+ /**
24
+ * Woosh_Autoloader constructor.
25
+ *
26
+ * @param $class
27
+ */
28
+ public function __construct(
29
+ $class
30
+ ) {
31
+ $this->class = $class;
32
+
33
+ $this->load();
34
+ }
35
+
36
+ /**
37
+ * Build filepath for requested class.
38
+ */
39
+ public function load()
40
+ {
41
+ $path = explode('_', $this->class);
42
+ $this->file = '';
43
+
44
+ if (count($path) == 1) {
45
+ if (ctype_upper($path[0])) {
46
+ $this->file = 'class-' . strtolower(str_replace('_', '-', $this->class)) . '.php';
47
+ } else {
48
+ $parts = preg_split('/(?=[A-Z])/', lcfirst($path[0]));
49
+ $this->file = 'class-' . strtolower(implode('-', $parts)) . '.php';
50
+ }
51
+ } else {
52
+ array_shift($path);
53
+ end($path);
54
+ $i = 0;
55
+
56
+ while ($i < key($path)) {
57
+ $this->file .= strtolower($path[$i]) . '/';
58
+ $i++;
59
+ }
60
+
61
+ // If entire part of path is written uppercase, we don't want to split.
62
+ if (ctype_upper($path[$i])) {
63
+ $pieces[] = $path[$i];
64
+ // Words like OmgfPro or SuperStealth should be split up.
65
+ } else {
66
+ $pieces = preg_split('/(?=[A-Z])/', lcfirst($path[$i]));
67
+ }
68
+
69
+ $this->file .= 'class-' . strtolower(implode('-', $pieces)) . '.php';
70
+ }
71
+
72
+ return $this->file;
73
+ }
74
+ }