Skip to content

Instantly share code, notes, and snippets.

@merianos
Last active August 20, 2023 15:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save merianos/cb22c831d51e2566083eb6ac1adc2d9b to your computer and use it in GitHub Desktop.
Save merianos/cb22c831d51e2566083eb6ac1adc2d9b 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