Created
October 22, 2018 22:59
-
-
Save JoelEadeDesign/bfe46a6e1e7499041e5f7207960d959e to your computer and use it in GitHub Desktop.
Add theme fonts to Elementor' Style Font Family Select Menus
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
<?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