<?php
/**
 * Createing a bog pannel for customizer
 *
 *
 */
$categories = get_categories(array('hide_empty' => 0));
foreach ($categories as $category) {
	$cat[$category->term_id] = $category->cat_name;
}
/****************************/
// START BLOG SECTION FOR HOME PAGE
/*============BLOG PANEL============*/
$wp_customize->add_section(
	'dinero_blog_section',
	array(
		'title' => __( 'Blog Posts', 'luzuk-premium' ),
		'panel' => 'luzuk_premium_home_panel1',
     	'priority' =>30
	)
);

$wp_customize->add_setting('dinero_reset_blog_settings',array(
  'sanitize_callback'   => 'sanitize_text_field'
));
$wp_customize->add_control(new dinero_Reset_Custom_Control($wp_customize, 'dinero_reset_blog_settings',array(
  'type' => 'reset_control',
   'priority' => 1,
  'label' => __('Reset Blog Section Settings', 'dinero'),
  'description' => 'dinero_blog_reset_settings',
  'section' => 'dinero_blog_section'
)));

$wp_customize->add_setting('luzuk_blog_nav', array(
       'sanitize_callback' => 'wp_kses_post',
    ));

    $wp_customize->add_control(new luzuk_Tab_Control($wp_customize, 'luzuk_blog_nav', array(
       'section' => 'dinero_blog_section',
       'priority' => 1,
       'buttons' => array(
          array(
             'name' => esc_html__('General', 'luzuk-premium'),
            'icon' => 'dashicons dashicons-welcome-write-blog',
            'fields' => array(
                'dinero_blog_enable', 
                'blogs_maintitle',
                'dinero_blog_head_icon_enable',
                'dinero_blog_head_icon',
                'blogs_subtitle',
                'blog_post_count',
                'blog_cat_exclude'
            ),
            'active' => true,
         ),
          array(
            'name' => esc_html__('Style', 'luzuk-premium'),
            'icon' => 'dashicons dashicons-art',
            'fields' => array(     
                'dinero_blog_section_bg_color',
                'dinero_blog_section_bg_image',
                'dinero_blog_image_opacity',
                'dinero_blog_title_color1',
                'dinero_blog_title_color2',
                'dinero_blog_subtitle_color',
                'dinero_blog_box_onload_effects',
                'dinero_blog_head_align',
                'dinero_blog_content_align'
            ),
         ),
          array(
            'name' => esc_html__('Layout', 'luzuk-premium'),
            'icon' => 'dashicons dashicons-layout',
            'fields' => array(                
                'dinero_blog_padding',
                'dinero_blog_section_t_padding',
                'dinero_blog_section_b_padding',
                'dinero_blog_section_width',
                'dinero_blog_post_image_height',
                'dinero_blog_post_excerpt'
            ),
         )
        ),
    )));

$wp_customize->add_setting( 'dinero_blog_enable',array(
    'default' => true,
    'sanitize_callback' => 'dinero_switch_sanitization'
) );
$wp_customize->add_control( new Dinero_Toggle_Switch_Custom_Control( $wp_customize, 'dinero_blog_enable',array(
    'label' => __( 'Disable Section','dinero' ),
    'section' => 'dinero_blog_section'
)));

$wp_customize->add_setting(
    'blogs_maintitle',
    array(
        'sanitize_callback' => 'luzuk_sanitize_text',
        'default'           => __( 'My blogs', 'Luzuk' )
    )
);
$wp_customize->add_control(
    'blogs_maintitle',
    array(
        'settings'      => 'blogs_maintitle',
        'section'       => 'dinero_blog_section', 
        'type'          => 'text',
        'label'         => __( 'Section Heading', 'Luzuk' )
    )
);

$wp_customize->add_setting('dinero_blog_head_icon_enable',array(
        'default' => 'No',
        'sanitize_callback' => 'dinero_sanitize_choices',
    ));
    $wp_customize->add_control('dinero_blog_head_icon_enable',array(
        'type' => 'radio',
        'label' => __('Heading Icon Display','dinero'),
        'choices' => array (
            'No' => __('No','dinero'),
            'Yes' => __('Yes','dinero')        
        ),
        'section' => 'dinero_blog_section'
    ));
 $wp_customize->add_setting(
        'dinero_blog_head_icon',
        array(
            'default'           => 'fa fa-bell',
            'sanitize_callback' => 'luzuk_sanitize_text'
        )
    );        
    $wp_customize->add_control(
        new luzuk_Fontawesome_Icon_Chooser(
            $wp_customize,
            'dinero_blog_head_icon',
            array(
                // 'settings'      => 'dinero_blog_head_icon_enable',
                'section'       => 'dinero_blog_section',
                'type'          => 'icon',
                'label'         => __( 'FontAwesome Icon', 'luzuk-premium' ),
                'active_callback' => 'dinero_blog_type_icon'
            )
        )
    );


