Version Description
- OMGF settings screen is now easily extendable: added filters, actions, etc.
- Overall performance improvements and reduced code footprint.
Download this release
Release Info
Developer | DaanvandenBergh |
Plugin | OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy. |
Version | 3.7.0 |
Comparing to | |
See all releases |
Code changes from version 3.6.2 to 3.7.0
- assets/css/omgf-admin.css +1 -1
- assets/css/omgf-admin.less +1 -1
- assets/css/omgf-admin.min.css +1 -0
- host-webfonts-local.php +1 -1
- includes/admin/class-settings.php +11 -10
- includes/admin/settings/class-advanced.php +236 -0
- includes/admin/settings/class-builder.php +162 -0
- includes/class-admin.php +8 -0
- includes/class-omgf.php +1 -2
- includes/frontend/class-functions.php +1 -39
- readme.txt +5 -1
- templates/admin/block-advanced-settings.phtml +0 -205
- templates/admin/block-generate-stylesheet.phtml +2 -2
assets/css/omgf-admin.css
CHANGED
@@ -52,7 +52,7 @@
|
|
52 |
margin-top: 0.66em;
|
53 |
}
|
54 |
.omgf-generate-stylesheet .omgf-search-section {
|
55 |
-
max-width:
|
56 |
margin-top: 1em;
|
57 |
}
|
58 |
.omgf-generate-stylesheet .omgf-search-section a.omgf-apply.button {
|
52 |
margin-top: 0.66em;
|
53 |
}
|
54 |
.omgf-generate-stylesheet .omgf-search-section {
|
55 |
+
max-width: 666px;
|
56 |
margin-top: 1em;
|
57 |
}
|
58 |
.omgf-generate-stylesheet .omgf-search-section a.omgf-apply.button {
|
assets/css/omgf-admin.less
CHANGED
@@ -64,7 +64,7 @@
|
|
64 |
}
|
65 |
|
66 |
.omgf-search-section {
|
67 |
-
max-width:
|
68 |
margin-top: 1em;
|
69 |
|
70 |
a {
|
64 |
}
|
65 |
|
66 |
.omgf-search-section {
|
67 |
+
max-width: 666px;
|
68 |
margin-top: 1em;
|
69 |
|
70 |
a {
|
assets/css/omgf-admin.min.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.omgf-nav{padding:1em 0 1.5em}.omgf-nav a{cursor:pointer}.omgf-nav .dashicons-before:before{margin-right:.25em;line-height:1.15em}.settings-column.left{float:left;width:66%}.settings-column.right{float:right;width:21.75%}#omgf-welcome-panel{padding:20px 10px 5px}#omgf-welcome-panel h3>.dashicons{line-height:1.4}.omgf-generate-stylesheet table{margin-top:.66em}.omgf-generate-stylesheet .omgf-search-section{max-width:666px;margin-top:1em}.omgf-generate-stylesheet .omgf-search-section a.omgf-apply.button{width:85px}.omgf-generate-stylesheet .omgf-search-section a.omgf-apply span:before{line-height:1.4;width:16px}.omgf-generate-stylesheet .omgf-search-section caption{text-align:left;font-size:1.2em;font-weight:600;margin:.66em 0 .33em}.omgf-generate-stylesheet .omgf-search-section span.omgf-apply.font-styles-search{width:75%}.omgf-generate-stylesheet .omgf-search-section #omgf-search{line-height:38px;width:360px;padding:3px 10px}.omgf-generate-stylesheet .omgf-search-section #omgf-font-styles .omgf-font-remove,.omgf-generate-stylesheet .omgf-search-section #omgf-font-styles .omgf-font-no-remove{cursor:pointer;padding:0 0 0 20px;position:relative;display:inline-block}.omgf-generate-stylesheet .omgf-search-section #omgf-font-styles .omgf-font-remove:before,.omgf-generate-stylesheet .omgf-search-section #omgf-font-styles .omgf-font-no-remove:before{position:absolute;left:0}.omgf-generate-stylesheet .omgf-search-section #omgf-font-styles #font-styles-nav.sticky{background:#f1f1f1;box-shadow:0 1px 1px rgba(0,0,0,0.04);width:565px}.omgf-generate-stylesheet #omgf-control-panel{margin-top:1em}.omgf-generate-stylesheet #omgf-control-panel .button-cancel{color:#a00;text-decoration:none;border-color:transparent;box-shadow:none;background:0;border-radius:3px;white-space:nowrap;padding:1px 10px !important}.omgf-generate-stylesheet #omgf-control-panel .button-cancel:hover{cursor:pointer;background:#d54e21;color:#fff;border-color:#d54e21}.omgf-loading{position:absolute;width:100%;height:100%;left:0;right:0;top:0;text-align:center}.omgf-loading .spinner{top:50%;left:50%;position:absolute;-ms-transform:translate(0,-70%);transform:translate(0,-70%)}.sticky{position:-webkit-sticky;position:sticky}.sticky.top{top:25px}.sticky.bottom{bottom:0}@media only screen and (max-width:1024px){.settings-column{display:block;float:none}.settings-column.left,.settings-column.right{width:100%}}
|
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.
|
8 |
* Author: Daan van den Bergh
|
9 |
* Author URI: https://daan.dev
|
10 |
* License: GPL2v2 or later
|
4 |
* Plugin Name: OMGF
|
5 |
* Plugin URI: https://daan.dev/wordpress-plugins/host-google-fonts-locally
|
6 |
* Description: Minimize DNS requests and leverage browser cache by easily saving Google Fonts to your server and removing the external Google Fonts.
|
7 |
+
* Version: 3.7.0
|
8 |
* Author: Daan van den Bergh
|
9 |
* Author URI: https://daan.dev
|
10 |
* License: GPL2v2 or later
|
includes/admin/class-settings.php
CHANGED
@@ -26,13 +26,13 @@ class OMGF_Admin_Settings extends OMGF_Admin
|
|
26 |
/**
|
27 |
* Option Values
|
28 |
*/
|
29 |
-
const OMGF_FONT_DISPLAY_OPTIONS =
|
30 |
-
'
|
31 |
-
'
|
32 |
-
'
|
33 |
-
'
|
34 |
-
'
|
35 |
-
|
36 |
|
37 |
/**
|
38 |
* Generate Stylesheet
|
@@ -53,7 +53,6 @@ class OMGF_Admin_Settings extends OMGF_Admin
|
|
53 |
const OMGF_ADV_SETTING_REMOVE_VERSION = 'omgf_remove_version';
|
54 |
const OMGF_ADV_SETTING_DISPLAY_OPTION = 'omgf_display_option';
|
55 |
const OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS = 'omgf_remove_gfonts';
|
56 |
-
const OMGF_ADV_SETTING_ENABLE_PRELOAD = 'omgf_preload';
|
57 |
const OMGF_ADV_SETTING_OPTIMIZE_EDIT_ROLES = 'omgf_optimize_edit_roles';
|
58 |
const OMGF_ADV_SETTING_UNINSTALL = 'omgf_uninstall';
|
59 |
const OMGF_ADV_SETTING_ENQUEUE_ORDER = 'omgf_enqueue_order';
|
@@ -125,7 +124,7 @@ class OMGF_Admin_Settings extends OMGF_Admin
|
|
125 |
}
|
126 |
?>
|
127 |
<div class="wrap">
|
128 |
-
<h1
|
129 |
|
130 |
<p>
|
131 |
<?= get_plugin_data(OMGF_PLUGIN_FILE)['Description']; ?>
|
@@ -255,7 +254,9 @@ class OMGF_Admin_Settings extends OMGF_Admin
|
|
255 |
settings_fields(OMGF_Admin_Settings::OMGF_SETTINGS_FIELD_ADVANCED);
|
256 |
do_settings_sections(OMGF_Admin_Settings::OMGF_SETTINGS_FIELD_ADVANCED);
|
257 |
|
258 |
-
|
|
|
|
|
259 |
|
260 |
do_action('omgf_after_settings_form_settings');
|
261 |
|
26 |
/**
|
27 |
* Option Values
|
28 |
*/
|
29 |
+
const OMGF_FONT_DISPLAY_OPTIONS = [
|
30 |
+
'swap' => 'Swap (recommended)',
|
31 |
+
'auto' => 'Auto',
|
32 |
+
'block' => 'Block',
|
33 |
+
'fallback' => 'Fallback',
|
34 |
+
'optional' => 'Optional'
|
35 |
+
];
|
36 |
|
37 |
/**
|
38 |
* Generate Stylesheet
|
53 |
const OMGF_ADV_SETTING_REMOVE_VERSION = 'omgf_remove_version';
|
54 |
const OMGF_ADV_SETTING_DISPLAY_OPTION = 'omgf_display_option';
|
55 |
const OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS = 'omgf_remove_gfonts';
|
|
|
56 |
const OMGF_ADV_SETTING_OPTIMIZE_EDIT_ROLES = 'omgf_optimize_edit_roles';
|
57 |
const OMGF_ADV_SETTING_UNINSTALL = 'omgf_uninstall';
|
58 |
const OMGF_ADV_SETTING_ENQUEUE_ORDER = 'omgf_enqueue_order';
|
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']; ?>
|
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 |
|
includes/admin/settings/class-advanced.php
ADDED
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Advanced extends OMGF_Admin_Settings_Builder
|
20 |
+
{
|
21 |
+
/** @var string $utmTags */
|
22 |
+
private $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* OMGF_Admin_Settings_Advanced constructor.
|
26 |
+
*/
|
27 |
+
public function __construct()
|
28 |
+
{
|
29 |
+
$this->title = __('Advanced Settings', $this->plugin_text_domain);
|
30 |
+
|
31 |
+
// Open
|
32 |
+
// @formatter:off
|
33 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_title'], 10);
|
34 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_description'], 15);
|
35 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_before'], 20);
|
36 |
+
|
37 |
+
// Settings
|
38 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_remove_google_fonts'], 25);
|
39 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_display_option'], 30);
|
40 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_cache_dir'], 35);
|
41 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_cache_uri'], 40);
|
42 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_force_ssl'], 45);
|
43 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_relative_url'], 50);
|
44 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_cdn_url'], 55);
|
45 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_webfont_loader'], 60);
|
46 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_remove_version'], 65);
|
47 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_enqueue_order'], 70);
|
48 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_optimize_edit_roles'], 75);
|
49 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_uninstall'], 80);
|
50 |
+
|
51 |
+
// Close
|
52 |
+
add_filter('omgf_advanced_settings_content', [$this, 'do_after'], 100);
|
53 |
+
// @formatter:on
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Description
|
58 |
+
*/
|
59 |
+
public function do_description()
|
60 |
+
{
|
61 |
+
?>
|
62 |
+
<p>
|
63 |
+
<?php _e('* <strong>Generate stylesheet</strong> after changing this setting.', $this->plugin_text_domain); ?>
|
64 |
+
<br/>
|
65 |
+
<?php _e('** <strong>Download Fonts</strong> and <strong>Generate Stylesheet</strong> after changing this setting.', $this->plugin_text_domain); ?>
|
66 |
+
</p>
|
67 |
+
<?php
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
*
|
72 |
+
*/
|
73 |
+
public function do_remove_google_fonts()
|
74 |
+
{
|
75 |
+
$this->do_checkbox(
|
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 |
+
|
83 |
+
/**
|
84 |
+
*
|
85 |
+
*/
|
86 |
+
public function do_display_option()
|
87 |
+
{
|
88 |
+
$this->do_select(
|
89 |
+
__('Font-display option', $this->plugin_text_domain),
|
90 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_DISPLAY_OPTION,
|
91 |
+
OMGF_Admin_Settings::OMGF_FONT_DISPLAY_OPTIONS,
|
92 |
+
OMGF_DISPLAY_OPTION,
|
93 |
+
__('Select which font-display strategy to use. Defaults to Swap (recommended).', $this->plugin_text_domain),
|
94 |
+
'*'
|
95 |
+
);
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
*
|
100 |
+
*/
|
101 |
+
public function do_cache_dir()
|
102 |
+
{
|
103 |
+
$this->do_text(
|
104 |
+
__('Save font files to...', $this->plugin_text_domain),
|
105 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH,
|
106 |
+
__('e.g. /uploads/omgf', $this->plugin_text_domain),
|
107 |
+
OMGF_CACHE_PATH,
|
108 |
+
__("The folder (inside <code>wp-content</code>) where font files should be stored. Give each site a unique value if you're using Multisite. Defaults to <code>/uploads/omgf</code>. After changing this setting, the folder will be created if it doesn't exist and existing files will be moved automatically.", $this->plugin_text_domain),
|
109 |
+
'**'
|
110 |
+
);
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
*
|
115 |
+
*/
|
116 |
+
public function do_cache_uri()
|
117 |
+
{
|
118 |
+
$this->do_text(
|
119 |
+
__('Serve font files from...', $this->plugin_text_domain),
|
120 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_URI,
|
121 |
+
__('e.g. /app/uploads/omgf', $this->plugin_text_domain),
|
122 |
+
OMGF_CACHE_URI,
|
123 |
+
__('The relative path to serve font files from. Useful for when you\'re using security through obscurity plugins, such as WP Hide. If left empty, the cache directory specified above will be used.', $this->plugin_text_domain),
|
124 |
+
'**'
|
125 |
+
);
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
*
|
130 |
+
*/
|
131 |
+
public function do_force_ssl()
|
132 |
+
{
|
133 |
+
$this->do_checkbox(
|
134 |
+
__('Force SSL?', $this->plugin_text_domain),
|
135 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL,
|
136 |
+
OMGF_FORCE_SSL,
|
137 |
+
__('Some plugins mess up WordPress\' URL structure, which can cause OMGF to generate incorrect URLs in the stylesheet. If OMGF is generating non-SSL (<code>http://...</code>) URLs in the stylesheet, and you have the <strong>Site</strong> and <strong>WordPress Address</strong> (in <strong>Settings</strong> > <strong>General</strong>) set to SSL (<code>https://</code>), then enable this option.', $this->plugin_text_domain),
|
138 |
+
'**'
|
139 |
+
);
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
*
|
144 |
+
*/
|
145 |
+
public function do_relative_url()
|
146 |
+
{
|
147 |
+
$this->do_checkbox(
|
148 |
+
__('Use Relative URLs?', $this->plugin_text_domain),
|
149 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_RELATIVE_URL,
|
150 |
+
OMGF_RELATIVE_URL,
|
151 |
+
__('Use relative instead of absolute (full) URLs to generate the stylesheet. <strong>Warning!</strong> This disables the CDN URL!', $this->plugin_text_domain),
|
152 |
+
'**'
|
153 |
+
);
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
*
|
158 |
+
*/
|
159 |
+
public function do_cdn_url()
|
160 |
+
{
|
161 |
+
$this->do_text(
|
162 |
+
__('Serve fonts from CDN', $this->plugin_text_domain),
|
163 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL,
|
164 |
+
__('e.g. cdn.mydomain.com', $this->plugin_text_domain),
|
165 |
+
OMGF_CDN_URL,
|
166 |
+
__("Are you using a CDN? Then enter the URL here. Leave empty when using CloudFlare.", $this->plugin_text_domain),
|
167 |
+
'**'
|
168 |
+
);
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
*
|
173 |
+
*/
|
174 |
+
public function do_webfont_loader()
|
175 |
+
{
|
176 |
+
$this->do_checkbox(
|
177 |
+
__('Use Web Font Loader?', $this->plugin_text_domain),
|
178 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_WEB_FONT_LOADER,
|
179 |
+
OMGF_WEB_FONT_LOADER,
|
180 |
+
__('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.', $this->plugin_text_domain)
|
181 |
+
);
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
*
|
186 |
+
*/
|
187 |
+
public function do_remove_version()
|
188 |
+
{
|
189 |
+
$this->do_checkbox(
|
190 |
+
__('Remove version parameter?', $this->plugin_text_domain),
|
191 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_VERSION,
|
192 |
+
OMGF_REMOVE_VERSION,
|
193 |
+
__('This removes the <code>?ver=x.x.x</code> parameter from the Stylesheet\'s (<code>fonts.css</code>) request. ', $this->plugin_text_domain)
|
194 |
+
);
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
*
|
199 |
+
*/
|
200 |
+
public function do_enqueue_order()
|
201 |
+
{
|
202 |
+
$this->do_number(
|
203 |
+
__('Change enqueue order of stylesheet? (experimental)', $this->plugin_text_domain),
|
204 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_ENQUEUE_ORDER,
|
205 |
+
OMGF_ENQUEUE_ORDER,
|
206 |
+
__('Lower this value if the generated stylesheet (<code>fonts.css</code>) is not captured by your CSS minification/combining plugin. Doesn\'t work with Web Font Loader enabled.', $this->plugin_text_domain),
|
207 |
+
0
|
208 |
+
);
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
*
|
213 |
+
*/
|
214 |
+
public function do_optimize_edit_roles()
|
215 |
+
{
|
216 |
+
$this->do_checkbox(
|
217 |
+
__('Optimize fonts for logged in editors/administrators?', $this->plugin_text_domain),
|
218 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_OPTIMIZE_EDIT_ROLES,
|
219 |
+
OMGF_OPTIMIZE_EDIT_ROLES,
|
220 |
+
__('Should only be used for debugging/testing purposes. Leave disabled when e.g. using a page builder or switching themes.', $this->plugin_text_domain)
|
221 |
+
);
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
*
|
226 |
+
*/
|
227 |
+
public function do_uninstall()
|
228 |
+
{
|
229 |
+
$this->do_checkbox(
|
230 |
+
__('Remove settings and files at uninstall?', $this->plugin_text_domain),
|
231 |
+
OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL,
|
232 |
+
OMGF_UNINSTALL,
|
233 |
+
__('Warning! This will remove all settings and cached fonts upon plugin deletion.', $this->plugin_text_domain)
|
234 |
+
);
|
235 |
+
}
|
236 |
+
}
|
includes/admin/settings/class-builder.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Builder
|
20 |
+
{
|
21 |
+
/** @var string $plugin_text_domain */
|
22 |
+
protected $plugin_text_domain = 'host-webfonts-local';
|
23 |
+
|
24 |
+
/** @var $title */
|
25 |
+
protected $title;
|
26 |
+
|
27 |
+
/**
|
28 |
+
*
|
29 |
+
*/
|
30 |
+
public function do_before()
|
31 |
+
{
|
32 |
+
?>
|
33 |
+
<table class="form-table">
|
34 |
+
<?php
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
*
|
39 |
+
*/
|
40 |
+
public function do_after()
|
41 |
+
{
|
42 |
+
?>
|
43 |
+
</table>
|
44 |
+
<?php
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
*
|
49 |
+
*/
|
50 |
+
public function do_title()
|
51 |
+
{
|
52 |
+
?>
|
53 |
+
<h3><?= $this->title ?></h3>
|
54 |
+
<?php
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Generate select setting
|
59 |
+
*
|
60 |
+
* @param $label
|
61 |
+
* @param $select
|
62 |
+
* @param $options
|
63 |
+
* @param $selected
|
64 |
+
* @param $description
|
65 |
+
* @param bool $update_required
|
66 |
+
*/
|
67 |
+
public function do_select($label, $select, $options, $selected, $description, $update_required = false)
|
68 |
+
{
|
69 |
+
?>
|
70 |
+
<tr>
|
71 |
+
<th scope="row">
|
72 |
+
<?= apply_filters($select . '_setting_label', $label); ?> <?= $update_required ?: ''; ?>
|
73 |
+
</th>
|
74 |
+
<td>
|
75 |
+
<select name="<?= $select; ?>" class="<?= str_replace('_', '-', $select); ?>">
|
76 |
+
<?php
|
77 |
+
$options = apply_filters($select . '_setting_options', $options);
|
78 |
+
?>
|
79 |
+
<?php foreach ($options as $option => $option_label): ?>
|
80 |
+
<option value="<?= $option; ?>" <?= ($selected == $option) ? 'selected' : ''; ?>><?= $option_label; ?></option>
|
81 |
+
<?php endforeach; ?>
|
82 |
+
</select>
|
83 |
+
<p class="description">
|
84 |
+
<?= apply_filters($select . '_setting_description', $description); ?>
|
85 |
+
</p>
|
86 |
+
</td>
|
87 |
+
</tr>
|
88 |
+
<?php
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Generate number setting.
|
93 |
+
*
|
94 |
+
* @param $label
|
95 |
+
* @param $name
|
96 |
+
* @param $value
|
97 |
+
* @param $description
|
98 |
+
*/
|
99 |
+
public function do_number($label, $name, $value, $description, $min = 0)
|
100 |
+
{
|
101 |
+
?>
|
102 |
+
<tr valign="top">
|
103 |
+
<th scope="row"><?= apply_filters($name . '_setting_label', $label); ?></th>
|
104 |
+
<td>
|
105 |
+
<input class="<?= str_replace('_', '-', $name); ?>" type="number" name="<?= $name; ?>" min="<?= $min; ?>" value="<?= $value; ?>"/>
|
106 |
+
<p class="description">
|
107 |
+
<?= apply_filters($name . '_setting_description', $description); ?>
|
108 |
+
</p>
|
109 |
+
</td>
|
110 |
+
</tr>
|
111 |
+
<?php
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Generate text setting.
|
116 |
+
*
|
117 |
+
* @param $label
|
118 |
+
* @param $name
|
119 |
+
* @param $placeholder
|
120 |
+
* @param $value
|
121 |
+
* @param string $description
|
122 |
+
* @param bool $update_required
|
123 |
+
*/
|
124 |
+
public function do_text($label, $name, $placeholder, $value, $description = '', $update_required = false, $visible = true)
|
125 |
+
{
|
126 |
+
?>
|
127 |
+
<tr class="<?= str_replace('_', '-', $name); ?>-row" <?= $visible ? '' : 'style="display: none;"'; ?>>
|
128 |
+
<th scope="row"><?= apply_filters($name . '_setting_label', $label); ?> <?= $update_required ?: ''; ?></th>
|
129 |
+
<td>
|
130 |
+
<input class="<?= str_replace('_', '-', $name); ?>" type="text" name="<?= $name; ?>" placeholder="<?= $placeholder; ?>" value="<?= $value; ?>"/>
|
131 |
+
<p class="description">
|
132 |
+
<?= apply_filters($name . 'setting_description', $description); ?>
|
133 |
+
</p>
|
134 |
+
</td>
|
135 |
+
</tr>
|
136 |
+
<?php
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Generate checkbox setting.
|
141 |
+
*
|
142 |
+
* @param $label
|
143 |
+
* @param $name
|
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); ?>
|
157 |
+
</p>
|
158 |
+
</td>
|
159 |
+
</tr>
|
160 |
+
<?php
|
161 |
+
}
|
162 |
+
}
|
includes/class-admin.php
CHANGED
@@ -34,6 +34,9 @@ class OMGF_Admin
|
|
34 |
// @formatter:off
|
35 |
add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
|
36 |
add_action('admin_notices', [$this, 'add_notice']);
|
|
|
|
|
|
|
37 |
add_filter('pre_update_option_omgf_cache_dir', [$this, 'cache_dir_changed'], 10, 2);
|
38 |
add_filter('pre_update_option_omgf_cache_uri', [$this, 'serve_uri_changed'], 10, 2);
|
39 |
add_filter('pre_update_option_omgf_relative_url', [$this, 'relative_url_changed'], 10, 2);
|
@@ -79,6 +82,11 @@ class OMGF_Admin
|
|
79 |
OMGF_Admin_Notice::print_notice();
|
80 |
}
|
81 |
|
|
|
|
|
|
|
|
|
|
|
82 |
/**
|
83 |
* When the cache path is changed, OMGF moves the entire fonts folder to its new destination and throws a notice to
|
84 |
* regenerate the stylesheet.
|
34 |
// @formatter:off
|
35 |
add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
|
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);
|
42 |
add_filter('pre_update_option_omgf_relative_url', [$this, 'relative_url_changed'], 10, 2);
|
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.
|
includes/class-omgf.php
CHANGED
@@ -83,9 +83,8 @@ class OMGF
|
|
83 |
define('OMGF_CURRENT_BLOG_ID', get_current_blog_id());
|
84 |
define('OMGF_FONTS_DIR', WP_CONTENT_DIR . OMGF_CACHE_PATH);
|
85 |
define('OMGF_FONTS_URL', $this->get_fonts_url());
|
86 |
-
define('OMGF_DISPLAY_OPTION', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_DISPLAY_OPTION)) ?: '
|
87 |
define('OMGF_REMOVE_GFONTS', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS)));
|
88 |
-
define('OMGF_PRELOAD', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_ENABLE_PRELOAD)));
|
89 |
define('OMGF_ENQUEUE_ORDER', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_ENQUEUE_ORDER, 10)));
|
90 |
define('OMGF_OPTIMIZE_EDIT_ROLES', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_OPTIMIZE_EDIT_ROLES, 'on')));
|
91 |
define('OMGF_UNINSTALL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL)));
|
83 |
define('OMGF_CURRENT_BLOG_ID', get_current_blog_id());
|
84 |
define('OMGF_FONTS_DIR', WP_CONTENT_DIR . OMGF_CACHE_PATH);
|
85 |
define('OMGF_FONTS_URL', $this->get_fonts_url());
|
86 |
+
define('OMGF_DISPLAY_OPTION', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_DISPLAY_OPTION, 'swap')) ?: 'swap');
|
87 |
define('OMGF_REMOVE_GFONTS', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS)));
|
|
|
88 |
define('OMGF_ENQUEUE_ORDER', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_ENQUEUE_ORDER, 10)));
|
89 |
define('OMGF_OPTIMIZE_EDIT_ROLES', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_OPTIMIZE_EDIT_ROLES, 'on')));
|
90 |
define('OMGF_UNINSTALL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL)));
|
includes/frontend/class-functions.php
CHANGED
@@ -51,10 +51,6 @@ class OMGF_Frontend_Functions
|
|
51 |
add_action('wp_print_styles', array($this, 'auto_detect_fonts'), PHP_INT_MAX - 10000);
|
52 |
}
|
53 |
|
54 |
-
if (!OMGF_WEB_FONT_LOADER) {
|
55 |
-
add_action('init', array($this, 'is_preload_enabled'));
|
56 |
-
}
|
57 |
-
|
58 |
$this->db = new OMGF_DB();
|
59 |
// Needs to be loaded before stylesheet.
|
60 |
add_action('wp_enqueue_scripts', array($this, 'preload_fonts'), 0);
|
@@ -168,40 +164,6 @@ class OMGF_Frontend_Functions
|
|
168 |
include OMGF_PLUGIN_DIR . 'templates/frontend-' . $name . '.phtml';
|
169 |
}
|
170 |
|
171 |
-
/**
|
172 |
-
* Check if the Preload option is enabled.
|
173 |
-
*/
|
174 |
-
public function is_preload_enabled()
|
175 |
-
{
|
176 |
-
if (!$this->do_optimize) {
|
177 |
-
return;
|
178 |
-
}
|
179 |
-
|
180 |
-
if (OMGF_PRELOAD == 'on') {
|
181 |
-
// @formatter:off
|
182 |
-
add_action('wp_enqueue_scripts', array($this, 'add_stylesheet_preload'), 0);
|
183 |
-
// @formatter:on
|
184 |
-
}
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Prioritize the loading of fonts by adding a resource hint to the document head.
|
189 |
-
*
|
190 |
-
* Does not work with Web Font Loader enabled.
|
191 |
-
*/
|
192 |
-
public function add_stylesheet_preload()
|
193 |
-
{
|
194 |
-
global $wp_styles;
|
195 |
-
|
196 |
-
$style = isset($wp_styles->registered[self::OMGF_STYLE_HANDLE]) ? $wp_styles->registered[self::OMGF_STYLE_HANDLE] : null;
|
197 |
-
|
198 |
-
/** Do not add 'preload' if Minification plugins are enabled. */
|
199 |
-
if ($style) {
|
200 |
-
$source = $style->src . ($style->ver ? "?ver={$style->ver}" : "");
|
201 |
-
echo "<link rel='preload' href='{$source}' as='style' crossorigin='anonymous'/>\n";
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
/**
|
206 |
* Saves the used Google Fonts in the database, so it can be used by auto-detection.
|
207 |
*/
|
@@ -248,7 +210,7 @@ class OMGF_Frontend_Functions
|
|
248 |
$urls = array_reduce($font_urls, 'array_merge', []);
|
249 |
|
250 |
foreach ($urls as $url) {
|
251 |
-
echo "<link rel='preload' href='$url' as='font' type='font/" . pathinfo($url, PATHINFO_EXTENSION) . "' crossorigin
|
252 |
}
|
253 |
}
|
254 |
}
|
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);
|
164 |
include OMGF_PLUGIN_DIR . 'templates/frontend-' . $name . '.phtml';
|
165 |
}
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
/**
|
168 |
* Saves the used Google Fonts in the database, so it can be used by auto-detection.
|
169 |
*/
|
210 |
$urls = array_reduce($font_urls, 'array_merge', []);
|
211 |
|
212 |
foreach ($urls as $url) {
|
213 |
+
echo "<link rel='preload' href='$url' as='font' type='font/" . pathinfo($url, PATHINFO_EXTENSION) . "' crossorigin />\n";
|
214 |
}
|
215 |
}
|
216 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: DaanvandenBergh
|
|
3 |
Tags: google, fonts, gdpr, cache, speed, preload, font-display, webfonts, subsets, remove, minimize, external, requests
|
4 |
Requires at least: 4.6
|
5 |
Tested up to: 5.4
|
6 |
-
Stable tag: 3.
|
7 |
Requires PHP: 7.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -112,6 +112,10 @@ N/A
|
|
112 |
|
113 |
== Changelog ==
|
114 |
|
|
|
|
|
|
|
|
|
115 |
= 3.6.2 =
|
116 |
* Added filter so Auto Remove can be disabled by other plugins (OMGF Pro, in this case.)
|
117 |
|
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 |
|
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 |
|
templates/admin/block-advanced-settings.phtml
DELETED
@@ -1,205 +0,0 @@
|
|
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 |
-
$utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
20 |
-
?>
|
21 |
-
<div>
|
22 |
-
<h3><?= __('Advanced Settings', 'host-webfonts-local'); ?></h3>
|
23 |
-
<p>
|
24 |
-
<?php _e('* <strong>Generate stylesheet</strong> after changing this setting.', 'host-webfonts-local'); ?><br />
|
25 |
-
<?php _e('** <strong>Download Fonts</strong> and <strong>Generate Stylesheet</strong> after changing this setting.', 'host-webfonts-local'); ?>
|
26 |
-
</p>
|
27 |
-
<table class="form-table">
|
28 |
-
<tr valign="top">
|
29 |
-
<th scope="row">
|
30 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>">
|
31 |
-
<?php _e('Remove Google Fonts', 'host-webfonts-local'); ?>
|
32 |
-
</label>
|
33 |
-
</th>
|
34 |
-
<td>
|
35 |
-
<input class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>" id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_GOOGLE_FONTS; ?>" <?= OMGF_REMOVE_GFONTS == 'on' ? 'checked = "checked"' : ''; ?> />
|
36 |
-
<p class="description">
|
37 |
-
<?= sprintf(__('Remove any 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>).', 'host-webfonts-local'), 'https://woosh.dev/wordpress-plugins/host-google-fonts-pro/' . $utmTags); ?>
|
38 |
-
</p>
|
39 |
-
</td>
|
40 |
-
</tr>
|
41 |
-
<tr valign="top">
|
42 |
-
<th scope="row">
|
43 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_DISPLAY_OPTION; ?>">
|
44 |
-
<?php _e('Font-display option', 'host-webfonts-local'); ?> *
|
45 |
-
</label>
|
46 |
-
</th>
|
47 |
-
<td>
|
48 |
-
<select id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_DISPLAY_OPTION; ?>" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_DISPLAY_OPTION; ?>">
|
49 |
-
<?php foreach (OMGF_Admin_Settings::OMGF_FONT_DISPLAY_OPTIONS as $label => $value): ?>
|
50 |
-
<option value="<?= $value; ?>" <?= $value == OMGF_DISPLAY_OPTION ? 'selected' : ''; ?>><?php _e($label, 'host-webfonts-local'); ?></option>
|
51 |
-
<?php endforeach; ?>
|
52 |
-
</select>
|
53 |
-
<br/>
|
54 |
-
<p class="description">
|
55 |
-
<?php _e('Select which font-display strategy to use. Defaults to \'Auto\'. \'Swap\' is recommended.', 'host-webfonts-local'); ?>
|
56 |
-
<a target="_blank" href="https://developers.google.com/web/updates/2016/02/font-display"><?php _e('Read more', 'host-webfonts-local'); ?></a>
|
57 |
-
</p>
|
58 |
-
</td>
|
59 |
-
</tr>
|
60 |
-
<tr valign="top">
|
61 |
-
<th scope="row">
|
62 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>">
|
63 |
-
<?php _e('Save font files to...', 'host-webfonts-local'); ?> *
|
64 |
-
</label>
|
65 |
-
</th>
|
66 |
-
<td>
|
67 |
-
<input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH; ?>" placeholder="<?= __('e.g. /uploads/omgf', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_PATH; ?>"/>
|
68 |
-
<p class="description">
|
69 |
-
<?php _e("The folder (inside <code>wp-content</code>) where font files should be stored. Give each site a unique value if you're using Multisite. Defaults to <code>/uploads/omgf</code>. After changing this setting, the folder will be created if it doesn't exist and existing files will be moved automatically.", 'host-webfonts-local'); ?>
|
70 |
-
</p>
|
71 |
-
</td>
|
72 |
-
</tr>
|
73 |
-
<tr valign="top">
|
74 |
-
<th scope="row">
|
75 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_URI; ?>">
|
76 |
-
<?php _e('Serve font files from...', 'host-webfonts-local'); ?> *
|
77 |
-
</label>
|
78 |
-
</th>
|
79 |
-
<td>
|
80 |
-
<input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_URI; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_URI; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_URI; ?>" placeholder="<?= __('e.g. /app/uploads/omgf', 'host-webfonts-local'); ?>" value="<?= OMGF_CACHE_URI; ?>" />
|
81 |
-
<p class="description">
|
82 |
-
<?php _e('The relative path to serve font files from. Useful for when you\'re using security through obscurity plugins, such as WP Hide. If left empty, the cache directory specified above will be used.', 'host-webfonts-local'); ?>
|
83 |
-
</p>
|
84 |
-
</td>
|
85 |
-
</tr>
|
86 |
-
<tr valign="top">
|
87 |
-
<th scope="row">
|
88 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>">
|
89 |
-
<?php _e('Force SSL?', 'host-webfonts-local'); ?> **
|
90 |
-
</label>
|
91 |
-
</th>
|
92 |
-
<td>
|
93 |
-
<input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_FORCE_SSL; ?>" <?= OMGF_FORCE_SSL ? "checked ='checked'" : ''; ?> />
|
94 |
-
<p class="description">
|
95 |
-
<?php _e('Some plugins mess up WordPress\' URL structure, which can cause OMGF to generate incorrect URLs in the stylesheet. If OMGF is generating non-SSL (<code>http://...</code>) URLs in the stylesheet, and you have the <strong>Site</strong> and <strong>WordPress Address</strong> (in <strong>Settings</strong> > <strong>General</strong>) set to SSL (<code>https://</code>), then enable this option.', 'host-webfonts-local'); ?>
|
96 |
-
</p>
|
97 |
-
</td>
|
98 |
-
</tr>
|
99 |
-
<tr valign="top">
|
100 |
-
<th scope="row">
|
101 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_RELATIVE_URL; ?>">
|
102 |
-
<?php _e('Use Relative URLs?', 'host-webfonts-local'); ?> **
|
103 |
-
</label>
|
104 |
-
</th>
|
105 |
-
<td>
|
106 |
-
<input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_RELATIVE_URL; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_RELATIVE_URL; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_RELATIVE_URL; ?>" <?= OMGF_RELATIVE_URL ? "checked ='checked'" : ''; ?> />
|
107 |
-
<p class="description">
|
108 |
-
<?php _e('Use relative instead of absolute (full) URLs to generate the stylesheet. <strong>Warning!</strong> This disables the CDN URL!', 'host-webfonts-local'); ?>
|
109 |
-
</p>
|
110 |
-
</td>
|
111 |
-
</tr>
|
112 |
-
<tr valign="top">
|
113 |
-
<th scope="row">
|
114 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>">
|
115 |
-
<?php _e('Serve fonts from CDN', 'host-webfonts-local'); ?> **
|
116 |
-
</label>
|
117 |
-
</th>
|
118 |
-
<td>
|
119 |
-
<input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_CDN_URL; ?>" placeholder="<?= __('e.g. cdn.mydomain.com', 'host-webfonts-local'); ?>" value="<?= OMGF_CDN_URL; ?>" <?= OMGF_RELATIVE_URL ? 'disabled' : ''; ?> />
|
120 |
-
<p class="description">
|
121 |
-
<?php _e("Are you using a CDN? Then enter the URL here. Leave empty when using CloudFlare.", 'host-webfonts-local'); ?>
|
122 |
-
</p>
|
123 |
-
</td>
|
124 |
-
</tr>
|
125 |
-
<tr valign="top">
|
126 |
-
<th scope="row">
|
127 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_WEB_FONT_LOADER; ?>">
|
128 |
-
<?php _e('Use Web Font Loader?', 'host-webfonts-local'); ?>
|
129 |
-
</label>
|
130 |
-
</th>
|
131 |
-
<td>
|
132 |
-
<input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_WEB_FONT_LOADER; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_WEB_FONT_LOADER; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_WEB_FONT_LOADER; ?>" <?= OMGF_WEB_FONT_LOADER ? "checked = 'checked'" : ""; ?> />
|
133 |
-
<p class="description">
|
134 |
-
<?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'); ?>
|
135 |
-
</p>
|
136 |
-
</td>
|
137 |
-
</tr>
|
138 |
-
<tr valign="top">
|
139 |
-
<th scope="row">
|
140 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_VERSION; ?>">
|
141 |
-
<?php _e('Remove version parameter?', 'host-webfonts-local'); ?>
|
142 |
-
</label>
|
143 |
-
</th>
|
144 |
-
<td>
|
145 |
-
<input id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_VERSION; ?>" class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_VERSION; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_REMOVE_VERSION; ?>" <?= OMGF_REMOVE_VERSION ? "checked = 'checked'" : ""; ?> />
|
146 |
-
<p class="description">
|
147 |
-
<?php _e('This removes the <code>?ver=x.x.x</code> parameter from the Stylesheet\'s (<code>fonts.css</code>) request. ', 'host-webfonts-local'); ?>
|
148 |
-
</p>
|
149 |
-
</td>
|
150 |
-
</tr>
|
151 |
-
<tr valign="top">
|
152 |
-
<th scope="row">
|
153 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_ENABLE_PRELOAD; ?>">
|
154 |
-
<?php _e('Enable preload for stylesheet (experimental)', 'host-webfonts-local'); ?>
|
155 |
-
</label>
|
156 |
-
</th>
|
157 |
-
<td>
|
158 |
-
<input class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_ENABLE_PRELOAD; ?>" id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_ENABLE_PRELOAD; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_ENABLE_PRELOAD; ?>" <?= OMGF_PRELOAD == 'on' ? 'checked = "checked"' : ''; ?> />
|
159 |
-
<p class="description">
|
160 |
-
<?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'); ?>
|
161 |
-
<a target="_blank" href="https://developers.google.com/web/fundamentals/performance/resource-prioritization#preload"><?php _e('Read more', 'host-webfonts-local'); ?></a>
|
162 |
-
</p>
|
163 |
-
</td>
|
164 |
-
</tr>
|
165 |
-
<tr valign="top">
|
166 |
-
<th scope="row">
|
167 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_ENQUEUE_ORDER; ?>">
|
168 |
-
<?php _e('Change enqueue order of stylesheet? (experimental)', 'host-webfonts-local'); ?>
|
169 |
-
</label>
|
170 |
-
</th>
|
171 |
-
<td>
|
172 |
-
<input type="number" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_ENQUEUE_ORDER; ?>" id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_ENQUEUE_ORDER ?>" min="0" value="<?= OMGF_ENQUEUE_ORDER; ?>" />
|
173 |
-
<p class="description">
|
174 |
-
<?php _e('Lower this value if the generated stylesheet (<code>fonts.css</code>) is not captured by your CSS minification/combining plugin. Doesn\'t work with Web Font Loader enabled.', 'host-webfonts-local'); ?>
|
175 |
-
</p>
|
176 |
-
</td>
|
177 |
-
</tr>
|
178 |
-
<tr valign="top">
|
179 |
-
<th scope="row">
|
180 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_OPTIMIZE_EDIT_ROLES ?>">
|
181 |
-
<?php _e('Optimize fonts for logged in editors/administrators?', 'host-webfonts-local'); ?>
|
182 |
-
</label>
|
183 |
-
</th>
|
184 |
-
<td>
|
185 |
-
<input class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_OPTIMIZE_EDIT_ROLES ?>" id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_OPTIMIZE_EDIT_ROLES ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_OPTIMIZE_EDIT_ROLES ?>" <?= OMGF_OPTIMIZE_EDIT_ROLES == 'on' ? 'checked = "checked"' : '' ?> />
|
186 |
-
<p class="description">
|
187 |
-
<?php _e('Should only be used for debugging/testing purposes. Leave disabled when e.g. using a page builder or switching themes.', 'host-webfonts-local'); ?>
|
188 |
-
</p>
|
189 |
-
</td>
|
190 |
-
</tr>
|
191 |
-
<tr valign="top">
|
192 |
-
<th scope="row">
|
193 |
-
<label for="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL ?>">
|
194 |
-
<?php _e('Remove settings and files at uninstall?', 'host-webfonts-local'); ?>
|
195 |
-
</label>
|
196 |
-
</th>
|
197 |
-
<td>
|
198 |
-
<input class="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL ?>" id="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL ?>" <?= OMGF_UNINSTALL == 'on' ? 'checked = "checked"' : '' ?> />
|
199 |
-
<p class="description">
|
200 |
-
<?php _e('Warning! This will remove all settings and cached fonts upon plugin deletion.', 'host-webfonts-local'); ?>
|
201 |
-
</p>
|
202 |
-
</td>
|
203 |
-
</tr>
|
204 |
-
</table>
|
205 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/admin/block-generate-stylesheet.phtml
CHANGED
@@ -30,8 +30,8 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
30 |
<div class="omgf-search-section">
|
31 |
<div class="omgf-search-box">
|
32 |
<input type="text" id="omgf-search" class="form-input-tip ui-autocomplete-input" placeholder="<?php _e('Search... [e.g. Roboto, Open Sans, Poppins]', 'host-webfonts-local'); ?>" />
|
33 |
-
<input type="button" id="omgf-search-subsets" class="button button-
|
34 |
-
<input type="button" id="omgf-auto-detect" class="button button-
|
35 |
</div>
|
36 |
<table>
|
37 |
<caption><?php _e('Available subsets', 'host-webfonts-local'); ?></caption>
|
30 |
<div class="omgf-search-section">
|
31 |
<div class="omgf-search-box">
|
32 |
<input type="text" id="omgf-search" class="form-input-tip ui-autocomplete-input" placeholder="<?php _e('Search... [e.g. Roboto, Open Sans, Poppins]', 'host-webfonts-local'); ?>" />
|
33 |
+
<input type="button" id="omgf-search-subsets" class="button button-secondary button-hero" value="<?php _e('Search', 'host-webfonts-local'); ?>"/>
|
34 |
+
<input type="button" id="omgf-auto-detect" class="button button-primary button-hero" value="<?= apply_filters('omgf_generate_stylesheet_auto_detect_title', __('Auto Detect', 'host-webfonts-local')); ?>" />
|
35 |
</div>
|
36 |
<table>
|
37 |
<caption><?php _e('Available subsets', 'host-webfonts-local'); ?></caption>
|