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

Version Description

Added uninstall script.

Download this release

Release Info

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

Code changes from version 2.1.6 to 2.2.0

css/hwl-admin.css CHANGED
@@ -1,9 +1,17 @@
1
- /**
2
- * @package: OMGF
3
- * @author: Daan van den Bergh
 
 
 
 
 
 
 
 
4
  * @copyright: (c) 2019 Daan van den Bergh
5
- * @url: https://daan.dev
6
- */
7
 
8
  /**
9
  * Responsiveness
1
+ /* * * * * * * * * * * * * * * * * * * * *
2
+ *
3
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
4
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
5
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
6
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
7
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
8
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
9
+ *
10
+ * @package : OMGF
11
+ * @author : Daan van den Bergh
12
  * @copyright: (c) 2019 Daan van den Bergh
13
+ * @url : https://daan.dev
14
+ * * * * * * * * * * * * * * * * * * * */
15
 
16
  /**
17
  * Responsiveness
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: 2.1.6
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
@@ -41,7 +41,7 @@ function omgf_autoload($class)
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';
@@ -59,7 +59,6 @@ function omgf_autoload($class)
59
  }
60
 
61
  return include OMGF_PLUGIN_DIR . 'includes/' . $filename;
62
-
63
  }
64
 
65
  spl_autoload_register('omgf_autoload');
@@ -71,7 +70,13 @@ spl_autoload_register('omgf_autoload');
71
  */
72
  function omgf_init()
73
  {
74
- return new OMGF();
 
 
 
 
 
 
75
  }
76
 
77
- add_action('plugins_loaded', 'omgf_init', PHP_INT_MAX);
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: 2.2.0
8
  * Author: Daan van den Bergh
9
  * Author URI: https://daan.dev
10
  * License: GPL2v2 or later
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';
59
  }
60
 
61
  return include OMGF_PLUGIN_DIR . 'includes/' . $filename;
 
62
  }
63
 
64
  spl_autoload_register('omgf_autoload');
70
  */
71
  function omgf_init()
72
  {
73
+ static $omgf = null;
74
+
75
+ if ($omgf === null) {
76
+ $omgf = new OMGF();
77
+ }
78
+
79
+ return $omgf;
80
  }
81
 
82
+ omgf_init();
includes/admin/class-settings.php CHANGED
@@ -1,24 +1,41 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
11
  class OMGF_Admin_Settings extends OMGF_Admin
