add_panel('blockenix_layout_panel', [ 'title' => __('Layout Settings', 'blockenix'), 'priority' => 30, ]); $wp_customize->add_section('blockenix_layout_settings', [ 'title' => __('Container & Width', 'blockenix'), 'panel' => 'blockenix_layout_panel', 'priority' => 1, ]); $wp_customize->add_setting('blockenix_container_type', [ 'default' => 'container', 'transport' => 'refresh', 'sanitize_callback' => 'blnx_sanitize_container_type', ]); $wp_customize->add_control('blockenix_container_type_control', [ 'label' => __('Container Type', 'blockenix'), 'section' => 'blockenix_layout_settings', 'settings' => 'blockenix_container_type', 'type' => 'radio', 'choices' => [ 'container' => __('Contained (Boxed)', 'blockenix'), 'container-fluid' => __('Full Width', 'blockenix'), 'custom-width' => __('Custom Width', 'blockenix'), ], ]); $wp_customize->add_setting('blockenix_custom_width', [ 'default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_control('blockenix_custom_width_control', [ 'label' => __('Custom Width (px)', 'blockenix'), 'section' => 'blockenix_layout_settings', 'settings' => 'blockenix_custom_width', 'type' => 'number', 'input_attrs' => [ 'min' => 200, 'max' => 2000, 'step' => 10, ], ]); } /** * Add logo settings */ function blnx_add_logo_settings($wp_customize) { $wp_customize->add_panel('blockenix_header_panel', [ 'title' => __('Header Settings', 'blockenix'), 'priority' => 20, ]); $wp_customize->add_section('blockenix_logo_section', [ 'title' => __('Logo', 'blockenix'), 'panel' => 'blockenix_header_panel', 'priority' => 1, ]); $wp_customize->add_setting('blockenix_logo', [ 'default' => '', 'transport' => 'refresh', 'sanitize_callback' => 'esc_url_raw', ]); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'blockenix_logo', [ 'label' => __('Site Logo', 'blockenix'), 'section' => 'blockenix_logo_section', 'settings' => 'blockenix_logo', ])); $logo_dimensions = [ 'width' => [ 'default' => 150, 'min' => 50, 'max' => 500, ], 'height' => [ 'default' => 50, 'min' => 20, 'max' => 300, ] ]; foreach ($logo_dimensions as $dimension => $values) { $wp_customize->add_setting("blockenix_logo_$dimension", [ 'default' => $values['default'], 'transport' => 'refresh', 'sanitize_callback' => 'absint', ]); $dimension_label = ucfirst($dimension); $wp_customize->add_control("blockenix_logo_$dimension", [ 'label' => sprintf(__('Logo %s (px)', 'blockenix'), $dimension_label), 'section' => 'blockenix_logo_section', 'type' => 'number', 'input_attrs' => [ 'min' => $values['min'], 'max' => $values['max'], 'step' => 5, ], ]); } } /** * Helper function to add header and menu color settings */ function blnx_add_header_menu_colors($wp_customize) { $wp_customize->add_section('blockenix_header_colors', [ 'title' => __('Header Colors', 'blockenix'), 'panel' => 'blockenix_header_panel', 'priority' => 2, ]); $wp_customize->add_setting('header_bg_color', [ 'default' => '#1a1a2e', 'transport' => 'postMessage', 'sanitize_callback' => 'blnx_sanitize_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'header_bg_color', [ 'label' => __('Header Background Color', 'blockenix'), 'section' => 'blockenix_header_colors', 'settings' => 'header_bg_color', ])); $wp_customize->add_section('blockenix_menu_colors', [ 'title' => __('Menu Colors', 'blockenix'), 'panel' => 'blockenix_header_panel', 'priority' => 3, ]); $menu_color_settings = [ 'menu_bg' => ['transparent', __('Menu Background Color', 'blockenix')], 'menu_text' => ['#ffffff', __('Menu Text Color', 'blockenix')], 'menu_hover_bg' => ['#16213e', __('Menu Hover Background Color', 'blockenix')], 'menu_hover_text' => ['#4a9eff', __('Menu Hover Text Color', 'blockenix')], ]; foreach ($menu_color_settings as $setting => $values) { $wp_customize->add_setting($setting . '_color', [ 'default' => $values[0], 'transport' => 'postMessage', 'sanitize_callback' => 'blnx_sanitize_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, $setting . '_color', [ 'label' => $values[1], 'section' => 'blockenix_menu_colors', 'settings' => $setting . '_color', ])); } } /** * Helper function to add footer settings */ function blnx_add_footer_settings($wp_customize) { $wp_customize->add_panel('blockenix_footer_panel', [ 'title' => __('Footer Settings', 'blockenix'), 'priority' => 50, ]); $wp_customize->add_section('blockenix_footer_section', [ 'title' => __('Footer Colors', 'blockenix'), 'panel' => 'blockenix_footer_panel', 'priority' => 1, ]); $wp_customize->add_setting('footer_background_color', [ 'default' => '#1a1a2e', 'transport' => 'postMessage', 'sanitize_callback' => 'blnx_sanitize_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'footer_background_color', [ 'label' => __('Footer Background Color', 'blockenix'), 'section' => 'blockenix_footer_section', 'settings' => 'footer_background_color', ])); $wp_customize->add_setting('footer_text_color', [ 'default' => '#ffffff', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'footer_text_color', [ 'label' => __('Footer Text Color', 'blockenix'), 'section' => 'blockenix_footer_section', 'settings' => 'footer_text_color', ])); } /** * Helper function to add global settings */ function blnx_add_global_settings($wp_customize) { $wp_customize->add_panel('blockenix_global_panel', [ 'title' => __('Global Settings', 'blockenix'), 'priority' => 40, ]); $wp_customize->add_section('blockenix_global_colors', [ 'title' => __('Global Colors', 'blockenix'), 'panel' => 'blockenix_global_panel', 'priority' => 1, ]); $wp_customize->add_section('blockenix_global_typography', [ 'title' => __('Global Typography', 'blockenix'), 'panel' => 'blockenix_global_panel', 'priority' => 2, ]); $wp_customize->add_setting('body_font_family', [ 'default' => 'Arial, sans-serif', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $fonts_array = blnx_get_google_fonts_list(); $web_safe_fonts = [ 'Arial, sans-serif' => 'Arial', 'Helvetica, sans-serif' => 'Helvetica', 'Georgia, serif' => 'Georgia', 'Times New Roman, serif' => 'Times New Roman', 'system-ui, sans-serif' => 'System UI' ]; $fonts_array = array_merge($web_safe_fonts, $fonts_array); $wp_customize->add_control('body_font_family', [ 'label' => __('Body Font Family', 'blockenix'), 'section' => 'blockenix_global_typography', 'type' => 'select', 'choices' => $fonts_array ]); $wp_customize->add_setting('body_font_size', [ 'default' => '16', 'transport' => 'refresh', 'sanitize_callback' => 'absint', ]); $wp_customize->add_control('body_font_size', [ 'label' => __('Body Font Size (px)', 'blockenix'), 'description' => __('Note: Use responsive font sizes below for device-specific control.', 'blockenix'), 'section' => 'blockenix_global_typography', 'type' => 'number', 'input_attrs' => [ 'min' => 12, 'max' => 24, 'step' => 1, ], 'priority' => 5, ]); // Line Height $wp_customize->add_setting('body_line_height', [ 'default' => '1.6', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('body_line_height', [ 'label' => __('Body Line Height', 'blockenix'), 'section' => 'blockenix_global_typography', 'type' => 'number', 'input_attrs' => [ 'min' => 1, 'max' => 2, 'step' => 0.1, ], ]); // Body Font Weight $wp_customize->add_setting('body_font_weight', [ 'default' => '400', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('body_font_weight', [ 'label' => __('Body Font Weight', 'blockenix'), 'section' => 'blockenix_global_typography', 'type' => 'select', 'choices' => [ '100' => __('Thin (100)', 'blockenix'), '200' => __('Extra Light (200)', 'blockenix'), '300' => __('Light (300)', 'blockenix'), '400' => __('Normal (400)', 'blockenix'), '500' => __('Medium (500)', 'blockenix'), '600' => __('Semi Bold (600)', 'blockenix'), '700' => __('Bold (700)', 'blockenix'), '800' => __('Extra Bold (800)', 'blockenix'), '900' => __('Black (900)', 'blockenix'), ], ]); // Body Font Style $wp_customize->add_setting('body_font_style', [ 'default' => 'normal', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('body_font_style', [ 'label' => __('Body Font Style', 'blockenix'), 'section' => 'blockenix_global_typography', 'type' => 'select', 'choices' => [ 'normal' => __('Normal', 'blockenix'), 'italic' => __('Italic', 'blockenix'), 'oblique' => __('Oblique', 'blockenix'), ], ]); // Body Text Alignment $wp_customize->add_setting('body_text_align', [ 'default' => 'left', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('body_text_align', [ 'label' => __('Body Text Alignment', 'blockenix'), 'section' => 'blockenix_global_typography', 'type' => 'select', 'choices' => [ 'left' => __('Left', 'blockenix'), 'center' => __('Center', 'blockenix'), 'right' => __('Right', 'blockenix'), 'justify' => __('Justify', 'blockenix'), ], ]); // Responsive Font Sizes for Body - Single control with device switching $wp_customize->add_setting('body_font_size_desktop', [ 'default' => '16', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('body_font_size_tablet', [ 'default' => '15', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('body_font_size_mobile', [ 'default' => '14', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_control(new Blockenix_Responsive_Control($wp_customize, 'body_font_size', [ 'label' => __('Body Font Size (px)', 'blockenix'), 'section' => 'blockenix_global_typography', 'setting' => 'body_font_size_desktop', // Default setting for compatibility 'responsive_settings' => [ 'desktop' => 'body_font_size_desktop', 'tablet' => 'body_font_size_tablet', 'mobile' => 'body_font_size_mobile', ], 'defaults' => [ 'desktop' => '16', 'tablet' => '15', 'mobile' => '14', ], 'input_attrs' => [ 'min' => 10, 'max' => 24, 'step' => 1, ], ])); // Heading Font Family Setting $wp_customize->add_setting('heading_font_family', [ 'default' => 'system-ui, sans-serif', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $heading_fonts_array = blnx_get_google_fonts_list(); $heading_web_safe_fonts = [ 'Arial, sans-serif' => 'Arial', 'Helvetica, sans-serif' => 'Helvetica', 'Georgia, serif' => 'Georgia', 'Times New Roman, serif' => 'Times New Roman', 'system-ui, sans-serif' => 'System UI' ]; $heading_fonts_array = array_merge($heading_web_safe_fonts, $heading_fonts_array); $wp_customize->add_control('heading_font_family', [ 'label' => __('Heading Font Family', 'blockenix'), 'section' => 'blockenix_global_typography', 'type' => 'select', 'choices' => $heading_fonts_array, 'priority' => 10 ]); // Individual heading settings $heading_tags = [ 'h1' => __('H1', 'blockenix'), 'h2' => __('H2', 'blockenix'), 'h3' => __('H3', 'blockenix'), 'h4' => __('H4', 'blockenix'), 'h5' => __('H5', 'blockenix'), 'h6' => __('H6', 'blockenix') ]; foreach ($heading_tags as $tag => $label) { // Font size $wp_customize->add_setting($tag . '_font_size', [ 'default' => ($tag === 'h1' ? 32 : ($tag === 'h2' ? 28 : ($tag === 'h3' ? 24 : ($tag === 'h4' ? 20 : ($tag === 'h5' ? 18 : 16))))), 'transport' => 'refresh', 'sanitize_callback' => 'absint', ]); $wp_customize->add_control($tag . '_font_size', [ 'label' => sprintf(__('%s Font Size (px)', 'blockenix'), $label), 'section' => 'blockenix_global_typography', 'type' => 'number', 'input_attrs' => [ 'min' => 12, 'max' => 72, 'step' => 1, ], ]); // Line height $wp_customize->add_setting($tag . '_line_height', [ 'default' => 1.2, 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control($tag . '_line_height', [ 'label' => sprintf(__('%s Line Height', 'blockenix'), $label), 'section' => 'blockenix_global_typography', 'type' => 'number', 'input_attrs' => [ 'min' => 1, 'max' => 2, 'step' => 0.1, ], ]); // Font Weight $wp_customize->add_setting($tag . '_font_weight', [ 'default' => ($tag === 'h1' || $tag === 'h2' ? '700' : '600'), 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control($tag . '_font_weight', [ 'label' => sprintf(__('%s Font Weight', 'blockenix'), $label), 'section' => 'blockenix_global_typography', 'type' => 'select', 'choices' => [ '100' => __('Thin (100)', 'blockenix'), '200' => __('Extra Light (200)', 'blockenix'), '300' => __('Light (300)', 'blockenix'), '400' => __('Normal (400)', 'blockenix'), '500' => __('Medium (500)', 'blockenix'), '600' => __('Semi Bold (600)', 'blockenix'), '700' => __('Bold (700)', 'blockenix'), '800' => __('Extra Bold (800)', 'blockenix'), '900' => __('Black (900)', 'blockenix'), ], ]); // Font Style $wp_customize->add_setting($tag . '_font_style', [ 'default' => 'normal', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control($tag . '_font_style', [ 'label' => sprintf(__('%s Font Style', 'blockenix'), $label), 'section' => 'blockenix_global_typography', 'type' => 'select', 'choices' => [ 'normal' => __('Normal', 'blockenix'), 'italic' => __('Italic', 'blockenix'), 'oblique' => __('Oblique', 'blockenix'), ], ]); // Text Alignment $wp_customize->add_setting($tag . '_text_align', [ 'default' => 'left', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control($tag . '_text_align', [ 'label' => sprintf(__('%s Text Alignment', 'blockenix'), $label), 'section' => 'blockenix_global_typography', 'type' => 'select', 'choices' => [ 'left' => __('Left', 'blockenix'), 'center' => __('Center', 'blockenix'), 'right' => __('Right', 'blockenix'), 'justify' => __('Justify', 'blockenix'), ], ]); // Responsive Font Sizes - Single control with device switching $desktop_default = absint($tag === 'h1' ? 32 : ($tag === 'h2' ? 28 : ($tag === 'h3' ? 24 : ($tag === 'h4' ? 20 : ($tag === 'h5' ? 18 : 16))))); $tablet_default = absint($tag === 'h1' ? 28 : ($tag === 'h2' ? 26 : ($tag === 'h3' ? 22 : ($tag === 'h4' ? 19 : ($tag === 'h5' ? 17 : 15))))); $mobile_default = absint($tag === 'h1' ? 24 : ($tag === 'h2' ? 22 : ($tag === 'h3' ? 20 : ($tag === 'h4' ? 18 : ($tag === 'h5' ? 16 : 14))))); $wp_customize->add_setting($tag . '_font_size_desktop', [ 'default' => $desktop_default, 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting($tag . '_font_size_tablet', [ 'default' => $tablet_default, 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting($tag . '_font_size_mobile', [ 'default' => $mobile_default, 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_control(new Blockenix_Responsive_Control($wp_customize, $tag . '_font_size', [ 'label' => sprintf(__('%s Font Size (px)', 'blockenix'), $label), 'section' => 'blockenix_global_typography', 'setting' => $tag . '_font_size_desktop', // Default setting for compatibility 'responsive_settings' => [ 'desktop' => $tag . '_font_size_desktop', 'tablet' => $tag . '_font_size_tablet', 'mobile' => $tag . '_font_size_mobile', ], 'defaults' => [ 'desktop' => $desktop_default, 'tablet' => $tablet_default, 'mobile' => $mobile_default, ], 'input_attrs' => [ 'min' => 10, 'max' => 72, 'step' => 1, ], ])); } $global_colors = [ 'text' => ['#374151', __('Text Color', 'blockenix')], ]; foreach ($global_colors as $color => $values) { $wp_customize->add_setting("global_{$color}_color", [ 'default' => $values[0], 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, "global_{$color}_color", [ 'label' => $values[1], 'section' => 'blockenix_global_colors', 'settings' => "global_{$color}_color", ])); } // Heading Text Color Setting $wp_customize->add_setting('heading_text_color', [ 'default' => '#2563eb', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'heading_text_color', [ 'label' => __('Heading Text Color', 'blockenix'), 'section' => 'blockenix_global_colors', 'settings' => 'heading_text_color', ])); // Button Settings Section $wp_customize->add_section('blockenix_button_settings', [ 'title' => __('Button Settings', 'blockenix'), 'panel' => 'blockenix_global_panel', 'priority' => 3, 'description' => __('Customize button appearance including colors, typography, spacing, and borders.', 'blockenix'), ]); // Button Background Color $wp_customize->add_setting('button_bg_color', [ 'default' => '#2563eb', 'transport' => 'postMessage', 'sanitize_callback' => 'blnx_sanitize_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'button_bg_color', [ 'label' => __('Button Background Color', 'blockenix'), 'section' => 'blockenix_button_settings', 'settings' => 'button_bg_color', ])); // Button Hover Background Color $wp_customize->add_setting('button_hover_bg_color', [ 'default' => '#1d4ed8', 'transport' => 'postMessage', 'sanitize_callback' => 'blnx_sanitize_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'button_hover_bg_color', [ 'label' => __('Button Hover Background Color', 'blockenix'), 'section' => 'blockenix_button_settings', 'settings' => 'button_hover_bg_color', ])); // Button Text Color $wp_customize->add_setting('button_text_color', [ 'default' => '#ffffff', 'transport' => 'postMessage', 'sanitize_callback' => 'blnx_sanitize_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'button_text_color', [ 'label' => __('Button Text Color', 'blockenix'), 'section' => 'blockenix_button_settings', 'settings' => 'button_text_color', ])); // Button Text Hover Color $wp_customize->add_setting('button_text_hover_color', [ 'default' => '#ffffff', 'transport' => 'postMessage', 'sanitize_callback' => 'blnx_sanitize_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'button_text_hover_color', [ 'label' => __('Button Text Hover Color', 'blockenix'), 'section' => 'blockenix_button_settings', 'settings' => 'button_text_hover_color', ])); // Button Font Family $wp_customize->add_setting('button_font_family', [ 'default' => 'Arial, sans-serif', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $fonts_array = blnx_get_google_fonts_list(); $web_safe_fonts = [ 'Arial, sans-serif' => 'Arial', 'Helvetica, sans-serif' => 'Helvetica', 'Georgia, serif' => 'Georgia', 'Times New Roman, serif' => 'Times New Roman', 'system-ui, sans-serif' => 'System UI' ]; $fonts_array = array_merge($web_safe_fonts, $fonts_array); $wp_customize->add_control('button_font_family', [ 'label' => __('Button Font Family', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'select', 'choices' => $fonts_array, ]); // Button Font Size (Responsive) $wp_customize->add_setting('button_font_size_desktop', [ 'default' => '16', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('button_font_size_tablet', [ 'default' => '15', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('button_font_size_mobile', [ 'default' => '14', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_control(new Blockenix_Responsive_Control($wp_customize, 'button_font_size', [ 'label' => __('Button Font Size (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'responsive_settings' => [ 'desktop' => 'button_font_size_desktop', 'tablet' => 'button_font_size_tablet', 'mobile' => 'button_font_size_mobile', ], 'defaults' => [ 'desktop' => '16', 'tablet' => '15', 'mobile' => '14', ], 'input_attrs' => [ 'min' => 10, 'max' => 24, 'step' => 1, ], ])); // Button Alignment $wp_customize->add_setting('button_text_align', [ 'default' => 'left', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('button_text_align', [ 'label' => __('Button Alignment', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'select', 'choices' => [ 'left' => __('Left', 'blockenix'), 'center' => __('Center', 'blockenix'), 'right' => __('Right', 'blockenix'), 'justify' => __('Justify', 'blockenix'), ], ]); // Button Font Weight $wp_customize->add_setting('button_font_weight', [ 'default' => '600', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('button_font_weight', [ 'label' => __('Button Font Weight', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'select', 'choices' => [ '100' => __('Thin (100)', 'blockenix'), '200' => __('Extra Light (200)', 'blockenix'), '300' => __('Light (300)', 'blockenix'), '400' => __('Normal (400)', 'blockenix'), '500' => __('Medium (500)', 'blockenix'), '600' => __('Semi Bold (600)', 'blockenix'), '700' => __('Bold (700)', 'blockenix'), '800' => __('Extra Bold (800)', 'blockenix'), '900' => __('Black (900)', 'blockenix'), ], ]); // Button Font Style $wp_customize->add_setting('button_font_style', [ 'default' => 'normal', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('button_font_style', [ 'label' => __('Button Font Style', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'select', 'choices' => [ 'normal' => __('Normal', 'blockenix'), 'italic' => __('Italic', 'blockenix'), 'oblique' => __('Oblique', 'blockenix'), ], ]); // Button Padding $wp_customize->add_setting('button_padding_top', [ 'default' => '12', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('button_padding_right', [ 'default' => '24', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('button_padding_bottom', [ 'default' => '12', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('button_padding_left', [ 'default' => '24', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_control('button_padding_top', [ 'label' => __('Button Padding Top (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ]); $wp_customize->add_control('button_padding_right', [ 'label' => __('Button Padding Right (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ]); $wp_customize->add_control('button_padding_bottom', [ 'label' => __('Button Padding Bottom (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ]); $wp_customize->add_control('button_padding_left', [ 'label' => __('Button Padding Left (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ]); // Button Margin $wp_customize->add_setting('button_margin_top', [ 'default' => '0', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('button_margin_right', [ 'default' => '0', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('button_margin_bottom', [ 'default' => '0', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('button_margin_left', [ 'default' => '0', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_control('button_margin_top', [ 'label' => __('Button Margin Top (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ]); $wp_customize->add_control('button_margin_right', [ 'label' => __('Button Margin Right (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ]); $wp_customize->add_control('button_margin_bottom', [ 'label' => __('Button Margin Bottom (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ]); $wp_customize->add_control('button_margin_left', [ 'label' => __('Button Margin Left (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ]); // Button Border $wp_customize->add_setting('button_border_width', [ 'default' => '1', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_setting('button_border_style', [ 'default' => 'solid', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_setting('button_border_color', [ 'default' => '#2563eb', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color', ]); $wp_customize->add_setting('button_border_radius', [ 'default' => '4', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ]); $wp_customize->add_control('button_border_width', [ 'label' => __('Button Border Width (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 10, 'step' => 1, ], ]); $wp_customize->add_control('button_border_style', [ 'label' => __('Button Border Style', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'select', 'choices' => [ 'none' => __('None', 'blockenix'), 'solid' => __('Solid', 'blockenix'), 'dashed' => __('Dashed', 'blockenix'), 'dotted' => __('Dotted', 'blockenix'), 'double' => __('Double', 'blockenix'), ], ]); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'button_border_color', [ 'label' => __('Button Border Color', 'blockenix'), 'section' => 'blockenix_button_settings', 'settings' => 'button_border_color', ])); $wp_customize->add_control('button_border_radius', [ 'label' => __('Button Border Radius (px)', 'blockenix'), 'section' => 'blockenix_button_settings', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 50, 'step' => 1, ], ]); } // Register customizer settings add_action('customize_register', 'blnx_customize_register'); add_action('customize_register', 'blnx_customize_layout_settings'); /** * Sanitize color input - handles hex colors and 'transparent' */ function blnx_sanitize_color($color) { if (empty($color) || is_array($color)) { return 'transparent'; } if ('transparent' === $color) { return $color; } return sanitize_hex_color($color); } /** * Sanitize container type input */ function blnx_sanitize_container_type($input) { $valid = ['container', 'container-fluid', 'custom-width']; return in_array($input, $valid) ? $input : 'container'; } /** * Get Google Fonts list directly from Google Fonts API * Fetches all available fonts from https://fonts.google.com/ * Uses caching for performance and falls back to curated list if API fails */ function blnx_get_google_fonts_list() { // Check if cached fonts exist $cached_fonts = get_transient('blockenix_google_fonts'); if (false !== $cached_fonts && !empty($cached_fonts)) { return $cached_fonts; } $fonts_array = []; // Fetch from Google Fonts public metadata endpoint (no API key required) $public_fonts_url = 'https://fonts.google.com/metadata/fonts'; $response = wp_remote_get($public_fonts_url, [ 'timeout' => 15, 'sslverify' => true, 'headers' => [ 'Accept' => 'application/json', ], ]); if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) === 200) { $fonts_data = json_decode(wp_remote_retrieve_body($response), true); if (!empty($fonts_data['familyMetadataList']) && is_array($fonts_data['familyMetadataList'])) { foreach ($fonts_data['familyMetadataList'] as $font) { if (isset($font['family'])) { $fonts_array[$font['family']] = $font['family']; } } } } // Fallback to curated list if API method fails if (empty($fonts_array)) { $fonts_array = [ 'Inter', 'Roboto', 'Open Sans', 'Lato', 'Montserrat', 'Raleway', 'Poppins', 'Source Sans Pro', 'Nunito', 'Ubuntu', 'Oswald', 'Playfair Display', 'Merriweather', 'Work Sans', 'DM Sans', 'Manrope', 'Plus Jakarta Sans', 'Figtree', 'Space Grotesk', 'Outfit', 'Lora', 'Crimson Text', 'Libre Baskerville', 'PT Serif', 'Roboto Slab', 'Bitter', 'Bebas Neue', 'Anton', 'Righteous', 'Fredoka One', 'Bungee', 'Roboto Mono', 'Source Code Pro', 'Fira Code', 'Dancing Script', 'Pacifico', 'Caveat', 'Kalam', 'Comfortaa', 'Quicksand', 'Muli', 'Rubik', 'Fira Sans', 'PT Sans', 'Noto Sans', 'Dosis', 'Arimo', 'Titillium Web', 'Varela Round', 'Exo', 'Rajdhani', 'Abel', 'Josefin Sans', 'Libre Franklin', 'Hind', ]; } // Format fonts for dropdown: "Font Name, fallback" => "Font Name" // We'll determine fallback based on font category $formatted_fonts = []; $serif_keywords = ['serif', 'slab', 'baskerville', 'crimson', 'lora', 'merriweather', 'bitter', 'playfair']; $mono_keywords = ['mono', 'code']; $handwriting_keywords = ['script', 'dancing', 'pacifico', 'caveat', 'kalam', 'comfortaa']; foreach ($fonts_array as $font_name) { $font_lower = strtolower($font_name); $is_serif = false; $is_mono = false; $is_handwriting = false; foreach ($serif_keywords as $keyword) { if (strpos($font_lower, $keyword) !== false) { $is_serif = true; break; } } foreach ($mono_keywords as $keyword) { if (strpos($font_lower, $keyword) !== false) { $is_mono = true; break; } } foreach ($handwriting_keywords as $keyword) { if (strpos($font_lower, $keyword) !== false) { $is_handwriting = true; break; } } if ($is_serif) { $formatted_fonts[$font_name . ', serif'] = $font_name; } elseif ($is_mono) { $formatted_fonts[$font_name . ', monospace'] = $font_name; } elseif ($is_handwriting) { $formatted_fonts[$font_name . ', cursive'] = $font_name; } else { $formatted_fonts[$font_name . ', sans-serif'] = $font_name; } } // Sort alphabetically for better UX ksort($formatted_fonts); // Cache for 7 days (refresh more frequently to get new fonts) set_transient('blockenix_google_fonts', $formatted_fonts, 7 * DAY_IN_SECONDS); return $formatted_fonts; } /** * Enqueue customizer styles with device icons */ function blnx_customizer_styles() { // Ensure Dashicons are loaded wp_enqueue_style('dashicons'); wp_add_inline_style('customize-controls', ' /* Mobile Icon - Using Dashicons smartphone */ #customize-control-body_font_size_mobile .customize-control-title::before, #customize-control-h1_font_size_mobile .customize-control-title::before, #customize-control-h2_font_size_mobile .customize-control-title::before, #customize-control-h3_font_size_mobile .customize-control-title::before, #customize-control-h4_font_size_mobile .customize-control-title::before, #customize-control-h5_font_size_mobile .customize-control-title::before, #customize-control-h6_font_size_mobile .customize-control-title::before { content: "\\f470"; font-family: "dashicons"; display: inline-block; margin-right: 8px; font-size: 18px; vertical-align: middle; line-height: 1; color: #555; } /* Tablet Icon - Using Dashicons tablet */ #customize-control-body_font_size_tablet .customize-control-title::before, #customize-control-h1_font_size_tablet .customize-control-title::before, #customize-control-h2_font_size_tablet .customize-control-title::before, #customize-control-h3_font_size_tablet .customize-control-title::before, #customize-control-h4_font_size_tablet .customize-control-title::before, #customize-control-h5_font_size_tablet .customize-control-title::before, #customize-control-h6_font_size_tablet .customize-control-title::before { content: "\\f471"; font-family: "dashicons"; display: inline-block; margin-right: 8px; font-size: 18px; vertical-align: middle; line-height: 1; color: #555; } /* Desktop Icon - Using Dashicons desktop */ #customize-control-body_font_size_desktop .customize-control-title::before, #customize-control-h1_font_size_desktop .customize-control-title::before, #customize-control-h2_font_size_desktop .customize-control-title::before, #customize-control-h3_font_size_desktop .customize-control-title::before, #customize-control-h4_font_size_desktop .customize-control-title::before, #customize-control-h5_font_size_desktop .customize-control-title::before, #customize-control-h6_font_size_desktop .customize-control-title::before { content: "\\f472"; font-family: "dashicons"; display: inline-block; margin-right: 8px; font-size: 18px; vertical-align: middle; line-height: 1; color: #555; } '); } add_action('customize_controls_enqueue_scripts', 'blnx_customizer_styles');