-
AuthorPosts
-
April 17, 2016 at 12:37 am #615613
I’m going to use my own list of Google fonts in Enfold-Child > General Styling > Fonts, for that I’ve created the following folder and file structure in my Enfold-Child theme, mirroring the original Enfold structure:
enfold-child/ enfold-child/includes/ enfold-child/includes/admin/ enfold-child/includes/admin/register-backend-google-fonts.php
and have added the following line into functions.php of Enfold-Child:
require_once( get_stylesheet_directory() . '/includes/admin/register-backend-google-fonts.php' );
It had no effect and Enfold-Child still uses original register-backend-google-fonts.php file from Enfold theme folder.
What have I skipped?
What should I correct to force Enfold-Child to use my own register-backend-google-fonts.php instead of original one without altering any file of the original Enfold theme?April 18, 2016 at 11:32 am #616285Hey!
Try adding this at the very end of your theme / child theme functions.php file:
add_filter( 'avf_google_heading_font', 'avia_add_custom_font'); add_filter( 'avf_google_content_font', 'avia_add_custom_font'); function avia_add_custom_font($fonts) { $fonts['Custom Google Font Name Here'] = 'Custom Google Font Name Here'; return $fonts; }
Cheers!
JosueApril 18, 2016 at 11:43 am #616302Modifying child theme this way will finally make its functions.php extremely huge and hard to deal with. I’m looking for a way that allows just load child’s register-backend-google-fonts.php for child theme.
April 18, 2016 at 12:00 pm #616317Again, it’s not possible -via child theme- to remove/modify an
include
declaration, to circumvent that limitation there are filters and actions that can be hooked via child theme functions.php (or any .php file included from it).Regards,
JosueApril 18, 2016 at 2:46 pm #616530Then why not to just wrap the aforesaid
include
declaration into a filter or an action initially! ) So that it could be overridden through a child theme.April 18, 2016 at 3:02 pm #616545Can the function be used to load multiple fonts and if so, how should it be written?
April 18, 2016 at 4:02 pm #616605Why not if it initiates
require_once()
call?April 20, 2016 at 9:14 am #618085Hi!
@kacharava: What are the advantages that you’re expecting to get from this? Why not use the existing filter? If you can convince Kriesi about its advantages, maybe we’ll included it in the next update. You can request the feature here: https://kriesi.at/support/enfold-feature-requests/@rwwwood: Something like this will work:
add_filter( 'avf_google_heading_font', 'avia_add_custom_font'); add_filter( 'avf_google_content_font', 'avia_add_custom_font'); function avia_add_custom_font($fonts) { $fonts['Custom Google Font Name Here'] = 'Custom Google Font Name Here'; $fonts['Another Custom Google Font Name Here'] = 'Another Custom Google Font Name Here'; return $fonts; }
Best regards,
IsmaelApril 20, 2016 at 5:03 pm #618490The only advantage is not altering original files while modifying the theme the way it is expected to be modified. The method offered here doesn’t allow to get rid of the fonts that will never be used. The easiest method is to force Enfold to use child’s list but this method is supressed for some reason.
April 21, 2016 at 7:47 am #618974Hey!
FYI a font being listed doesn’t mean it will be loaded, the theme only loads it if you have it selected it in General Styling > Fonts or in Advanced Styling.
Regards,
JosueApril 21, 2016 at 9:50 am #619014I know that. But I want all fonts without Cyrillic support to be hidden.
April 21, 2016 at 11:21 am #619046Well in that case you can override the whole array with a code like this:
add_filter( 'avf_google_heading_font', 'avia_add_custom_font'); add_filter( 'avf_google_content_font', 'avia_add_custom_font'); function avia_add_custom_font($fonts) { $new_fonts = array(); $new_fonts['Custom Google Font Name Here'] = 'Custom Google Font Name Here'; $new_fonts['Another Custom Google Font Name Here'] = 'Another Custom Google Font Name Here'; return $new_fonts; }
Regards,
JosueApril 21, 2016 at 11:59 am #619077Thanks, Josue.
My poor Efold child’s functions.php… -
AuthorPosts
- The topic ‘How to replace predefined Google fonts template from Enfold with Enfold-Child?’ is closed to new replies.