12
  {
13
- const OMGF_FONT_DISPLAY_OPTIONS = array(
14
  'Auto (default)' => 'auto',
15
  'Block' => 'block',
16
  'Swap' => 'swap',
17
  'Fallback' => 'fallback',
18
  'Optional' => 'optional'
19
  );
20
- const OMGF_AUTO_DETECTION_ENABLED_LABEL = 'omgf_auto_detection_enabled';
21
- const OMGF_DETECTED_FONTS_LABEL = 'omgf_detected_fonts';
 
 
 
 
 
 
 
 
 
22
 
23
  /**
24
  * OMGF_Admin_Settings constructor.
@@ -101,39 +118,43 @@ class OMGF_Admin_Settings extends OMGF_Admin
101
  {
102
  register_setting(
103
  'caos-webfonts-basic-settings',
104
- self::OMGF_AUTO_DETECTION_ENABLED_LABEL
105
  );
106
  register_setting(
107
  'caos-webfonts-basic-settings',
108
- self::OMGF_DETECTED_FONTS_LABEL
109
  );
110
  register_setting(
111
  'caos-webfonts-basic-settings',
112
- 'caos_webfonts_cache_dir'
113
  );
114
  register_setting(
115
  'caos-webfonts-basic-settings',
116
- 'caos_webfonts_cdn_url'
117
  );
118
  register_setting(
119
  'caos-webfonts-basic-settings',
120
- 'omgf_web_font_loader'
121
  );
122
  register_setting(
123
  'caos-webfonts-basic-settings',
124
- 'caos_webfonts_remove_version'
125
  );
126
  register_setting(
127
  'caos-webfonts-basic-settings',
128
- 'caos_webfonts_display_option'
129
  );
130
  register_setting(
131
  'caos-webfonts-basic-settings',
132
- 'caos_webfonts_remove_gfonts'
133
  );
134
  register_setting(
135
  'caos-webfonts-basic-settings',
136
- 'caos_webfonts_preload'
 
 
 
 
137
  );
138
  }
139
 
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
19
  class OMGF_Admin_Settings extends OMGF_Admin
20
  {
21
+ const OMGF_FONT_DISPLAY_OPTIONS = array(
22
  'Auto (default)' => 'auto',
23
  'Block' => 'block',
24
  'Swap' => 'swap',
25
  'Fallback' => 'fallback',
26
  'Optional' => 'optional'
27
  );
28
+ const OMGF_SETTING_AUTO_DETECTION_ENABLED = 'omgf_auto_detection_enabled';
29
+ const OMGF_SETTING_DETECTED_FONTS = 'omgf_detected_fonts';
30
+ const OMGF_SETTING_CACHE_DIR = 'caos_webfonts_cache_dir';
31
+ const OMGF_SETTING_CDN_URL = 'caos_webfonts_cdn_url';
32
+ const OMGF_SETTING_WEB_FONT_LOADER = 'omgf_web_font_loader';
33
+ const OMGF_SETTING_REMOVE_VERSION = 'caos_webfonts_remove_version';
34
+ const OMGF_SETTING_DISPLAY_OPTION = 'caos_webfonts_display_option';
35
+ const OMGF_SETTING_REMOVE_GOOGLE_FONTS = 'caos_webfonts_remove_gfonts';
36
+ const OMGF_SETTING_ENABLE_PRELOAD = 'caos_webfonts_preload';
37
+ const OMGF_SETTING_DB_VERSION = 'caos_webfonts_db_version';
38
+ const OMGF_SETTING_UNINSTALL = 'omgf_uninstall';
39
 
40
  /**
41
  * OMGF_Admin_Settings constructor.
118
  {
119
  register_setting(
120
  'caos-webfonts-basic-settings',
121
+ self::OMGF_SETTING_AUTO_DETECTION_ENABLED
122
  );
123
  register_setting(
124
  'caos-webfonts-basic-settings',
125
+ self::OMGF_SETTING_DETECTED_FONTS
126
  );
127
  register_setting(
128
  'caos-webfonts-basic-settings',
129
+ self::OMGF_SETTING_CACHE_DIR
130
  );
131
  register_setting(
132
  'caos-webfonts-basic-settings',
133
+ self::OMGF_SETTING_CDN_URL
134
  );
135
  register_setting(
136
  'caos-webfonts-basic-settings',
137
+ self::OMGF_SETTING_WEB_FONT_LOADER
138
  );
139
  register_setting(
140
  'caos-webfonts-basic-settings',
141
+ self::OMGF_SETTING_REMOVE_VERSION
142
  );
143
  register_setting(
144
  'caos-webfonts-basic-settings',
145
+ self::OMGF_SETTING_DISPLAY_OPTION
146
  );
147
  register_setting(
148
  'caos-webfonts-basic-settings',
149
+ self::OMGF_SETTING_REMOVE_GOOGLE_FONTS
150
  );
151
  register_setting(
152
  'caos-webfonts-basic-settings',
153
+ self::OMGF_SETTING_ENABLE_PRELOAD
154
+ );
155
+ register_setting(
156
+ 'caos-webfonts-basic-settings',
157
+ self::OMGF_SETTING_UNINSTALL
158
  );
159
  }
160
 
includes/ajax/class-detect.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
@@ -26,7 +34,7 @@ class OMGF_AJAX_Detect
26
  $fonts = $this->build_subsets_array($font_properties);
27
 
28
  /** It only needs to run once. */
29
- update_option(OMGF_Admin_Settings::OMGF_AUTO_DETECTION_ENABLED_LABEL, false);
30
 
31
  wp_die(json_encode($fonts));
32
  }
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
34
  $fonts = $this->build_subsets_array($font_properties);
35
 
36
  /** It only needs to run once. */
37
+ update_option(OMGF_Admin_Settings::OMGF_SETTING_AUTO_DETECTION_ENABLED, false);
38
 
39
  wp_die(json_encode($fonts));
40
  }
includes/ajax/class-download.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
includes/ajax/class-generate.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
includes/class-admin.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
includes/class-ajax.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
@@ -62,8 +70,8 @@ class OMGF_AJAX
62
  */
63
  public function clean_queue()
64
  {
65
- update_option(OMGF_Admin_Settings::OMGF_DETECTED_FONTS_LABEL, '');
66
- update_option(OMGF_Admin_Settings::OMGF_AUTO_DETECTION_ENABLED_LABEL, '');
67
 
68
  wp_die($this->db->clean_queue());
69
  }
@@ -75,8 +83,8 @@ class OMGF_AJAX
75
  */
76
  public function empty_directory()
77
  {
78
- update_option(OMGF_Admin_Settings::OMGF_DETECTED_FONTS_LABEL, '');
79
- update_option(OMGF_Admin_Settings::OMGF_AUTO_DETECTION_ENABLED_LABEL, '');
80
 
81
  return array_map('unlink', array_filter((array) glob(OMGF_UPLOAD_DIR . '/*')));
82
  }
@@ -171,8 +179,8 @@ class OMGF_AJAX
171
  */
172
  public function auto_detect()
173
  {
174
- $used_fonts = json_decode(get_option(OMGF_Admin_Settings::OMGF_DETECTED_FONTS_LABEL));
175
- $auto_detect = get_option(OMGF_Admin_Settings::OMGF_AUTO_DETECTION_ENABLED_LABEL);
176
 
177
  if ($used_fonts && $auto_detect) {
178
  new OMGF_AJAX_Detect($used_fonts);
@@ -190,7 +198,7 @@ class OMGF_AJAX
190
  */
191
  private function enable_auto_detect()
192
  {
193
- update_option(OMGF_Admin_Settings::OMGF_AUTO_DETECTION_ENABLED_LABEL, true);
194
  }
195
 
196
  /**
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
70
  */
71
  public function clean_queue()
72
  {
73
+ update_option(OMGF_Admin_Settings::OMGF_SETTING_DETECTED_FONTS, '');
74
+ update_option(OMGF_Admin_Settings::OMGF_SETTING_AUTO_DETECTION_ENABLED, '');
75
 
76
  wp_die($this->db->clean_queue());
77
  }
83
  */
84
  public function empty_directory()
85
  {
86
+ update_option(OMGF_Admin_Settings::OMGF_SETTING_DETECTED_FONTS, '');
87
+ update_option(OMGF_Admin_Settings::OMGF_SETTING_AUTO_DETECTION_ENABLED, '');
88
 
89
  return array_map('unlink', array_filter((array) glob(OMGF_UPLOAD_DIR . '/*')));
90
  }
179
  */
180
  public function auto_detect()
181
  {
182
+ $used_fonts = json_decode(get_option(OMGF_Admin_Settings::OMGF_SETTING_DETECTED_FONTS));
183
+ $auto_detect = get_option(OMGF_Admin_Settings::OMGF_SETTING_AUTO_DETECTION_ENABLED);
184
 
185
  if ($used_fonts && $auto_detect) {
186
  new OMGF_AJAX_Detect($used_fonts);
198
  */
199
  private function enable_auto_detect()
200
  {
201
+ update_option(OMGF_Admin_Settings::OMGF_SETTING_AUTO_DETECTION_ENABLED, true);
202
  }
203
 
204
  /**
includes/class-db.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
includes/class-omgf.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
@@ -18,7 +26,6 @@ class OMGF
18
  $this->define_constants();
19
 
20
  if (is_admin()) {
21
- $this->do_setup();
22
  $this->do_settings();
23
  $this->add_ajax_hooks();
24
  }
@@ -28,8 +35,8 @@ class OMGF
28
  }
29
 
30
  // @formatter:off
31
- register_activation_hook(OMGF_PLUGIN_FILE, array($this, 'create_cache_dir'));
32
  register_activation_hook(OMGF_PLUGIN_FILE, array($this, 'do_setup'));
 
33
  register_deactivation_hook(OMGF_PLUGIN_FILE, array($this, 'dequeue_css_js'));
34
  // @formatter:on
35
  }
@@ -46,27 +53,19 @@ class OMGF
46
  define('OMGF_DB_CHARSET', $wpdb->get_charset_collate());
47
  define('OMGF_HELPER_URL', 'https://google-webfonts-helper.herokuapp.com/api/fonts/');
48
  define('OMGF_FILENAME', 'fonts.css');
49
- define('OMGF_AUTO_DETECT_ENABLED', esc_attr(get_option(OMGF_Admin_Settings::OMGF_AUTO_DETECTION_ENABLED_LABEL, false)));
50
- define('OMGF_CACHE_DIR', esc_attr(get_option('caos_webfonts_cache_dir')) ?: '/cache/omgf-webfonts');
51
- define('OMGF_CDN_URL', esc_attr(get_option('caos_webfonts_cdn_url')));
52
- define('OMGF_WEB_FONT_LOADER', esc_attr(get_option('omgf_web_font_loader')));
53
- define('OMGF_REMOVE_VERSION', esc_attr(get_option('caos_webfonts_remove_version')));
54
  define('OMGF_CURRENT_BLOG_ID', get_current_blog_id());
55
  define('OMGF_UPLOAD_DIR', WP_CONTENT_DIR . OMGF_CACHE_DIR);
56
  define('OMGF_UPLOAD_URL', $this->get_upload_url());
57
- define('OMGF_DISPLAY_OPTION', esc_attr(get_option('caos_webfonts_display_option')) ?: 'auto');
58
- define('OMGF_REMOVE_GFONTS', esc_attr(get_option('caos_webfonts_remove_gfonts')));
59
- define('OMGF_PRELOAD', esc_attr(get_option('caos_webfonts_preload')));
60
- }
61
-
62
- /**
63
- * @return OMGF_Setup
64
- */
65
- private function do_setup()
66
- {
67
- return new OMGF_Setup();
68
  }
69
-
70
  /**
71
  * @return OMGF_Admin_Settings
72
  */
@@ -91,6 +90,16 @@ class OMGF
91
  return new OMGF_Frontend_Functions();
92
  }
93
 
 
 
 
 
 
 
 
 
 
 
94
  /**
95
  * Create cache dir upon plugin (re-)activation.
96
  */
@@ -137,4 +146,13 @@ class OMGF
137
  wp_dequeue_style(OMGF_Admin::OMGF_ADMIN_CSS_HANDLE);
138
  wp_dequeue_style(OMGF_Frontend_Functions::OMGF_STYLE_HANDLE);
139
  }
 
 
 
 
 
 
 
 
 
140
  }
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
26
  $this->define_constants();
27
 
28
  if (is_admin()) {
 
29
  $this->do_settings();
30
  $this->add_ajax_hooks();
31
  }
35
  }
