Skip to content

Commit

Permalink
fixes #1786
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Feb 8, 2018
1 parent c206249 commit 27a00a3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/class-kirki.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ public static function add_field( $config_id, $args ) {
return;
}

// If the field is font-awesome, enqueue the icons on the frontend.
if ( class_exists( 'Kirki_Modules_CSS' ) && ( 'fontawesome' === $args['type'] || 'kirki-fontawesome' === $args['type'] ) ) {
Kirki_Modules_CSS::add_fontawesome_script();
}

$str = str_replace( array( '-', '_' ), ' ', $args['type'] );
$classname = 'Kirki_Field_' . str_replace( ' ', '_', ucwords( $str ) );
if ( class_exists( $classname ) ) {
Expand Down
26 changes: 25 additions & 1 deletion modules/css/class-kirki-modules-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ class Kirki_Modules_CSS {
*/
protected $css_to_file;

/**
* Should we enqueue font-awesome?
*
* @static
* @access protected
* @since 3.0.26
* @var bool
*/
protected static $enqueue_fa = false;

/**
* Constructor
*
Expand Down Expand Up @@ -203,7 +213,8 @@ public function inline_dynamic_css() {
}
$this->processed = true;
}
if ( apply_filters( 'kirki_load_fontawesome', true ) ) {

if ( self::$enqueue_fa && apply_filters( 'kirki_load_fontawesome', true ) ) {
wp_enqueue_script( 'kirki-fontawesome-font', 'https://use.fontawesome.com/30858dc40a.js', array(), '4.0.7', true );
}
}
Expand Down Expand Up @@ -292,4 +303,17 @@ public static function loop_controls( $config_id ) {
return Kirki_Modules_CSS_Generator::styles_parse( Kirki_Modules_CSS_Generator::add_prefixes( $css ) );
}
}

/**
* Runs when we're adding a font-awesome field to allow enqueueing the
* fontawesome script on the frontend.
*
* @static
* @since 3.0.26
* @access public
* @return void
*/
public static function add_fontawesome_script() {
self::$enqueue_fa = true;
}
}

0 comments on commit 27a00a3

Please sign in to comment.