$wp_customize->add_setting(
    'blogs_subtitle',
    array(
        'sanitize_callback' => 'luzuk_sanitize_text',
        'default'           => __( 'CHOOSE AND EXPLORE', 'Luzuk' )
    )
);
$wp_customize->add_control(
    'blogs_subtitle',
    array(
        'settings'      => 'blogs_subtitle',
        'section'       => 'dinero_blog_section', 
        'type'          => 'text',
        'label'         => __( 'Section Sub Heading', 'Luzuk' )
    )
);
//BLOG SETTINGS
$wp_customize->add_setting(
    'blog_post_count',
    array(
        'default'           => '3',
        'sanitize_callback' => 'luzuk_sanitize_choices'
    )
);
$wp_customize->add_control(
    new luzuk_Dropdown_Chooser(
        $wp_customize,
        'blog_post_count',
        array(
            'settings'      => 'blog_post_count',
            'section'       => 'dinero_blog_section',
            'label'         => __( 'Number of Posts to show', 'luzuk-premium' ),
            'choices'       => $luzuk_post_count_choice
        )
    )
);
$wp_customize->add_setting(
    'blog_cat_exclude',
    array(
        'sanitize_callback' => 'luzuk_sanitize_text'
    )
);
$wp_customize->add_control(
    new luzuk_Customize_Checkbox_Multiple(
        $wp_customize,
        'blog_cat_exclude',
        array(
            'label' => __('Exclude Category from Blog Posts', 'luzuk-premium'),
            'section' => 'dinero_blog_section',
            'settings' => 'blog_cat_exclude',
            'choices' => $luzuk_cat
        )
    )
);

// CREATING A BLOG SECTION IN CUSTOMIZER FOR BLOG PAGES
$wp_customize->add_section(
    'premium_blog_area',
    array(
        'title' => __( 'Blog Page Settings', 'luzuk-premium' ),
        // 'panel' => 'luzuk_premium_home_panel'
        'priority' =>19
    )
);

$wp_customize->add_setting('blog_categories_settings', array('sanitize_callback' => 'luzuk_sanitize_text'));
$wp_customize->add_control('blog_categories_settings', array(
    'settings' => 'blog_categories_settings',
    'label'    => __('Posts on Blog Page', 'luzuk-premium'),
    'section'  => 'lpremium_blog_area',
    'type'     => 'radio',
    'choices'  => array(
        '0' => __('Excerpts','luzuk-premium'),
        '1' => __('Full Posts','luzuk-premium'),
    ),
));
// ADDING THE CATEGORY TO SELECT
$wp_customize->add_setting('blog_categories', array('sanitize_callback' => 'luzuk_sanitize_text'));
$wp_customize->add_control(
    new luzuk_Customize_Checkbox_Multiple(
        $wp_customize,
        'blog_categories',
        array(
            'label' => __('Exclude Category from Blog Posts', 'luzuk-premium'),
            'section' => 'premium_blog_area',
            'settings' => 'blog_categories',
            'choices' => $cat
        )
    )
);


// backgroundManager($wp_customize, 'blog', 'dinero_blog_section', $color='#fff', get_template_directory_uri().'/images/default-gray.png', 'img');

