Created
September 19, 2018 15:50
-
-
Save corypina/efad2f250544c94b5ade9b8ea16c13d5 to your computer and use it in GitHub Desktop.
Register custom fonts into the Customizer and Page Builder interfaces in 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
<?php | |
/** | |
* Customizer Custom Fonts | |
* | |
* Add fonts to the BB Theme Customizer and BB Page Builder | |
* Fonts will be listed under "System" fonts in the drop downs | |
* | |
* Solution originally found here: | |
* https://www.warpconduit.net/2016/02/15/adding-custom-fonts-to-the-beaver-builder-child-theme-customizer/ | |
*/ | |
add_action( 'init', 'customize_font_list' ); | |
function customize_font_list(){ | |
$custom_fonts = array( | |
// Enter the font name as you would in CSS | |
'franklin-gothic-urw' => array( | |
// Fall back fonts | |
'fallback' => 'Arial, sans-serif', | |
// Available weights | |
'weights' => array('100','400','500','600','800') | |
), | |
); | |
// Nothing to change below here | |
foreach($custom_fonts as $name => $settings){ | |
// Add to Theme Customizer | |
if(class_exists('FLFontFamilies') && isset(FLFontFamilies::$system)){ | |
FLFontFamilies::$system[$name] = $settings; | |
} | |
// Add to Page Builder | |
if(class_exists('FLBuilderFontFamilies') && isset(FLBuilderFontFamilies::$system)){ | |
FLBuilderFontFamilies::$system[$name] = $settings; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment