Created
September 7, 2021 08:54
-
-
Save gr1zix/cba2374c773471fe8a12880bf7b9e070 to your computer and use it in GitHub Desktop.
Elementor register custom font (Font will be listed on Elementor fonts selector)
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
/* Enabling font which stored on fonts/ folder */ | |
@font-face { | |
font-family: 'Organetto'; | |
src: url('fonts/Organetto-Light.eot'); | |
src: local('Organetto Light'), local('Organetto-Light'), | |
url('fonts/Organetto-Light.eot?#iefix') format('embedded-opentype'), | |
url('fonts/Organetto-Light.woff2') format('woff2'), | |
url('fonts/Organetto-Light.woff') format('woff'), | |
url('fonts/Organetto-Light.ttf') format('truetype'), | |
url('fonts/Organetto-Light.svg#Organetto-Light') format('svg'); | |
font-weight: 300; | |
font-style: normal; | |
font-display: swap; | |
} | |
@font-face { | |
font-family: 'Organetto'; | |
src: url('fonts/Organetto-Regular.eot'); | |
src: local('Organetto Regular'), local('Organetto-Regular'), | |
url('fonts/Organetto-Regular.eot?#iefix') format('embedded-opentype'), | |
url('fonts/Organetto-Regular.woff2') format('woff2'), | |
url('fonts/Organetto-Regular.woff') format('woff'), | |
url('fonts/Organetto-Regular.ttf') format('truetype'), | |
url('fonts/Organetto-Regular.svg#Organetto-Regular') format('svg'); | |
font-weight: normal; | |
font-style: normal; | |
font-display: swap; | |
} | |
@font-face { | |
font-family: 'Organetto Bold SemiExp'; | |
src: url('fonts/Organetto-BoldSemiExp.eot'); | |
src: local('Organetto Bold SemiExp'), local('Organetto-BoldSemiExp'), | |
url('fonts/Organetto-BoldSemiExp.eot?#iefix') format('embedded-opentype'), | |
url('fonts/Organetto-BoldSemiExp.woff2') format('woff2'), | |
url('fonts/Organetto-BoldSemiExp.woff') format('woff'), | |
url('fonts/Organetto-BoldSemiExp.ttf') format('truetype'), | |
url('fonts/Organetto-BoldSemiExp.svg#Organetto-BoldSemiExp') format('svg'); | |
font-weight: bold; | |
font-style: normal; | |
font-display: swap; | |
} | |
@font-face { | |
font-family: 'Organetto'; | |
src: url('fonts/Organetto-Bold.eot'); | |
src: local('Organetto Bold'), local('Organetto-Bold'), | |
url('fonts/Organetto-Bold.eot?#iefix') format('embedded-opentype'), | |
url('fonts/Organetto-Bold.woff2') format('woff2'), | |
url('fonts/Organetto-Bold.woff') format('woff'), | |
url('fonts/Organetto-Bold.ttf') format('truetype'), | |
url('fonts/Organetto-Bold.svg#Organetto-Bold') format('svg'); | |
font-weight: bold; | |
font-style: normal; | |
font-display: swap; | |
} |
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
<?php | |
/** | |
* Elementor register custom font | |
* 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('options'); | |
// Then we append the custom font family in the list of the fonts we retrieved in the previous step | |
$new_fonts = array_merge([ | |
'Organetto' => 'system', | |
'Organetto Bold SemiExp' => '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( '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