Version Description
Added option to use relative URLs in the generated stylesheet.
Download this release
Release Info
Developer | DaanvandenBergh |
Plugin | OMGF | GDPR/DSVGO Compliant, Faster Google Fonts. Easy. |
Version | 2.4.0 |
Comparing to | |
See all releases |
Code changes from version 2.3.0 to 2.4.0
- host-webfonts-local.php +2 -2
- includes/admin/class-settings.php +1 -0
- includes/class-omgf.php +5 -0
- js/hwl-admin.js +24 -8
- readme.txt +4 -1
- templates/admin/block-basic-settings.phtml +16 -3
- templates/admin/block-generate-stylesheet.phtml +1 -1
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.
|
8 |
* Author: Daan van den Bergh
|
9 |
* Author URI: https://daan.dev
|
10 |
* License: GPL2v2 or later
|
@@ -20,7 +20,7 @@ defined('ABSPATH') || exit;
|
|
20 |
define('OMGF_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
21 |
define('OMGF_PLUGIN_FILE', __FILE__);
|
22 |
define('OMGF_DB_VERSION', '2.2.2');
|
23 |
-
define('OMGF_STATIC_VERSION', '2.
|
24 |
define('OMGF_WEB_FONT_LOADER_VERSION', '1.6.26');
|
25 |
|
26 |
/**
|
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.4.0
|
8 |
* Author: Daan van den Bergh
|
9 |
* Author URI: https://daan.dev
|
10 |
* License: GPL2v2 or later
|
20 |
define('OMGF_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
21 |
define('OMGF_PLUGIN_FILE', __FILE__);
|
22 |
define('OMGF_DB_VERSION', '2.2.2');
|
23 |
+
define('OMGF_STATIC_VERSION', '2.4.0');
|
24 |
define('OMGF_WEB_FONT_LOADER_VERSION', '1.6.26');
|
25 |
|
26 |
/**
|
includes/admin/class-settings.php
CHANGED
@@ -37,6 +37,7 @@ class OMGF_Admin_Settings extends OMGF_Admin
|
|
37 |
const OMGF_SETTING_DB_VERSION = 'omgf_db_version';
|
38 |
const OMGF_SETTING_UNINSTALL = 'omgf_uninstall';
|
39 |
const OMGF_SETTING_ENQUEUE_ORDER = 'omgf_enqueue_order';
|
|
|
40 |
|
41 |
/**
|
42 |
* OMGF_Admin_Settings constructor.
|
37 |
const OMGF_SETTING_DB_VERSION = 'omgf_db_version';
|
38 |
const OMGF_SETTING_UNINSTALL = 'omgf_uninstall';
|
39 |
const OMGF_SETTING_ENQUEUE_ORDER = 'omgf_enqueue_order';
|
40 |
+
const OMGF_SETTING_RELATIVE_URL = 'omgf_relative_url';
|
41 |
|
42 |
/**
|
43 |
* OMGF_Admin_Settings constructor.
|
includes/class-omgf.php
CHANGED
@@ -55,6 +55,7 @@ class OMGF
|
|
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)));
|
@@ -129,6 +130,10 @@ class OMGF
|
|
129 |
*/
|
130 |
public function get_upload_url()
|
131 |
{
|
|
|
|
|
|
|
|
|
132 |
if (OMGF_CDN_URL) {
|
133 |
$uploadUrl = '//' . OMGF_CDN_URL . '/' . $this->get_content_dir() . OMGF_CACHE_DIR;
|
134 |
} else {
|
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_RELATIVE_URL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_RELATIVE_URL)));
|
59 |
define('OMGF_CDN_URL', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_CDN_URL)));
|
60 |
define('OMGF_WEB_FONT_LOADER', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_WEB_FONT_LOADER)));
|
61 |
define('OMGF_REMOVE_VERSION', esc_attr(get_option(OMGF_Admin_Settings::OMGF_SETTING_REMOVE_VERSION)));
|
130 |
*/
|
131 |
public function get_upload_url()
|
132 |
{
|
133 |
+
If (OMGF_RELATIVE_URL) {
|
134 |
+
return '/' . $this->get_content_dir() . OMGF_CACHE_DIR;
|
135 |
+
}
|
136 |
+
|
137 |
if (OMGF_CDN_URL) {
|
138 |
$uploadUrl = '//' . OMGF_CDN_URL . '/' . $this->get_content_dir() . OMGF_CACHE_DIR;
|
139 |
} else {
|
js/hwl-admin.js
CHANGED
@@ -112,6 +112,7 @@ function hwlRenderAvailableSubsets(response)
|
|
112 |
for (let ii = 0; ii < subsetArray.length; ii++) {
|
113 |
subsets = subsetArray[ii]['subsets'];
|
114 |
family = subsetArray[ii]['family'];
|
|
|
115 |
id = subsetArray[ii]['id'];
|
116 |
usedStyles = subsetArray[ii]['used_styles'];
|
117 |
|
@@ -291,7 +292,7 @@ function hwlGatherSelectedSubsets()
|
|
291 |
subsets[id]['selected'] = selectedSubsets;
|
292 |
subsets[id]['available'] = {};
|
293 |
subsets[id]['available'] = availableSubsets;
|
294 |
-
})
|
295 |
|
296 |
return subsets;
|
297 |
}
|
@@ -500,13 +501,28 @@ function hwlRemoveRow(rowId)
|
|
500 |
jQuery('#' + rowId).remove();
|
501 |
}
|
502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
}
|
508 |
|
509 |
-
|
510 |
-
|
511 |
-
|
|
|
|
|
|
|
|
|
512 |
});
|
112 |
for (let ii = 0; ii < subsetArray.length; ii++) {
|
113 |
subsets = subsetArray[ii]['subsets'];
|
114 |
family = subsetArray[ii]['family'];
|
115 |
+
|
116 |
id = subsetArray[ii]['id'];
|
117 |
usedStyles = subsetArray[ii]['used_styles'];
|
118 |
|
292 |
subsets[id]['selected'] = selectedSubsets;
|
293 |
subsets[id]['available'] = {};
|
294 |
subsets[id]['available'] = availableSubsets;
|
295 |
+
});
|
296 |
|
297 |
return subsets;
|
298 |
}
|
501 |
jQuery('#' + rowId).remove();
|
502 |
}
|
503 |
|
504 |
+
/**
|
505 |
+
* TODO: Move all above functions within document.ready().
|
506 |
+
*/
|
507 |
+
jQuery(document).ready(function($) {
|
508 |
+
/**
|
509 |
+
* Toggle different options that aren't compatible with each other.
|
510 |
+
*/
|
511 |
+
$('#omgf_web_font_loader, #omgf_preload').click(function () {
|
512 |
+
if (this.className === 'omgf_web_font_loader' && this.checked === true) {
|
513 |
+
$('#omgf_preload').attr('checked', false);
|
514 |
+
}
|
515 |
|
516 |
+
if (this.className === 'omgf_preload' && this.checked === true) {
|
517 |
+
$('#omgf_web_font_loader').attr('checked', false);
|
518 |
+
}
|
519 |
+
});
|
520 |
|
521 |
+
$('#omgf_relative_url').click(function () {
|
522 |
+
if (this.checked === true) {
|
523 |
+
$('#omgf_cdn_url').prop('disabled', true);
|
524 |
+
} else {
|
525 |
+
$('#omgf_cdn_url').prop('disabled', false);
|
526 |
+
}
|
527 |
+
})
|
528 |
});
|
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.
|
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.3.0 =
|
119 |
Added experimental enqueue order option.
|
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.4.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.4.0 =
|
119 |
+
Added option to use relative URLs in the generated stylesheet.
|
120 |
+
|
121 |
= 2.3.0 =
|
122 |
Added experimental enqueue order option.
|
123 |
|
templates/admin/block-basic-settings.phtml
CHANGED
@@ -33,7 +33,20 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
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/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
</p>
|
38 |
</td>
|
39 |
</tr>
|
@@ -44,7 +57,7 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
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>
|
@@ -131,7 +144,7 @@ $utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=settings';
|
|
131 |
<td>
|
132 |
<input type="number" name="<?= OMGF_Admin_Settings::OMGF_SETTING_ENQUEUE_ORDER; ?>" id="<?= OMGF_Admin_Settings::OMGF_SETTING_ENQUEUE_ORDER ?>" min="0" value="<?= OMGF_ENQUEUE_ORDER; ?>" />
|
133 |
<p class="description">
|
134 |
-
<?php _e('Lower this value if the generated stylesheet (<code>fonts.css</code>) is not captured by your CSS minification/combining plugin.', 'host-webfonts-local'); ?>
|
135 |
</p>
|
136 |
</td>
|
137 |
</tr>
|
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/omgf-webfonts</code>.", 'host-webfonts-local'); ?>
|
37 |
+
</p>
|
38 |
+
</td>
|
39 |
+
</tr>
|
40 |
+
<tr valign="top">
|
41 |
+
<th scope="row">
|
42 |
+
<label for="<?= OMGF_Admin_Settings::OMGF_SETTING_RELATIVE_URL; ?>">
|
43 |
+
<?php _e('Use Relative URLs?', 'host-webfonts-local'); ?> *
|
44 |
+
</label>
|
45 |
+
</th>
|
46 |
+
<td>
|
47 |
+
<input id="<?= OMGF_Admin_Settings::OMGF_SETTING_RELATIVE_URL; ?>" class="<?= OMGF_Admin_Settings::OMGF_SETTING_RELATIVE_URL; ?>" type="checkbox" name="<?= OMGF_Admin_Settings::OMGF_SETTING_RELATIVE_URL; ?>" <?= OMGF_RELATIVE_URL ? "checked ='checked'" : ''; ?> />
|
48 |
+
<p class="description">
|
49 |
+
<?php _e('Use relative instead of absolute (full) URLs to generate the stylesheet. <strong>Warning!</strong> This disables the CDN URL!', 'host-webfonts-local'); ?>
|
50 |
</p>
|
51 |
</td>
|
52 |
</tr>
|
57 |
</label>
|
58 |
</th>
|
59 |
<td>
|
60 |
+
<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; ?>" <?= OMGF_RELATIVE_URL ? 'disabled' : ''; ?> />
|
61 |
<p class="description">
|
62 |
<?php _e("Are you using a CDN? Then enter the URL here.", 'host-webfonts-local'); ?>
|
63 |
</p>
|
144 |
<td>
|
145 |
<input type="number" name="<?= OMGF_Admin_Settings::OMGF_SETTING_ENQUEUE_ORDER; ?>" id="<?= OMGF_Admin_Settings::OMGF_SETTING_ENQUEUE_ORDER ?>" min="0" value="<?= OMGF_ENQUEUE_ORDER; ?>" />
|
146 |
<p class="description">
|
147 |
+
<?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'); ?>
|
148 |
</p>
|
149 |
</td>
|
150 |
</tr>
|
templates/admin/block-generate-stylesheet.phtml
CHANGED
@@ -20,7 +20,7 @@ $db = new OMGF_DB();
|
|
20 |
?>
|
21 |
<div class="">
|
22 |
<h3><?php _e('Generate Stylesheet', 'host-webfonts-local'); ?></h3>
|
23 |
-
<p class="description">* Default WordPress font.</p>
|
24 |
<div class="hwl-search-box">
|
25 |
<input type="text" name="search-field"
|
26 |
id="search-field" class="form-input-tip ui-autocomplete-input" placeholder="<?php _e('Search... (e.g. Roboto,Open Sans)', 'host-webfonts-local'); ?>"/>
|
20 |
?>
|
21 |
<div class="">
|
22 |
<h3><?php _e('Generate Stylesheet', 'host-webfonts-local'); ?></h3>
|
23 |
+
<p class="description">* Default WordPress font: enable only if you're sure that your theme uses it.</p>
|
24 |
<div class="hwl-search-box">
|
25 |
<input type="text" name="search-field"
|
26 |
id="search-field" class="form-input-tip ui-autocomplete-input" placeholder="<?php _e('Search... (e.g. Roboto,Open Sans)', 'host-webfonts-local'); ?>"/>
|