'Custom text', 'title_description' => 'Site title and/or description', ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } } function nucleus_sanitize_fonts( $input ) { $valid = array( 'Open Sans' => 'Open Sans', 'Alegreya Sans' => 'Alegreya Sans', 'Arimo' => 'Arimo', 'Asap' => 'Asap', 'Bitter' => 'Bitter', 'Cabin' => 'Cabin', 'Cuprum' => 'Cuprum', 'Dosis' => 'Dosis', 'Droid Serif' => 'Droid Serif', 'Exo' => 'Exo', 'Raleway' => 'Raleway', 'Titillium Web' => 'Titillium Web', 'Ubuntu' => 'Ubuntu', ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } } function nucleus_sanitize_theme_color( $input ) { $valid = array( '#00BCD5' => 'Blue', '#0073AA' => 'Blue WP', '#82A31D' => 'Green', '#FA4C00' => 'Orange', '#F882B3' => 'Pink', '#7B0099' => 'Purple', ); if ( array_key_exists( $input, $valid ) ) { return $input; } else { return ''; } } /**------------------------------- * Nucleus Customizer --------------------------------*/ add_action('customize_register', 'nucleus_theme_customizer'); function nucleus_theme_customizer( $wp_customize ) { $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; /** * PANEL: GENERAL SETTINGS * * Sections: Site identity, Colors, Fonts, Top br, Background image */ $wp_customize->add_panel ('panel_configuracion_general', array( 'title' => __('General settings', 'nucleus'), 'priority' => '9')); /** * Site identity */ $wp_customize->add_section( 'title_tagline', array( 'panel' => 'panel_configuracion_general', 'title' => __( 'Site Identity', 'nucleus' ), 'priority' => 10, )); /** * Colors */ $wp_customize->add_section( 'colors', array( 'panel' => 'panel_configuracion_general', 'title' => __( 'Colors', 'nucleus' ), 'priority' => 11, )); // Theme color $wp_customize->add_setting('nucleus_color_tema', array('default' => '#00BCD5', 'sanitize_callback' => 'nucleus_sanitize_theme_color' )); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'nucleus_color_tema', array( 'label' => __( 'Theme color', 'nucleus' ), 'section' => 'colors', 'settings' => 'nucleus_color_tema', 'type' => 'select', 'priority' => '1', 'choices' => array( '#00BCD5' => __( 'Blue','nucleus' ), '#0073AA' => __( 'Blue WP','nucleus' ), '#82A31D' => __( 'Green','nucleus' ), '#FA4C00' => __( 'Orange','nucleus' ), '#F882B3' => __( 'Pink','nucleus' ), '#7B0099' => __( 'Purple', 'nucleus' ), ) ) ) ); // Show top line $wp_customize->add_setting('nucleus_linea_superior_color', array('default' => 1, 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_linea_superior_color', array( 'type' => 'checkbox', 'label' => __('Show color line at the top of the page', 'nucleus'), 'section' => 'colors', 'priority' => '2' )); // Title color in excerpts $wp_customize->add_setting('nucleus_color_entry_title_link', array('default' => '', 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_color_entry_title_link', array( 'type' => 'checkbox', 'label' => __('Apply to entry title link', 'nucleus'), 'section' => 'colors', 'priority' => '3' )); // Title border-left-color $wp_customize->add_setting('nucleus_color_entry_title_border', array('default' => '', 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_color_entry_title_border', array( 'type' => 'checkbox', 'label' => __('Apply to the border top of entry title', 'nucleus'), 'description' => __( '(Unchecked: Gray)', 'nucleus'), 'section' => 'colors', 'priority' => '4' )); // Widgets border-top-color $wp_customize->add_setting('nucleus_color_widget_border_top', array('default' => '', 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_color_widget_border_top', array( 'type' => 'checkbox', 'label' => __('Apply to widget border-top', 'nucleus'), 'section' => 'colors', 'description' => __( '(Unchecked: Gray)', 'nucleus'), 'priority' => '5' )); /** * Fonts */ $wp_customize->add_section('nucleus_fonts' , array( 'panel' => 'panel_configuracion_general', 'title' => __('Fonts', 'nucleus'), 'priority' => 12, )); $wp_customize->add_setting('nucleus_fonts', array('default' => 'Open Sans', 'sanitize_callback' => 'nucleus_sanitize_fonts' )); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'nucleus_fonts', array( 'label' => __( 'Select font', 'nucleus' ), 'section' => 'nucleus_fonts', 'settings' => 'nucleus_fonts', 'type' => 'select', 'choices' => array( 'Open Sans' => 'Open Sans', 'Alegreya Sans' => 'Alegreya Sans', 'Arimo' => 'Arimo', 'Asap' => 'Asap', 'Bitter' => 'Bitter', 'Cabin' => 'Cabin', 'Cuprum' => 'Cuprum', 'Dosis' => 'Dosis', 'Droid Serif' => 'Droid Serif', 'Exo' => 'Exo', 'Raleway' => 'Raleway', 'Titillium Web' => 'Titillium Web', 'Ubuntu' => 'Ubuntu', ) ) ) ); /** * Background image */ $wp_customize->add_section( 'background_image', array( 'panel' => 'panel_configuracion_general', 'title' => __( 'Background Image', 'nucleus' ), 'priority' => 14, )); /** * PANEL HEADER * * Sections: Top bar, Header image, Main menu */ $wp_customize->add_panel ('panel_cabecera', array( 'title' => __('Header', 'nucleus'), 'priority' => '10')); /** * Top bar */ $wp_customize->add_section('nucleus_top_bar' , array( 'panel' => 'panel_cabecera', 'title' => __('Top bar','nucleus'), 'priority' => 10, )); // Enable top bar $wp_customize->add_setting('nucleus_enable_top_bar', array('default' => 1, 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_enable_top_bar', array( 'type' => 'checkbox', 'label' => __('Enable top bar', 'nucleus'), 'section' => 'nucleus_top_bar', )); // Top bar text $wp_customize->add_setting('nucleus_text_top_bar', array('default' => 'custom_text', 'sanitize_callback' => 'nucleus_sanitize_text_top_bar', )); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'nucleus_text_top_bar', array( 'label' => __( 'What text you want to display on the left of the top bar?', 'nucleus' ), 'section' => 'nucleus_top_bar', 'settings' => 'nucleus_text_top_bar', 'type' => 'select', 'choices' => array( 'custom_text' => __( 'Custom text','nucleus' ), 'title_description' => __( 'Site title and/or tagline','nucleus' ), ) ) ) ); // Site title $wp_customize->add_setting('nucleus_site_title_top_bar', array('default' => 1, 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_site_title_top_bar', array( 'type' => 'checkbox', 'label' => __('Display site title on the top bar', 'nucleus'), 'section' => 'nucleus_top_bar', )); // Site description $wp_customize->add_setting('nucleus_site_description_top_bar', array('default' => 1, 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_site_description_top_bar', array( 'type' => 'checkbox', 'label' => __('Display tagline on the top bar', 'nucleus'), 'section' => 'nucleus_top_bar', )); // Top bar custom text $wp_customize->add_setting('nucleus_custom_text_top_bar', array('default' => __('Custom text or site title and/or tagline', 'nucleus'), 'sanitize_callback' => 'nucleus_sanitize_text')); $wp_customize->add_control('nucleus_custom_text_top_bar', array( 'label' => __('Custom text', 'nucleus'), 'section' => 'nucleus_top_bar', 'type' => 'text', )); /** * Logo */ $wp_customize->get_control('custom_logo')->description = __('The logo is shown on the left of the site title and tagline. If you do not want the site title and tagline are displayed, uncheck "Display Site Title and Tagline" found below. The recommended maximum height is 60px.', 'nucleus'); // logo max-height $wp_customize->add_setting('nucleus_altura_logo', array('default' => 60, 'sanitize_callback' => 'nucleus_sanitize_text',)); $wp_customize->add_control( 'nucleus_altura_logo', array( 'type' => 'number', 'section' => 'title_tagline', 'label' => __('Maximum height of the logo', 'nucleus'), 'priority' => 8, 'input_attrs' => array( 'min' => 50, 'max' => 200, 'step' => 2, ), ) ); // Round logo $wp_customize->add_setting('nucleus_logo_rounded', array('default' => '', 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_logo_rounded', array( 'type' => 'checkbox', 'label' => __('Rounded', 'nucleus'), 'description' => '(' . __('The original logo must be square', 'nucleus') . ')', 'section' => 'title_tagline', 'priority' => 9, )); /** * Header image */ $wp_customize->add_section('header_image' , array( 'panel' => 'panel_cabecera', 'title' => __('Header Image','nucleus'), 'priority' => '12', )); // Header image grayscale $wp_customize->add_setting('nucleus_header_image_grayscale', array('default' => '', 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_header_image_grayscale', array( 'type' => 'checkbox', 'label' => __('Header image grayscale', 'nucleus'), 'section' => 'header_image', )); /** * Main menu */ $wp_customize->add_section('menu_principal' , array( 'panel' => 'panel_cabecera', 'title' => __('Main Menu','nucleus'), 'priority' => '13', )); // Uppercase menu $wp_customize->add_setting('nucleus_uppercase_menu', array('default' => 1, 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_uppercase_menu', array( 'type' => 'checkbox', 'label' => __('Uppercase menu', 'nucleus'), 'section' => 'menu_principal', )); /** * PANEL CONTENT */ $wp_customize->add_panel ('panel_contenido', array( 'title' => __('Content', 'nucleus'), 'priority' => '12')); /** * Sidebar */ $wp_customize->add_section('nucleus_sidebar' , array( 'panel' => 'panel_contenido', 'title' => __('Sidebar','nucleus'), 'priority' => '11', )); $wp_customize->add_setting('nucleus_show_icon_widget_title', array('default' => 1, 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_show_icon_widget_title', array( 'type' => 'checkbox', 'label' => __("Show icon in widget title.", 'nucleus'), 'section' => 'nucleus_sidebar', )); /** * Posts */ $wp_customize->add_section('nucleus_entradas' , array( 'panel' => 'panel_contenido', 'title' => __('Posts','nucleus'), 'priority' => '10', )); $wp_customize->add_setting('nucleus_contenido_completo_entradas', array('default' => '', 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_contenido_completo_entradas', array( 'type' => 'checkbox', 'label' => __("Show full content of the entries in main page and archive pages.", 'nucleus'), 'section' => 'nucleus_entradas', )); $wp_customize->add_setting('nucleus_related_posts', array('default' => '', 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_related_posts', array( 'type' => 'checkbox', 'label' => __('Display related posts at the end of entries', 'nucleus'), 'section' => 'nucleus_entradas', )); $wp_customize->add_setting('nucleus_related_posts_title', array('default' => __('Related posts...', 'nucleus'), 'sanitize_callback' => 'nucleus_sanitize_text',)); $wp_customize->add_control('nucleus_related_posts_title', array( 'type' => 'text', 'label' => __('Related posts title', 'nucleus'), 'section' => 'nucleus_entradas', )); /** * Footer */ $wp_customize->add_section('nucleus_footer' , array( 'title' => __('Footer', 'nucleus'), 'priority' => 12, )); // Display social icons $wp_customize->add_setting('nucleus_footer_social_icons', array('default' => 1, 'sanitize_callback' => 'nucleus_sanitize_checkbox',)); $wp_customize->add_control('nucleus_footer_social_icons', array( 'type' => 'checkbox', 'label' => __('Show social icons on footer', 'nucleus'), 'section' => 'nucleus_footer', )); // Credits $wp_customize->add_setting('nucleus_footer_text_left', array('default' => __('Copyright 2015', 'nucleus'), 'sanitize_callback' => 'nucleus_sanitize_text',)); $wp_customize->add_control('nucleus_footer_text_left', array( 'type' => 'textarea', 'label' => __('Footer text left', 'nucleus'), 'section' => 'nucleus_footer', )); $wp_customize->add_setting('nucleus_footer_text_center', array('default' => __('Footer text center', 'nucleus'), 'sanitize_callback' => 'nucleus_sanitize_text',)); $wp_customize->add_control('nucleus_footer_text_center', array( 'type' => 'textarea', 'label' => __('Footer text center', 'nucleus'), 'section' => 'nucleus_footer', )); } // Load Javascript postMessage handlers add_action( 'customize_preview_init', 'nucleus_customize_preview_js' ); function nucleus_customize_preview_js() { wp_enqueue_script( 'nucleus-customize-preview', get_template_directory_uri() . '/js/customize-preview.js', array( 'customize-preview' ), '05', true ); }