Typekit Fonts for WordPress - Version 1.8.4

Version Description

  • Add support for Typekit's synchronous tracking code by setting async to false. Useful for avoiding FOUT.
  • WordPress 4.8 compatibility.
Download this release

Release Info

Developer jamescollins
Plugin Icon 128x128 Typekit Fonts for WordPress
Version 1.8.4
Comparing to
See all releases

Code changes from version 1.8.3 to 1.8.4

languages/typekit-fonts-for-wordpress.pot CHANGED
@@ -2,13 +2,13 @@
2
  # This file is distributed under the same license as the Typekit Fonts for WordPress package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Typekit Fonts for WordPress 1.8.3\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/typekit-fonts-for-wordpress\n"
7
- "POT-Creation-Date: 2016-11-22 03:34:54+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
2
  # This file is distributed under the same license as the Typekit Fonts for WordPress package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Typekit Fonts for WordPress 1.8.4\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/typekit-fonts-for-wordpress\n"
7
+ "POT-Creation-Date: 2017-06-21 06:10:56+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: jamescollins, glenn-om4
3
  Donate link: https://om4.com.au/plugins/#donate
4
  Tags: typekit, fonts, font, design, wp, multisite, wpmu, css, snippet
5
  Requires at least: 4.2
6
- Tested up to: 4.7
7
- Stable tag: 1.8.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -20,7 +20,7 @@ To use this plugin you need to sign up with Typekit, install this plugin and the
20
 
21
  Detailed instructions are available on the plugin's settings page.
22
 
23
- This plugin uses [Typekit's asynchronous embed code](http://blog.typekit.com/2015/08/04/new-embed-code-for-asynchronous-font-loading/), which doesn't block the rendering of the page while fonts are loading.
24
 
25
  Compatible with WordPress Multisite.
26
 
@@ -61,6 +61,10 @@ Please see [this page](http://help.typekit.com/customer/portal/articles/6786-bro
61
 
62
  == Changelog ==
63
 
 
 
 
 
64
  = 1.8.3 =
65
  * WordPress 4.7 compatibility.
66
  * Add "Settings" link on plugins screen.
3
  Donate link: https://om4.com.au/plugins/#donate
4
  Tags: typekit, fonts, font, design, wp, multisite, wpmu, css, snippet
5
  Requires at least: 4.2
6
+ Tested up to: 4.8
7
+ Stable tag: 1.8.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
20
 
21
  Detailed instructions are available on the plugin's settings page.
22
 
23
+ This plugin by default uses [Typekit's asynchronous embed code](http://blog.typekit.com/2015/08/04/new-embed-code-for-asynchronous-font-loading/), which doesn't block the rendering of the page while fonts are loading. However if you prefer, you can use the synchronous tracking code by setting the async parameter to false.
24
 
25
  Compatible with WordPress Multisite.
26
 
61
 
62
  == Changelog ==
63
 
64
+ = 1.8.4 =
65
+ * Add support for Typekit's synchronous tracking code by setting async to false. Useful for avoiding FOUT.
66
+ * WordPress 4.8 compatibility.
67
+
68
  = 1.8.3 =
69
  * WordPress 4.7 compatibility.
70
  * Add "Settings" link on plugins screen.
typekit.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Typekit Fonts for WordPress
4
  Plugin URI: https://om4.com.au/plugins/typekit-fonts-for-wordpress-plugin/
5
  Description: Use a range of hundreds of high quality fonts on your WordPress website by integrating the <a href="http://typekit.com">Typekit</a> font service into your WordPress blog.
6
- Version: 1.8.3
7
  Author: OM4
8
  Author URI: https://om4.com.au/plugins/
9
  Text Domain: typekit-fonts-for-wordpress
@@ -11,7 +11,7 @@ License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
 
14
- /* Copyright 2009-2016 OM4 (email : plugins@om4.com.au)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
@@ -41,8 +41,8 @@ class OM4_Typekit {
41
 
42
  private $admin;
43
 
44
- public $embedcode = '<script src="https://use.typekit.net/%s.js"></script>
45
- <script>try{Typekit.load({ async: true });}catch(e){}</script>';
46
 
47
  /**
48
  * Perl-based regular expression that is used to extract the ID from the typekit embed code
@@ -61,13 +61,16 @@ class OM4_Typekit {
61
  * @var string
62
  */
63
  public $embedcodeurl = 'https://use.typekit.net/%s.js';
 
 
64
 
65
  /*
66
  * Default settings
67
  */
68
  private $settings = array(
69
  'id'=> '',
70
- 'css' => ''
 
71
  );
72
 
73
  /**
@@ -156,7 +159,10 @@ class OM4_Typekit {
156
  * @return string The typekit embed code if the unique account ID has been set, otherwise an empty string
157
  */
158
  public function GetEmbedCode() {
159
- if ('' != $id = $this->GetAccountID()) return sprintf($this->embedcode, $id);
 
 
 
160
  return '';
161
  }
162
 
@@ -168,6 +174,21 @@ class OM4_Typekit {
168
  if (strlen($this->settings['id'])) return $this->settings['id'];
169
  return '';
170
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  /**
173
  * Extract the unique account id from the JavaScript embed code
@@ -178,9 +199,15 @@ class OM4_Typekit {
178
 
179
  $this->settings['id'] = '';
180
  // Attempt to extract the kit ID from the embed code using our regular expression
181
- if ( preg_match($this->embedcoderegexp, $code, $matches) && 4 == sizeof($matches) ) {
182
  $this->settings['id'] = $matches[3];
183
  }
 
 
 
 
 
 
184
  }
185
 
186
  /*
3
  Plugin Name: Typekit Fonts for WordPress
4
  Plugin URI: https://om4.com.au/plugins/typekit-fonts-for-wordpress-plugin/
5
  Description: Use a range of hundreds of high quality fonts on your WordPress website by integrating the <a href="http://typekit.com">Typekit</a> font service into your WordPress blog.
6
+ Version: 1.8.4
7
  Author: OM4
8
  Author URI: https://om4.com.au/plugins/
9
  Text Domain: typekit-fonts-for-wordpress
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
13
 
14
+ /* Copyright 2009-2017 OM4 (email : plugins@om4.com.au)
15
 
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
41
 
42
  private $admin;
43
 
44
+ public $embedcode = '<script src="https://use.typekit.net/%1$s.js"></script>
45
+ <script>try{Typekit.load({ async: %2$s });}catch(e){}</script>';
46
 
47
  /**
48
  * Perl-based regular expression that is used to extract the ID from the typekit embed code
61
  * @var string
62
  */
63
  public $embedcodeurl = 'https://use.typekit.net/%s.js';
64
+
65
+ public $embedcodeasyncregexp = '#async: (true|false)#i';
66
 
67
  /*
68
  * Default settings
69
  */
70
  private $settings = array(
71
  'id'=> '',
72
+ 'css' => '',
73
+ 'async' => true,
74
  );
75
 
76
  /**
159
  * @return string The typekit embed code if the unique account ID has been set, otherwise an empty string
160
  */
161
  public function GetEmbedCode() {
162
+ if ( '' != $id = $this->GetAccountID() ) {
163
+ $async = $this->GetAsync() ? 'true' : 'false';
164
+ return sprintf( $this->embedcode, $id, $async );
165
+ }
166
  return '';
167
  }
168
 
174
  if (strlen($this->settings['id'])) return $this->settings['id'];
175
  return '';
176
  }
177
+
178
+ /**
179
+ * Get the stored value for the async parameter.
180
+ *
181
+ * Defaults to true.
182
+ *
183
+ * @return bool
184
+ */
185
+ public function GetAsync() {
186
+ if ( isset( $this->settings['async'] ) && false === $this->settings['async'] ) {
187
+ return false;
188
+ } else {
189
+ return true;
190
+ }
191
+ }
192
 
193
  /**
194
  * Extract the unique account id from the JavaScript embed code
199
 
200
  $this->settings['id'] = '';
201
  // Attempt to extract the kit ID from the embed code using our regular expression
202
+ if ( preg_match( $this->embedcoderegexp, $code, $matches ) && 4 == sizeof( $matches ) ) {
203
  $this->settings['id'] = $matches[3];
204
  }
205
+
206
+ if ( preg_match( $this->embedcodeasyncregexp, $code, $matches ) && 2 == sizeof( $matches ) && 'false' === $matches[1] ) {
207
+ $this->settings['async'] = false;
208
+ } else {
209
+ $this->settings['async'] = true;
210
+ }
211
  }
212
 
213
  /*