-
Hi there,
The background color is in a separate filter: https://github.com/tomusborne/generatepress/blob/3.4.0/inc/defaults.php#L55
The search modal defaults can be found here: https://github.com/tomusborne/generatepress/blob/3.4.0/inc/defaults.php#L192-L194
When CSS is changed in the Customizer, we use JS to insert the changed CSS right above the closing
</head>
tag. It’s not possible to put anything under this temporary CSS.Let me know if you need more info 🙂
-
pixelattack
Hello!
I would have bet that I had tried those modal defaults… They work great.
Regarding the body properties, I will simply set the colors through the customizer and leave the defaults as they are.
Out of the box, the theme assigns a global color to the body and most other core elements. If you maintain those global color names in your palette, then you don’t need to set the defaults, just the global color values.
The issue with that is that the –contrast variable is assigned both to the text of the body and the hovered link.
Anyway, it would be a great addition if you could set defaults for the body properties, just like all the other elements.
Thank you all for your time.
-
You can set the body defaults like this:
add_filter( 'generate_option_defaults', function( $defaults ) { $defaults['background_color'] = 'var(--base-2)'; $defaults['text_color'] = 'var(--contrast)'; $defaults['link_color'] = 'var(--accent)'; $defaults['link_color_hover'] = 'var(--contrast)'; return $defaults; } );
Hope this helps!
-
pixelattack
Hello Tom,
this is what I was describing in a previous post. Even though I have managed to set the defaults for all the other elements (top bar, header, primary navigation etc.) the defaults for the body cannot be set.
function testtheme_set_default_colors( $settings ) { $settings['global_colors'] = [ [ 'name' => __( 'Neutral White', 'generatepress' ), 'slug' => 'neutral-white', 'color' => '#ffffff', ], [ 'name' => __( 'Neutral Light', 'generatepress' ), 'slug' => 'neutral-light', 'color' => '#faf0f4', ], [ 'name' => sprintf( __( 'Neutral Grey %s', 'generatepress' ), '010' ), 'slug' => 'neutral-grey-010', 'color' => '#ebeff5', ], [ 'name' => sprintf( __( 'Neutral Grey %s', 'generatepress' ), '020' ), 'slug' => 'neutral-grey-020', 'color' => '#58606e', ], [ 'name' => __( 'Neutral Dark', 'generatepress' ), 'slug' => 'neutral-dark', 'color' => '#15233b', ], [ 'name' => __( 'Primary', 'generatepress' ), 'slug' => 'primary', 'color' => '#114599', ], [ 'name' => sprintf( __( 'Secondary %s', 'generatepress' ), '010' ), 'slug' => 'secondary-010', 'color' => '#ed5393', ], ]; return $settings; } add_filter( 'generate_option_defaults', 'testtheme_set_default_colors' ); function testtheme_set_default_colors_in_customizer( $defaults ) { // Body - THESE DO NOT WORK $defaults['background_color'] = 'var(--neutral-white)'; $defaults['text_color'] = 'var(--neutral-grey-020)'; $defaults['link_color'] = 'var(--secondary-010)'; $defaults['link_color_hover'] = 'var(--secondary-020)'; // Top Bar $defaults['top_bar_background_color'] = 'var(--neutral-grey-010)'; $defaults['top_bar_text_color'] = ''; $defaults['top_bar_link_color'] = ''; $defaults['top_bar_link_color_hover'] = ''; // Header $defaults['header_background_color'] = 'var(--neutral-white)'; $defaults['header_text_color'] = ''; $defaults['header_link_color'] = ''; $defaults['header_link_hover_color'] = ''; $defaults['site_title_color'] = 'var(--primary)'; $defaults['site_tagline_color'] = 'var(--primary)'; // Primary Navigation $defaults['navigation_background_color'] = 'var(--neutral-light)'; $defaults['navigation_background_hover_color'] = ''; $defaults['navigation_background_current_color'] = ''; $defaults['navigation_text_color'] = 'var(--primary)'; $defaults['navigation_text_hover_color'] = 'var(--neutral-dark)'; $defaults['navigation_text_current_color'] = 'var(--neutral-dark)'; $defaults['subnavigation_background_color'] = 'var(--neutral-grey-010)'; $defaults['subnavigation_background_hover_color'] = ''; $defaults['subnavigation_background_current_color'] = ''; $defaults['subnavigation_text_color'] = ''; $defaults['subnavigation_text_hover_color'] = ''; $defaults['subnavigation_text_current_color'] = ''; // Buttons $defaults['form_button_background_color'] = 'var(--secondary-010)'; $defaults['form_button_background_color_hover'] = 'var(--secondary-020)'; $defaults['form_button_text_color'] = 'var(--neutral-white)'; $defaults['form_button_text_color_hover'] = ''; // Content $defaults['content_background_color'] = 'var(--neutral-white)'; $defaults['content_text_color'] = ''; $defaults['content_link_color'] = ''; $defaults['content_link_hover_color'] = ''; $defaults['content_title_color'] = ''; $defaults['blog_post_title_color'] = ''; $defaults['blog_post_title_hover_color'] = ''; $defaults['entry_meta_text_color'] = ''; $defaults['entry_meta_link_color'] = ''; $defaults['entry_meta_link_color_hover'] = ''; $defaults['h1_color'] = 'var(--primary)'; $defaults['h2_color'] = 'var(--primary)'; $defaults['h3_color'] = 'var(--primary)'; $defaults['h4_color'] = 'var(--primary)'; $defaults['h5_color'] = 'var(--primary)'; $defaults['h6_color'] = 'var(--primary)'; // Forms $defaults['form_background_color'] = 'var(--neutral-white)'; $defaults['form_background_color_focus'] = ''; $defaults['form_text_color'] = 'var(--neutral-grey-020)'; $defaults['form_text_color_focus'] = ''; $defaults['form_border_color'] = 'var(--neutral-grey-020)'; $defaults['form_border_color_focus'] = ''; // Sidebar Widgets $defaults['sidebar_widget_background_color'] = 'var(--neutral-light)'; $defaults['sidebar_widget_text_color'] = ''; $defaults['sidebar_widget_link_color'] = ''; $defaults['sidebar_widget_link_hover_color'] = ''; $defaults['sidebar_widget_title_color'] = ''; // Footer Widgets $defaults['footer_widget_background_color'] = ''; $defaults['footer_widget_text_color'] = ''; $defaults['footer_widget_link_color'] = ''; $defaults['footer_widget_link_hover_color'] = ''; $defaults['footer_widget_title_color'] = ''; // Footer Bar $defaults['footer_background_color'] = 'var(--neutral-dark)'; $defaults['footer_text_color'] = 'var(--neutral-white)'; $defaults['footer_link_color'] = ''; $defaults['footer_link_hover_color'] = ''; // Back to Top $defaults['back_to_top_background_color'] = 'var(--secondary-010)'; $defaults['back_to_top_background_color_hover'] = 'var(--secondary-020)'; $defaults['back_to_top_text_color'] = 'var(--neutral-white)'; $defaults['back_to_top_text_color_hover'] = ''; // Search $defaults['search_modal_bg_color'] = 'var(--neutral-white)'; $defaults['search_modal_text_color'] = ''; $defaults['search_modal_overlay_bg_color'] = 'rgba(0,0,0,0.2)'; return $defaults; } add_filter( 'generate_color_option_defaults', 'testtheme_set_default_colors_in_customizer');
Is there something I am missing?
-
$defaults['background_color'] = 'var(--neutral-white)'; $defaults['text_color'] = 'var(--neutral-grey-020)'; $defaults['link_color'] = 'var(--secondary-010)'; $defaults['link_color_hover'] = 'var(--secondary-020)';
These need to go in your first function, not the second one. They exist in the
generate_option_defaults
filter.Let me know if that helps or not 🙂
-
pixelattack
Wow, you’re totally right! I swear, I must’ve stared at that code a thousand times and still missed it. Thanks a lot for the support. Works great!
-
Glad I could help! 🙂
- You must be logged in to reply to this topic.