Skip to content

Instantly share code, notes, and snippets.

@JoelEadeDesign
Created October 22, 2018 22:59
Show Gist options
  • Save JoelEadeDesign/bfe46a6e1e7499041e5f7207960d959e to your computer and use it in GitHub Desktop.
Save JoelEadeDesign/bfe46a6e1e7499041e5f7207960d959e to your computer and use it in GitHub Desktop.
Add theme fonts to Elementor' Style Font Family Select Menus
<?php
/**
* Elementor Custom Fonts
* Source: https://merianos.wordpress.com/2017/09/22/elementor-register-custom-font-family-in-the-fonts-control/
*/
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(
[ 'Font Name 01' => 'custom' ],
[ 'Font Name 02' => 'custom' ],
[ 'Font Name 03' => 'custom' ],
$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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment