<?php

function health_customize_portfolio_tab($wp_customize, $theme_name) {

	$wp_customize->add_panel('health_portfolio_settings',
	array(
		'title' => esc_html__( 'Portfolio', 'health' ),
		'priority' => 55,
		)
	);

	// portfolio general settings
	$wp_customize->add_section( 'health_portfolio_general_settings' , array(
		'title'      => esc_html__( 'Portfolio General', 'health' ),
		'priority'   => 10,
		'panel' => 'health_portfolio_settings'
	) );

	$wp_customize->add_setting( 'health_portfolio_settings_thumb_width' , array(
		'default'     => '556',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_absinteger'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_thumb_width',
		array(
			'label'    => esc_html__( 'Portfolio Tumbnails Width (px)', 'health' ),
			'section'  => 'health_portfolio_general_settings',
			'settings' => 'health_portfolio_settings_thumb_width',
			'type'     => 'textfield',
			'description' => esc_html__( 'Default: 556px', 'health' ),
			'priority' => 10
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_thumb_height' , array(
		'default'     => '556',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_absinteger'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_thumb_height',
		array(
			'label'    => esc_html__( 'Portfolio Tumbnails Height (px)', 'health' ),
			'section'  => 'health_portfolio_general_settings',
			'settings' => 'health_portfolio_settings_thumb_height',
			'type'     => 'textfield',
			'description' => esc_html__( 'Default: 556px', 'health' ),
			'priority' => 20
		)
	);


	// portfolio categories page settings
	$wp_customize->add_section( 'health_portfolio_categories_settings' , array(
		'title'      => esc_html__( 'Portfolio Category and Archive Pages', 'health' ),
		'priority'   => 20,
		'panel' => 'health_portfolio_settings'
	) );

	$wp_customize->add_setting( 'health_portfolio_settings_type' , array(
		'default'     => 'type_without_icons',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_portfolio_type'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_type',
		array(
			'label'    => esc_html__( 'Item type', 'health' ),
			'section'  => 'health_portfolio_categories_settings',
			'settings' => 'health_portfolio_settings_type',
			'description' => esc_html__( 'Portfolio items per row for portfolio category and archive pages.', 'health' ),
			'type'     => 'select',
			'choices'  => array(
				'type_without_icons' => esc_html__( 'Without over icons with space', 'health' ),
				'type_without_space' => esc_html__( 'Without over icons and space', 'health' ),
				'type_with_icons' => esc_html__( 'With over icons', 'health' ),
			),
			'priority' => 10
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_perrow' , array(
		'default'     => '2',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_portfolio_perrow'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_perrow',
		array(
			'label'    => esc_html__( 'Portfolio Column Number', 'health' ),
			'section'  => 'health_portfolio_categories_settings',
			'settings' => 'health_portfolio_settings_perrow',
			'description' => esc_html__( 'Portfolio items per row for portfolio category and archive pages.', 'health' ),
			'type'     => 'select',
			'choices'  => array(
				'2' => esc_html__( '2 columns', 'health' ),
				'3' => esc_html__( '3 columns', 'health' ),
				'4' => esc_html__( '4 columns', 'health' ),
			),
			'priority' => 20
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_perpage' , array(
		'default'     => '',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_per_page'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_perpage',
		array(
			'label'    => esc_html__( 'Portfolio Item per page', 'health' ),
			'section'  => 'health_portfolio_categories_settings',
			'settings' => 'health_portfolio_settings_perpage',
			'description' => esc_html__( 'Portfolio items per page for portfolio category and archive pages. Leave empty to show all items.', 'health' ),
			'type'     => 'textfield',
			'priority' => 30
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_sidebar_type' , array(
		'default'     => '2',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_sidebar_portfolio_type'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_sidebar_type',
		array(
			'label'    => esc_html__( 'Portfolio sidebar type', 'health' ),
			'section'  => 'health_portfolio_categories_settings',
			'settings' => 'health_portfolio_settings_sidebar_type',
			'description' => esc_html__( 'Select sidebar type for portfolio category and archive pages.', 'health' ),
			'type'     => 'select',
			'choices'  => array(
				'1' => esc_html__( 'Full width', 'health' ),
				'2' => esc_html__( 'Right Sidebar', 'health' ),
				'3' => esc_html__( 'Left Sidebar', 'health' ),
			),
			'priority' => 40
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_sidebar_content' , array(
		'default'     => 'sidebar-1',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_sidebar_portfolio_content'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_sidebar_content',
		array(
			'label'    => esc_html__( 'Portfolio sidebar content', 'health' ),
			'section'  => 'health_portfolio_categories_settings',
			'settings' => 'health_portfolio_settings_sidebar_content',
			'description' => esc_html__( 'Select sidebar content for portfolio category and archive pages.', 'health' ),
			'type'     => 'select',
			'choices'  => array(
				'sidebar-1' => esc_html__( 'WP Default Sidebar', 'health' ),
				'global-sidebar-1' => esc_html__( 'Blog Sidebar', 'health' ),
				'portfolio-sidebar-1' => esc_html__( 'Portfolio Sidebar', 'health' ),
				'custom-area-1' => esc_html__( 'Custom Area', 'health' ),
			),
			'priority' => 50
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_loadmore' , array(
		'default'     => esc_html__('Load more', 'health' ),
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_text'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_loadmore',
		array(
			'label'    => esc_html__( 'Load More button text', 'health' ),
			'section'  => 'health_portfolio_categories_settings',
			'settings' => 'health_portfolio_settings_loadmore',
			'type'     => 'textfield',
			'priority' => 60
		)
	);


	// portfolio single page settings
	$wp_customize->add_section( 'health_portfolio_single_settings' , array(
		'title'      => esc_html__( 'Portfolio Single Page', 'health' ),
		'priority'   => 30,
		'panel' => 'health_portfolio_settings'
	) );

	$wp_customize->add_setting( 'health_portfolio_settings_related_show' , array(
		'default'     => 'on',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_onoff'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_related_show',
		array(
			'label'    => esc_html__( 'Show block Related projects', 'health' ),
			'section'  => 'health_portfolio_single_settings',
			'settings' => 'health_portfolio_settings_related_show',
			'description' => esc_html__( 'Select on/off Related projects for portfolio single pages.', 'health' ),
			'type'     => 'select',
			'choices'  => array(
				'on' => esc_html__( 'On', 'health' ),
				'off' => esc_html__( 'Off', 'health' ),
			),
			'priority' => 10
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_related_title' , array(
		'default'     => esc_html__('Related projects', 'health' ),
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_text'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_related_title',
		array(
			'label'    => esc_html__( 'Title block Related Projects', 'health' ),
			'section'  => 'health_portfolio_single_settings',
			'settings' => 'health_portfolio_settings_related_title',
			'type'     => 'textfield',
			'priority' => 20
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_related_desc' , array(
		'default'     => '',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_text'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_related_desc',
		array(
			'label'    => esc_html__( 'Description block Related Projects', 'health' ),
			'section'  => 'health_portfolio_single_settings',
			'settings' => 'health_portfolio_settings_related_desc',
			'type'     => 'textarea',
			'priority' => 30
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_share' , array(
		'default'     => 'on',
		'transport'   => 'refresh',
		'sanitize_callback' => 'health_sanitize_onoff'
	) );

	$wp_customize->add_control(
		'health_portfolio_settings_share',
		array(
			'label'    => esc_html__( 'Show share', 'health' ),
			'section'  => 'health_portfolio_single_settings',
			'settings' => 'health_portfolio_settings_share',
			'description' => esc_html__( 'Select on/off share for portfolio single pages.', 'health' ),
			'type'     => 'select',
			'choices'  => array(
				'on' => esc_html__( 'On', 'health' ),
				'off' => esc_html__( 'Off', 'health' ),
			),
			'priority' => 40
		)
	);

	$wp_customize->add_setting( 'health_portfolio_settings_link_to_all' , array(
		'default'     => '0',
		'transport'   => 'refresh',
		'sanitize_callback' => 'esc_url'
	) );
	$wp_customize->add_control( 'health_portfolio_settings_page', array(
		'label'    => esc_html__( 'Select Page For All Works', 'health' ),
		'section'  => 'health_portfolio_single_settings',
		'settings' => 'health_portfolio_settings_link_to_all',
		'type'     => 'dropdown-pages',
		'priority' => 50
	) );


}