add_section('apollosegundo_header_section', array( 'title' => __('Cabecera - Apollo Segundo','apollosegundo'), 'description' => __('Adapta el tema a tus necesidades','apollosegundo'), 'priority' => 200 )); /* Add settings && controls */ // Header background $wp_customize->add_setting('load_header_image', array( 'sanitize_callback' => 'apollosegundo_sanitize_image' )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'load_header_image', array( 'label' => __('Imagen de fondo: 1440x400 px','apollosegundo'), 'section' => 'apollosegundo_header_section', 'settings' => 'load_header_image' ))); // Position of background $wp_customize->add_setting('background_position', array( 'default' => 'center', 'sanitize_callback' => 'apollosegundo_sanitize_select' )); $wp_customize->add_control('background_position', array( 'label' => __('Posición de la imagen de fondo','apollosegundo'), 'section' => 'apollosegundo_header_section', 'type' => 'select', 'choices' => array( 'left-top' => __('Superior Izquierda','apollosegundo'), 'right-top' => __('Superior Derecha','apollosegundo'), 'center-top' => __('Superior Centrado','apollosegundo'), 'left-bottom' => __('Inferior Izquierda','apollosegundo'), 'right-bottom' => __('Inferior Derecha','apollosegundo'), 'center-bottom' => __('Inferior Centrado','apollosegundo'), 'left-center' => __('Centrado Izquierda','apollosegundo'), 'right-center' => __('Centrado Derecha','apollosegundo'), 'center-center' => __('Centrado','apollosegundo') ) )); // Change color header text $wp_customize->add_setting('header_color', array( 'default' => '#fff', 'sanitize_callback' => 'sanitize_hex_color' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'header_color', array( 'label' => __('Color del texto de cabecera', 'apollosegundo'), 'section' => 'apollosegundo_header_section', 'settings' => 'header_color' ))); // Apply shadow to header text $wp_customize->add_setting('apply_shadow', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('apply_shadow', array( 'label' => __('Aplicar sombra al texto de cabecera','apollosegundo'), 'section' => 'apollosegundo_header_section', 'type' => 'checkbox' )); /*** COLORS CUSTOMIZATION ***/ /* Add section */ $wp_customize->add_section('apollosegundo_colors_section', array( 'title' => __('Colores - Apollo Segundo','apollosegundo'), 'description' => __('Adapta el tema a tus necesidades','apollosegundo'), 'priority' => 200 )); /* Add settings && controls */ // Main color $wp_customize->add_setting('main_color', array( 'default' => '#222', 'sanitize_callback' => 'sanitize_hex_color', 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'transport' => 'refresh' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'main_color', array( 'label' => __('Color principal', 'apollosegundo'), 'section' => 'apollosegundo_colors_section', 'settings' => 'main_color' ))); // Main color hover $wp_customize->add_setting('main_color_hover', array( 'default' => '#3c3c3c', 'sanitize_callback' => 'sanitize_hex_color' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'main_color_hover', array( 'label' => __('Color principal hover', 'apollosegundo'), 'section' => 'apollosegundo_colors_section', 'settings' => 'main_color_hover' ))); // Secondary color $wp_customize->add_setting('secondary_color', array( 'default' => '#747474', 'sanitize_callback' => 'sanitize_hex_color' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'secondary_color', array( 'label' => __('Color secundario', 'apollosegundo'), 'section' => 'apollosegundo_colors_section', 'settings' => 'secondary_color' ))); // Interface color $wp_customize->add_setting('interface_color', array( 'default' => '#D4D4D4', 'sanitize_callback' => 'sanitize_hex_color' )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'interface_color', array( 'label' => __('Color interfaz', 'apollosegundo'), 'section' => 'apollosegundo_colors_section', 'settings' => 'interface_color' ))); /*** SOCIAL MEDIA CUSTOMIZATION ***/ /* Add section */ $wp_customize->add_section('apollosegundo_sm_section', array( 'title' => __('Redes sociales - Apollo Segundo','apollosegundo'), 'description' => __('Adapta el tema a tus necesidades','apollosegundo'), 'priority' => 200 )); /* Add settings && controls */ // Instagram $wp_customize->add_setting('sm_instagram', array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control('sm_instagram', array( 'label' => __('Perfil de Instragram','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'url' )); // Display Instagram icon $wp_customize->add_setting('display_instagram', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('display_instagram', array( 'label' => __('Mostrar icono de Instragram','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'checkbox' )); // Facebook $wp_customize->add_setting('sm_facebook', array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control('sm_facebook', array( 'label' => __('Perfil o página de Facebook','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'url' )); // Display Facebook icon $wp_customize->add_setting('display_facebook', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('display_facebook', array( 'label' => __('Mostrar icono de Facebook','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'checkbox' )); // Twitter $wp_customize->add_setting('sm_twitter', array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control('sm_twitter', array( 'label' => __('Perfil de Twitter','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'url' )); // Display Twitter icon $wp_customize->add_setting('display_twitter', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('display_twitter', array( 'label' => __('Mostrar icono de Twitter','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'checkbox' )); // Youtube $wp_customize->add_setting('sm_youtube', array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control('sm_youtube', array( 'label' => __('Canal de Youtube','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'url' )); // Display Youtube icon $wp_customize->add_setting('display_youtube', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('display_youtube', array( 'label' => __('Mostrar icono de Youtube','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'checkbox' )); // Vimeo $wp_customize->add_setting('sm_vimeo', array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control('sm_vimeo', array( 'label' => __('Canal de Vimeo','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'url' )); // Display Vimeo icon $wp_customize->add_setting('display_vimeo', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('display_vimeo', array( 'label' => __('Mostrar icono de Vimeo','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'checkbox' )); // Pinterest $wp_customize->add_setting('sm_pinterest', array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control('sm_pinterest', array( 'label' => __('Perfil de Pinterest','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'url' )); // Display Pinterest icon $wp_customize->add_setting('display_pinterest', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('display_pinterest', array( 'label' => __('Mostrar icono de Pinterest','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'checkbox' )); // Vine $wp_customize->add_setting('sm_vine', array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control('sm_vine', array( 'label' => __('Perfil de Vine','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'url' )); // Display Vine icon $wp_customize->add_setting('display_vine', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('display_vine', array( 'label' => __('Mostrar icono de Vine','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'checkbox' )); // Linkedin $wp_customize->add_setting('sm_linkedin', array( 'sanitize_callback' => 'esc_url_raw' )); $wp_customize->add_control('sm_linkedin', array( 'label' => __('Perfil de Linkedin','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'url' )); // Display Linkedin icon $wp_customize->add_setting('display_linkedin', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('display_linkedin', array( 'label' => __('Mostrar icono de Linkedin','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'checkbox' )); // Email $wp_customize->add_setting('sm_email', array( 'sanitize_callback' => 'apollosegundo_sanitize_email' )); $wp_customize->add_control('sm_email', array( 'label' => __('Correo electrónico','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'email' )); // Display Email icon $wp_customize->add_setting('display_email', array( 'sanitize_callback' => 'apollosegundo_sanitize_checkbox' )); $wp_customize->add_control('display_email', array( 'label' => __('Mostrar icono del email','apollosegundo'), 'section' => 'apollosegundo_sm_section', 'type' => 'checkbox' )); /*** FOOTER CUSTOMIZATION ***/ /* Add section */ $wp_customize->add_section('apollosegundo_footer_section', array( 'title' => __('Pie de página - Apollo Segundo','apollosegundo'), 'description' => __('Adapta el tema a tus necesidades','apollosegundo'), 'priority' => 200 )); /* Add settings && controls */ $wp_customize->add_setting('content_footer', array( 'default' => __('Web creada con WordPress','apollosegundo'), 'sanitize_callback' => 'apollosegundo_sanitize_textarea' )); $wp_customize->add_control('content_footer', array( 'label' => __('Texto para el pie de página','apollosegundo'), 'section' => 'apollosegundo_footer_section', 'type' => 'textarea' )); } add_action('customize_register','apollosegundo_theme_customize_register'); /* Apply customizations */ function apollosegundo_theme_customize_css(){ $header_color = get_theme_mod('header_color'); $main_color = get_theme_mod('main_color'); $main_color_hover = get_theme_mod('main_color_hover'); $secondary_color = get_theme_mod('secondary_color'); $interface_color = get_theme_mod('interface_color'); $header_image = get_theme_mod('load_header_image'); $background_position = str_replace("-"," ",get_theme_mod('background_position')); ?> 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', 'tif|tiff' => 'image/tiff', 'ico' => 'image/x-icon' ); // Return an array with file extension and mime_type. $file = wp_check_filetype( $image, $mimes ); // If $image has a valid mime_type, return it; otherwise, return the default. return ( $file['ext'] ? $image : $setting->default ); } /* Sanitize select */ function apollosegundo_sanitize_select( $input, $setting ) { // Ensure input is a slug. $input = sanitize_key( $input ); // Get list of choices from the control associated with the setting. $choices = $setting->manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } ?>