$wp_customize->add_setting( 'dinero_blog_section_bg_color', array(
       'default' => '',
       'sanitize_callback' => 'sanitize_hex_color'
    ));
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'dinero_blog_section_bg_color', array(
        'label' => __('Section Background Color','dinero'),
       'section' => 'dinero_blog_section',
    )));

    $wp_customize->add_setting( 'dinero_blog_section_bg_image', array(
       'default' => '',
       'sanitize_callback' => 'esc_url_raw'
    ));
    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'dinero_blog_section_bg_image', array(
        'label' => __('Section Background Image','dinero'),
       'section' => 'dinero_blog_section',
    )));


     $wp_customize->add_setting('dinero_blog_image_opacity',array(
        'default' => 1,
        'sanitize_callback' => 'dinero_sanitize_float'
    ));
    $wp_customize->add_control(new dinero_Custom_Control( $wp_customize, 'dinero_blog_image_opacity',array(
    'label' => __('Background Opacity','dinero'),
    'section' => 'dinero_blog_section',
    'input_attrs' => array(
            'min' => 0,
            'max' => 1,
            'step' => 0.1,
        ),
    )));


    $wp_customize->add_setting('dinero_blog_box_onload_effects',array(
        'default' => 'zoom-in',
        'sanitize_callback' => 'dinero_sanitize_choices',
    ));
    $wp_customize->add_control('dinero_blog_box_onload_effects',array(
        'type' => 'select',
        'label' => __('Onload Transition Effects','dinero'),
        'choices' => array (
            'wow bounceInLeft' => __('Bounce In Left','dinero'),
            'wow bounceInRight' => __('Bounce In Right','dinero'),
            'wow bounceInUp' => __('Bounce In Up','dinero'),
            'wow bounceInDown' => __('Bounce In Down','dinero'),
            'wow zoomIn' => __('Zoom In','dinero'),
            'wow zoomOut' => __('Zoom Out','dinero'),
            'wow fadeInDown' => __('Fade In Down','dinero'),            
            'wow fadeInUp' => __('Fade In Up','dinero'),
            'wow fadeInLeft' => __('Fade In Left','dinero'),
            'wow fadeInRight' => __('Fade In Right','dinero'),
            'flip-up' => __('Flip Up','dinero')
        ),
        'section' => 'dinero_blog_section',
    ));

 $wp_customize->add_setting('dinero_blog_head_align',array(
        'default' => 'Left',
        'sanitize_callback' => 'dinero_sanitize_choices',
    ));
    $wp_customize->add_control('dinero_blog_head_align',array(
        'type' => 'select',
        'label' => __('Section Head Alignment','dinero'),
        'choices' => array (
            'Center' => __('Center','dinero'),
            'Left' => __('Left','dinero'),
            'Right' => __('Right','dinero')
        ),
        'section' => 'dinero_blog_section',
    ));

    $wp_customize->add_setting('dinero_blog_content_align',array(
        'default' => 'Left',
        'sanitize_callback' => 'dinero_sanitize_choices',
    ));
    $wp_customize->add_control('dinero_blog_content_align',array(
        'type' => 'select',
        'label' => __('Content Box Alignment','dinero'),
        'choices' => array (
            'Center' => __('Center','dinero'),
            'Left' => __('Left','dinero'),
            'Right' => __('Right','dinero')
        ),
        'section' => 'dinero_blog_section',
    ));

 $wp_customize->add_setting('dinero_blog_post_image_height',array(
        'default' => 250,
        'sanitize_callback' => 'dinero_sanitize_integer'
    ));
    $wp_customize->add_control(new dinero_Custom_Control( $wp_customize, 'dinero_blog_post_image_height',array(
    'label' => __('Image Height','dinero'),
    'section' => 'dinero_blog_section',
    'input_attrs' => array(
            'min' => 0,
            'max' => 500,
            'step' => 1,
        ),
    )));

 $wp_customize->add_setting('dinero_blog_post_excerpt',array(
        'default' => 30,
        'sanitize_callback' => 'dinero_sanitize_integer'
    ));
    $wp_customize->add_control(new dinero_Custom_Control( $wp_customize, 'dinero_blog_post_excerpt',array(
    'label' => __('Excerpt Length','dinero'),
    'section' => 'dinero_blog_section',
    'input_attrs' => array(
            'min' => 0,
            'max' => 100,
            'step' => 1,
        ),
    )));


$wp_customize->add_setting('dinero_blog_padding',array(
      'sanitize_callback'   => 'esc_html'
   ));
   $wp_customize->add_control('dinero_blog_padding',array(
      'label' => __('Section Padding','dinero'),
      'section' => 'dinero_blog_section'
   ));

  $wp_customize->add_setting('dinero_blog_section_t_padding',array(
        'default' => '13',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('dinero_blog_section_t_padding',array(
    'type' => 'number',
    'label' => __('Top','dinero'),
    'section' => 'dinero_blog_section',
    ));
     $wp_customize->add_setting('dinero_blog_section_b_padding',array(
        'default' => '6',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('dinero_blog_section_b_padding',array(
    'type' => 'number',
    'label' => __('Bottom','dinero'),
    'section' => 'dinero_blog_section',
    ));

    $wp_customize->add_setting('dinero_blog_section_width',array(
        'default' => 'Box Width',
        'sanitize_callback' => 'dinero_sanitize_choices',
    ));
    $wp_customize->add_control('dinero_blog_section_width',array(
        'type' => 'select',
        'label' => __('Section Width','dinero'),
        'choices' => array (
            'Box Width' => __('Box Width','dinero'),
            'Full Width' => __('Full Width','dinero')
        ),
        'section' => 'dinero_blog_section',
    ));

addColorPalatOption($wp_customize, 'dinero_blog_title_color1', 'dinero_blog_section', 'Section Heading color 1 ', '');

addColorPalatOption($wp_customize, 'dinero_blog_title_color2', 'dinero_blog_section', 'Section Heading color 2 ', '');

addColorPalatOption($wp_customize, 'dinero_blog_subtitle_color', 'dinero_blog_section', 'Section Sub Heading color ', '');


?>