36
 
37
  // @formatter:off
 
38
  register_activation_hook(OMGF_PLUGIN_FILE, array($this, 'do_setup'));
39
+ register_activation_hook(OMGF_PLUGIN_FILE, array($this, 'create_cache_dir'));
40
  register_deactivation_hook(OMGF_PLUGIN_FILE, array($this, 'dequeue_css_js'));
41
  // @formatter:on
42
  }
53
  define('OMGF_DB_CHARSET', $wpdb->get_charset_collate());
54
  define('OMGF_HELPER_URL', 'https://google-webfonts-helper.herokuapp.com/api/fonts/');
55
  define('OMGF_FILENAME', 'fonts.css');
56
+ define('OMGF_AUTO_DETECT_ENABLED', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_AUTO_DETECTION_ENABLED, false)));
57
+ define('OMGF_CACHE_DIR', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_CACHE_DIR)) ?: '/cache/omgf-webfonts');
58
+ define('OMGF_CDN_URL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_CDN_URL)));
59
+ define('OMGF_WEB_FONT_LOADER', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_WEB_FONT_LOADER)));
60
+ define('OMGF_REMOVE_VERSION', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_REMOVE_VERSION)));
61
  define('OMGF_CURRENT_BLOG_ID', get_current_blog_id());
62
  define('OMGF_UPLOAD_DIR', WP_CONTENT_DIR . OMGF_CACHE_DIR);
63
  define('OMGF_UPLOAD_URL', $this->get_upload_url());
64
+ define('OMGF_DISPLAY_OPTION', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_DISPLAY_OPTION)) ?: 'auto');
65
+ define('OMGF_REMOVE_GFONTS', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_REMOVE_GOOGLE_FONTS)));
66
+ define('OMGF_PRELOAD', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_ENABLE_PRELOAD)));
67
+ define('OMGF_UNINSTALL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_UNINSTALL)));
 
 
 
 
 
 
 
68
  }
 
69
  /**
70
  * @return OMGF_Admin_Settings
71
  */
90
  return new OMGF_Frontend_Functions();
91
  }
92
 
93
+ /**
94
+ * @return OMGF_Setup
95
+ */
96
+ public function do_setup()
97
+ {
98
+ register_uninstall_hook(OMGF_PLUGIN_FILE, 'OMGF::do_uninstall');
99
+
100
+ return new OMGF_Setup();
101
+ }
102
+
103
  /**
104
  * Create cache dir upon plugin (re-)activation.
105
  */
146
  wp_dequeue_style(OMGF_Admin::OMGF_ADMIN_CSS_HANDLE);
147
  wp_dequeue_style(OMGF_Frontend_Functions::OMGF_STYLE_HANDLE);
148
  }
149
+
150
+ /**
151
+ * @return OMGF_Uninstall
152
+ * @throws ReflectionException
153
+ */
154
+ public static function do_uninstall()
155
+ {
156
+ return new OMGF_Uninstall();
157
+ }
158
  }
includes/class-setup.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
includes/class-uninstall.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
+ * @package : OMGF
12
+ * @author : Daan van den Bergh
13
+ * @copyright: (c) 2019 Daan van den Bergh
14
+ * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
+
17
+ defined('ABSPATH') || exit;
18
+
19
+ class OMGF_Uninstall
20
+ {
21
+ /** @var QM_DB $wpdb */
22
+ private $wpdb;
23
+
24
+ /** @var array $options */
25
+ private $options;
26
+
27
+ /** @var string $table */
28
+ private $table;
29
+
30
+ /** @var string $cacheDir */
31
+ private $cacheDir;
32
+
33
+ /**
34
+ * OMGF_Uninstall constructor.
35
+ * @throws ReflectionException
36
+ */
37
+ public function __construct()
38
+ {
39
+ if (OMGF_UNINSTALL !== 'on') {
40
+ return;
41
+ }
42
+
43
+ global $wpdb;
44
+
45
+ $this->wpdb = $wpdb;
46
+ $this->options = $this->get_options();
47
+ $this->table = OMGF_DB_TABLENAME;
48
+ $this->cacheDir = OMGF_UPLOAD_DIR;
49
+
50
+ $this->remove_db_entries();
51
+ $this->drop_tables();
52
+ $this->delete_files();
53
+ $this->delete_dir();
54
+ }
55
+
56
+ /**
57
+ * @return array
58
+ * @throws ReflectionException
59
+ */
60
+ private function get_options()
61
+ {
62
+ $settings = new OMGF_Admin_Settings();
63
+ $reflection = new ReflectionClass($settings);
64
+ $constants = $reflection->getConstants();
65
+
66
+ return array_filter(
67
+ $constants,
68
+ function ($key) {
69
+ return strpos($key, 'OMGF_SETTING') !== false;
70
+ },
71
+ ARRAY_FILTER_USE_KEY
72
+ );
73
+ }
74
+
75
+ /**
76
+ * Remove all settings stored in the wp_options table.
77
+ */
78
+ private function remove_db_entries()
79
+ {
80
+ foreach ($this->options as $key => $option) {
81
+ delete_option($option);
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Drop all tables associated with OMGF.
87
+ */
88
+ private function drop_tables()
89
+ {
90
+ $this->wpdb->query(
91
+ 'DROP TABLE IF EXISTS ' . $this->table . ', ' . $this->table . '_subsets;'
92
+ );
93
+ }
94
+
95
+ /**
96
+ * Delete all files stored in the cache directory.
97
+ *
98
+ * @return array
99
+ */
100
+ private function delete_files()
101
+ {
102
+ return array_map('unlink', glob($this->cacheDir . '/*.*'));
103
+ }
104
+
105
+ /**
106
+ * Delete the cache directory.
107
+ *
108
+ * @return bool
109
+ */
110
+ private function delete_dir()
111
+ {
112
+ return rmdir($this->cacheDir);
113
+ }
114
+ }
includes/frontend/class-functions.php CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
@@ -151,6 +159,6 @@ class OMGF_Frontend_Functions
151
  $google_fonts_src[] = $font->src;
152
  }
153
 
154
- update_option(OMGF_Admin_Settings::OMGF_DETECTED_FONTS_LABEL, json_encode($google_fonts_src));
155
  }
