Hi 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-L138