wordpress.org – How to make a block for header font styling at customizer via function.php?

Question

I am trying to make a section block to change font size at the customizer for the header, I can change font color with generate_css but not able to change size?
my code for changing color is bellow, I need help to make code for changing size.

Blockquote
class header_font_color {
public static function register ( $wp_customize ) {

    $wp_customize->add_setting('header_emakers_fontcolor', array(
        'default' => 'No'
    ));

    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'header_emakers_fontcolor-control', array(
        'label' => 'Display the Header Font Color?',
        'section' => 'colors',
        'settings' => 'header_emakers_fontcolor',
        'type' => 'select',
        'choices' => array('No'=> 'No', 'Yes' => 'Yes')
    )));



    $wp_customize->add_setting( 'header_emakers_fontcolor',
        array(
            'default'    => '#000000',
            'type'       => 'theme_mod',
            'capability' => 'edit_theme_options',
            'transport'  => 'refresh',
            'sanitize_callback'  => 'esc_attr',
        )
    );

    $wp_customize->add_control( new WP_Customize_Color_Control(
        $wp_customize,
        'mytheme_header_emakers_fontcolor',
        array(
            'label'      => __( 'Header Font Color', 'customtheme' ),
            'settings'   => 'header_emakers_fontcolor',
            'priority'   => 10,
            'section'    => 'colors',
        )
    ) );

}


public static function header_outputt() {
    ?>

    <style type="text/css">

        <?php self::generate_css('.header-main *',  'color', 'header_emakers_fontcolor'); ?>
    </style>

    <?php
}


public static function generate_css( $selector, $style, $mod_name, $prefix='', $postfix='', $echo=true ) {
    $return = '';
    $mod = get_theme_mod($mod_name);
    if ( ! empty( $mod ) ) {
        $return = sprintf('%s { %s:%s; }',
            $selector,
            $style,
            $prefix.$mod.$postfix
        );
        if ( $echo ) {
            echo $return;
        }
    }
    return $return;
}

}

add_action( ‘customize_register’ , array( ‘header_font_color’ , ‘register’ ) );

add_action( ‘wp_footer’ , array( ‘header_font_color’ , ‘header_outputt’ ) );

0
Babita Verma 5 months 2021-05-27T03:13:46-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse