Created
July 24, 2017 23:01
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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