<?php
/**
* Header Banner Options.
*
* @package Cargo And Shipping Company
*/

$cargo_and_shipping_company_default = cargo_and_shipping_company_get_default_theme_options();
$cargo_and_shipping_company_post_category_list = cargo_and_shipping_company_post_category_list();

$wp_customize->add_section( 'cargo_and_shipping_company_header_slider_setting',
    array(
    'title'      => esc_html__( 'Slider Settings', 'cargo-and-shipping-company' ),
    'priority'   => 10,
    'capability' => 'edit_theme_options',
    'panel'      => 'cargo_and_shipping_company_theme_home_pannel',
    )
);

// Show/Hide Site Logo
$wp_customize->add_setting('cargo_and_shipping_company_display_logo', array(
    'default'           => false,
    'capability'        => 'edit_theme_options',
    'sanitize_callback' => 'cargo_and_shipping_company_sanitize_checkbox',
));
$wp_customize->add_control('cargo_and_shipping_company_display_logo', array(
    'label'    => esc_html__('Enable / Disable Site Logo', 'cargo-and-shipping-company'),
    'section'  => 'title_tagline',
    'type'     => 'checkbox',
));

// Show/Hide Site Title
$wp_customize->add_setting('cargo_and_shipping_company_display_title', array(
    'default'           => true,
    'capability'        => 'edit_theme_options',
    'sanitize_callback' => 'cargo_and_shipping_company_sanitize_checkbox',
));
$wp_customize->add_control('cargo_and_shipping_company_display_title', array(
    'label'    => esc_html__('Enable / Disable Site Title', 'cargo-and-shipping-company'),
    'section'  => 'title_tagline',
    'type'     => 'checkbox',
));

// Show/Hide Site Tagline
$wp_customize->add_setting('cargo_and_shipping_company_display_header_text',
    array(
        'default'           => false,
        'capability' => 'edit_theme_options',
        'sanitize_callback' => 'cargo_and_shipping_company_sanitize_checkbox',
    )
);
$wp_customize->add_control('cargo_and_shipping_company_display_header_text',
    array(
        'label' => esc_html__('Enable / Disable Site Tagline', 'cargo-and-shipping-company'),
        'section' => 'title_tagline',
        'type' => 'checkbox',
    )
);

$wp_customize->add_setting('cargo_and_shipping_company_header_slider',
    array(
        'default' => $cargo_and_shipping_company_default['cargo_and_shipping_company_header_slider'],
        'capability' => 'edit_theme_options',
        'sanitize_callback' => 'cargo_and_shipping_company_sanitize_checkbox',
    )
);
$wp_customize->add_control('cargo_and_shipping_company_header_slider',
    array(
        'label' => esc_html__('Enable Slider', 'cargo-and-shipping-company'),
        'section' => 'cargo_and_shipping_company_header_slider_setting',
        'type' => 'checkbox',
    )
);

// Get the number of sliders (default or saved)
$cargo_and_shipping_company_default['cargo_and_shipping_company_slider_count'] = 1;

// Slider Count Setting
$wp_customize->add_setting('cargo_and_shipping_company_slider_count', array(
    'default'           => $cargo_and_shipping_company_default['cargo_and_shipping_company_slider_count'],
    'capability'        => 'edit_theme_options',
    'sanitize_callback' => 'cargo_and_shipping_company_sanitize_number_range',
));
$wp_customize->add_control('cargo_and_shipping_company_slider_count', array(
    'label'       => esc_html__('Number of Sliders', 'cargo-and-shipping-company'),
    'section'     => 'cargo_and_shipping_company_header_slider_setting',
    'type'        => 'number',
    'input_attrs' => array(
        'min'   => 1,
        'max'   => 3,
        'step'  => 1,
    ),
    'description' => __('Set number of sliders, then publish and refresh to load fields.', 'cargo-and-shipping-company'),
));


$cargo_and_shipping_company_slider_count = get_theme_mod('cargo_and_shipping_company_slider_count', $cargo_and_shipping_company_default['cargo_and_shipping_company_slider_count']);

for ( $cargo_and_shipping_company_slide_i = 1; $cargo_and_shipping_company_slide_i <= $cargo_and_shipping_company_slider_count; $cargo_and_shipping_company_slide_i++ ) {

    // Slider Image
    $wp_customize->add_setting("cargo_and_shipping_company_slider_image_$cargo_and_shipping_company_slide_i", array(
        'default'           => '',
        'sanitize_callback' => 'esc_url_raw',
    ));
    $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, "cargo_and_shipping_company_slider_image_$cargo_and_shipping_company_slide_i", array(
        /* translators: %d: Sldier Image Count. */
        'label'   => sprintf(__('Slider Image %d', 'cargo-and-shipping-company'), $cargo_and_shipping_company_slide_i),
        'section' => 'cargo_and_shipping_company_header_slider_setting',
    )));

    // Short Title
    $wp_customize->add_setting("cargo_and_shipping_company_slider_short_title_$cargo_and_shipping_company_slide_i", array(
        'default'           => isset($cargo_and_shipping_company_default["cargo_and_shipping_company_slider_short_title_$cargo_and_shipping_company_slide_i"]) ? $cargo_and_shipping_company_default["cargo_and_shipping_company_slider_short_title_$cargo_and_shipping_company_slide_i"] : '',
        'sanitize_callback' => 'sanitize_text_field',
    ));
    $wp_customize->add_control("cargo_and_shipping_company_slider_short_title_$cargo_and_shipping_company_slide_i", array(
        /* translators: %d: Sldier Short Title Count. */
        'label'   => sprintf(__('Slider Short Title %d', 'cargo-and-shipping-company'), $cargo_and_shipping_company_slide_i),
        'section' => 'cargo_and_shipping_company_header_slider_setting',
        'type'    => 'text',
    ));

    // Main Title
    $wp_customize->add_setting("cargo_and_shipping_company_slider_title_$cargo_and_shipping_company_slide_i", array(
        'default'           => isset($cargo_and_shipping_company_default["cargo_and_shipping_company_slider_title_$cargo_and_shipping_company_slide_i"]) ? $cargo_and_shipping_company_default["cargo_and_shipping_company_slider_title_$cargo_and_shipping_company_slide_i"] : '',
        'sanitize_callback' => 'sanitize_text_field',
    ));
    $wp_customize->add_control("cargo_and_shipping_company_slider_title_$cargo_and_shipping_company_slide_i", array(
        /* translators: %d: Sldier Title Count. */
        'label'   => sprintf(__('Slider Title %d', 'cargo-and-shipping-company'), $cargo_and_shipping_company_slide_i),
        'section' => 'cargo_and_shipping_company_header_slider_setting',
        'type'    => 'text',
    ));

    // Content
    $wp_customize->add_setting("cargo_and_shipping_company_slider_content_$cargo_and_shipping_company_slide_i", array(
        'default'           => isset($cargo_and_shipping_company_default["cargo_and_shipping_company_slider_content_$cargo_and_shipping_company_slide_i"]) ? $cargo_and_shipping_company_default["cargo_and_shipping_company_slider_content_$cargo_and_shipping_company_slide_i"] : '',
        'sanitize_callback' => 'sanitize_text_field',
    ));
    $wp_customize->add_control("cargo_and_shipping_company_slider_content_$cargo_and_shipping_company_slide_i", array(
        /* translators: %d: Sldier Content Count. */
        'label'   => sprintf(__('Slider Content %d', 'cargo-and-shipping-company'), $cargo_and_shipping_company_slide_i),
        'section' => 'cargo_and_shipping_company_header_slider_setting',
        'type'    => 'text',
    ));

    // Button Text
    $wp_customize->add_setting("cargo_and_shipping_company_slider_btn_text_$cargo_and_shipping_company_slide_i", array(
        'default'           => isset($cargo_and_shipping_company_default["cargo_and_shipping_company_slider_btn_text_$cargo_and_shipping_company_slide_i"]) ? $cargo_and_shipping_company_default["cargo_and_shipping_company_slider_btn_text_$cargo_and_shipping_company_slide_i"] : '',
        'sanitize_callback' => 'sanitize_text_field',
    ));
    $wp_customize->add_control("cargo_and_shipping_company_slider_btn_text_$cargo_and_shipping_company_slide_i", array(
        /* translators: %d: Sldier Button Text Count. */
        'label'   => sprintf(__('Slider Button Text %d', 'cargo-and-shipping-company'), $cargo_and_shipping_company_slide_i),
        'section' => 'cargo_and_shipping_company_header_slider_setting',
        'type'    => 'text',
    ));

    // Button URL
    $wp_customize->add_setting("cargo_and_shipping_company_slider_btn_url_$cargo_and_shipping_company_slide_i", array(
        'default'           => isset($cargo_and_shipping_company_default["cargo_and_shipping_company_slider_btn_url_$cargo_and_shipping_company_slide_i"]) ? $cargo_and_shipping_company_default["cargo_and_shipping_company_slider_btn_url_$cargo_and_shipping_company_slide_i"] : '',
        'sanitize_callback' => 'esc_url_raw',
    ));
    $wp_customize->add_control("cargo_and_shipping_company_slider_btn_url_$cargo_and_shipping_company_slide_i", array(
        /* translators: %d: Slider Button URL Count. */
        'label'   => sprintf(__('Slider Button URL %d', 'cargo-and-shipping-company'), $cargo_and_shipping_company_slide_i),
        'section' => 'cargo_and_shipping_company_header_slider_setting',
        'type'    => 'url',
    ));
}

