Skip to content

Instantly share code, notes, and snippets.

@fastlinemedia
Created July 24, 2017 23:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fastlinemedia/b031a7afa0085538446eb8a0ba22a0c6 to your computer and use it in GitHub Desktop.
Save fastlinemedia/b031a7afa0085538446eb8a0ba22a0c6 to your computer and use it in GitHub Desktop.
Using the fl_builder_icon_sets filter to add custom icon fonts to Beaver Builder
function my_custom_icons( $sets ) {
$path = get_stylesheet_directory() . '/my-custom-icons/';
$url = get_stylesheet_directory_uri() . '/my-custom-icons/';
$data = json_decode( file_get_contents( $path . 'selection.json' ) );
$icons = array();
foreach ( $data->icons as $icon ) {
$prefs = $data->preferences->fontPref;
$postfix = isset( $prefs->postfix ) ? $prefs->postfix : '';
if ( isset( $prefs->selector ) && 'class' == $prefs->selector ) {
$selector = trim( str_replace( '.', ' ', $prefs->classSelector ) ) . ' ';
} else {
$selector = '';
}
$icons[] = $selector . $prefs->prefix . $icon->properties->name . $postfix;
}
$sets[ 'my-custom-icons' ] = array(
'name' => 'My Custom Icons',
'prefix' => '',
'type' => 'icomoon',
'path' => $path,
'url' => $url,
'stylesheet' => $url . 'style.css',
'icons' => $icons,
);
return $sets;
}
add_filter( 'fl_builder_icon_sets', 'my_custom_icons' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment