Last active
June 12, 2024 19:14
-
-
Save merianos/cb22c831d51e2566083eb6ac1adc2d9b to your computer and use it in GitHub Desktop.
Elementor custom fonts in font control
This file contains hidden or 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
/** | |
* 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