get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->remove_control( 'header_textcolor' );
//$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
if ( isset( $wp_customize->selective_refresh ) ) {
// Site title and description
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => 'brazilcolors_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'brazilcolors_customize_partial_blogdescription',
) );
// Slide 01
$wp_customize->selective_refresh->add_partial( 'mcn_title_slider_1', array(
'selector' => '#mcn_title_slider_edit_1',
'render_callback' => 'brazilcolors_customize_partial_mcn_title_slider_1',
) );
$wp_customize->selective_refresh->add_partial( 'mcn_desc_slider_1', array(
'selector' => '#mcn_desc_slider_edit_1',
'render_callback' => 'brazilcolors_customize_partial_mcn_desc_slider_1',
) );
$wp_customize->selective_refresh->add_partial( 'mcn_btn_text_slider_1', array(
'selector' => '#mcn_btn_text_slider_edit_1',
'render_callback' => 'brazilcolors_customize_partial_mcn_btn_text_slider_1',
) );
// Slide 02
$wp_customize->selective_refresh->add_partial( 'mcn_title_slider_2', array(
'selector' => '#mcn_title_slider_edit_2',
'render_callback' => 'brazilcolors_customize_partial_mcn_title_slider_2',
) );
$wp_customize->selective_refresh->add_partial( 'mcn_desc_slider_2', array(
'selector' => '#mcn_desc_slider_edit_2',
'render_callback' => 'brazilcolors_customize_partial_mcn_desc_slider_2',
) );
$wp_customize->selective_refresh->add_partial( 'mcn_btn_text_slider_2', array(
'selector' => '#mcn_btn_text_slider_edit_2',
'render_callback' => 'brazilcolors_customize_partial_mcn_btn_text_slider_2',
) );
// Slide 03
$wp_customize->selective_refresh->add_partial( 'mcn_title_slider_3', array(
'selector' => '#mcn_title_slider_edit_3',
'render_callback' => 'brazilcolors_customize_partial_mcn_title_slider_3',
) );
$wp_customize->selective_refresh->add_partial( 'mcn_desc_slider_3', array(
'selector' => '#mcn_desc_slider_edit_3',
'render_callback' => 'brazilcolors_customize_partial_mcn_desc_slider_3',
) );
$wp_customize->selective_refresh->add_partial( 'mcn_btn_text_slider_3', array(
'selector' => '#mcn_btn_text_slider_edit_3',
'render_callback' => 'brazilcolors_customize_partial_mcn_btn_text_slider_3',
) );
// Floater Shortcuts mcn_floatshortcuts_onoff
$wp_customize->selective_refresh->add_partial( 'mcn_floatshortcuts_onoff', array(
'selector' => '#mcn_floater_shortcut',
'render_callback' => 'brazilcolors_customize_partial_mcn_floatshortcuts_onoff',
) );
}
}
add_action( 'customize_register', 'brazilcolors_customize_register' );
/**
* Render the site title for the selective refresh partial.
*
* @return void
*/
function brazilcolors_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @return void
*/
function brazilcolors_customize_partial_blogdescription() {
bloginfo( 'description' );
}
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function brazilcolors_customize_preview_js() {
wp_enqueue_script( 'brazilcolors-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'brazilcolors_customize_preview_js' );
/**
* Customizer
*/
function brazilcolors_register_theme_customizer( $wp_customize ) {
// Defaults colors values
$colors_args = array(
'color_0' => '#ffffff', // Site title color, site description color, menu bar links color, footer text color
'color_1' => '#efab19', // Primary color
'color_2' => '#44444c', // Primary hover color
'color_3' => '#53535c' // Menu bar and footer background color
);
// Logo size
$wp_customize->add_setting(
'mcn_logo_size',
array(
'default' => 100,
'transport' => 'postMessage',
'sanitize_callback' => 'brazilcolors_sanitize_number'
)
);
$wp_customize->add_control( 'mcn_logo_size', array(
'type' => 'range',
'section' => 'title_tagline',
'label' => __( 'Logo size', 'brazil-colors' ),
'description' => __( 'Change logo size', 'brazil-colors' ),
'input_attrs' => array(
'min' => 20,
'max' => 100,
'step' => 1,
),
) );
// Header text color
$wp_customize->add_setting(
'mcn_headertext_color',
array(
'default' => $colors_args['color_0'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'headertext_color',
array(
'label' => __( 'Header text color', 'brazil-colors' ),
'section' => 'colors',
'settings' => 'mcn_headertext_color'
)
)
);
// Primary color
$wp_customize->add_setting(
'mcn_primary_color',
array(
'default' => $colors_args['color_1'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'primary_color',
array(
'label' => __( 'Primary Color', 'brazil-colors' ),
'section' => 'colors',
'settings' => 'mcn_primary_color'
)
)
);
// Primary color hover
$wp_customize->add_setting(
'mcn_primary_color_hover',
array(
'default' => $colors_args['color_2'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'primary_color_hover',
array(
'label' => __( 'Primary Color Hover', 'brazil-colors' ),
'section' => 'colors',
'settings' => 'mcn_primary_color_hover'
)
)
);
// Menu bar background color
$wp_customize->add_setting(
'mcn_menu_bar_bg_color',
array(
'default' => $colors_args['color_3'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'menu_bar_background_color',
array(
'label' => __( 'Menu Bar Background Color', 'brazil-colors' ),
'section' => 'colors',
'settings' => 'mcn_menu_bar_bg_color'
)
)
);
// Menu bar links color
$wp_customize->add_setting(
'mcn_menu_link_color',
array(
'default' => $colors_args['color_0'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'menu_bar_link_color',
array(
'label' => __( 'Menu Bar Link Color', 'brazil-colors' ),
'section' => 'colors',
'settings' => 'mcn_menu_link_color'
)
)
);
// Header Image
$wp_customize->add_setting(
'mcn_header_image_location',
array(
'default' => 'header-image-all',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_radio'
)
);
$wp_customize->add_control(
'mcn_header_image_location',
array(
'label' => __( 'Display options', 'brazil-colors' ),
'section' => 'header_image',
'settings' => 'mcn_header_image_location',
'type' => 'radio',
'choices' => array(
'header-image-all' => __( 'Show in all templates', 'brazil-colors' ),
'header-image-frontpage' => __( 'Show only in frontpage', 'brazil-colors' ),
'header-image-pages' => __( 'Show only in archives and singular pages', 'brazil-colors' ),
),
)
);
// Header Slider
$wp_customize->add_section(
'mcn_options_slider',
array(
'title' => __( 'Slider', 'brazil-colors' ),
'priority' => 100
)
);
// Active or Desactive the slider
$wp_customize->add_setting(
'mcn_slider_onoff',
array(
'default' => 'on',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_checkbox'
)
);
$wp_customize->add_control(
'mcn_slider_onoff',
array(
'label' => __( 'Enable slider', 'brazil-colors' ),
'section' => 'mcn_options_slider',
'settings' => 'mcn_slider_onoff',
'type' => 'checkbox'
)
);
// Auto slider
$wp_customize->add_setting(
'mcn_slider_auto',
array(
'default' => '0',
'transport' => 'refresh',
'sanitize_callback' => 'absint'
)
);
$wp_customize->add_control(
'mcn_slider_auto',
array(
'label' => __( 'Auto slider', 'brazil-colors' ),
'description' => __( 'Milliseconds before progressing to next slide automatically. Use 0 value to disable.', 'brazil-colors' ),
'section' => 'mcn_options_slider',
'settings' => 'mcn_slider_auto',
'type' => 'number'
)
);
// Slides
$default_image_1 = get_template_directory_uri() . '/images/oliver-kiss-379394.jpg';
$default_image_2 = get_template_directory_uri() . '/images/luca-bravo-207676.jpg';
$default_image_3 = get_template_directory_uri() . '/images/rawpixel-com-255076.jpg';
$slides_array = array(
array(
'name' => __('First','brazil-colors'),
'title' => 'Welcome to the Brazil Colors',
'desc' => 'Feel free to customize your website',
'image' => $default_image_1
),
array(
'name' => __('Seccond','brazil-colors'),
'title' => 'Your website, your creativity',
'desc' => 'Brazil Colors was made for you to use your creativity',
'image' => $default_image_2
),
array(
'name' => __('Third','brazil-colors'),
'title' => 'We hope you enjoy',
'desc' => 'We want you to have a great experience',
'image' => $default_image_3
),
);
$num = 1;
foreach( $slides_array as $slide ):
$wp_customize->add_setting(
'mcn_image_slider_'.$num,
array(
'default' => $slide['image'],
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_setting(
'mcn_title_slider_'.$num,
array(
'default' => $slide['title'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_setting(
'mcn_desc_slider_'.$num,
array(
'default' => $slide['desc'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_setting(
'mcn_btn_text_slider_'.$num,
array(
'default' => __( 'See more', 'brazil-colors' ),
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_setting(
'mcn_btn_uri_slider_'.$num,
array(
'default' => '#',
'transport' => 'postMessage',
'sanitize_callback' => 'esc_url_raw'
)
);
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'mcn_slide_image_'.$num, array(
'label' => $slide['name'] . __( ' Slide Image', 'brazil-colors' ),
'section' => 'mcn_options_slider',
'settings' => 'mcn_image_slider_'.$num,
'type' => 'image',
) ) );
$wp_customize->add_control(
'mcn_title_slider_'.$num,
array(
'label' => $slide['name'] . __( ' Slider Title', 'brazil-colors' ),
'section' => 'mcn_options_slider',
'type' => 'text',
)
);
$wp_customize->add_control(
'mcn_desc_slider_'.$num,
array(
'label' => $slide['name'] . __( ' Slider Description', 'brazil-colors' ),
'section' => 'mcn_options_slider',
'type' => 'text',
)
);
$wp_customize->add_control(
'mcn_btn_text_slider_'.$num,
array(
'label' => $slide['name'] . __( ' Slider Buttom Text', 'brazil-colors' ),
'section' => 'mcn_options_slider',
'type' => 'text',
)
);
$wp_customize->add_control(
'mcn_btn_uri_slider_'.$num,
array(
'label' => $slide['name'] . __( ' Slider Buttom Link', 'brazil-colors' ),
'section' => 'mcn_options_slider',
'type' => 'text',
)
);
$num++;
endforeach;
// Typography
// ## Add a Google Font control
require_once dirname(__FILE__) . '/customizer/select/google-font-dropdown-custom-control.php';
$wp_customize->add_panel( 'mcn_panel_typography', array(
'priority' => 10,
'theme_supports' => '',
'title' => __( 'Typography', 'brazil-colors' ),
'description' => ''
) );
// ## Website Title Font Family
$wp_customize->add_section(
'mcn_options_typography_1',
array(
'title' => __( 'Website Title', 'brazil-colors' ),
'priority' => 51,
'panel' => 'mcn_panel_typography'
)
);
$wp_customize->add_setting(
'mcn_sitetitle_typography',
array(
'default' => 'Montserrat',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control( new Google_Font_Dropdown_Custom_Control( $wp_customize, 'mcn_sitetitle_typography', array(
'label' => __( 'Website title typography', 'brazil-colors' ),
'description' => __( 'You can select any font family available in fonts.google.com Google Fonts', 'brazil-colors' ),
'section' => 'mcn_options_typography_1',
'settings' => 'mcn_sitetitle_typography',
'priority' => 12
) ) );
$wp_customize->add_setting(
'mcn_sitetitle_weight',
array(
'default' => '700',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_select'
)
);
$wp_customize->add_control( 'mcn_sitetitle_weight', array(
'type' => 'select',
'description' => __( 'The font family you choose may not have the Light and Bold styles, when this occurs the font family is not loaded, and you should then select the Regular style.', 'brazil-colors' ),
'priority' => 13,
'section' => 'mcn_options_typography_1',
'label' => __( 'Font weight', 'brazil-colors' ),
'choices' => array(
'300' => 'Light',
'400' => 'Regular',
'700' => 'Bold',
)
) );
// ## Headings Font Family
$wp_customize->add_section(
'mcn_options_typography_2',
array(
'title' => __( 'Headings', 'brazil-colors' ),
'priority' => 51,
'panel' => 'mcn_panel_typography'
)
);
$wp_customize->add_setting(
'mcn_titles_typography',
array(
'default' => 'Montserrat',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control( new Google_Font_Dropdown_Custom_Control( $wp_customize, 'mcn_titles_typography', array(
'label' => __( 'Headings typography', 'brazil-colors' ),
'description' => __( 'You can select any font family available in fonts.google.com Google Fonts', 'brazil-colors' ),
'section' => 'mcn_options_typography_2',
'settings' => 'mcn_titles_typography',
'priority' => 12
) ) );
$wp_customize->add_setting(
'mcn_titles_weight',
array(
'default' => '700',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_select'
)
);
$wp_customize->add_control( 'mcn_titles_weight', array(
'type' => 'select',
'description' => __( 'The font family you choose may not have the Light and Bold styles, when this occurs the font family is not loaded, and you should then select the Regular style.', 'brazil-colors' ),
'priority' => 13,
'section' => 'mcn_options_typography_2',
'label' => __( 'Font weight', 'brazil-colors' ),
'choices' => array(
'300' => 'Light',
'400' => 'Regular',
'700' => 'Bold',
)
) );
// ## Body Font Family
$wp_customize->add_section(
'mcn_options_typography_3',
array(
'title' => __( 'Body', 'brazil-colors' ),
'priority' => 51,
'panel' => 'mcn_panel_typography'
)
);
$wp_customize->add_setting(
'mcn_body_typography',
array(
'default' => 'Libre+Franklin',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control( new Google_Font_Dropdown_Custom_Control( $wp_customize, 'mcn_body_typography', array(
'label' => __( 'Body typography', 'brazil-colors' ),
'description' => __( 'You can select any font family available in fonts.google.com Google Fonts', 'brazil-colors' ),
'section' => 'mcn_options_typography_3',
'settings' => 'mcn_body_typography',
'priority' => 12
) ) );
$wp_customize->add_setting(
'mcn_body_weight',
array(
'default' => '400',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_select'
)
);
$wp_customize->add_control( 'mcn_body_weight', array(
'type' => 'select',
'description' => __( 'The font family you choose may not have the Light and Bold styles, when this occurs the font family is not loaded, and you should then select the Regular style.', 'brazil-colors' ),
'priority' => 13,
'section' => 'mcn_options_typography_3',
'label' => __( 'Font weight', 'brazil-colors' ),
'choices' => array(
'300' => 'Light',
'400' => 'Regular',
'700' => 'Bold',
)
) );
// ## Navigation Bar Font Family
$wp_customize->add_section(
'mcn_options_typography_4',
array(
'title' => __( 'Navigation Bar', 'brazil-colors' ),
'priority' => 51,
'panel' => 'mcn_panel_typography'
)
);
$wp_customize->add_setting(
'mcn_navigationbar_typography',
array(
'default' => 'Libre+Franklin',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control( new Google_Font_Dropdown_Custom_Control( $wp_customize, 'mcn_navigationbar_typography', array(
'label' => __( 'Navigation bar typography', 'brazil-colors' ),
'description' => __( 'You can select any font family available in fonts.google.com Google Fonts', 'brazil-colors' ),
'section' => 'mcn_options_typography_4',
'settings' => 'mcn_navigationbar_typography',
'priority' => 12
) ) );
$wp_customize->add_setting(
'mcn_navigationbar_weight',
array(
'default' => '400',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_select'
)
);
$wp_customize->add_control( 'mcn_navigationbar_weight', array(
'type' => 'select',
'description' => __( 'The font family you choose may not have the Light and Bold styles, when this occurs the font family is not loaded, and you should then select the Regular style.', 'brazil-colors' ),
'priority' => 13,
'section' => 'mcn_options_typography_4',
'label' => __( 'Font weight', 'brazil-colors' ),
'choices' => array(
'300' => 'Light',
'400' => 'Regular',
'700' => 'Bold',
)
) );
// Footer
$wp_customize->add_section(
'mcn_options_footer',
array(
'title' => __( 'Footer', 'brazil-colors' ),
'priority' => 100
)
);
// ## Footer Credits
$wp_customize->add_setting(
'mcn_footer_credits',
array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_checkbox'
)
);
$wp_customize->add_control(
'mcn_footer_credits',
array(
'label' => __( 'Hide footer theme credits', 'brazil-colors' ),
'section' => 'mcn_options_footer',
'settings' => 'mcn_footer_credits',
'type' => 'checkbox'
)
);
// ## Footer notes
$wp_customize->add_setting(
'mcn_footer_notes',
array(
'default' => '',
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control(
'mcn_footer_notes',
array(
'label' => __( 'Footer notes', 'brazil-colors' ),
'section' => 'mcn_options_footer',
'settings' => 'mcn_footer_notes',
'type' => 'textarea'
)
);
// ## Footer Background
$wp_customize->add_setting(
'mcn_footer_background',
array(
'default' => $colors_args['color_3'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'footer_background',
array(
'label' => __( 'Footer background color', 'brazil-colors' ),
'section' => 'colors',
'settings' => 'mcn_footer_background'
)
)
);
// ## Footer anchor color
$wp_customize->add_setting(
'mcn_footer_link_color',
array(
'default' => $colors_args['color_1'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'footer_link_color',
array(
'label' => __( 'Footer links color', 'brazil-colors' ),
'section' => 'colors',
'settings' => 'mcn_footer_link_color'
)
)
);
// ## Footer text color
$wp_customize->add_setting(
'mcn_footer_text_color',
array(
'default' => $colors_args['color_0'],
'transport' => 'postMessage',
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'footer_text_color',
array(
'label' => __( 'Footer text color', 'brazil-colors' ),
'section' => 'colors',
'settings' => 'mcn_footer_text_color'
)
)
);
// Floater Shortcuts
$wp_customize->add_section(
'mcn_options_floatshortcuts',
array(
'title' => __( 'Floater Shortcuts', 'brazil-colors' ),
'priority' => 51
)
);
// ## Active or Desactive the Float Shortcuts
$wp_customize->add_setting(
'mcn_floatshortcuts_onoff',
array(
'default' => 'on',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_checkbox'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_onoff',
array(
'label' => __( 'Enable Floater Shortcuts', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_onoff',
'type' => 'checkbox'
)
);
// ## Active or Desactive the Float Shortcuts Search Buttom
$wp_customize->add_setting(
'mcn_floatshortcuts_search_onoff',
array(
'default' => 'on',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_checkbox'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_search_onoff',
array(
'label' => __( 'Enable Search Buttom', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_search_onoff',
'type' => 'checkbox'
)
);
// ## Float Shortcuts Facebook
$wp_customize->add_setting(
'mcn_floatshortcuts_facebook',
array(
'default' => 'https://www.facebook.com',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_url'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_facebook',
array(
'label' => __( 'Facebook URL', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_facebook',
'type' => 'url'
)
);
// ## Float Shortcuts Youtube
$wp_customize->add_setting(
'mcn_floatshortcuts_youtube',
array(
'default' => 'https://www.youtube.com',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_url'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_youtube',
array(
'label' => __( 'Youtube URL', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_youtube',
'type' => 'url'
)
);
// ## Float Shortcuts Instagram
$wp_customize->add_setting(
'mcn_floatshortcuts_instagram',
array(
'default' => 'https://www.instagram.com',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_url'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_instagram',
array(
'label' => __( 'Instagram URL', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_instagram',
'type' => 'url'
)
);
// ## Float Shortcuts Twitter
$wp_customize->add_setting(
'mcn_floatshortcuts_twitter',
array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_url'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_twitter',
array(
'label' => __( 'Twitter URL', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_twitter',
'type' => 'url'
)
);
// ## Float Shortcuts Google Plus
$wp_customize->add_setting(
'mcn_floatshortcuts_googleplus',
array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_url'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_googleplus',
array(
'label' => __( 'Google Plus URL', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_googleplus',
'type' => 'url'
)
);
// ## Float Shortcuts Tumblr
$wp_customize->add_setting(
'mcn_floatshortcuts_tumblr',
array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_url'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_tumblr',
array(
'label' => __( 'Tumblr URL', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_tumblr',
'type' => 'url'
)
);
// ## Float Shortcuts Linkedin
$wp_customize->add_setting(
'mcn_floatshortcuts_linkedin',
array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_url'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_linkedin',
array(
'label' => __( 'Linkedin URL', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_linkedin',
'type' => 'url'
)
);
// ## Float Shortcuts Spotify
$wp_customize->add_setting(
'mcn_floatshortcuts_spotify',
array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_url'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_spotify',
array(
'label' => __( 'Spotify URL', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_spotify',
'type' => 'url'
)
);
// ## Float Shortcuts iTunes
$wp_customize->add_setting(
'mcn_floatshortcuts_itunes',
array(
'default' => '',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_url'
)
);
$wp_customize->add_control(
'mcn_floatshortcuts_itunes',
array(
'label' => __( 'iTunes URL', 'brazil-colors' ),
'section' => 'mcn_options_floatshortcuts',
'settings' => 'mcn_floatshortcuts_itunes',
'type' => 'url'
)
);
// Layout
$wp_customize->add_section(
'mcn_options_layout',
array(
'title' => __( 'Layout', 'brazil-colors' ),
'priority' => 50
)
);
// ## Layout archive
$wp_customize->add_setting(
'mcn_layout_archive',
array(
'default' => 'rightsidebar',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_radio'
)
);
$wp_customize->add_setting(
'mcn_layout_archive_content',
array(
'default' => 'blog',
'transport' => 'refresh',
'sanitize_callback' => 'brazilcolors_sanitize_radio'
)
);
$wp_customize->add_control(
'mcn_layout_archive',
array(
'label' => __( 'Layout Archive', 'brazil-colors' ),
'section' => 'mcn_options_layout',
'settings' => 'mcn_layout_archive',
'type' => 'radio',
'choices' => array(
'nosidebar' => __( 'No sidebar', 'brazil-colors' ),
'rightsidebar' => __( 'Right sidebar', 'brazil-colors' ),
'leftsidebar' => __( 'Left sidebar', 'brazil-colors' ),
),
)
);
$wp_customize->add_control(
'mcn_layout_archive_content',
array(
'label' => __( 'Layout Archive Content', 'brazil-colors' ),
'section' => 'mcn_options_layout',
'settings' => 'mcn_layout_archive_content',
'type' => 'radio',
'choices' => array(
'blog' => __( 'Blog layout', 'brazil-colors' ),
'magazine' => __( 'Magazine layout', 'brazil-colors' ),
'masonry' => __( 'Masonry layout', 'brazil-colors' ),
),
)
);
}
add_action( 'customize_register', 'brazilcolors_register_theme_customizer' );
// Customizer css styles
function brazilcolors_customizer_css() {
// Set default colors
$colors_args = array(
'color_0' => '#ffffff', // Site title color, site description color, menu bar links color, footer text color
'color_1' => '#efab19', // Primary color
'color_2' => '#44444c', // Primary hover color
'color_3' => '#53535c' // Menu bar and footer background color
);
// Get theme mods values
$site_header_text_color = get_theme_mod( 'mcn_headertext_color', $colors_args['color_0'] );
$primary_color = get_theme_mod( 'mcn_primary_color', $colors_args['color_1'] );
$primary_color_hover = get_theme_mod( 'mcn_primary_color_hover', $colors_args['color_2'] );
$link_text_color = get_theme_mod( 'mcn_link_color', $colors_args['color_1'] );
$menu_bar_background = get_theme_mod( 'mcn_menu_bar_bg_color', $colors_args['color_3'] );
$menu_bar_link_text_color = get_theme_mod( 'mcn_menu_link_color', $colors_args['color_0'] );
$site_footer_background = get_theme_mod( 'mcn_footer_background', $colors_args['color_3'] );
$site_footer_text_color = get_theme_mod( 'mcn_footer_text_color', $colors_args['color_0'] );
$site_footer_link_text_color = get_theme_mod( 'mcn_footer_link_color', $colors_args['color_1'] );
$sitetitle_font_family_embed = get_theme_mod( 'mcn_sitetitle_typography', 'Montserrat' );
$sitetitle_font_family = str_replace( '+', ' ', $sitetitle_font_family_embed );
$sitetitle_font_weight = get_theme_mod( 'mcn_sitetitle_weight', '700' );
$site_logo_size = get_theme_mod( 'mcn_logo_size', 100 );
$heading_font_family_embed = get_theme_mod( 'mcn_titles_typography', 'Montserrat' );
$heading_font_family = str_replace( '+', ' ', $heading_font_family_embed );
$heading_font_weight = get_theme_mod( 'mcn_titles_weight', '700' );
$body_font_family_embed = get_theme_mod( 'mcn_body_typography', 'Libre+Franklin' );
$body_font_family = str_replace( '+', ' ', $body_font_family_embed );
$body_font_weight = get_theme_mod( 'mcn_body_weight', '400' );
$navigationbar_font_family_embed = get_theme_mod( 'mcn_navigationbar_typography', 'Libre+Franklin' );
$navigationbar_font_family = str_replace( '+', ' ', $navigationbar_font_family_embed );
$navigationbar_font_weight = get_theme_mod( 'mcn_body_weight', '400' );
// Embed Fonts
$weight_fonts_array = array(
array( 'font' => $sitetitle_font_family_embed, 'weight' => $sitetitle_font_weight ),
array( 'font' => $heading_font_family_embed, 'weight' => $heading_font_weight ),
array( 'font' => $body_font_family_embed, 'weight' => $body_font_weight ),
array( 'font' => $navigationbar_font_family_embed, 'weight' => $navigationbar_font_weight ),
);
$embed_fonts_array = array();
$embed_fonts_array_2 = array();
$font_heith_check = '';
$embed_fonts_array = array(
$heading_font_family_embed . ':' => $heading_font_family_embed . ':' ,
$body_font_family_embed . ':' => $body_font_family_embed . ':',
$navigationbar_font_family_embed . ':' => $navigationbar_font_family_embed . ':',
$sitetitle_font_family_embed . ':' => $sitetitle_font_family_embed . ':'
);
// Formating string for embed google fonts meta tags
foreach( $weight_fonts_array as $font_data ) :
$font_name = $font_data['font'] . ':';
$font_weight = $font_data['weight'];
foreach( $embed_fonts_array as $font ) :
if( $font_name == $font ) :
if( ! isset( $embed_fonts_array_2[$font] ) ) :
$embed_fonts_array_2[$font] = $font_name;
endif;
$check_height[] = $font_weight;
if( $font_heith_check != $font_weight ) :
$embed_fonts_array_2[$font] .= $font_weight . ',';
endif;
$font_heith_check = $font_weight;
endif;
endforeach;
endforeach;
// Render meta tag for embed google fonts
foreach( $embed_fonts_array_2 as $embed_font ) :
echo '' . "\xA";
endforeach;
?>
manager->get_control( $setting->id )->choices;
//return input if valid or return default option
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
//checkbox sanitization function
function brazilcolors_sanitize_checkbox( $checked ){
// boolean check.
return ( ( isset( $checked ) && true == $checked ) ? true : false );
}
//radio box sanitization function
function brazilcolors_sanitize_radio( $input, $setting ){
//input must be a slug: lowercase alphanumeric characters, dashes and underscores are allowed only
$input = sanitize_key($input);
//get the list of possible radio box options
$choices = $setting->manager->get_control( $setting->id )->choices;
//return input if valid or return default option
return ( array_key_exists( $input, $choices ) ? $input : $setting->default );
}
//range sanitization function
function brazilcolors_sanitize_number( $number, $setting ) {
// ensure $number is an absolute integer (whole number, zero or greater).
$number = absint( $number );
// if the input is an absolute integer, return it; otherwise, return the default
return ( $number ? $number : $setting->default );
}
//url sanitization function
function brazilcolors_sanitize_url( $url ) {
return esc_url_raw( $url );
}
/**
* Customizer - end
*/