Always Include Icon Font

I uploaded a custom Icomoon icon font, and want it to be included in all pages, even when no Beaver Builder widgets that use icons are present. The reason is I created parts of the page template that use the Icomoon icons outside of Beaver Builder.

Is there an WP action or function to trigger this within the template PHP?

The other route would be to include the Icomoon icons directly in the theme, but I would like to keep the icons available within Beaver Builder widgets as well.

Thanks!

Here’s a (hackish) way of doing it:

add_action('wp', 'my_enqueue_bb_uploaded_icon');
function my_enqueue_bb_uploaded_icon() {
	$sets = FLBuilderIcons::get_sets();
  foreach($sets as $font_key=>$val) {
    if($val[name] == 'FONT NAME HERE') :
      $key = $font_key;
    endif;
  }

	if ( isset( $key ) ) {
		$set = $sets[ $key ];
		if ( 'icomoon' == $set['type'] ) {
			wp_enqueue_style( $key, $set['stylesheet'], array(), FL_BUILDER_VERSION );
		}
		if ( 'fontello' == $set['type'] ) {
			wp_enqueue_style( $key, $set['stylesheet'], array(), FL_BUILDER_VERSION );
		}
	}
}

Thanks Josh! Here is the final PHP I added to functions.php:


add_action('wp', 'my_enqueue_bb_uploaded_icon');
function my_enqueue_bb_uploaded_icon() {
    $sets = FLBuilderIcons::get_sets();
  foreach($sets as $font_key=>$val) {
    if($val['name'] == 'icomoon') :
      $key = $font_key;
    endif;
  }

    if ( isset( $key ) ) {
        $set = $sets[ $key ];
        if ( 'icomoon' == $set['type'] ) {
            wp_enqueue_style( $key, $set['stylesheet'], array(), FL_BUILDER_VERSION );
        }
    }
}

Hey Josh,

Thanks for jumping in! :slight_smile:

Derek,

Glad you sorted it out, and thanks for sharing the final code! Enjoy! :slight_smile:

Ben