Version Description
Download this release
Release Info
Developer | everpress |
Plugin | Local Google Fonts |
Version | 0.17 |
Comparing to | |
See all releases |
Code changes from version 0.16 to 0.17
- README.md +9 -1
- assets/admin.css +45 -0
- assets/admin.js +20 -0
- includes/class-local-google-fonts-admin.php +6 -3
- includes/class-local-google-fonts-upgrade.php +87 -0
- includes/class-local-google-fonts.php +33 -2
- local-google-fonts.php +5 -3
- views/settings.php +124 -105
README.md
CHANGED
@@ -4,7 +4,7 @@ Contributors: everpress, xaverb
|
|
4 |
Tags: googlefonts, google, fonts, gdpr, lgf, font, speed
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 6.0
|
7 |
-
Stable tag: 0.
|
8 |
Requires PHP: 5.6+
|
9 |
License: GPLv2 or later
|
10 |
Author: EverPress
|
@@ -84,6 +84,14 @@ You may have loaded a subset which doesn't included required characters. Check a
|
|
84 |
|
85 |
## Changelog
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
### 0.16
|
88 |
|
89 |
- using absolute path to support Google Fonts in [Mailster](https://mailster.co/?utm_campaign=wporg&utm_source=Local+Google+Fonts&utm_medium=readme).
|
4 |
Tags: googlefonts, google, fonts, gdpr, lgf, font, speed
|
5 |
Requires at least: 4.6
|
6 |
Tested up to: 6.0
|
7 |
+
Stable tag: 0.17
|
8 |
Requires PHP: 5.6+
|
9 |
License: GPLv2 or later
|
10 |
Author: EverPress
|
84 |
|
85 |
## Changelog
|
86 |
|
87 |
+
### 0.17
|
88 |
+
|
89 |
+
- remove `ver` query argument from URLs as they are added by WordPress. _Please review settings as fonts may have to be reloaded_
|
90 |
+
- introduced upgrade class for future updates
|
91 |
+
- added: welcome message after plugin activation
|
92 |
+
- added Codeable banner
|
93 |
+
- fixed: PHP warning on missing key
|
94 |
+
|
95 |
### 0.16
|
96 |
|
97 |
- using absolute path to support Google Fonts in [Mailster](https://mailster.co/?utm_campaign=wporg&utm_source=Local+Google+Fonts&utm_medium=readme).
|
assets/admin.css
CHANGED
@@ -12,3 +12,48 @@
|
|
12 |
summary {
|
13 |
cursor: pointer;
|
14 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
summary {
|
13 |
cursor: pointer;
|
14 |
}
|
15 |
+
|
16 |
+
.wrap-inner {
|
17 |
+
display: flex;
|
18 |
+
gap: 20px;
|
19 |
+
}
|
20 |
+
.main {
|
21 |
+
flex-basis: 100%;
|
22 |
+
}
|
23 |
+
.main code.original-url {
|
24 |
+
line-break: anywhere;
|
25 |
+
font-size: 12px;
|
26 |
+
display: block;
|
27 |
+
}
|
28 |
+
|
29 |
+
.lgf-side {
|
30 |
+
width: 240px;
|
31 |
+
padding: 2em;
|
32 |
+
flex: 0 0 auto;
|
33 |
+
background: white;
|
34 |
+
border-radius: 4px;
|
35 |
+
border: 1px solid #d9e1eb;
|
36 |
+
box-shadow: 0 1px 2px 0 rgb(0 0 0 / 10%);
|
37 |
+
align-self: baseline;
|
38 |
+
}
|
39 |
+
@media only screen and (max-width: 960px) {
|
40 |
+
.lgf-side {
|
41 |
+
display: none;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
.lgf-side .howto {
|
45 |
+
font-style: italic;
|
46 |
+
opacity: 0.4;
|
47 |
+
}
|
48 |
+
.lgf-side .codable-link {
|
49 |
+
max-width: 100%;
|
50 |
+
display: block;
|
51 |
+
margin: 2em 0 2em 0;
|
52 |
+
}
|
53 |
+
.lgf-side .button {
|
54 |
+
width: 100%;
|
55 |
+
}
|
56 |
+
#TB_window iframe {
|
57 |
+
padding: 2em;
|
58 |
+
box-sizing: border-box;
|
59 |
+
}
|
assets/admin.js
CHANGED
@@ -4,4 +4,24 @@ jQuery(document).ready(function ($) {
|
|
4 |
$('.host-locally').on('click', function () {
|
5 |
$(this).addClass('updating-message');
|
6 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
});
|
4 |
$('.host-locally').on('click', function () {
|
5 |
$(this).addClass('updating-message');
|
6 |
});
|
7 |
+
|
8 |
+
$('.get-support').on('click', function () {
|
9 |
+
var url = new URL(
|
10 |
+
'https://app.codeable.io/affiliate-form/affiliate-form.html'
|
11 |
+
);
|
12 |
+
var args = new URLSearchParams();
|
13 |
+
|
14 |
+
args.set('origin', location.origin);
|
15 |
+
args.set('affiliateUrl', location.href);
|
16 |
+
args.set('shortcode', 'adTZj');
|
17 |
+
args.set('TB_iframe', 'true');
|
18 |
+
args.set('height', 800);
|
19 |
+
args.set('width', 900);
|
20 |
+
|
21 |
+
tb_show(
|
22 |
+
$(this).text(),
|
23 |
+
'https://app.codeable.io/affiliate-form/affiliate-form.html?' +
|
24 |
+
args.toString()
|
25 |
+
);
|
26 |
+
});
|
27 |
});
|
includes/class-local-google-fonts-admin.php
CHANGED
@@ -54,8 +54,8 @@ class LGF_Admin {
|
|
54 |
$url = plugin_dir_url( LGF_PLUGIN_FILE ) . 'assets';
|
55 |
$path = plugin_dir_path( LGF_PLUGIN_FILE ) . 'assets';
|
56 |
|
57 |
-
wp_enqueue_script( 'local-google-fonts-admin', $url . '/admin.js', array( 'jquery' ), filemtime( $path . '/admin.js' ), true );
|
58 |
-
wp_enqueue_style( 'local-google-fonts-admin', $url . '/admin.css', array(), filemtime( $path . '/admin.css' ) );
|
59 |
|
60 |
add_action( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
|
61 |
|
@@ -125,7 +125,7 @@ class LGF_Admin {
|
|
125 |
return;
|
126 |
}
|
127 |
|
128 |
-
include_once dirname( LGF_PLUGIN_FILE ).'/views/settings.php';
|
129 |
|
130 |
}
|
131 |
|
@@ -135,6 +135,9 @@ class LGF_Admin {
|
|
135 |
$folder = WP_CONTENT_DIR . '/uploads/fonts';
|
136 |
$folder_url = WP_CONTENT_URL . '/uploads/fonts';
|
137 |
|
|
|
|
|
|
|
138 |
$id = md5( $src );
|
139 |
|
140 |
// a bit sanitation as URLs are often registered with esc_url
|
54 |
$url = plugin_dir_url( LGF_PLUGIN_FILE ) . 'assets';
|
55 |
$path = plugin_dir_path( LGF_PLUGIN_FILE ) . 'assets';
|
56 |
|
57 |
+
wp_enqueue_script( 'local-google-fonts-admin', $url . '/admin.js', array( 'thickbox', 'jquery' ), filemtime( $path . '/admin.js' ), true );
|
58 |
+
wp_enqueue_style( 'local-google-fonts-admin', $url . '/admin.css', array( 'thickbox' ), filemtime( $path . '/admin.css' ) );
|
59 |
|
60 |
add_action( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
|
61 |
|
125 |
return;
|
126 |
}
|
127 |
|
128 |
+
include_once dirname( LGF_PLUGIN_FILE ) . '/views/settings.php';
|
129 |
|
130 |
}
|
131 |
|
135 |
$folder = WP_CONTENT_DIR . '/uploads/fonts';
|
136 |
$folder_url = WP_CONTENT_URL . '/uploads/fonts';
|
137 |
|
138 |
+
// remove 'ver' query arg as it is added by WP
|
139 |
+
$src = remove_query_arg( 'ver', $src );
|
140 |
+
|
141 |
$id = md5( $src );
|
142 |
|
143 |
// a bit sanitation as URLs are often registered with esc_url
|
includes/class-local-google-fonts-upgrade.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
namespace EverPress;
|
5 |
+
|
6 |
+
class LGF_Upgrade {
|
7 |
+
|
8 |
+
private static $instance = null;
|
9 |
+
|
10 |
+
private $from;
|
11 |
+
private $to;
|
12 |
+
|
13 |
+
private function __construct() {
|
14 |
+
|
15 |
+
add_filter( 'upgrader_pre_install', array( $this, 'upgrader_pre_install' ), 10, 2 );
|
16 |
+
}
|
17 |
+
|
18 |
+
public static function get_instance() {
|
19 |
+
if ( self::$instance === null ) {
|
20 |
+
self::$instance = new LGF_Upgrade();
|
21 |
+
}
|
22 |
+
|
23 |
+
return self::$instance;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function upgrader_pre_install( $res, $hook_extra ) {
|
27 |
+
|
28 |
+
// store the current version of the plugin before the update kicks in
|
29 |
+
if ( $res && isset( $hook_extra['plugin'] ) ) {
|
30 |
+
if ( $hook_extra['plugin'] === plugin_basename( LGF_PLUGIN_FILE ) ) {
|
31 |
+
$plugin_data = get_plugin_data( LGF_PLUGIN_FILE, false, false );
|
32 |
+
$this->from = $plugin_data['Version'];
|
33 |
+
add_filter( 'upgrader_post_install', array( $this, 'upgrader_post_install' ), 10, 3 );
|
34 |
+
}
|
35 |
+
}
|
36 |
+
return $res;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function upgrader_post_install( $res, $hook_extra, $result ) {
|
40 |
+
|
41 |
+
// on success run the delta updates
|
42 |
+
if ( $res && isset( $hook_extra['plugin'] ) ) {
|
43 |
+
if ( $hook_extra['plugin'] === plugin_basename( LGF_PLUGIN_FILE ) ) {
|
44 |
+
$plugin_data = get_plugin_data( LGF_PLUGIN_FILE, false, false );
|
45 |
+
$this->to = $plugin_data['Version'];
|
46 |
+
|
47 |
+
$this->run();
|
48 |
+
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
return $res;
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
private function run() {
|
57 |
+
$class = new \ReflectionClass( $this );
|
58 |
+
$methods = $class->getMethods( \ReflectionMethod::IS_PRIVATE );
|
59 |
+
|
60 |
+
$updates = wp_list_pluck( $methods, 'name' );
|
61 |
+
$updates = preg_grep( '/^update_([\d_+])/', $updates );
|
62 |
+
|
63 |
+
foreach ( $updates as $update_method ) {
|
64 |
+
|
65 |
+
// get version number from method
|
66 |
+
$version = str_replace( 'update_', '', $update_method );
|
67 |
+
$version = str_replace( '_', '.', $version );
|
68 |
+
|
69 |
+
// call method only if needed
|
70 |
+
if ( version_compare( $version, $this->from, '>' ) && version_compare( $version, $this->to, '<=' ) ) {
|
71 |
+
call_user_func( array( $this, $update_method ) );
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
|
78 |
+
/*
|
79 |
+
* run updates for specific versions
|
80 |
+
*/
|
81 |
+
private function update_0_17() {
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
|
87 |
+
}
|
includes/class-local-google-fonts.php
CHANGED
@@ -11,6 +11,7 @@ class LGF {
|
|
11 |
|
12 |
private function __construct() {
|
13 |
|
|
|
14 |
register_deactivation_hook( LGF_PLUGIN_FILE, array( $this, 'deactivate' ) );
|
15 |
|
16 |
add_filter( 'style_loader_src', array( $this, 'switch_stylesheet_src' ), 10, 2 );
|
@@ -20,6 +21,8 @@ class LGF {
|
|
20 |
add_filter( 'local_google_fonts_replace_in_content', array( $this, 'replace_in_content' ) );
|
21 |
add_filter( 'local_google_fonts_replace_url', array( $this, 'google_to_local_url' ), 10, 2 );
|
22 |
|
|
|
|
|
23 |
}
|
24 |
|
25 |
public static function get_instance() {
|
@@ -36,7 +39,10 @@ class LGF {
|
|
36 |
$urls = array_diff( $urls, array( 'fonts.googleapis.com' ) );
|
37 |
} elseif ( 'preconnect' === $relation_type ) {
|
38 |
foreach ( $urls as $key => $url ) {
|
39 |
-
if (
|
|
|
|
|
|
|
40 |
unset( $urls[ $key ] );
|
41 |
}
|
42 |
}
|
@@ -48,6 +54,9 @@ class LGF {
|
|
48 |
|
49 |
public function process_url( $src, $handle ) {
|
50 |
|
|
|
|
|
|
|
51 |
$id = md5( $src );
|
52 |
|
53 |
if ( ! function_exists( 'download_url' ) ) {
|
@@ -172,6 +181,11 @@ class LGF {
|
|
172 |
|
173 |
public function google_to_local_url( $src, $handle = null ) {
|
174 |
|
|
|
|
|
|
|
|
|
|
|
175 |
$id = md5( $src );
|
176 |
|
177 |
$folder = WP_CONTENT_DIR . '/uploads/fonts';
|
@@ -186,7 +200,7 @@ class LGF {
|
|
186 |
|
187 |
// do not load on customizer preview.
|
188 |
if ( is_customize_preview() ) {
|
189 |
-
return $
|
190 |
}
|
191 |
|
192 |
if ( is_null( $handle ) ) {
|
@@ -205,6 +219,8 @@ class LGF {
|
|
205 |
$options = get_option( 'local_google_fonts' );
|
206 |
if ( isset( $options['auto_load'] ) ) {
|
207 |
$src = $this->process_url( $src, $handle );
|
|
|
|
|
208 |
}
|
209 |
}
|
210 |
|
@@ -247,6 +263,18 @@ class LGF {
|
|
247 |
return true;
|
248 |
}
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
private function wp_filesystem() {
|
251 |
global $wp_filesystem;
|
252 |
|
@@ -260,6 +288,9 @@ class LGF {
|
|
260 |
|
261 |
}
|
262 |
|
|
|
|
|
|
|
263 |
public function deactivate() {
|
264 |
$this->clear();
|
265 |
}
|
11 |
|
12 |
private function __construct() {
|
13 |
|
14 |
+
register_activation_hook( LGF_PLUGIN_FILE, array( $this, 'activate' ) );
|
15 |
register_deactivation_hook( LGF_PLUGIN_FILE, array( $this, 'deactivate' ) );
|
16 |
|
17 |
add_filter( 'style_loader_src', array( $this, 'switch_stylesheet_src' ), 10, 2 );
|
21 |
add_filter( 'local_google_fonts_replace_in_content', array( $this, 'replace_in_content' ) );
|
22 |
add_filter( 'local_google_fonts_replace_url', array( $this, 'google_to_local_url' ), 10, 2 );
|
23 |
|
24 |
+
add_action( 'admin_notices', array( $this, 'maybe_welcome_message' ) );
|
25 |
+
|
26 |
}
|
27 |
|
28 |
public static function get_instance() {
|
39 |
$urls = array_diff( $urls, array( 'fonts.googleapis.com' ) );
|
40 |
} elseif ( 'preconnect' === $relation_type ) {
|
41 |
foreach ( $urls as $key => $url ) {
|
42 |
+
if ( ! isset( $url['href'] ) ) {
|
43 |
+
continue;
|
44 |
+
}
|
45 |
+
if ( preg_match( '/\/\/fonts\.(gstatic|googleapis)\.com/', $url['href'] ) ) {
|
46 |
unset( $urls[ $key ] );
|
47 |
}
|
48 |
}
|
54 |
|
55 |
public function process_url( $src, $handle ) {
|
56 |
|
57 |
+
// remove 'ver' query arg as it is added by WP
|
58 |
+
$src = remove_query_arg( 'ver', $src );
|
59 |
+
|
60 |
$id = md5( $src );
|
61 |
|
62 |
if ( ! function_exists( 'download_url' ) ) {
|
181 |
|
182 |
public function google_to_local_url( $src, $handle = null ) {
|
183 |
|
184 |
+
$org = $src;
|
185 |
+
|
186 |
+
// remove 'ver' query arg as it is added by WP
|
187 |
+
$src = remove_query_arg( 'ver', $src );
|
188 |
+
|
189 |
$id = md5( $src );
|
190 |
|
191 |
$folder = WP_CONTENT_DIR . '/uploads/fonts';
|
200 |
|
201 |
// do not load on customizer preview.
|
202 |
if ( is_customize_preview() ) {
|
203 |
+
return $org;
|
204 |
}
|
205 |
|
206 |
if ( is_null( $handle ) ) {
|
219 |
$options = get_option( 'local_google_fonts' );
|
220 |
if ( isset( $options['auto_load'] ) ) {
|
221 |
$src = $this->process_url( $src, $handle );
|
222 |
+
} else {
|
223 |
+
$src = $org;
|
224 |
}
|
225 |
}
|
226 |
|
263 |
return true;
|
264 |
}
|
265 |
|
266 |
+
public function maybe_welcome_message() {
|
267 |
+
|
268 |
+
if ( get_option( 'local_google_fonts_buffer' ) || get_option( 'local_google_fonts' ) ) {
|
269 |
+
return;
|
270 |
+
}
|
271 |
+
?>
|
272 |
+
<div class="notice notice-info">
|
273 |
+
<p><?php printf( esc_html__( 'Thanks for using Local Google Fonts. Please check the %s.', 'local-google-fonts' ), '<a href="' . admin_url( 'options-general.php?page=lgf-settings' ) . '">' . esc_html__( 'settings page', 'local-google-fonts' ) . '</a>' ); ?></p>
|
274 |
+
</div>
|
275 |
+
<?php
|
276 |
+
}
|
277 |
+
|
278 |
private function wp_filesystem() {
|
279 |
global $wp_filesystem;
|
280 |
|
288 |
|
289 |
}
|
290 |
|
291 |
+
public function activate() {}
|
292 |
+
|
293 |
+
|
294 |
public function deactivate() {
|
295 |
$this->clear();
|
296 |
}
|
local-google-fonts.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Local Google Fonts
|
4 |
Description: Host your used Google fonts on your server and make your site GDPR compliant.
|
5 |
-
Version: 0.
|
6 |
Author: EverPress
|
7 |
Author URI: https://everpress.co
|
8 |
License: GPLv2 or later
|
@@ -19,7 +19,9 @@ if ( ! defined( 'LGF_PLUGIN_FILE' ) ) {
|
|
19 |
if ( ! class_exists( 'EverPress\LGF' ) ) {
|
20 |
include_once 'includes/class-local-google-fonts.php';
|
21 |
include_once 'includes/class-local-google-fonts-admin.php';
|
|
|
22 |
}
|
23 |
|
24 |
-
|
25 |
-
|
|
2 |
/*
|
3 |
Plugin Name: Local Google Fonts
|
4 |
Description: Host your used Google fonts on your server and make your site GDPR compliant.
|
5 |
+
Version: 0.17
|
6 |
Author: EverPress
|
7 |
Author URI: https://everpress.co
|
8 |
License: GPLv2 or later
|
19 |
if ( ! class_exists( 'EverPress\LGF' ) ) {
|
20 |
include_once 'includes/class-local-google-fonts.php';
|
21 |
include_once 'includes/class-local-google-fonts-admin.php';
|
22 |
+
include_once 'includes/class-local-google-fonts-upgrade.php';
|
23 |
}
|
24 |
|
25 |
+
LGF::get_instance();
|
26 |
+
LGF_Admin::get_instance();
|
27 |
+
LGF_Upgrade::get_instance();
|
views/settings.php
CHANGED
@@ -15,117 +15,136 @@ if ( ! $count ) :
|
|
15 |
<div class="wrap">
|
16 |
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
17 |
|
18 |
-
<
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
<hr>
|
27 |
-
<h2><?php printf( esc_html__( _n( '%d Google font source found on your site.', '%d Google font sources found on your site.', $count, 'local-google-fonts' ) ), $count ); ?></h2>
|
28 |
|
29 |
-
<p><?php esc_html_e( 'This page shows all discovered Google Fonts over time. If you miss a font start browsing your front end so they end up showing here.', 'local-google-fonts' ); ?></p>
|
30 |
|
31 |
-
|
32 |
|
33 |
-
<h3><?php esc_html_e( 'Handle', 'local-google-fonts' ); ?>: <code><?php esc_html_e( $data['handle'] ); ?></code></h3>
|
34 |
-
<p><?php esc_html_e( 'Original URL', 'local-google-fonts' ); ?>: <
|
35 |
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
<?php foreach ( $font->variants as $variant ) : ?>
|
65 |
-
<span class="variant"><?php printf( '%s %s', $variant->fontStyle, $variant->fontWeight ); ?></span>
|
66 |
-
<?php endforeach ?>
|
67 |
-
</p>
|
68 |
-
<?php $active_subsets = isset( $data['subsets'] ) ? $data['subsets'][ $font->id ] : array_keys( array_filter( (array) $font->subsetMap ) ); ?>
|
69 |
-
<p><strong><?php esc_html_e( 'Subsets', 'local-google-fonts' ); ?></strong><br>
|
70 |
-
<?php foreach ( $font->subsetMap as $subset => $is_active ) : ?>
|
71 |
-
<label title="<?php printf( esc_attr__( 'Load %s subset with this font', 'local-google-fonts' ), $subset ); ?>" class="subset"><input type="checkbox" name="subsets[<?php echo esc_attr( $data['handle'] ); ?>][<?php echo esc_attr( $font->id ); ?>][]" value="<?php echo esc_attr( $subset ); ?>" <?php checked( in_array( $subset, $active_subsets ) ); ?>> <?php echo esc_html( $subset ); ?> </label>
|
72 |
-
<?php endforeach ?>
|
73 |
-
</p>
|
74 |
-
<details>
|
75 |
-
<summary><strong><?php printf( esc_html__( '%1$d of %2$d files loaded.', 'local-google-fonts' ), $font->loaded, $font->total ); ?></strong></summary>
|
76 |
-
<div style="max-height: 280px; overflow: scroll;font-size: small;white-space: nowrap; overflow: hidden; overflow-y: auto;" class="code">
|
77 |
<?php foreach ( $font->variants as $variant ) : ?>
|
78 |
-
|
79 |
-
<h4><?php printf( '%s %s', $variant->fontStyle, $variant->fontWeight ); ?></h4>
|
80 |
-
<?php foreach ( array( 'woff', 'svg', 'woff2', 'ttf', 'eot' ) as $ext ) : ?>
|
81 |
-
<ul>
|
82 |
-
<li>
|
83 |
-
<?php $file = $data['id'] . '/' . $filename . '-' . $variant->id . '.' . $ext; ?>
|
84 |
-
<?php if ( file_exists( $folder . '/' . $file ) ) : ?>
|
85 |
-
<code><?php esc_html_e( 'Local', 'local-google-fonts' ); ?>: <a href="<?php echo esc_url( $folder_url . '/' . $file ); ?>" download><?php echo esc_html( basename( $file ) ); ?></a></code>
|
86 |
-
<strong title="<?php esc_attr_e( 'loaded, served from your server', 'local-google-fonts' ); ?>">✔</strong>
|
87 |
-
<?php else : ?>
|
88 |
-
<code><?php esc_html_e( 'Local', 'local-google-fonts' ); ?>: <?php echo esc_html( basename( $file ) ); ?></code>
|
89 |
-
<strong class="wp-ui-text-notification" title="<?php esc_attr_e( 'not loaded, served from Google servers', 'local-google-fonts' ); ?>">✕</strong>
|
90 |
-
<?php endif; ?>
|
91 |
-
</li>
|
92 |
-
<li><code><?php esc_html_e( 'Remote', 'local-google-fonts' ); ?>: <?php echo esc_url( $variant->{$ext} ); ?></code></li>
|
93 |
-
</ul>
|
94 |
-
<?php endforeach; ?>
|
95 |
-
</div>
|
96 |
<?php endforeach ?>
|
97 |
-
</
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
<?php
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
</div>
|
15 |
<div class="wrap">
|
16 |
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
17 |
|
18 |
+
<div class="wrap-inner">
|
19 |
+
<section class="main">
|
20 |
+
<form action="options.php" method="post">
|
21 |
+
<?php
|
22 |
+
settings_fields( 'local_google_fonts_settings_page' );
|
23 |
+
do_settings_sections( 'local_google_fonts_settings_page' );
|
24 |
|
25 |
+
?>
|
26 |
+
<?php submit_button(); ?>
|
27 |
+
|
28 |
+
<hr>
|
29 |
+
<h2><?php printf( esc_html__( _n( '%d Google font source found on your site.', '%d Google font sources found on your site.', $count, 'local-google-fonts' ) ), $count ); ?></h2>
|
30 |
|
31 |
+
<p><?php esc_html_e( 'This page shows all discovered Google Fonts over time. If you miss a font start browsing your front end so they end up showing here.', 'local-google-fonts' ); ?></p>
|
32 |
|
33 |
+
<?php foreach ( $buffer as $id => $data ) : ?>
|
34 |
|
35 |
+
<h3><?php esc_html_e( 'Handle', 'local-google-fonts' ); ?>: <code><?php esc_html_e( $data['handle'] ); ?></code></h3>
|
36 |
+
<p><?php esc_html_e( 'Original URL', 'local-google-fonts' ); ?>: <a href="<?php echo esc_url( $data['src'] ); ?>" class="dashicons dashicons-external" target="_blank" title="<?php esc_attr_e( 'show original URL', 'local-google-fonts' ); ?>"></a><code class="original-url"><?php echo rawurldecode( $data['src'] ); ?></code></p>
|
37 |
|
38 |
+
<?php $fontinfo = $this->get_font_info( $data['src'], $data['handle'] ); ?>
|
39 |
|
40 |
+
<?php if ( is_wp_error( $fontinfo ) ) : ?>
|
41 |
+
<div class="notice inline error">
|
42 |
+
<p><strong><?php echo esc_html( $fontinfo->get_error_message() ); ?></strong></p>
|
43 |
+
</div>
|
44 |
+
<?php else : ?>
|
45 |
+
|
46 |
+
<table class="wp-list-table widefat fixed striped table-view-list ">
|
47 |
+
<thead>
|
48 |
+
<tr>
|
49 |
+
<th scope="col" id="name" class="manage-column column-name column-primary" style="width: 150px"><?php esc_html_e( 'Name', 'local-google-fonts' ); ?></th>
|
50 |
+
<th scope="col" id="description" class="manage-column column-description"><?php esc_html_e( 'Variants', 'local-google-fonts' ); ?></th>
|
51 |
+
<th scope="col" id="auto-updates" class="manage-column column-auto-updates" style="width: 250px"><?php esc_html_e( 'Status', 'local-google-fonts' ); ?></th>
|
52 |
+
</tr>
|
53 |
+
</thead>
|
54 |
+
<tbody>
|
55 |
+
<?php foreach ( $fontinfo as $i => $font ) : ?>
|
56 |
+
|
57 |
+
<?php $filename = $font->id . '-' . $font->version . '-' . $font->defSubset; ?>
|
58 |
+
<tr>
|
59 |
+
<td><strong><?php echo esc_html( $font->family ); ?></strong><br>
|
60 |
+
<?php if ( $font->id != $font->original ) : ?>
|
61 |
+
<span class="font-alternative" title="<?php esc_attr_e( 'This is the best alternative for a font no longer supported.', 'local-google-fonts' ); ?>"><?php esc_html_e( 'alternative', 'local-google-fonts' ); ?></span>
|
62 |
+
<?php endif; ?>
|
63 |
+
</td>
|
64 |
+
<td>
|
65 |
+
<p class="code">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
<?php foreach ( $font->variants as $variant ) : ?>
|
67 |
+
<span class="variant"><?php printf( '%s %s', $variant->fontStyle, $variant->fontWeight ); ?></span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
<?php endforeach ?>
|
69 |
+
</p>
|
70 |
+
<?php $active_subsets = isset( $data['subsets'] ) ? $data['subsets'][ $font->id ] : array_keys( array_filter( (array) $font->subsetMap ) ); ?>
|
71 |
+
<p><strong><?php esc_html_e( 'Subsets', 'local-google-fonts' ); ?></strong><br>
|
72 |
+
<?php foreach ( $font->subsetMap as $subset => $is_active ) : ?>
|
73 |
+
<label title="<?php printf( esc_attr__( 'Load %s subset with this font', 'local-google-fonts' ), $subset ); ?>" class="subset"><input type="checkbox" name="subsets[<?php echo esc_attr( $data['handle'] ); ?>][<?php echo esc_attr( $font->id ); ?>][]" value="<?php echo esc_attr( $subset ); ?>" <?php checked( in_array( $subset, $active_subsets ) ); ?>> <?php echo esc_html( $subset ); ?> </label>
|
74 |
+
<?php endforeach ?>
|
75 |
+
</p>
|
76 |
+
<details>
|
77 |
+
<summary><strong><?php printf( esc_html__( '%1$d of %2$d files loaded.', 'local-google-fonts' ), $font->loaded, $font->total ); ?></strong></summary>
|
78 |
+
<div style="max-height: 280px; overflow: scroll;font-size: small;white-space: nowrap; overflow: hidden; overflow-y: auto;" class="code">
|
79 |
+
<?php foreach ( $font->variants as $variant ) : ?>
|
80 |
+
<div>
|
81 |
+
<h4><?php printf( '%s %s', $variant->fontStyle, $variant->fontWeight ); ?></h4>
|
82 |
+
<?php foreach ( array( 'woff', 'svg', 'woff2', 'ttf', 'eot' ) as $ext ) : ?>
|
83 |
+
<ul>
|
84 |
+
<li>
|
85 |
+
<?php $file = $data['id'] . '/' . $filename . '-' . $variant->id . '.' . $ext; ?>
|
86 |
+
<?php if ( file_exists( $folder . '/' . $file ) ) : ?>
|
87 |
+
<code><?php esc_html_e( 'Local', 'local-google-fonts' ); ?>: <a href="<?php echo esc_url( $folder_url . '/' . $file ); ?>" download><?php echo esc_html( basename( $file ) ); ?></a></code>
|
88 |
+
<strong title="<?php esc_attr_e( 'loaded, served from your server', 'local-google-fonts' ); ?>">✔</strong>
|
89 |
+
<?php else : ?>
|
90 |
+
<code><?php esc_html_e( 'Local', 'local-google-fonts' ); ?>: <?php echo esc_html( basename( $file ) ); ?></code>
|
91 |
+
<strong class="wp-ui-text-notification" title="<?php esc_attr_e( 'not loaded, served from Google servers', 'local-google-fonts' ); ?>">✕</strong>
|
92 |
+
<?php endif; ?>
|
93 |
+
</li>
|
94 |
+
<li><code><?php esc_html_e( 'Remote', 'local-google-fonts' ); ?>: <?php echo esc_url( $variant->{$ext} ); ?></code></li>
|
95 |
+
</ul>
|
96 |
+
<?php endforeach; ?>
|
97 |
+
</div>
|
98 |
+
<?php endforeach ?>
|
99 |
+
</div>
|
100 |
+
</details>
|
101 |
+
</td>
|
102 |
+
<td>
|
103 |
+
<?php if ( is_dir( $folder . '/' . $data['id'] ) ) : ?>
|
104 |
+
<?php printf( '%s %s', '<strong>✔</strong>', esc_html__( 'loaded, served from your server', 'local-google-fonts' ) ); ?>
|
105 |
+
<?php else : ?>
|
106 |
+
<?php printf( '%s %s', '<strong class="wp-ui-text-notification">✕</strong>', esc_html__( 'not loaded, served from Google servers', 'local-google-fonts' ) ); ?>
|
107 |
+
<?php endif; ?>
|
108 |
+
|
109 |
+
</td>
|
110 |
+
|
111 |
+
</tr>
|
112 |
+
<?php endforeach ?>
|
113 |
+
</tbody>
|
114 |
+
</table>
|
115 |
+
<p>
|
116 |
+
<?php if ( is_dir( $folder . '/' . $data['id'] ) ) : ?>
|
117 |
+
<button class="host-locally button button-primary" name="hostlocal" value="<?php echo esc_attr( $data['handle'] ); ?>"><?php esc_html_e( 'Reload Fonts', 'local-google-fonts' ); ?></button>
|
118 |
+
<button class="host-locally button button-link-delete" name="removelocal" value="<?php echo esc_attr( $data['handle'] ); ?>"><?php esc_html_e( 'Remove hosted files', 'local-google-fonts' ); ?></button>
|
119 |
+
<?php else : ?>
|
120 |
+
<button class="host-locally button button-primary" name="hostlocal" value="<?php echo esc_attr( $data['handle'] ); ?>"><?php esc_html_e( 'Host locally', 'local-google-fonts' ); ?></button>
|
121 |
+
<?php endif; ?>
|
122 |
+
</p>
|
123 |
+
<?php endif; ?>
|
124 |
+
|
125 |
+
<?php endforeach ?>
|
126 |
+
<hr>
|
127 |
+
<p class="textright">
|
128 |
+
<button class="host-locally button button-link-delete" name="flush" value="1"><?php esc_html_e( 'Remove all stored data', 'local-google-fonts' ); ?></button>
|
129 |
+
</p>
|
130 |
+
<?php submit_button(); ?>
|
131 |
+
|
132 |
+
</form>
|
133 |
+
</section>
|
134 |
+
<aside class="lgf-side">
|
135 |
+
|
136 |
+
<h3><?php printf(esc_attr__( 'Optimize %s', 'local-google-fonts' ), wp_parse_url( get_option('home'), PHP_URL_HOST)); ?></h3>
|
137 |
+
<p><?php printf(esc_attr__( 'We partner with %s to provide a trusted resource for hiring top quality premium support to help you optimize your site.', 'local-google-fonts' ),'<a href="https://codeable.io/?ref=k8TPX" ref="noopener noreferrer" target="_blank">Codeable</a>'); ?></p>
|
138 |
+
|
139 |
+
<a href="https://codeable.io/?ref=k8TPX" class="codable-link" ref="noopener noreferrer" target="_blank" title="<?php esc_attr_e( 'visit Codeable', 'local-google-fonts' ); ?>">
|
140 |
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 498 127"><defs><path d="M0 126.968h499.874V0H0z"/></defs><g fill="none" fill-rule="evenodd"><path d="m193.5 52.009-8.951 4.146c-2.278-2.276-4.476-3.983-9.114-3.983-5.288 0-10.903 3.983-10.903 11.624 0 7.56 5.615 11.463 10.903 11.463 4.638 0 6.836-1.626 9.114-3.902l9.032 4.145c-4.07 6.829-10.416 9.999-18.308 9.999-9.439 0-22.05-6.828-22.05-21.705 0-14.714 12.611-21.949 22.05-21.949 7.73 0 14.239 3.333 18.226 10.162M205.273 63.878c0 7.478 5.613 11.462 10.903 11.462 5.207 0 10.903-3.984 10.903-11.462 0-7.723-5.696-11.707-10.903-11.707-5.29 0-10.903 3.984-10.903 11.707m33.035 0c0 14.795-12.531 21.786-22.132 21.786s-22.214-6.991-22.214-21.786c0-14.796 12.613-22.03 22.214-22.03 9.6 0 22.132 7.234 22.132 22.03M273.28 63.634c0-7.56-5.371-11.462-11.148-11.462-5.777 0-10.741 3.902-10.741 11.462 0 7.804 4.964 11.706 10.74 11.706 5.778 0 11.148-3.902 11.148-11.706Zm11.065-36.257v57.474H272.71v-6.666c0 3.008-5.451 7.479-12.611 7.479-8.87 0-20.017-6.991-20.017-22.03 0-14.552 11.148-21.787 20.017-21.787 7.16 0 12.611 4.715 12.611 6.666V27.377h11.636ZM299.95 59.57h20.18c-1.303-5.204-5.94-7.805-10.172-7.805-4.15 0-8.462 2.601-10.008 7.804m30.432 8.21h-30.514c1.384 5.284 5.696 8.049 11.31 8.049 5.29 0 7.324-1.22 10.335-2.845l6.427 6.259c-3.743 3.82-8.868 6.422-17.168 6.422-10.496 0-22.458-7.235-22.458-21.786 0-14.795 12.125-22.03 21.644-22.03 9.601 0 22.946 7.235 20.424 25.932M343.523 63.634c0 7.804 4.962 11.706 10.74 11.706 5.777 0 11.147-3.902 11.147-11.706 0-7.56-5.37-11.462-11.147-11.462-5.778 0-10.74 3.902-10.74 11.462m21.318-15.121v-5.934h11.635V84.85H364.84v-6.666c0 3.008-5.452 7.479-12.613 7.479-8.869 0-20.017-6.991-20.017-22.03 0-14.552 11.148-21.787 20.017-21.787 7.16 0 12.613 4.715 12.613 6.666M415.613 63.634c0-7.56-4.963-11.462-10.74-11.462-5.778 0-11.148 3.902-11.148 11.462 0 7.804 5.37 11.706 11.147 11.706 5.778 0 10.74-3.902 10.74-11.706m11.31 0c0 15.039-11.146 22.03-20.015 22.03-7.161 0-12.613-4.471-12.613-7.479v6.666h-11.635V27.377h11.635v21.136c0-1.95 5.452-6.666 12.613-6.666 8.869 0 20.016 7.235 20.016 21.787" fill="#151D23"/><path fill="#151D23" mask="url(#b)" d="M430.997 84.851h11.636V27.377h-11.636zM458.206 59.57h20.18c-1.302-5.204-5.94-7.805-10.171-7.805-4.15 0-8.462 2.601-10.009 7.804m30.432 8.21h-30.513c1.383 5.284 5.696 8.049 11.31 8.049 5.29 0 7.324-1.22 10.334-2.845l6.428 6.259c-3.742 3.82-8.87 6.422-17.168 6.422-10.497 0-22.458-7.235-22.458-21.786 0-14.795 12.124-22.03 21.644-22.03 9.601 0 22.946 7.235 20.423 25.932"/><path d="M42.362 84.645c0 23.375 18.966 42.323 42.362 42.323 23.397 0 42.362-18.948 42.362-42.323 0-23.374-18.965-42.322-42.362-42.322v42.322H42.362Z" fill="#FFB199" mask="url(#b)"/><path fill="#165260" mask="url(#b)" d="M84.724 42.323V0H0v84.645h42.362V42.323z"/></g></svg>
|
141 |
+
</a>
|
142 |
+
|
143 |
+
<p><?php esc_attr_e( 'Get a quote within 10 minutes without obligations.', 'local-google-fonts' ); ?></p>
|
144 |
+
|
145 |
+
<button class="button button-hero button-primary get-support"><?php esc_attr_e( 'Request Quote', 'local-google-fonts' ); ?>*</button>
|
146 |
+
|
147 |
+
<p class="howto">* <?php esc_attr_e( 'Links to Codeable are affiliate links.', 'local-google-fonts' ); ?></p>
|
148 |
+
</aside>
|
149 |
+
</div>
|
150 |
</div>
|