Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #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?

    #616285

    Hey!

    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!
    Josue

    #616302

    Modifying 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.

    #616317

    Again, 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,
    Josue

    #616530

    Then 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.

    #616545

    Can the function be used to load multiple fonts and if so, how should it be written?

    #616605

    Why not if it initiates require_once() call?

    #618085

    Hi!


    @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,
    Ismael

    #618490

    The 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.

    #618974

    Hey!

    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,
    Josue

    #619014

    I know that. But I want all fonts without Cyrillic support to be hidden.

    #619046

    Well 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,
    Josue

    #619077

    Thanks, Josue.
    My poor Efold child’s functions.php…

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘How to replace predefined Google fonts template from Enfold with Enfold-Child?’ is closed to new replies.