156
  }
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18
 
159
  $google_fonts_src[] = $font->src;
160
  }
161
 
162
+ update_option(OMGF_Admin_Settings::OMGF_SETTING_DETECTED_FONTS, json_encode($google_fonts_src));
163
  }
164
  }
js/hwl-admin.js CHANGED
@@ -1,9 +1,17 @@
1
- /**
2
- * @package: OMGF
3
- * @author: Daan van den Bergh
 
 
 
 
 
 
 
 
4
  * @copyright: (c) 2019 Daan van den Bergh
5
- * @url: https://daan.dev
6
- */
7
 
8
  /**
9
  * When user is done typing, trigger search.
1
+ /* * * * * * * * * * * * * * * * * * * * *
2
+ *
3
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
4
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
5
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
6
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
7
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
8
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
9
+ *
10
+ * @package : OMGF
11
+ * @author : Daan van den Bergh
12
  * @copyright: (c) 2019 Daan van den Bergh
13
+ * @url : https://daan.dev
14
+ * * * * * * * * * * * * * * * * * * * */
15
 
16
  /**
17
  * When user is done typing, trigger search.
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://daan.dev/donate/
4
  Tags: google, fonts, host, save, local, locally, webfonts, update, minimize, external, requests, leverage, browser, cache
5
  Requires at least: 4.6
6
  Tested up to: 5.3
7
- Stable tag: 2.1.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -115,6 +115,9 @@ N/A
115
 
116
  == Changelog ==
117
 
 
 
 
118
  = 2.1.6 =
119
  Fixed bug where tables weren't created upon installation. Moved logic to plugin activation, instead of 'plugins_loaded'.
120
 
4
  Tags: google, fonts, host, save, local, locally, webfonts, update, minimize, external, requests, leverage, browser, cache
5
  Requires at least: 4.6
6
  Tested up to: 5.3
7
+ Stable tag: 2.2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
115
 
116
  == Changelog ==
117
 
118
+ = 2.2.0 =
119
+ Added uninstall script.
120
+
121
  = 2.1.6 =
122
  Fixed bug where tables weren't created upon installation. Moved logic to plugin activation, instead of 'plugins_loaded'.
123
 
templates/admin/block-basic-settings.phtml CHANGED
@@ -1,15 +1,21 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
 
 
8
 
9
- // Exit if accessed directly
10
- if (!defined('ABSPATH')) {
11
- exit;
12
- }
13
  $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
14
  ?>
15
  <div class="">
@@ -20,12 +26,12 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
20
  <table class="form-table">
21
  <tr valign="top">
22
  <th scope="row">
23
- <label for="caos_webfonts_cache_dir">
24
  <?php _e('Save webfonts to...', 'host-webfonts-local'); ?> *
25
  </label>
26
  </th>
27
  <td>
28
- <input id="caos_webfonts_cache_dir" class="caos_webfonts_cache_dir" type="text" name="caos_webfonts_cache_dir" placeholder="<?= __('e.g. /cache/omgf-webfonts', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_DIR; ?>"/>
29
  <p class="description">
30
  <?php _e("Changes the path where webfonts are cached inside WordPress' content directory (usually <code>wp-content</code>). If you're using Multisite, give each site a unique cache directory path. Defaults to <code>/cache/caos-webfonts</code>.", 'host-webfonts-local'); ?>
31
  </p>
@@ -33,12 +39,12 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
33
  </tr>
34
  <tr valign="top">
35
  <th scope="row">
36
- <label for="caos_webfonts_cdn_url">
37
  <?php _e('Serve fonts from CDN', 'host-webfonts-local'); ?> *
38
  </label>
39
  </th>
40
  <td>
41
- <input id="caos_webfonts_cdn_url" class="caos_webfonts_cdn_url" type="text" name="caos_webfonts_cdn_url" placeholder="<?= __('e.g. cdn.mydomain.com', 'host-webfonts-local'); ?>" value="<?= OMGF_CDN_URL; ?>"/>
42
  <p class="description">
43
  <?php _e("Are you using a CDN? Then enter the URL here.", 'host-webfonts-local'); ?>
44
  </p>
@@ -46,12 +52,12 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
46
  </tr>
47
  <tr valign="top">
48
  <th scope="row">
49
- <label for="omgf_web_font_loader">
50
  <?php _e('Use Web Font Loader?', 'host-webfonts-local'); ?>
51
  </label>
52
  </th>
53
  <td>
54
- <input id="omgf_web_font_loader" class="omgf_web_font_loader" type="checkbox" name="omgf_web_font_loader" <?= OMGF_WEB_FONT_LOADER ? "checked = 'checked'" : ""; ?> />
55
  <p class="description">
56
  <?php _e('Use Typekit\'s Web Font Loader to load fonts asynchronously. <strong>Caution:</strong> while this might raise your Pagespeed Score, it could temporarily cause fonts to be displayed unstyled.', 'host-webfonts-local'); ?>
57
  </p>
@@ -59,12 +65,12 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
59
  </tr>
60
  <tr valign="top">
61
  <th scope="row">
62
- <label for="caos_webfonts_remove_version">
63
  <?php _e('Remove version parameter?', 'host-webfonts-local'); ?>
64
  </label>
65
  </th>
66
  <td>
67
- <input id="caos_webfonts_remove_version" class="caos_webfonts_remove_version" type="checkbox" name="caos_webfonts_remove_version" <?= OMGF_REMOVE_VERSION ? "checked = 'checked'" : ""; ?> />
68
  <p class="description">
69
  <?php _e('This removes the <code>?ver=x.x.x</code> parameter from the Stylesheet\'s (<code>fonts.css</code>) request. ', 'host-webfonts-local'); ?>
70
  </p>
@@ -72,12 +78,12 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
72
  </tr>
73
  <tr valign="top">
74
  <th scope="row">
75
- <label for="caos_webfonts_display_option">
76
  <?php _e('Font-display option', 'host-webfonts-local'); ?>
77
  </label>
78
  </th>
79
  <td>
80
- <select id="caos_webfonts_display_option" name="caos_webfonts_display_option">
81
  <?php foreach (OMGF_Admin_Settings::OMGF_FONT_DISPLAY_OPTIONS as $label => $value): ?>
82
  <option value="<?= $value; ?>" <?= $value == OMGF_DISPLAY_OPTION ? 'selected' : ''; ?>><?php _e($label, 'host-webfonts-local'); ?></option>
83
  <?php endforeach; ?>
@@ -91,12 +97,12 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
91
  </tr>
92
  <tr valign="top">
93
  <th scope="row">
94
- <label for="caos_webfonts_remove_gfonts">
95
  <?php _e('Remove Google Fonts (experimental)', 'host-webfonts-local'); ?>
96
  </label>
97
  </th>
98
  <td>
99
- <input class="caos_webfonts_remove_gfonts" id="caos_webfonts_remove_gfonts" type="checkbox" name="caos_webfonts_remove_gfonts" <?= OMGF_REMOVE_GFONTS == 'on' ? 'checked = "checked"' : ''; ?> />
100
  <p class="description">
101
  <?= sprintf(__('Enabling this option will attempt to remove any externally hosted Google Fonts-stylesheets from your WordPress-blog. If it doesn\'t work for you, click %shere%s for a more comprehensive guide.', 'host-webfonts-local'), '<a target="_blank" href="' . OMGF_SITE_URL . '/how-to/remove-google-fonts-wordpress/' . $utmTags . '">', '</a>'); ?>
102
  </p>
@@ -104,17 +110,30 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
104
  </tr>
105
  <tr valign="top">
106
  <th scope="row">
107
- <label for="caos_webfonts_preload">
108
  <?php _e('Enable preload for stylesheet (experimental)', 'host-webfonts-local'); ?>
109
  </label>
110
  </th>
111
  <td>
112
- <input class="caos_webfonts_preload" id="caos_webfonts_preload" type="checkbox" name="caos_webfonts_preload" <?= OMGF_PRELOAD == 'on' ? 'checked = "checked"' : ''; ?> />
113
  <p class="description">
114
  <?php _e('Leave this disabled if you\'re using a CSS minification plugin, such as Autoptimize or W3 Total Cache, or when using Web Font Loader.', 'host-webfonts-local'); ?>
115
  <a target="_blank" href="https://developers.google.com/web/fundamentals/performance/resource-prioritization#preload"><?php _e('Read more', 'host-webfonts-local'); ?></a>
116
  </p>
117
  </td>
118
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  </table>
120
  </div>
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
+
17
+ defined('ABSPATH') || exit;
18
 
 
 
 
 
19
  $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
20
  ?>
21
  <div class="">
26
  <table class="form-table">
27
  <tr valign="top">
28
  <th scope="row">
29
+ <label for="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_DIR; ?>">
30
  <?php _e('Save webfonts to...', 'host-webfonts-local'); ?> *
31
  </label>
32
  </th>
33
  <td>
34
+ <input id="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_DIR; ?>" class="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_DIR; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_SETTING_CACHE_DIR; ?>" placeholder="<?= __('e.g. /cache/omgf-webfonts', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_DIR; ?>"/>
35
  <p class="description">
36
  <?php _e("Changes the path where webfonts are cached inside WordPress' content directory (usually <code>wp-content</code>). If you're using Multisite, give each site a unique cache directory path. Defaults to <code>/cache/caos-webfonts</code>.", 'host-webfonts-local'); ?>
37
  </p>
39
  </tr>
40
  <tr valign="top">
41
  <th scope="row">
42
+ <label for="<?= OMGF_Admin_Settings::OMGF_SETTING_CDN_URL; ?>">
43
  <?php _e('Serve fonts from CDN', 'host-webfonts-local'); ?> *
44
  </label>
45
  </th>
46
  <td>
47
+ <input id="<?= OMGF_Admin_Settings::OMGF_SETTING_CDN_URL; ?>" class="<?= OMGF_Admin_Settings::OMGF_SETTING_CDN_URL; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_SETTING_CDN_URL; ?>" placeholder="<?= __('e.g. cdn.mydomain.com', 'host-webfonts-local'); ?>" value="<?= OMGF_CDN_URL; ?>"/>
48
  <p class="description">
49
  <?php _e("Are you using a CDN? Then enter the URL here.", 'host-webfonts-local'); ?>
50
  </p>
52
  </tr>
53
  <tr valign="top">
54
  <th scope="row">
55
+ <label for="<?= OMGF_Admin_Settings::OMGF_SETTING_WEB_FONT_LOADER; ?>">
56
  <?php _e('Use Web Font Loader?', 'host-webfonts-local'); ?>
57
  </label>
58
  </th>
59
  <td>
60
+ <input id="<?= OMGF_Admin_Settings::OMGF_SETTING_WEB_FONT_LOADER; ?>" class="<?= OMGF_Admin_Settings::OMGF_SETTING_WEB_FONT_LOADER; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_SETTING_WEB_FONT_LOADER; ?>" <?= OMGF_WEB_FONT_LOADER ? "checked = 'checked'" : ""; ?> />
61
  <p class="description">
62
  <?php _e('Use Typekit\'s Web Font Loader to load fonts asynchronously. <strong>Caution:</strong> while this might raise your Pagespeed Score, it could temporarily cause fonts to be displayed unstyled.', 'host-webfonts-local'); ?>
63
  </p>
65
  </tr>
66
  <tr valign="top">
67
  <th scope="row">
68
+ <label for="<?= OMGF_Admin_Settings::OMGF_SETTING_REMOVE_VERSION; ?>">
69
  <?php _e('Remove version parameter?', 'host-webfonts-local'); ?>
70
  </label>
71
  </th>
72
  <td>
73
+ <input id="<?= OMGF_Admin_Settings::OMGF_SETTING_REMOVE_VERSION; ?>" class="<?= OMGF_Admin_Settings::OMGF_SETTING_REMOVE_VERSION; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_SETTING_REMOVE_VERSION; ?>" <?= OMGF_REMOVE_VERSION ? "checked = 'checked'" : ""; ?> />
74
  <p class="description">
75
  <?php _e('This removes the <code>?ver=x.x.x</code> parameter from the Stylesheet\'s (<code>fonts.css</code>) request. ', 'host-webfonts-local'); ?>
76
  </p>
78
  </tr>
79
  <tr valign="top">
80
  <th scope="row">
81
+ <label for="<?= OMGF_Admin_Settings::OMGF_SETTING_DISPLAY_OPTION; ?>">
82
  <?php _e('Font-display option', 'host-webfonts-local'); ?>
83
  </label>
84
  </th>
85
  <td>
86
+ <select id="<?= OMGF_Admin_Settings::OMGF_SETTING_DISPLAY_OPTION; ?>" name="<?= OMGF_Admin_Settings::OMGF_SETTING_DISPLAY_OPTION; ?>">
87
  <?php foreach (OMGF_Admin_Settings::OMGF_FONT_DISPLAY_OPTIONS as $label => $value): ?>
88
  <option value="<?= $value; ?>" <?= $value == OMGF_DISPLAY_OPTION ? 'selected' : ''; ?>><?php _e($label, 'host-webfonts-local'); ?></option>
89
  <?php endforeach; ?>
97
  </tr>
98
  <tr valign="top">
99
  <th scope="row">
100
+ <label for="<?= OMGF_Admin_Settings::OMGF_SETTING_REMOVE_GOOGLE_FONTS; ?>">
101
  <?php _e('Remove Google Fonts (experimental)', 'host-webfonts-local'); ?>
102
  </label>
103
  </th>
104
  <td>
105
+ <input class="<?= OMGF_Admin_Settings::OMGF_SETTING_REMOVE_GOOGLE_FONTS; ?>" id="<?= OMGF_Admin_Settings::OMGF_SETTING_REMOVE_GOOGLE_FONTS; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_SETTING_REMOVE_GOOGLE_FONTS; ?>" <?= OMGF_REMOVE_GFONTS == 'on' ? 'checked = "checked"' : ''; ?> />
106
  <p class="description">
107
  <?= sprintf(__('Enabling this option will attempt to remove any externally hosted Google Fonts-stylesheets from your WordPress-blog. If it doesn\'t work for you, click %shere%s for a more comprehensive guide.', 'host-webfonts-local'), '<a target="_blank" href="' . OMGF_SITE_URL . '/how-to/remove-google-fonts-wordpress/' . $utmTags . '">', '</a>'); ?>
108
  </p>
110
  </tr>
111
  <tr valign="top">
112
  <th scope="row">
113
+ <label for="<?= OMGF_Admin_Settings::OMGF_SETTING_ENABLE_PRELOAD; ?>">
114
  <?php _e('Enable preload for stylesheet (experimental)', 'host-webfonts-local'); ?>
115
  </label>
116
  </th>
117
  <td>
118
+ <input class="<?= OMGF_Admin_Settings::OMGF_SETTING_ENABLE_PRELOAD; ?>" id="<?= OMGF_Admin_Settings::OMGF_SETTING_ENABLE_PRELOAD; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_SETTING_ENABLE_PRELOAD; ?>" <?= OMGF_PRELOAD == 'on' ? 'checked = "checked"' : ''; ?> />
119
  <p class="description">
120
  <?php _e('Leave this disabled if you\'re using a CSS minification plugin, such as Autoptimize or W3 Total Cache, or when using Web Font Loader.', 'host-webfonts-local'); ?>
121
  <a target="_blank" href="https://developers.google.com/web/fundamentals/performance/resource-prioritization#preload"><?php _e('Read more', 'host-webfonts-local'); ?></a>
122
  </p>
123
  </td>
124
  </tr>
125
+ <tr valign="top">
126
+ <th scope="row">
127
+ <label for="<?= OMGF_Admin_Settings::OMGF_SETTING_UNINSTALL ?>">
128
+ <?php _e('Remove settings and files at uninstall?', 'host-webfonts-local'); ?>
129
+ </label>
130
+ </th>
131
+ <td>
132
+ <input class="<?= OMGF_Admin_Settings::OMGF_SETTING_UNINSTALL ?>" id="<?= OMGF_Admin_Settings::OMGF_SETTING_UNINSTALL ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_SETTING_UNINSTALL ?>" <?= OMGF_UNINSTALL == 'on' ? 'checked = "checked"' : '' ?> />
133
+ <p class="description">
134
+ <?php _e('Warning! This will remove all settings and cached fonts upon plugin deletion.', 'host-webfonts-local'); ?>
135
+ </p>
136
+ </td>
137
+ </tr>
138
  </table>
139
  </div>
templates/admin/block-generate-stylesheet.phtml CHANGED
@@ -1,15 +1,20 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
- // Exit if accessed directly
10
- if (!defined('ABSPATH')) {
11
- exit;
12
- }
13
 
14
  $db = new OMGF_DB();
15
  ?>
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
+ defined('ABSPATH') || exit;
 
 
 
18
 
19
  $db = new OMGF_DB();
20
  ?>
templates/admin/block-welcome.phtml CHANGED
@@ -1,15 +1,21 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
 
 
8
 
9
- // Exit if accessed directly
10
- if (!defined('ABSPATH')) {
11
- exit;
12
- }
13
  $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=support_tab';
14
  ?>
15
  <div id="welcome-panel" class="welcome-panel">
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
+
17
+ defined('ABSPATH') || exit;
18
 
 
 
 
 
19
  $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=support_tab';
20
  ?>
21
  <div id="welcome-panel" class="welcome-panel">
templates/frontend-web-font-loader.phtml CHANGED
@@ -1,10 +1,18 @@
1
  <?php
2
- /**
 
 
 
 
 
 
 
 
3
  * @package : OMGF
4
  * @author : Daan van den Bergh
5
  * @copyright: (c) 2019 Daan van den Bergh
6
  * @url : https://daan.dev
7
- */
8
 
9
  defined('ABSPATH') || exit;
10
 
1
  <?php
2
+ /* * * * * * * * * * * * * * * * * * * * *
3
+ *
4
+ * ██████╗ ███╗ ███╗ ██████╗ ███████╗
5
+ * ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
6
+ * ██║ ██║██╔████╔██║██║ ███╗█████╗
7
+ * ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
8
+ * ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
9
+ * ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
10
+ *
11
  * @package : OMGF
12
  * @author : Daan van den Bergh
13
  * @copyright: (c) 2019 Daan van den Bergh
14
  * @url : https://daan.dev
15
+ * * * * * * * * * * * * * * * * * * * */
16
 
17
  defined('ABSPATH') || exit;
18