Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carasmo/18e1dbb9d44b3f3f4b73c096a04bb37c to your computer and use it in GitHub Desktop.
Save carasmo/18e1dbb9d44b3f3f4b73c096a04bb37c to your computer and use it in GitHub Desktop.
How to add only the theme font choices and remove the Google fonts from Beaver Builder. See the image in the comment.
<?php
//don't add again
// Save Time? Consider a donation via PayPal @ me@christinacreativedesign.com
add_action( 'wp_head', 'childprefix_beaver_builder_modifications', 0 );
/*
* Beaver Builder Builder Enabled Modifications
* Apply childprefix_replace_system_fonts_with_theme_fonts();
* Apply childprefix_remove_google_font_optgroup_beaver_builder_interface();
*/
function childprefix_beaver_builder_modifications() {
if ( ! class_exists( 'FLBuilder' ) && ! FLBuilderModel::is_builder_enabled() ) return;
add_action( 'wp_head', 'childprefix_remove_google_font_optgroup_beaver_builder_interface' );
add_filter( 'fl_builder_font_families_system', 'childprefix_replace_system_fonts_with_theme_fonts', 10, 3 );
}
/*
* Remove Google Fonts from Beaver Builder via CSS only
*/
function childprefix_remove_google_font_optgroup_beaver_builder_interface() {
echo '<style>optgroup[label=\'Google\'] {display: none!important;}</style>';
}
/*
* Replace Beaver Builder System Fonts with Choices from Theme
* Ref: http://kb.wpbeaverbuilder.com/article/234-add-web-fonts-to-your-theme-and-page-builder
*/
function childprefix_replace_system_fonts_with_theme_fonts() {
$body[ 'Unna' ] = array(
'fallback' => 'sans-serif',
'weights' => array(
'400',
'700'
),
);
$script[ 'Kaushan Script' ] = array(
'fallback' => 'sans-serif',
'weights' => array(
'400',
),
);
return array_merge( $body, $script );
}
@carasmo
Copy link
Author

carasmo commented Jan 7, 2018

screen shot 2018-01-07 at 1 58 27 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment