<?php

//========================== Single Blog ============================================//

// Add Single Blog Page Settings Section (only once)
$wp_customize->add_section('neatnote_single_blog_setting', array(
    'title'    => __('Single Blog Page Settings', 'neatnote'),
    'priority' => 30,
    'panel'    => 'neatnote_theme_options_panel',
));

// Enable/Disable Social Share Icons
$wp_customize->add_setting('neatnote_enable_social_share', array(
    'default'           => false,
    'sanitize_callback' => 'wp_validate_boolean',
));

$wp_customize->add_control('neatnote_enable_social_share', array(
    'type'    => 'checkbox',
    'label'   => __('Enable Social Share Icons', 'neatnote'),
    'section' => 'neatnote_single_blog_setting',
));

// Define social networks
$social_networks = [
    'facebook'  => __('Facebook', 'neatnote'),
    'twitter'   => __('Twitter', 'neatnote'),
    'linkedin'  => __('LinkedIn', 'neatnote'),
    'tumblr'    => __('Tumblr', 'neatnote'),
    'whatsapp'  => __('WhatsApp', 'neatnote'),
    'telegram'  => __('Telegram', 'neatnote'),
    'email'     => __('Email', 'neatnote'),
];

foreach ($social_networks as $network => $label) {
    $wp_customize->add_setting("neatnote_social_share_{$network}", array(
        'default'           => false,
        'sanitize_callback' => 'wp_validate_boolean',
    ));

    $wp_customize->add_control("neatnote_social_share_{$network}", array(
        'type'    => 'checkbox',
        'label'   => $label,
        'section' => 'neatnote_single_blog_setting',
        'active_callback' => function () {
            return get_theme_mod('neatnote_enable_social_share', false);
        },
    ));
}

// Color Options for Blog Page
$color_options = array(
    'font_color'                => __('Font Color', 'neatnote'),
    'social_media_color'        => __('Social Media Color', 'neatnote'),
    'social_media_hover_color'  => __('Social Media Hover Color', 'neatnote'),
    'post_content_list_color'   => __('List Color', 'neatnote'),
);

foreach ($color_options as $setting_key => $label) {
    $wp_customize->add_setting("neatnote_{$setting_key}", array(
        'default'           => '#000000',
        'sanitize_callback' => 'sanitize_hex_color',
    ));

    $wp_customize->add_control(new WP_Customize_Color_Control(
        $wp_customize,
        "neatnote_{$setting_key}",
        array(
            'label'    => $label,
            'section'  => 'neatnote_single_blog_setting',
            'settings' => "neatnote_{$setting_key}",
        )
    ));
}
