add_section('footer_section', array( 'title' => 'Footer Settings', 'priority' => 130, )); // Company Name $wp_customize->add_setting('company_name', array( 'default' => '', // Default vuoto senza localizzazione 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage', // Rende possibile l'anteprima live )); $wp_customize->add_control('company_name', array( 'label' => 'Company name', 'section' => 'footer_section', 'type' => 'text', )); // Address $wp_customize->add_setting('footer_address', array( 'default' => '', // Default vuoto 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage', )); $wp_customize->add_control('footer_address', array( 'label' => 'Footer address', 'section' => 'footer_section', 'type' => 'text', )); // Email $wp_customize->add_setting('footer_email', array( 'default' => '', // Default vuoto 'sanitize_callback' => 'sanitize_email', 'transport' => 'postMessage', )); $wp_customize->add_control('footer_email', array( 'label' => 'Footer email', 'section' => 'footer_section', 'type' => 'email', )); // Telephone $wp_customize->add_setting('footer_phone', array( 'default' => '', // Default vuoto 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'postMessage', )); $wp_customize->add_control('footer_phone', array( 'label' => 'Footer phone', 'section' => 'footer_section', 'type' => 'text', )); } add_action('customize_register', 'dynamic_footer'); /* Custom Colors --------------------------------------- */ function flexitheme_remove_default_color_controls($wp_customize) { $wp_customize->remove_control('header_textcolor'); } add_action('customize_register', 'flexitheme_remove_default_color_controls', 20); function flexitheme_customize_colors($wp_customize) { $wp_customize->add_section('colors', array( 'title' => 'Colors', 'priority' => 30, )); // default colors $default_colors = [ 'color_body' => '#F2F2F2', 'color_default' => '#2F3845', 'color_primary' => '#f9bc60', 'color_secondary' => '#004643', 'color_link' => '#f9bc60', 'color_link_hover' => '#d79d45', 'background_header' => '#111111', 'color_link_header' => '#FFFFFF', 'color_link_header_hover' => '#f9bc60', 'background_footer' => '#111111', 'color_footer' => '#FFFFFF', 'color_link_footer' => '#FFFFFF', 'color_link_footer_hover' => '#f9bc60', 'background_footer_copyright' => '#f9bc60', 'color_footer_copyright' => '#2F3845', ]; foreach ($default_colors as $key => $default) { $wp_customize->add_setting($key, array( 'default' => $default, 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_hex_color', )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $key, array( 'label' => ucwords(str_replace('_', ' ', $key)), 'section' => 'colors', 'settings' => $key, ))); } } add_action('customize_register', 'flexitheme_customize_colors'); function flexitheme_apply_custom_colors() { ?> add_section('typography', array( 'title' => 'Typography', 'priority' => 30, 'description' => 'Customize the fonts for your website. Add your Google Fonts API key to access the full library.', )); // Google API Key $wp_customize->add_setting('google_fonts_api_key', array( 'default' => '', // Nessuna API Key di default 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', // Aggiungi la funzione di sanificazione qui )); $wp_customize->add_control('google_fonts_api_key', array( 'label' => 'Google Fonts API Key', 'description' => 'Enter your Google Fonts API key.
Get it from Google Cloud Console.', 'section' => 'typography', 'type' => 'text', 'priority' => 1, )); // Control for default font $wp_customize->add_setting('primary_font', array( 'default' => 'DM Sans', // Default value 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', // Aggiungi la funzione di sanificazione )); $wp_customize->add_control('primary_font', array( 'label' => 'Default Font (Body)', 'section' => 'typography', 'type' => 'select', 'choices' => $google_fonts, )); // Control Title font $wp_customize->add_setting('heading_font', array( 'default' => 'DM Sans', // Default value 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', // Aggiungi la funzione di sanificazione )); $wp_customize->add_control('heading_font', array( 'label' => 'Title font (H1-H6)', 'section' => 'typography', 'type' => 'select', 'choices' => fetch_google_fonts(), )); } add_action('customize_register', 'flexitheme_customize_fonts'); function flexitheme_enqueue_fonts() { $fonts = []; $primary_font = get_theme_mod('primary_font', 'DM Sans'); $heading_font = get_theme_mod('heading_font', 'DM Sans'); if (!in_array($primary_font, $fonts)) { $fonts[] = $primary_font; } if (!in_array($heading_font, $fonts)) { $fonts[] = $heading_font; } $query = ''; foreach ($fonts as $font) { $query .= 'family=' . urlencode($font) . ':wght@400;700&'; } wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?' . $query . 'display=swap', false); } add_action('wp_enqueue_scripts', 'flexitheme_enqueue_fonts'); function flexitheme_apply_custom_fonts() { $primary_font = get_theme_mod('primary_font', 'DM Sans'); $heading_font = get_theme_mod('heading_font', 'DM Sans'); ?> remove_section('header_image'); } add_action('customize_register', 'flexitheme_remove_customizer_sections', 20); /* Whatsapp Button -----------------------------------------*/ function flexitheme_customize_register($wp_customize) { // Aggiungi una sezione al Customizer $wp_customize->add_section('flexitheme_whatsapp_section', array( 'title' => 'WhatsApp Settings', 'description' => 'Configure the WhatsApp button settings.', 'priority' => 160, )); // Aggiungi un'impostazione per il numero di telefono $wp_customize->add_setting('whatsapp_phone_number', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', // Importante per sicurezza 'type' => 'option', // Usa 'option' per salvare nel database delle opzioni 'capability' => 'edit_theme_options', )); // Aggiungi un controllo per il numero di telefono $wp_customize->add_control('whatsapp_phone_number_control', array( 'label' => 'WhatsApp Phone Number', 'section' => 'flexitheme_whatsapp_section', 'settings' => 'whatsapp_phone_number', 'type' => 'text', 'description' => 'Enter your WhatsApp phone number (ex: 3912345678).', )); } add_action('customize_register', 'flexitheme_customize_register');