[Support request] Button Block Not Inheriting GeneratePress Button (Customiser) Style

Home Forums Support [Support request] Button Block Not Inheriting GeneratePress Button (Customiser) Style

Home Forums Support Button Block Not Inheriting GeneratePress Button (Customiser) Style

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2206409
    Raymond

    This is essentially a repost of this: https://wordpress.org/support/topic/button-block-not-inheriting-generatepress-button-style/

    I’ve done everything Tom recommends in his responses (added the filter to functions.php) but nothing has changed.

    The same applies to the font set for buttons in the customiser. Instead, the block is using the font set in body. Imo, if [some] customiser options are not working isn’t it better to exclude them altogether, since they add extra and not-useful code to websites?

    Is there an effective workaround?

    #2206724
    Ying
    Staff
    Customer Support

    Hi Raymond,

    I’ve done everything Tom recommends in his responses (added the filter to functions.php) but nothing has changed.

    Based on your reply in you original topic, it seemed working perfectly before, so it doesn’t work now?

    Imo, if [some] customiser options are not working isn’t it better to exclude them altogether, since they add extra and not-useful code to websites?

    Not sure what you mean.

    Can you share the exact code you are using and link us to your site where we can see the button?

    #2206806
    Raymond

    Based on your reply in you original topic, it seemed working perfectly before…

    I never actually said that it was working, otherwise I would not have started a new support topic. I also never commented on the original post; I only linked it to show that I’ve already searched for a solution and what I found doesn’t work.

    Not sure what you mean.

    I could be wrong, but I meant that all customiser style options are loaded on all pages. If some of them do not work, isn’t that extra code?

    Can you share the exact code you are using and link us to your site where we can see the button?
    It is a locally-hosted website on my PC. Here is the code:

    //---------------Force buttons to use customiser settings---------------------------
    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'] = '15';
        $defaults['button']['paddingRight'] = '35';
        $defaults['button']['paddingBottom'] = '15';
        $defaults['button']['paddingLeft'] = '35';
    
        $defaults['button']['fontSize'] = $typography_settings['buttons_font_size'];
        $defaults['button']['fontWeight'] = $typography_settings['buttons_font_weight'];
        $defaults['button']['textTransform'] = $typography_settings['buttons_font_transform'];
    	$defaults['button']['fontFamily'] = $typography_settings['font_buttons'];
    
        return $defaults;
    } );
    #2207126
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Our Typography system now allows you to add a custom selector, so you can target GenerateBlocks buttons without any code.

    For example, go to Customize > Typography and add a new Typography item in the Typography Manager. Open the Target Element dropdown and choose “Custom” at the very bottom.

    Now in the custom CSS selector field, you can add this: .gb-button

    Now configure the default typography settings for your GenerateBlocks buttons.

    For the colors and padding, you can now use this snippet:

    add_filter( 'generateblocks_defaults', function( $defaults ) {
        $color_settings = wp_parse_args(
            get_option( 'generate_settings', array() ),
            generate_get_color_defaults()
        );
    
        $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'] = '15';
        $defaults['button']['paddingRight'] = '35';
        $defaults['button']['paddingBottom'] = '15';
        $defaults['button']['paddingLeft'] = '35';
    
        return $defaults;
    } );

    Let me know if that helps or not 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.