<?php
/**
 * Blog/Archive section 
 */
// Blog/Archive section 
$wp_customize->add_section(
	'return_blog_archive_settings',
	array(
		'title' => esc_html__( 'Archive/Blog', 'return-blog' ),
		'description' => esc_html__( 'Settings for archive pages including blog page too.', 'return-blog' ),
		'panel' => 'return_blog_general_panel',
	)
);

// Archive excerpt length setting
$wp_customize->add_setting(
	'return_blog_archive_excerpt_length',
	array(
		'sanitize_callback' => 'return_blog_sanitize_number_range',
		'default' => 20,
	)
);

$wp_customize->add_control(
	'return_blog_archive_excerpt_length',
	array(
		'section'		=> 'return_blog_archive_settings',
		'label'			=> esc_html__( 'Excerpt more length:', 'return-blog' ),
		'type'			=> 'number',
		'input_attrs'   => array( 'min' => 5 ),
	)
);

// Date enable setting
$wp_customize->add_setting(
	'return_blog_enable_archive_date',
	array(
		'sanitize_callback' => 'return_blog_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'return_blog_enable_archive_date',
	array(
		'section'		=> 'return_blog_archive_settings',
		'label'			=> esc_html__( 'Enable date.', 'return-blog' ),
		'type'			=> 'checkbox',
	)
);

// Category enable setting
$wp_customize->add_setting(
	'return_blog_enable_archive_cat',
	array(
		'sanitize_callback' => 'return_blog_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'return_blog_enable_archive_cat',
	array(
		'section'		=> 'return_blog_archive_settings',
		'label'			=> esc_html__( 'Enable category.', 'return-blog' ),
		'type'			=> 'checkbox',
	)
);

// blog image enable setting
$wp_customize->add_setting(
	'return_blog_enable_archive_featured_img',
	array(
		'sanitize_callback' => 'return_blog_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'return_blog_enable_archive_featured_img',
	array(
		'section'		=> 'return_blog_archive_settings',
		'label'			=> esc_html__( 'Enable featured image.', 'return-blog' ),
		'type'			=> 'checkbox',
	)
);

// Content type setting
$wp_customize->add_setting(
	'return_blog_enable_archive_content_type',
	array(
		'sanitize_callback' => 'return_blog_sanitize_select',
		'default' => 'excerpt',
	)
);

$wp_customize->add_control(
	'return_blog_enable_archive_content_type',
	array(
		'section'		=> 'return_blog_archive_settings',
		'label'			=> esc_html__( 'Content type:', 'return-blog' ),
		'choices'		=> array(
			'full-content' => esc_html__( 'Full content', 'return-blog' ), 
			'excerpt' => esc_html__( 'Excerpt', 'return-blog' ), 
		),
		'type'			=> 'radio',
	)
);

// Pagination type setting
$wp_customize->add_setting(
	'return_blog_archive_pagination_type',
	array(
		'sanitize_callback' => 'return_blog_sanitize_select',
		'default' => 'numeric',
	)
);

$archive_pagination_description = '';
$archive_pagination_choices = array( 
			'disable' => esc_html__( '--Disable--', 'return-blog' ),
			'numeric' => esc_html__( 'Numeric', 'return-blog' ),
			'older_newer' => esc_html__( 'Older / Newer', 'return-blog' ),
		);
if ( ! class_exists( 'JetPack' ) ) {
	$archive_pagination_description = sprintf( esc_html__( 'We recommend to install %1$sJetpack%2$s and enable %3$sInfinite Scroll%4$s feature for automatic loading of posts.', 'return-blog' ), '<a target="_blank" href="http://wordpress.org/plugins/jetpack">', '</a>', '<b>', '</b>' );
} else {
	$archive_pagination_choices['infinite_scroll'] = esc_html__( 'Infinite Load', 'return-blog' );
}
$wp_customize->add_control(
	'return_blog_archive_pagination_type',
	array(
		'section'		=> 'return_blog_archive_settings',
		'label'			=> esc_html__( 'Pagination type:', 'return-blog' ),
		'description'			=>  $archive_pagination_description,
		'type'			=> 'select',
		'choices'		=> $archive_pagination_choices,
	)
);