add_setting('site_logo', array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr'
));
// Add a control to upload the logo
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'site_logo',
array(
'label' => 'Upload Site Logo',
'section' => 'title_tagline',
'settings' => 'site_logo',
) ) );
$wp_customize->add_setting( 'site_color', array(
'default' => '#29b28d',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'site_color', array(
'section' => 'colors',
'priority' => '10',
'label' => 'Site Primary Color'
) ) );
}
add_action('customize_register', 'logo_customizer_settings');
// Widget for google analytics code
function google_analytics_customizer($wp_customize){
$wp_customize->remove_control('header_textcolor');
$wp_customize->remove_control("background_color");
$wp_customize->add_section( 'google_analytics_section' , array(
'title' => 'Google analytics code',
'priority' => 110,
'description' => 'You can place your google analytics code here within the script tag',
) );
$wp_customize->add_setting( 'google_analytics_code', array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field'
) );
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'google_analytics_code',
array(
'label' => 'Google Analytics Code',
'section' => 'google_analytics_section',
'type' => 'textarea',
) ) );
}
add_action('customize_register', 'google_analytics_customizer');
// End widget for google analytics code
// Widget for color options
function theme_customize_register( $wp_customize ) {
// Body background color
$wp_customize->add_setting( 'body_bg_color', array(
'default' => '#ffffff',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'body_bg_color', array(
'section' => 'colors',
'label' => 'Body Background color'
) ) );
// Text color
$wp_customize->add_setting( 'text_color', array(
'default' => '#333333',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'text_color', array(
'section' => 'colors',
'label' => 'Text color'
) ) );
// Link color
$wp_customize->add_setting( 'link_color', array(
'default' => '#29b28d',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
'section' => 'colors',
'label' => 'Link color'
) ) );
// Accent color
$wp_customize->add_setting( 'accent_color', array(
'default' => '#00bf59',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'accent_color', array(
'section' => 'colors',
'label' => 'Accent color'
) ) );
}
add_action( 'customize_register', 'theme_customize_register' );
// End widget for color options
// Widget for header color section
function header_customizer_settings($wp_customize) {
$wp_customize->remove_section('header_image');
$wp_customize->add_section( 'header_section' , array(
'title' => 'Header',
'priority' => 50,
'description' => 'Update the colors for header',
) );
$wp_customize->add_setting( 'header_background', array(
'default' => '#ffffff',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_background',
array(
'label' => 'Header Background',
'section' => 'header_section',
) ) );
$wp_customize->add_setting( 'header_text_color', array(
'default' => '#333333',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_text_color',
array(
'label' => 'Header Text Color',
'section' => 'header_section',
) ) );
$wp_customize->add_setting( 'header_bg_img', array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr'
) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'header_bg_img',
array(
'label' => 'Header Background Image',
'section' => 'header_section',
) ) );
}
add_action('customize_register', 'header_customizer_settings');
// End widget for header color options
// Widget for footer color options
function footer_customizer_settings($wp_customize) {
$wp_customize->add_section( 'footer_section' , array(
'title' => 'Footer',
'priority' => 50,
'description' => 'Update the colors for header',
) );
$wp_customize->add_setting( 'footer_background', array(
'default' => '#2c2c2c',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'footer_background',
array(
'label' => 'Footer Background',
'section' => 'footer_section',
) ) );
$wp_customize->add_setting( 'footer_text_color', array(
'default' => '#777',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'footer_text_color',
array(
'label' => 'Footer Text Color',
'section' => 'footer_section',
) ) );
}
add_action('customize_register', 'footer_customizer_settings');
// End widget for footer color options
// Widget for button color options
function button_customizer($wp_customize){
$wp_customize->add_section( 'button_section' , array(
'title' => 'Button',
'priority' => 50,
'description' => 'Update the colors for buttons',
) );
$wp_customize->add_setting( 'primary_button_background_color', array(
'default' => '#29b28d',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_button_background_color', array(
'label' => 'Primary button background color',
'section' => 'button_section',
) ) );
$wp_customize->add_setting( 'primary_button_text_color', array(
'default' => '#ffffff',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_button_text_color',
array(
'label' => 'Primary button text color',
'section' => 'button_section',
) ) );
}
add_action('customize_register', 'button_customizer');
// End widget for button color options
// Widget for typography section.
function typography_customizer($wp_customize){
$n=100;
$font_size = [''];
for($i = 0; $i<=$n ; $i++){
array_push($font_size, $i);
}
$wp_customize->add_section( 'typography_section' , array(
'title' => 'Typography',
'priority' => 41,
'description' => 'Update the fonts size',
) );
$wp_customize->add_setting( 'body_font_size', array(
'default' => '15',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'body_font_size',
array(
'type' => 'select',
'label' => 'Body font size',
'section' => 'typography_section',
'choices' => $font_size
) ) );
$wp_customize->add_setting( 'header_font_size', array(
'default' => '15',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'header_font_size',
array(
'label' => 'Header font size',
'section' => 'typography_section',
'type' => 'select',
'choices' => $font_size
) ) );
$wp_customize->add_setting( 'footer_font_size', array(
'default' => '15',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'footer_font_size',
array(
'label' => 'Footer font size',
'section' => 'typography_section',
'type' => 'select',
'choices' => $font_size
) ) );
}
add_action('customize_register', 'typography_customizer');
// End widget for typography section
// Widget for google font section
function google_font_customizer($wp_customize){
$gfonts = array(
'' => '- Select a font -',
'Roboto:100,300,400,500,700,900' => '"Roboto", sans-serif',
'Noto+Sans:400,700' => '"Noto Sans", sans-serif',
'Open+Sans:300,400,600,700,800' => '"Open Sans", sans-serif',
'Lato:100,300,400,700,900' => '"Lato", sans-serif',
'Poppins:100,200,300,400,500,600,700,800,900' => '"Poppins", sans-serif',
'Montserrat:100,200,300,400,500,600,700,800,900' => '"Montserrat", sans-serif',
'Source+Sans+Pro:200,300,400,600,700,900' => '"Source Sans Pro", sans-serif',
'PT+Sans:400,700' => '"PT Sans", sans-serif',
'Roboto+Slab:100,400,700' => '"Roboto Slab", serif',
'Nunito:200,300,400,600,700,800,900' => '"Nunito", sans-serif',
'Oxygen:300,400,700' => '"Oxygen", sans-serif',
'Nunito+Sans:200,300,400,600,700,800,900' => '"Nunito Sans", sans-serif',
'Ropa+Sans' => '"Ropa Sans", sans-serif',
'Fira+Sans+Condensed:100,200,300,400,500,600,700,800,900' => '"Fira Sans Condensed", sans-serif',
);
$wp_customize->add_section( 'google_font_section' , array(
'title' => 'Google Fonts',
'priority' => 40,
) );
$wp_customize->add_setting( 'google_font', array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'google_font', array(
'label' => 'Google font',
'section' => 'google_font_section',
'type' => 'select',
'choices' => $gfonts
)));
$wp_customize->add_setting( 'google_heading_font', array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field',
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'google_heading_font', array(
'label' => 'Google Heading font',
'section' => 'google_font_section',
'type' => 'select',
'choices' => $gfonts
)));
}
add_action('customize_register', 'google_font_customizer');
// End widget for google font section
function theme_get_customizer_css() {
$gfonts = array(
'' => '- Select a font -',
'Roboto:100,300,400,500,700,900' => '"Roboto", sans-serif',
'Noto+Sans:400,700' => '"Noto Sans", sans-serif',
'Open+Sans:300,400,600,700,800' => '"Open Sans", sans-serif',
'Lato:100,300,400,700,900' => '"Lato", sans-serif',
'Poppins:100,200,300,400,500,600,700,800,900' => '"Poppins", sans-serif',
'Montserrat:100,200,300,400,500,600,700,800,900' => '"Montserrat", sans-serif',
'Source+Sans+Pro:200,300,400,600,700,900' => '"Source Sans Pro", sans-serif',
'PT+Sans:400,700' => '"PT Sans", sans-serif',
'Roboto+Slab:100,400,700' => '"Roboto Slab", serif',
'Nunito:200,300,400,600,700,800,900' => '"Nunito", sans-serif',
'Oxygen:300,400,700' => '"Oxygen", sans-serif',
'Nunito+Sans:200,300,400,600,700,800,900' => '"Nunito Sans", sans-serif',
'Ropa+Sans' => '"Ropa Sans", sans-serif',
'Fira+Sans+Condensed:100,200,300,400,500,600,700,800,900' => '"Fira Sans Condensed", sans-serif',
);
$google_analytics_code = get_theme_mod( 'google_analytics_code','');
if ( ! empty( $google_analytics_code ) ) {
echo $google_analytics_code;
}
$google_font = get_theme_mod( 'google_font','');
if ( ! empty( $google_font ) ) {
echo "";
}
$google_heading_font = get_theme_mod( 'google_heading_font','');
if ( ! empty( $google_heading_font ) ) {
echo "";
}
echo "";
}
add_action( 'wp_head', 'theme_get_customizer_css' ); ?>