Created
January 7, 2019 00:41
-
-
Save JoelEadeDesign/fa50cb0ad30d1fd2b7a8d206a1f44f59 to your computer and use it in GitHub Desktop.
Add Custom Font Names to Elementor & GeneratePress Font Family drop-down
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
/* ------------------------------------ | |
/* CUSTOM FONTS | |
/* ------------------------------------ */ | |
/* ELEMENTOR */ | |
function modify_controls( $controls_registry ) { | |
// First we get the fonts setting of the font control | |
$fonts = $controls_registry->get_control( 'font' )->get_settings( 'options' ); | |
// Then we append the custom font family in the list of the fonts we retrieved in the previous step | |
$new_fonts = array_merge( [ 'Biotif' => 'system' ], $fonts ); | |
// Then we set a new list of fonts as the fonts setting of the font control | |
$controls_registry->get_control( 'font' )->set_settings( 'options', $new_fonts ); | |
} | |
add_action( 'elementor/controls/controls_registered', 'modify_controls', 10, 1 ); | |
/* GENERATEPRESS */ | |
add_filter( 'generate_typography_default_fonts','jed_add_system_fonts' ); | |
function jed_add_system_fonts( $fonts ) { | |
$fonts[] = 'Biotif'; | |
return $fonts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment