- This topic has 5 replies, 4 voices, and was last updated 2 years, 2 months ago by Fernando.
-
AuthorPosts
-
October 28, 2020 at 11:43 am #1508367shane
I made some additional changes to layouts using the hooks from elements. I want to be able to just change the colour via the customiser instead of having to go back into elements and use it. The colour would be the same colour for example as the main navigation. Where are those values created / stored? Or does anyone know the php code to reference / pull that colour so I can simply set a value via <style> in elements which would change its colour everytime I changed the navigation colour?
October 28, 2020 at 4:37 pm #1508634DavidStaffCustomer SupportHi there,
you can use the generate_settings function like so:
// Generate Custom CSS from existing Customizer settings function db_custom_css_output() { if ( ! function_exists( 'generate_get_defaults' ) ) { return; } $generate_settings = wp_parse_args( get_option( 'generate_settings', array() ), generate_get_defaults() ); if ( ! class_exists( 'GeneratePress_CSS' ) ) { return; } if ( ! function_exists( 'generate_get_font_family_css' ) ) { return; } $css = new GeneratePress_CSS; // Get custom CSS properties from database // Change Selctor to CSS Class instead of element tag // Settings from CSS-output.php $css->set_selector( '.hero-background' ); $css->add_property( 'background-color', esc_attr( $generate_settings['navigation_background_color'] ) ); return apply_filters( 'db_custom_css_output', $css->css_output() ); } // Enqueue custom styles within generate-style-inline-css add_action( 'wp_enqueue_scripts', function() { wp_add_inline_style( 'generate-style', db_custom_css_output() ); }, 100 );
For reference:
https://github.com/tomusborne/generatepress/blob/cd3de8b045136141358cbf273a6efbd9fad3732a/inc/css-output.php#L137-L138January 26, 2022 at 6:02 pm #2095153onaltiHi. I need something like this too, but I’m not getting the Navigation Text color value. What should I use instead of $generate_settings[‘background_color’]?.
I tried [navigation_text_color ] but it chooses wrong.
Element Type > Header > Site Header >Navigation Colors > Navigation Text
elements/class-hero.php
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li > a, .header-wrap #mobile-header:not(.toggled):not(.navigation-stick) .main-nav > ul > li > a, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:focus' ); } $css->add_property( 'color', esc_attr( $options['navigation_text_color'] ) );
January 27, 2022 at 8:43 pm #2096658Fernando Customer SupportHi Onalti,
I’m sorry but I’m not quite sure I understand what you’re trying to do? To clarify, are you trying to set the Navigation Text color of the Header Element to the one set from the Customizer?
This may be unnecessary since if you don’t set a color in the Site Header options, by default, the Navigation Text in which this Header element is applied to automatically gets the color from the Customizer. 🙂
If you’ve already set a color, you’ll simply need to clear it and the color will default back to the one set in the Customizer.
See this for reference: https://share.getcloudapp.com/12u0gjw7
Please let us know if we misunderstood something. Thank you! 🙂
January 28, 2022 at 6:34 am #2097034onaltiHi there,
Yes, you misunderstood the point. David and Tom understood my question.January 30, 2022 at 9:23 pm #2099577Fernando Customer SupportSorry, I misunderstood. I’m glad that Tom and David are there to help! Let us know if you’ll need help with anything else. Hope you have a nice day! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.