// Services Settings

$wp_customize->add_section( 'cargo_and_shipping_company_about_us_setting',
    array(
    'title'      => esc_html__( 'Services Settings', 'cargo-and-shipping-company' ),
    'priority'   => 10,
    'capability' => 'edit_theme_options',
    'panel'      => 'cargo_and_shipping_company_theme_home_pannel',
    )
);

$wp_customize->add_setting('cargo_and_shipping_company_header_about_us',
    array(
        'default' => $cargo_and_shipping_company_default['cargo_and_shipping_company_header_about_us'],
        'capability' => 'edit_theme_options',
        'sanitize_callback' => 'cargo_and_shipping_company_sanitize_checkbox',
    )
);
$wp_customize->add_control('cargo_and_shipping_company_header_about_us',
    array(
        'label' => esc_html__('Enable Services', 'cargo-and-shipping-company'),
        'section' => 'cargo_and_shipping_company_about_us_setting',
        'type' => 'checkbox',
    )
);

$wp_customize->add_setting( 'cargo_and_shipping_company_about_us_section_title',
    array(
    'default'           => $cargo_and_shipping_company_default['cargo_and_shipping_company_about_us_section_title'],
    'capability'        => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
    )
);
$wp_customize->add_control( 'cargo_and_shipping_company_about_us_section_title',
    array(
    'label'    => esc_html__( 'Services Short Title', 'cargo-and-shipping-company' ),
    'section'  => 'cargo_and_shipping_company_about_us_setting',
    'type'     => 'text',
    )
);

$wp_customize->add_setting( 'cargo_and_shipping_company_about_us_section_sub_title',
    array(
    'default'           => $cargo_and_shipping_company_default['cargo_and_shipping_company_about_us_section_sub_title'],
    'capability'        => 'edit_theme_options',
    'sanitize_callback' => 'sanitize_text_field',
    )
);
$wp_customize->add_control( 'cargo_and_shipping_company_about_us_section_sub_title',
    array(
    'label'    => esc_html__( 'Services Heading', 'cargo-and-shipping-company' ),
    'section'  => 'cargo_and_shipping_company_about_us_setting',
    'type'     => 'text',
    )
);

$categories = get_categories();
$cat_post = array();
$cat_post[]= 'select';
$m = 0;
foreach($categories as $category){
    if($m==0){
        $default = $category->slug;
        $m++;
    }
    $cat_post[$category->slug] = $category->name;
}

$wp_customize->add_setting('cargo_and_shipping_company_video_section_left_post_cat',array(
    'default'   => 'select',
    'sanitize_callback' => 'cargo_and_shipping_company_sanitize_select',
));
$wp_customize->add_control('cargo_and_shipping_company_video_section_left_post_cat' ,array(
    'type'    => 'select',
    'choices' => $cat_post,
    'label' => __('Select Category to display Services','cargo-and-shipping-company'),
    'section' => 'cargo_and_shipping_company_about_us_setting',
));