• Resolved Clayton Chase

    (@claytonchase)


    Hey guys,

    The button block doesn’t seem to be inheriting the style I’ve set in GeneratePress. Any ideas on what might be happening?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Tom

    (@edge22)

    Hi there,

    It won’t do that by default.

    However, you can tell it to: https://generatepress.com/forums/topic/add-custom-css-selector-to-the-button-selector/#post-1322768

    Hope this helps! 🙂

    Thread Starter Clayton Chase

    (@claytonchase)

    Ah I see. So I’ve added the filter and it is working for the color but I’m wondering if it’s possible to inherit the font of the button settings in GeneratePress as well.

    Thread Starter Clayton Chase

    (@claytonchase)

    Figured out a simple enough solution for now. Just add the button class to the button block.

    Plugin Author Tom

    (@edge22)

    Yea, that’s a simple way to do it, although it does involve manually adding the class.

    We can extend the filter I provided to include typography options as well if you’d like 🙂

    Thread Starter Clayton Chase

    (@claytonchase)

    That would be great as well! Thanks Tom

    Plugin Author Tom

    (@edge22)

    Let’s give this a shot:

    add_filter( 'generateblocks_defaults', function( $defaults ) {
        $color_settings = wp_parse_args(
            get_option( 'generate_settings', array() ),
            generate_get_color_defaults()
        );
    
        $typography_settings = wp_parse_args(
            get_option( 'generate_settings', array() ),
            generate_get_default_fonts()
        );
    
        $defaults['button']['backgroundColor'] = $color_settings['form_button_background_color'];
        $defaults['button']['backgroundColorHover'] = $color_settings['form_button_background_color_hover'];
        $defaults['button']['textColor'] = $color_settings['form_button_text_color'];
        $defaults['button']['textColorHover'] = $color_settings['form_button_text_color_hover'];
        $defaults['button']['paddingTop'] = '10';
        $defaults['button']['paddingRight'] = '20';
        $defaults['button']['paddingBottom'] = '10';
        $defaults['button']['paddingLeft'] = '20';
    
        $defaults['button']['fontSize'] = $typography_settings['buttons_font_size'];
        $defaults['button']['fontWeight'] = $typography_settings['buttons_font_weight'];
        $defaults['button']['textTransform'] = $typography_settings['buttons_font_transform'];
    
        return $defaults;
    } );
    Thread Starter Clayton Chase

    (@claytonchase)

    Works like a charm. Thank you Tom! Really enjoying GB!

    Plugin Author Tom

    (@edge22)

    Awesome – thank you! 🙂

    Thread Starter Clayton Chase

    (@claytonchase)

    @edge22 it seems like the only things that isn’t being inherited is the font-family. I tried this but it doesn’t seem to be working.

    add_filter( 'generateblocks_defaults', function( $defaults ) {
        $color_settings = wp_parse_args(
            get_option( 'generate_settings', array() ),
            generate_get_color_defaults()
        );
    
        $typography_settings = wp_parse_args(
            get_option( 'generate_settings', array() ),
            generate_get_default_fonts()
        );
    
        $defaults['button']['backgroundColor'] = $color_settings['form_button_background_color'];
        $defaults['button']['backgroundColorHover'] = $color_settings['form_button_background_color_hover'];
        $defaults['button']['textColor'] = $color_settings['form_button_text_color'];
        $defaults['button']['textColorHover'] = $color_settings['form_button_text_color_hover'];
        $defaults['button']['paddingTop'] = '10';
        $defaults['button']['paddingRight'] = '20';
        $defaults['button']['paddingBottom'] = '10';
        $defaults['button']['paddingLeft'] = '20';
    
        $defaults['button']['fontFamily'] = $typography_settings['buttons_font_family'];
    	$defaults['button']['fontSize'] = $typography_settings['buttons_font_size'];
        $defaults['button']['fontWeight'] = $typography_settings['buttons_font_weight'];
        $defaults['button']['textTransform'] = $typography_settings['buttons_font_transform'];
    
        return $defaults;
    } );

    I added the $defaults['button']['fontFamily'] = $typography_settings['buttons_font_family']; line.

    Any thoughts?

    Plugin Author Tom

    (@edge22)

    Try this:

    $defaults['button']['fontFamily'] = $typography_settings['font_buttons'];

    Let me know 🙂

    Thread Starter Clayton Chase

    (@claytonchase)

    Perfect! Thanks Tom

    Plugin Author Tom

    (@edge22)

    No problem! 🙂

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Button Block Not Inheriting GeneratePress Button Style’ is closed to new replies.