<?php
/**
 * Moral Theme Customizer
 *
 * @package Moral
 *
 * advance setting
 */

$wp_customize->add_panel(
	'moral_magazine_general_panel',
	array(
		'title' => esc_html__( 'Theme Options', 'moral-magazine' ),
		'priority' => 107
	)
);



require get_parent_theme_file_path( '/inc/customizer/header.php' );

/**
 * General settings
 */
// General settings
$wp_customize->add_section(
	'moral_magazine_general_section',
	array(
		'title' => esc_html__( 'General', 'moral-magazine' ),
		'panel' => 'moral_magazine_general_panel',
	)
);

// Breadcrumb enable setting
$wp_customize->add_setting(
	'moral_magazine_breadcrumb_enable',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_breadcrumb_enable',
	array(
		'section'		=> 'moral_magazine_general_section',
		'label'			=> esc_html__( 'Enable breadcrumb.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

// Backtop enable setting
$wp_customize->add_setting(
	'moral_magazine_back_to_top_enable',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_back_to_top_enable',
	array(
		'section'		=> 'moral_magazine_general_section',
		'label'			=> esc_html__( 'Enable Scroll up.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);


/**
 * Global Layout
 */
// Global Layout
$wp_customize->add_section(
	'moral_magazine_global_layout',
	array(
		'title' => esc_html__( 'Global Layout', 'moral-magazine' ),
		'panel' => 'moral_magazine_general_panel',
	)
);

// Global site layout setting
$wp_customize->add_setting(
	'moral_magazine_site_layout',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_select',
		'default' => 'wide',
		'transport'	=> 'postMessage',
	)
);

$wp_customize->add_control(
	'moral_magazine_site_layout',
	array(
		'section'		=> 'moral_magazine_global_layout',
		'label'			=> esc_html__( 'Site layout', 'moral-magazine' ),
		'type'			=> 'radio',
		'choices'		=> array( 
			'boxed' => esc_html__( 'Boxed', 'moral-magazine' ), 
			'wide' => esc_html__( 'Wide', 'moral-magazine' ), 
		),
	)
);

// Global archive layout setting
$wp_customize->add_setting(
	'moral_magazine_archive_sidebar',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_select',
		'default' => 'right',
	)
);

$wp_customize->add_control(
	'moral_magazine_archive_sidebar',
	array(
		'section'		=> 'moral_magazine_global_layout',
		'label'			=> esc_html__( 'Archive Sidebar', 'moral-magazine' ),
		'description'			=> esc_html__( 'This option works on all archive pages like: 404, search, date, category, "Your latest posts" and so on.', 'moral-magazine' ),
		'type'			=> 'radio',
		'choices'		=> array( 
			'right' => esc_html__( 'Right', 'moral-magazine' ), 
			'no' => esc_html__( 'No Sidebar', 'moral-magazine' ), 
		),
	)
);

// Global page layout setting
$wp_customize->add_setting(
	'moral_magazine_global_page_layout',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_select',
		'default' => 'right',
	)
);

$wp_customize->add_control(
	'moral_magazine_global_page_layout',
	array(
		'section'		=> 'moral_magazine_global_layout',
		'label'			=> esc_html__( 'Global page sidebar', 'moral-magazine' ),
		'description'			=> esc_html__( 'This option works only on single pages including "Posts page". This setting can be overridden for single page from the metabox too.', 'moral-magazine' ),
		'type'			=> 'radio',
		'choices'		=> array( 
			'right' => esc_html__( 'Right', 'moral-magazine' ), 
			'no' => esc_html__( 'No Sidebar', 'moral-magazine' ), 
		),
	)
);

// Global post layout setting
$wp_customize->add_setting(
	'moral_magazine_global_post_layout',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_select',
		'default' => 'right',
	)
);

$wp_customize->add_control(
	'moral_magazine_global_post_layout',
	array(
		'section'		=> 'moral_magazine_global_layout',
		'label'			=> esc_html__( 'Global post sidebar', 'moral-magazine' ),
		'description'			=> esc_html__( 'This option works only on single posts. This setting can be overridden for single post from the metabox too.', 'moral-magazine' ),
		'type'			=> 'radio',
		'choices'		=> array(  
			'right' => esc_html__( 'Right', 'moral-magazine' ), 
			'no' => esc_html__( 'No Sidebar', 'moral-magazine' ), 
		),
	)
);

/**
 * Blog/Archive section 
 */
// Blog/Archive section 
$wp_customize->add_section(
	'moral_magazine_archive_settings',
	array(
		'title' => esc_html__( 'Archive/Blog', 'moral-magazine' ),
		'description' => esc_html__( 'Settings for archive pages including blog page too.', 'moral-magazine' ),
		'panel' => 'moral_magazine_general_panel',
	)
);

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

$wp_customize->add_control(
	'moral_magazine_archive_excerpt_length',
	array(
		'section'		=> 'moral_magazine_archive_settings',
		'label'			=> esc_html__( 'Excerpt more length:', 'moral-magazine' ),
		'type'			=> 'number',
		'input_attrs'   => array( 'min' => 5 ),
	)
);

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

$wp_customize->add_control(
	'moral_magazine_enable_archive_date',
	array(
		'section'		=> 'moral_magazine_archive_settings',
		'label'			=> esc_html__( 'Enable date.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

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

$wp_customize->add_control(
	'moral_magazine_enable_archive_cat',
	array(
		'section'		=> 'moral_magazine_archive_settings',
		'label'			=> esc_html__( 'Enable category.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

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

$wp_customize->add_control(
	'moral_magazine_enable_archive_featured_img',
	array(
		'section'		=> 'moral_magazine_archive_settings',
		'label'			=> esc_html__( 'Enable featured image.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

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

$wp_customize->add_control(
	'moral_magazine_enable_archive_content_type',
	array(
		'section'		=> 'moral_magazine_archive_settings',
		'label'			=> esc_html__( 'Content type:', 'moral-magazine' ),
		'choices'		=> array(
			'full-content' => esc_html__( 'Full content', 'moral-magazine' ), 
			'excerpt' => esc_html__( 'Excerpt', 'moral-magazine' ), 
		),
		'type'			=> 'radio',
	)
);

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

$archive_pagination_choices = array( 
	'disable' => esc_html__( '--Disable--', 'moral-magazine' ),
	'numeric' => esc_html__( 'Numeric', 'moral-magazine' ),
	'older_newer' => esc_html__( 'Older / Newer', 'moral-magazine' ),
);

$wp_customize->add_control(
	'moral_magazine_archive_pagination_type',
	array(
		'section'		=> 'moral_magazine_archive_settings',
		'label'			=> esc_html__( 'Pagination type:', 'moral-magazine' ),
		'type'			=> 'select',
		'choices'		=> $archive_pagination_choices,
	)
);

/**
 * Single setting section 
 */
// Single setting section 
$wp_customize->add_section(
	'moral_magazine_single_settings',
	array(
		'title' => esc_html__( 'Single Posts', 'moral-magazine' ),
		'description' => esc_html__( 'Settings for all single posts.', 'moral-magazine' ),
		'panel' => 'moral_magazine_general_panel',
	)
);

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

$wp_customize->add_control(
	'moral_magazine_enable_single_date',
	array(
		'section'		=> 'moral_magazine_single_settings',
		'label'			=> esc_html__( 'Enable date.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);


// Tag enable setting
$wp_customize->add_setting(
	'moral_magazine_enable_single_tag',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_enable_single_tag',
	array(
		'section'		=> 'moral_magazine_single_settings',
		'label'			=> esc_html__( 'Enable tags.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

// Comment enable setting
$wp_customize->add_setting(
	'moral_magazine_enable_single_comment',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_enable_single_comment',
	array(
		'section'		=> 'moral_magazine_single_settings',
		'label'			=> esc_html__( 'Enable comment.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);


// Author enable setting
$wp_customize->add_setting(
	'moral_magazine_enable_single_author',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_enable_single_author',
	array(
		'section'		=> 'moral_magazine_single_settings',
		'label'			=> esc_html__( 'Enable author.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);



// Featured image enable setting
$wp_customize->add_setting(
	'moral_magazine_enable_single_featured_img',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_enable_single_featured_img',
	array(
		'section'		=> 'moral_magazine_single_settings',
		'label'			=> esc_html__( 'Enable featured image.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

// Pagination enable setting
$wp_customize->add_setting(
	'moral_magazine_enable_single_pagination',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_enable_single_pagination',
	array(
		'section'		=> 'moral_magazine_single_settings',
		'label'			=> esc_html__( 'Enable pagination.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);


$wp_customize->add_setting(
	'moral_magazine_enable_single_enable_related_post',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_enable_single_enable_related_post',
	array(
		'section'		=> 'moral_magazine_single_settings',
		'label'			=> esc_html__( 'Enable Related Post.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

/**
 * Single pages setting section 
 */
// Single pages setting section 
$wp_customize->add_section(
	'moral_magazine_single_page_settings',
	array(
		'title' => esc_html__( 'Single Pages', 'moral-magazine' ),
		'description' => esc_html__( 'Settings for all single pages.', 'moral-magazine' ),
		'panel' => 'moral_magazine_general_panel',
	)
);

// Featured image enable setting
$wp_customize->add_setting(
	'moral_magazine_enable_single_page_featured_img',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_enable_single_page_featured_img',
	array(
		'section'		=> 'moral_magazine_single_page_settings',
		'label'			=> esc_html__( 'Enable featured image.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

/**
 * Reset all settings
 */
// Reset settings section
$wp_customize->add_section(
	'moral_magazine_reset_sections',
	array(
		'title' => esc_html__( 'Reset all', 'moral-magazine' ),
		'description' => esc_html__( 'Reset all settings to default.', 'moral-magazine' ),
		'panel' => 'moral_magazine_general_panel',
	)
);

// Reset sortable order setting
$wp_customize->add_setting(
	'moral_magazine_reset_settings',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => false,
		'transport'	=> 'postMessage',
	)
);

$wp_customize->add_control(
	'moral_magazine_reset_settings',
	array(
		'section'		=> 'moral_magazine_reset_sections',
		'label'			=> esc_html__( 'Reset all settings?', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

/**
 *
 *
 * Footer copyright
 *
 *
 */
// Footer copyright
$wp_customize->add_section(
	'moral_magazine_footer_section',
	array(
		'title' => esc_html__( 'Footer', 'moral-magazine' ),
		'priority' => 106,
		'panel' => 'moral_magazine_general_panel',
	)
);


// Footer text enable setting
$wp_customize->add_setting(
	'moral_magazine_enable_footer_text',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_checkbox',
		'default' => true,
	)
);

$wp_customize->add_control(
	'moral_magazine_enable_footer_text',
	array(
		'section'		=> 'moral_magazine_footer_section',
		'label'			=> esc_html__( 'Enable footer text.', 'moral-magazine' ),
		'type'			=> 'checkbox',
	)
);

// Footer copyright setting
$wp_customize->add_setting(
	'moral_magazine_copyright_txt',
	array(
		'sanitize_callback' => 'moral_magazine_sanitize_html',
		'default' => $default['moral_magazine_copyright_txt'],
		'transport'	=> 'postMessage',
	)
);

$wp_customize->add_control(
	'moral_magazine_copyright_txt',
	array(
		'section'		=> 'moral_magazine_footer_section',
		'label'			=> esc_html__( 'Copyright text:', 'moral-magazine' ),
		'type'			=> 'textarea',
	)
);
