Kirki - Version 3.0.25

Version Description

January 23 2018, dev time: 1 hour.

Please note that the typography controls since v3.0.23 no longer require subsets. This is not a bug or omission, subsets are simply no longer necessary because there's an implementation now that loads them properly without requiring the user to define it.

  • Fix: partial reversion of webfontloader improvements in order to resolve an issue with incorect font-weights loading.
Download this release

Release Info

Developer aristath
Plugin Icon 128x128 Kirki
Version 3.0.25
Comparing to
See all releases

Code changes from version 3.0.24 to 3.0.25

kirki.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: The ultimate WordPress Customizer Toolkit
6
  * Author: Aristeides Stathopoulos
7
  * Author URI: http://aristath.github.io
8
- * Version: 3.0.24
9
  * Text Domain: kirki
10
  *
11
  * GitHub Plugin URI: aristath/kirki
5
  * Description: The ultimate WordPress Customizer Toolkit
6
  * Author: Aristeides Stathopoulos
7
  * Author URI: http://aristath.github.io
8
+ * Version: 3.0.25
9
  * Text Domain: kirki
10
  *
11
  * GitHub Plugin URI: aristath/kirki
modules/webfonts/class-kirki-fonts-google.php CHANGED
@@ -26,6 +26,15 @@ final class Kirki_Fonts_Google {
26
  */
27
  private static $instance = null;
28
 
 
 
 
 
 
 
 
 
 
29
  /**
30
  * If set to true, forces loading ALL variants.
31
  *
26
  */
27
  private static $instance = null;
28
 
29
+ /**
30
+ * DUMMY. DOESN'T DO ANYTHING, SIMPLY BACKWARDS-COMPATIBILITY.
31
+ *
32
+ * @static
33
+ * @access public
34
+ * @var bool
35
+ */
36
+ public static $force_load_all_subsets = false;
37
+
38
  /**
39
  * If set to true, forces loading ALL variants.
40
  *
modules/webfonts/class-kirki-modules-webfonts-async.php CHANGED
@@ -58,7 +58,8 @@ final class Kirki_Modules_Webfonts_Async {
58
  $this->webfonts = $webfonts;
59
  $this->googlefonts = $googlefonts;
60
 
61
- add_action( 'wp_enqueue_scripts', array( $this, 'webfont_loader' ) );
 
62
  add_filter( 'wp_resource_hints', array( $this, 'resource_hints' ), 10, 2 );
63
 
64
  }
@@ -82,6 +83,7 @@ final class Kirki_Modules_Webfonts_Async {
82
  );
83
  }
84
  return $urls;
 
85
  }
86
 
87
  /**
@@ -95,14 +97,30 @@ final class Kirki_Modules_Webfonts_Async {
95
  // Go through our fields and populate $this->fonts.
96
  $this->webfonts->loop_fields( $this->config_id );
97
 
98
- // Apply the 'kirki_enqueue_google_fonts' filter.
99
  $this->googlefonts->fonts = apply_filters( 'kirki_enqueue_google_fonts', $this->googlefonts->fonts );
100
 
101
  // Goes through $this->fonts and adds or removes things as needed.
102
  $this->googlefonts->process_fonts();
103
 
104
- // Enqueue the script.
105
- wp_enqueue_script( 'kirki-webfonts', trailingslashit( Kirki::$url ) . 'modules/webfonts/kirki-webfonts.js', array( 'underscore' ), KIRKI_VERSION );
106
- wp_localize_script( 'kirki-webfonts', 'kirkiWebfonts', $this->googlefonts->fonts );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
  }
58
  $this->webfonts = $webfonts;
59
  $this->googlefonts = $googlefonts;
60
 
61
+ add_action( 'wp_head', array( $this, 'webfont_loader' ) );
62
+
63
  add_filter( 'wp_resource_hints', array( $this, 'resource_hints' ), 10, 2 );
64
 
65
  }
83
  );
84
  }
85
  return $urls;
86
+
87
  }
88
 
89
  /**
97
  // Go through our fields and populate $this->fonts.
98
  $this->webfonts->loop_fields( $this->config_id );
99
 
 
100
  $this->googlefonts->fonts = apply_filters( 'kirki_enqueue_google_fonts', $this->googlefonts->fonts );
101
 
102
  // Goes through $this->fonts and adds or removes things as needed.
103
  $this->googlefonts->process_fonts();
104
 
105
+ $fonts_to_load = array();
106
+ foreach ( $this->googlefonts->fonts as $font => $weights ) {
107
+ foreach ( $weights as $key => $value ) {
108
+ if ( 'italic' === $value ) {
109
+ $weights[ $key ] = '400i';
110
+ } else {
111
+ $weights[ $key ] = str_replace( array( 'regular', 'bold', 'italic' ), array( '400', '', 'i' ), $value );
112
+ }
113
+ }
114
+ $fonts_to_load[] = $font . ':' . join( ',', $weights ) . ':cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai';
115
+ }
116
+ wp_enqueue_script( 'webfont-loader', 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js', array(), KIRKI_VERSION );
117
+ if ( empty( $fonts_to_load ) ) {
118
+ return;
119
+ }
120
+ wp_add_inline_script(
121
+ 'webfont-loader',
122
+ 'WebFont.load({google:{families:[\'' . join( '\', \'', $fonts_to_load ) . '\']}});',
123
+ 'after'
124
+ );
125
  }
126
  }
modules/webfonts/kirki-webfonts.js DELETED
@@ -1,32 +0,0 @@
1
- /* global kirkiWebfonts, WebFont */
2
-
3
- // Asyncronously add webfontloader.
4
- ( function( document ) {
5
- let wfScript = document.createElement( 'script' ),
6
- scripts = document.scripts[0];
7
-
8
- wfScript.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
9
- wfScript.id = 'webfontloader';
10
- wfScript.async = true;
11
-
12
- scripts.parentNode.insertBefore( wfScript, scripts );
13
- } )( document );
14
-
15
- jQuery( document ).ready( function() {
16
- let script = document.querySelector( '#webfontloader' );
17
-
18
- // Check when the webfontloader finishes loading.
19
- script.addEventListener( 'load', function() {
20
-
21
- // Loop fonts.
22
- _.each( kirkiWebfonts, function( weights, family ) {
23
-
24
- // Add font.
25
- WebFont.load( {
26
- google:{
27
- families: [ family + ':' + weights.join( ',' ) + 'cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai' ]
28
- }
29
- } );
30
- } );
31
- } );
32
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: customizer,options framework, theme, mods, toolkit
4
  Donate link: https://aristath.github.io/donate
5
  Requires at least: 4.9
6
  Tested up to: 4.9.2
7
- Stable tag: 3.0.24
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -33,11 +33,19 @@ If you want to integrate Kirki in your theme or plugin, please read the instruct
33
 
34
  == Changelog ==
35
 
 
 
 
 
 
 
 
 
36
  = 3.0.24 =
37
 
38
  January 23 2018, dev time: 10 minutes.
39
 
40
- * Fix: Added back the `get_google_font_subsets()` method. Although it was alays meant just to be used internally apparently a couple of themes out there use it and its removal caused a fatal error.
41
 
42
  = 3.0.23 =
43
 
4
  Donate link: https://aristath.github.io/donate
5
  Requires at least: 4.9
6
  Tested up to: 4.9.2
7
+ Stable tag: 3.0.25
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
33
 
34
  == Changelog ==
35
 
36
+ = 3.0.25 =
37
+
38
+ January 23 2018, dev time: 1 hour.
39
+
40
+ Please note that the typography controls since v3.0.23 no longer require subsets. This is not a bug or omission, subsets are simply no longer necessary because there's an implementation now that loads them properly without requiring the user to define it.
41
+
42
+ * Fix: partial reversion of webfontloader improvements in order to resolve an issue with incorect font-weights loading.
43
+
44
  = 3.0.24 =
45
 
46
  January 23 2018, dev time: 10 minutes.
47
 
48
+ * Fix: Added back the `get_google_font_subsets()` method. Although it was always meant just to be used internally apparently a couple of themes out there use it and its removal caused a fatal error.
49
 
50
  = 3.0.23 =
51