Custom Adobe Fonts (Typekit) - Version 1.0.9

Version Description

Download this release

Release Info

Developer Nikschavan
Plugin Icon 128x128 Custom Adobe Fonts (Typekit)
Version 1.0.9
Comparing to
See all releases

Code changes from version 1.0.8 to 1.0.9

classes/class-custom-typekit-fonts-render.php CHANGED
@@ -15,6 +15,8 @@ if ( ! class_exists( 'Custom_Typekit_Fonts_Render' ) ) :
15
  */
16
  class Custom_Typekit_Fonts_Render {
17
 
 
 
18
  /**
19
  * Instance of Custom_Typekit_Fonts_Render
20
  *
@@ -62,7 +64,7 @@ if ( ! class_exists( 'Custom_Typekit_Fonts_Render' ) ) :
62
  */
63
  public function __construct() {
64
 
65
- add_action( 'wp_head', array( $this, 'typekit_embed_head' ) );
66
  // add Custom Font list into Astra customizer.
67
  add_action( 'astra_customizer_font_list', array( $this, 'add_customizer_font_list' ) );
68
  add_action( 'astra_render_fonts', array( $this, 'render_fonts' ) );
@@ -74,7 +76,7 @@ if ( ! class_exists( 'Custom_Typekit_Fonts_Render' ) ) :
74
  add_filter( 'elementor/fonts/groups', array( $this, 'elementor_group' ) );
75
  add_filter( 'elementor/fonts/additional_fonts', array( $this, 'add_elementor_fonts' ) );
76
 
77
- add_action( 'enqueue_block_editor_assets', array( $this, 'typekit_embed_head' ) );
78
  }
79
 
80
  /**
@@ -115,28 +117,30 @@ if ( ! class_exists( 'Custom_Typekit_Fonts_Render' ) ) :
115
  }
116
 
117
  /**
118
- * Add Script into wp head
119
  *
120
- * @since 1.0.0
121
  */
122
- function typekit_embed_head() {
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  $kit_info = get_option( 'custom-typekit-fonts' );
124
  if ( empty( $kit_info['custom-typekit-font-details'] ) ) {
125
- return;
126
  }
127
- ?>
128
- <script type="text/javascript">
129
- (function(d) {
130
- var config = {
131
- kitId : '<?php echo esc_js( $kit_info['custom-typekit-font-id'] ); ?>',
132
- scriptTimeout : 3000,
133
- async : true
134
- },
135
- h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
136
- })(document);
137
- </script>
138
-
139
- <?php
140
  }
141
 
142
  /**
15
  */
16
  class Custom_Typekit_Fonts_Render {
17
 
18
+ const TYPEKIT_EMBED_BASE = 'https://use.typekit.net/%s.css';
19
+
20
  /**
21
  * Instance of Custom_Typekit_Fonts_Render
22
  *
64
  */
65
  public function __construct() {
66
 
67
+ add_action( 'wp_enqueue_scripts', array( $this, 'typekit_embed_css' ) );
68
  // add Custom Font list into Astra customizer.
69
  add_action( 'astra_customizer_font_list', array( $this, 'add_customizer_font_list' ) );
70
  add_action( 'astra_render_fonts', array( $this, 'render_fonts' ) );
76
  add_filter( 'elementor/fonts/groups', array( $this, 'elementor_group' ) );
77
  add_filter( 'elementor/fonts/additional_fonts', array( $this, 'add_elementor_fonts' ) );
78
 
79
+ add_action( 'enqueue_block_editor_assets', array( $this, 'typekit_embed_css' ) );
80
  }
81
 
82
  /**
117
  }
118
 
119
  /**
120
+ * Enqueue Typekit CSS.
121
  *
122
+ * @return void
123
  */
124
+ public function typekit_embed_css() {
125
+
126
+ if ( false !== $this->get_typekit_embed_url() ) {
127
+ wp_enqueue_style( 'custom-typekit-css', $this->get_typekit_embed_url(), array() );
128
+ }
129
+
130
+ }
131
+
132
+ /**
133
+ * Get Typekit CSS embed URL
134
+ *
135
+ * @return String|Boolean If Kit ID is available the URL for typekit embed is returned.
136
+ */
137
+ private function get_typekit_embed_url() {
138
  $kit_info = get_option( 'custom-typekit-fonts' );
139
  if ( empty( $kit_info['custom-typekit-font-details'] ) ) {
140
+ return false;
141
  }
142
+
143
+ return sprintf( self::TYPEKIT_EMBED_BASE, $kit_info['custom-typekit-font-id'] );
 
 
 
 
 
 
 
 
 
 
 
144
  }
145
 
146
  /**
custom-typekit-fonts.php CHANGED
@@ -6,7 +6,7 @@
6
  * Author: Brainstorm Force
7
  * Author URI: http://www.brainstormforce.com
8
  * Text Domain: custom-typekit-fonts
9
- * Version: 1.0.8
10
  *
11
  * @package Typekit_Custom_Fonts
12
  */
@@ -25,7 +25,7 @@ define( 'CUSTOM_TYPEKIT_FONTS_FILE', __FILE__ );
25
  define( 'CUSTOM_TYPEKIT_FONTS_BASE', plugin_basename( CUSTOM_TYPEKIT_FONTS_FILE ) );
26
  define( 'CUSTOM_TYPEKIT_FONTS_DIR', plugin_dir_path( CUSTOM_TYPEKIT_FONTS_FILE ) );
27
  define( 'CUSTOM_TYPEKIT_FONTS_URI', plugins_url( '/', CUSTOM_TYPEKIT_FONTS_FILE ) );
28
- define( 'CUSTOM_TYPEKIT_FONTS_VER', '1.0.8' );
29
  /**
30
  * BSF Custom Fonts
31
  */
6
  * Author: Brainstorm Force
7
  * Author URI: http://www.brainstormforce.com
8
  * Text Domain: custom-typekit-fonts
9
+ * Version: 1.0.9
10
  *
11
  * @package Typekit_Custom_Fonts
12
  */
25
  define( 'CUSTOM_TYPEKIT_FONTS_BASE', plugin_basename( CUSTOM_TYPEKIT_FONTS_FILE ) );
26
  define( 'CUSTOM_TYPEKIT_FONTS_DIR', plugin_dir_path( CUSTOM_TYPEKIT_FONTS_FILE ) );
27
  define( 'CUSTOM_TYPEKIT_FONTS_URI', plugins_url( '/', CUSTOM_TYPEKIT_FONTS_FILE ) );
28
+ define( 'CUSTOM_TYPEKIT_FONTS_VER', '1.0.9' );
29
  /**
30
  * BSF Custom Fonts
31
  */
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpastra.com/
4
  Tags: custom typekit fonts, theme custom fonts, unlimited typekit custom fonts
5
  Requires at least: 4.4
6
  Tested up to: 5.0
7
- Stable tag: 1.0.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -49,6 +49,10 @@ If you're not using any of the supported plugins and theme, you can write the cu
49
 
50
  == Changelog ==
51
 
 
 
 
 
52
  = v1.0.8 =
53
  - Fixed: A few TypeKit fonts not being rendered correctly.
54
 
4
  Tags: custom typekit fonts, theme custom fonts, unlimited typekit custom fonts
5
  Requires at least: 4.4
6
  Tested up to: 5.0
7
+ Stable tag: 1.0.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
49
 
50
  == Changelog ==
51
 
52
+ = v1.0.9 =
53
+ - Improvement: Use CSS embed method for enqueueing TypeKit fonts. This should remove the slight delay in displaying the TypeKit fonts on the page,
54
+ - Fix: Post URL in the Block Editor goes behind the Editor Top Bar.
55
+
56
  = v1.0.8 =
57
  - Fixed: A few TypeKit fonts not being rendered correctly.
58