[Resolved] Theme Defaults Override in Child Theme for Colour Vars

Home Forums Support [Resolved] Theme Defaults Override in Child Theme for Colour Vars

Home Forums Support Theme Defaults Override in Child Theme for Colour Vars

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #2246612
    Tom
    Lead Developer
    Lead Developer

    This is an old legacy issue in the theme before we had tons of color options and separated them.

    Those specific defaults are handled in the generate_option_defaults filter: https://github.com/tomusborne/generatepress/blob/3.1.3/inc/defaults.php#L54-L58

    So it would be this:

    add_filter( 'generate_option_defaults', function( $defaults ) {
        $defaults['background_color'] = 'var(--base)';
        $defaults['text_color'] = 'var(--grey-1)';
        $defaults['link_color'] = 'var(--grey-1)';
        $defaults['link_color_hover'] = 'grey-3';
        $defaults['link_color_visited'] = 'var(--grey-1)';
    
        return $defaults;
    } );

    The rest of the color defaults are handled in the generate_color_option_defaults filter: https://github.com/tomusborne/generatepress/blob/3.1.3/inc/defaults.php#L121

    Let me know if that helps or not ๐Ÿ™‚

    #2246887
    David

    Thanks Tom, this leads on to how I then set defaults for all the other colour options in generate_color_option_defaults. Could you also provide an example for this? And if they have been previously set, do I also have to apply the filter to option_generate_settings as I do fr the colour overrides above? Thanks!

    #2247821
    Tom
    Lead Developer
    Lead Developer

    You do it the exact same way, just with their own respective names: https://github.com/tomusborne/generatepress/blob/3.1.3/inc/defaults.php#L121

    add_filter( 'generate_color_option_defaults', function( $defaults ) {
        $defaults['top_bar_background_color'] = '#fff';
    
        return $defaults;
    } );

    Yes, these filters are only for defaults when no saved value exists. If you need to overwrite the saved value, you use the option_generate_settings filter.

    Hope this helps!

    #2248497
    David

    Thanks Tom, very much appreciated.

    #2248759
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

Viewing 5 posts - 16 through 20 (of 20 total)
  • You must be logged in to reply to this topic.