Skip to content

Instantly share code, notes, and snippets.

@kaskad88
Forked from merianos/functions.php
Last active October 6, 2017 15:30
Show Gist options
  • Save kaskad88/f921d1de06fbf3a56c77bafba59d3ecf to your computer and use it in GitHub Desktop.
Save kaskad88/f921d1de06fbf3a56c77bafba59d3ecf to your computer and use it in GitHub Desktop.
Elementor custom fonts in font control
/**
* Responsible to modify the fonts list in the font control.
*/
function modify_controls( $controls_registry ) {
// First we get the fonts setting of the font control
$fonts = $controls_registry->get_control( 'font' )->get_settings( 'fonts' );
// Then we append the custom font family in the list of the fonts we retrieved in the previous step
$new_fonts = array_merge( [ 'Custom Font Family Name' => '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( 'fonts', $new_fonts );
}
add_action( 'elementor/controls/controls_registered', 'modify_controls', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment