<?php
/**
 * Post Options
 *
 * @package online_school_courses
 */

$wp_customize->add_section(
	'online_school_courses_post_options',
	array(
		'title' => esc_html__( 'Post Options', 'online-school-courses' ),
		'panel' => 'online_school_courses_theme_options',
	)
);

// ---------------------------------------- PAGINATION ----------------------------------------------------

// Add Separator Custom Control
$wp_customize->add_setting( 'online_school_courses_pagination_separator', array(
	'sanitize_callback' => 'sanitize_text_field',
) );

$wp_customize->add_control( new Online_School_Courses_Separator_Custom_Control( $wp_customize, 'online_school_courses_pagination_separator', array(
	'label' => __( 'Enable / Disable Pagination Section', 'online-school-courses' ),
	'section' => 'online_school_courses_post_options',
	'settings' => 'online_school_courses_pagination_separator',
) ) );

// Pagination - Enable Pagination.
$wp_customize->add_setting(
	'online_school_courses_enable_pagination',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_enable_pagination',
		array(
			'label'    => esc_html__( 'Enable Pagination', 'online-school-courses' ),
			'section'  => 'online_school_courses_post_options',
			'settings' => 'online_school_courses_enable_pagination',
			'type'     => 'checkbox',
		)
	)
);

// Pagination - Pagination Type.
$wp_customize->add_setting(
	'online_school_courses_pagination_type',
	array(
		'default'           => 'default',
		'sanitize_callback' => 'online_school_courses_sanitize_select',
	)
);

$wp_customize->add_control(
	'online_school_courses_pagination_type',
	array(
		'label'           => esc_html__( 'Pagination Type', 'online-school-courses' ),
		'section'         => 'online_school_courses_post_options',
		'settings'        => 'online_school_courses_pagination_type',
		'active_callback' => 'online_school_courses_is_pagination_enabled',
		'type'            => 'select',
		'choices'         => array(
			'default' => __( 'Default (Older/Newer)', 'online-school-courses' ),
			'numeric' => __( 'Numeric', 'online-school-courses' ),
		),
	)
);

// Post Options - Add Post Date Icon
$wp_customize->add_setting(
    'online_school_courses_post_date_icon',
    array(
        'default' => 'far fa-clock', 
        'sanitize_callback' => 'sanitize_text_field',
        'capability' => 'edit_theme_options',
    )
);

$wp_customize->add_control(new Online_School_Courses_Change_Icon_Control(
    $wp_customize, 
    'online_school_courses_post_date_icon',
    array(
        'label'    => __('Add Date Icon','online-school-courses'),
        'section'  => 'online_school_courses_post_options',
        'iconset'  => 'fa',
    )
));

// Post Options - Show / Hide Date.
$wp_customize->add_setting(
	'online_school_courses_post_hide_date',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_post_hide_date',
		array(
			'label'   => esc_html__( 'Show / Hide Date', 'online-school-courses' ),
			'section' => 'online_school_courses_post_options',
		)
	)
);

// Post Options - Add Post Author Icon
$wp_customize->add_setting(
    'online_school_courses_post_author_icon',
    array(
        'default' => 'fas fa-user', 
        'sanitize_callback' => 'sanitize_text_field',
        'capability' => 'edit_theme_options',
    )
);

$wp_customize->add_control(new Online_School_Courses_Change_Icon_Control(
    $wp_customize, 
    'online_school_courses_post_author_icon',
    array(
        'label'    => __('Add Author Icon','online-school-courses'),
        'section'  => 'online_school_courses_post_options',
        'iconset'  => 'fa',
    )
));

// Post Options - Show / Hide Author.
$wp_customize->add_setting(
	'online_school_courses_post_hide_author',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_post_hide_author',
		array(
			'label'   => esc_html__( 'Show / Hide Author', 'online-school-courses' ),
			'section' => 'online_school_courses_post_options',
		)
	)
);

// Post Options - Add Post Comments Icon
$wp_customize->add_setting(
    'online_school_courses_post_comments_icon',
    array(
        'default' => 'fas fa-comments', 
        'sanitize_callback' => 'sanitize_text_field',
        'capability' => 'edit_theme_options',
    )
);

$wp_customize->add_control(new Online_School_Courses_Change_Icon_Control(
    $wp_customize, 
    'online_school_courses_post_comments_icon',
    array(
        'label'    => __('Add Comments Icon','online-school-courses'),
        'section'  => 'online_school_courses_post_options',
        'iconset'  => 'fa',
    )
));

// Post Options - Show / Hide Comments.
$wp_customize->add_setting(
	'online_school_courses_post_hide_comments',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_post_hide_comments',
		array(
			'label'   => esc_html__( 'Show / Hide Comments', 'online-school-courses' ),
			'section' => 'online_school_courses_post_options',
		)
	)
);

// Post Options - Add Post Time Icon
$wp_customize->add_setting(
    'online_school_courses_post_time_icon',
    array(
        'default' => 'fas fa-clock', 
        'sanitize_callback' => 'sanitize_text_field',
        'capability' => 'edit_theme_options',
    )
);

$wp_customize->add_control(new Online_School_Courses_Change_Icon_Control(
    $wp_customize, 
    'online_school_courses_post_time_icon',
    array(
        'label'    => __('Add Time Icon','online-school-courses'),
        'section'  => 'online_school_courses_post_options',
        'iconset'  => 'fa',
    )
));

// Post Options - Show / Hide Time.
$wp_customize->add_setting(
	'online_school_courses_post_hide_time',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_post_hide_time',
		array(
			'label'   => esc_html__( 'Show / Hide Time', 'online-school-courses' ),
			'section' => 'online_school_courses_post_options',
		)
	)
);

// Post Options - Show / Hide Category.
$wp_customize->add_setting(
	'online_school_courses_post_hide_category',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_post_hide_category',
		array(
			'label'   => esc_html__( 'Show / Hide Category', 'online-school-courses' ),
			'section' => 'online_school_courses_post_options',
		)
	)
);

// Post Options - Show / Hide Feature Image.
$wp_customize->add_setting(
	'online_school_courses_post_hide_feature_image',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_post_hide_feature_image',
		array(
			'label'   => esc_html__( 'Show / Hide Featured Image', 'online-school-courses' ),
			'section' => 'online_school_courses_post_options',
		)
	)
);

// Post Options - Show / Hide Post Heading.
$wp_customize->add_setting(
	'online_school_courses_post_hide_post_heading',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_post_hide_post_heading',
		array(
			'label'   => esc_html__( 'Show / Hide Post Heading', 'online-school-courses' ),
			'section' => 'online_school_courses_post_options',
		)
	)
);

// Post Options - Show / Hide Post Content.
$wp_customize->add_setting(
	'online_school_courses_post_hide_post_content',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_post_hide_post_content',
		array(
			'label'   => esc_html__( 'Show / Hide Post Content', 'online-school-courses' ),
			'section' => 'online_school_courses_post_options',
		)
	)
);

// ---------------------------------------- Post layout ----------------------------------------------------

// Add Separator Custom Control
$wp_customize->add_setting( 'online_school_courses_archive_layuout_separator', array(
	'sanitize_callback' => 'sanitize_text_field',
) );

$wp_customize->add_control( new Online_School_Courses_Separator_Custom_Control( $wp_customize, 'online_school_courses_archive_layuout_separator', array(
	'label' => __( 'Archive/Blogs Layout Setting', 'online-school-courses' ),
	'section' => 'online_school_courses_post_options',
	'settings' => 'online_school_courses_archive_layuout_separator',
)));


// Archive Layout - Column Layout.
$wp_customize->add_setting(
	'online_school_courses_archive_column_layout',
	array(
		'default'           => 'column-1',
		'sanitize_callback' => 'online_school_courses_sanitize_select',
	)
);

$wp_customize->add_control(
	'online_school_courses_archive_column_layout',
	array(
		'label'   => esc_html__( 'Select Posts Layout', 'online-school-courses' ),
		'section' => 'online_school_courses_post_options',
		'type'    => 'select',
		'choices' => array(
			'column-1' => __( 'Column 1', 'online-school-courses' ),
			'column-2' => __( 'Column 2', 'online-school-courses' ),
			'column-3' => __( 'Column 3', 'online-school-courses' ),
			'column-4' => __( 'Column 4', 'online-school-courses' ),
		),
	)
);

$wp_customize->add_setting('online_school_courses_blog_layout_option_setting',array(
	'default' => 'Left',
	'sanitize_callback' => 'online_school_courses_sanitize_choices'
  ));
  $wp_customize->add_control(new Online_School_Courses_Image_Radio_Control($wp_customize, 'online_school_courses_blog_layout_option_setting', array(
	'type' => 'select',
	'label' => __('Blog Content Alignment','online-school-courses'),
	'section' => 'online_school_courses_post_options',
	'choices' => array(
		'Left' => esc_url(get_template_directory_uri()).'/resource/img/layout-2.png',
		'Default' => esc_url(get_template_directory_uri()).'/resource/img/layout-1.png',
		'Right' => esc_url(get_template_directory_uri()).'/resource/img/layout-3.png',
))));


// ---------------------------------------- Read More ----------------------------------------------------

// Add Separator Custom Control
$wp_customize->add_setting( 'online_school_courses_readmore_separators', array(
	'sanitize_callback' => 'sanitize_text_field',
) );

$wp_customize->add_control( new Online_School_Courses_Separator_Custom_Control( $wp_customize, 'online_school_courses_readmore_separators', array(
	'label' => __( 'Read More Button Settings', 'online-school-courses' ),
	'section' => 'online_school_courses_post_options',
	'settings' => 'online_school_courses_readmore_separators',
)));


// Post Options - Show / Hide Read More Button.
$wp_customize->add_setting(
	'online_school_courses_post_readmore_button',
	array(
		'default'           => true,
		'sanitize_callback' => 'online_school_courses_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Online_School_Courses_Toggle_Switch_Custom_Control(
		$wp_customize,
		'online_school_courses_post_readmore_button',
		array(
			'label'   => esc_html__( 'Show / Hide Read More Button', 'online-school-courses' ),
			'section' => 'online_school_courses_post_options',
		)
	)
);

$wp_customize->add_setting(
    'online_school_courses_readmore_btn_icon',
    array(
        'default' => 'fas fa-chevron-right', // Set default icon here
        'sanitize_callback' => 'sanitize_text_field',
        'capability' => 'edit_theme_options',
    )
);

$wp_customize->add_control(new Online_School_Courses_Change_Icon_Control(
    $wp_customize, 
    'online_school_courses_readmore_btn_icon',
    array(
        'label'    => __('Read More Icon','online-school-courses'),
        'section'  => 'online_school_courses_post_options',
        'iconset'  => 'fa',
    )
));

$wp_customize->add_setting(
	'online_school_courses_readmore_button_text',
	array(
		'default'           => 'Read More',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'online_school_courses_readmore_button_text',
	array(
		'label'           => esc_html__( 'Read More Button Text', 'online-school-courses' ),
		'section'         => 'online_school_courses_post_options',
		'settings'        => 'online_school_courses_readmore_button_text',
		'type'            => 'text',
	)
);

// Featured Image Dimension
$wp_customize->add_setting(
	'online_school_courses_blog_post_featured_image_dimension',
	array(
		'default' => 'default',
		'sanitize_callback' => 'online_school_courses_sanitize_choices'
	)
);

$wp_customize->add_control(
	'online_school_courses_blog_post_featured_image_dimension', 
	array(
		'type' => 'select',
		'label' => __('Featured Image Dimension','online-school-courses'),
		'section' => 'online_school_courses_post_options',
		'choices' => array(
			'default' => __('Default','online-school-courses'),
			'custom' => __('Custom Image Size','online-school-courses'),
		),
		'description' => __('Note: If you select "Custom Image Size", you can set a custom width and height up to 950px.', 'online-school-courses')
	)
);
 
// Featured Image Custom Width
$wp_customize->add_setting(
	'online_school_courses_blog_post_featured_image_custom_width',
	array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	)
);

$wp_customize->add_control(
	'online_school_courses_blog_post_featured_image_custom_width',
	array(
		'label'	=> __('Featured Image Custom Width','online-school-courses'),
		'section'=> 'online_school_courses_post_options',
		'type'=> 'text',
		'input_attrs' => array(
			'placeholder' => __( '300', 'online-school-courses' ),
		),
		'active_callback' => 'online_school_courses_blog_post_featured_image_dimension'
	)
);

// Featured Image Custom Height
$wp_customize->add_setting(
	'online_school_courses_blog_post_featured_image_custom_height',
	array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	)
);

$wp_customize->add_control(
	'online_school_courses_blog_post_featured_image_custom_height',
	array(
		'label'	=> __('Featured Image Custom Height','online-school-courses'),
		'section'=> 'online_school_courses_post_options',
		'type'=> 'text',
		'input_attrs' => array(
			'placeholder' => __( '300', 'online-school-courses' ),
		),
		'active_callback' => 'online_school_courses_blog_post_featured_image_dimension'
	)
);

// Featured Image Border Radius
$wp_customize->add_setting( 
	'online_school_courses_featured_image_border_radius', 
	array(
		'default'           => 10,
		'transport'         => 'refresh',
		'sanitize_callback' => 'online_school_courses_sanitize_range_value',
	) 
);

$wp_customize->add_control( 
	'online_school_courses_featured_image_border_radius', 
	array(
		'label'       => esc_html__( 'Featured Image Border Radius', 'online-school-courses' ),
		'section'     => 'online_school_courses_post_options',
		'type'        => 'range',
		'input_attrs' => array(
			'step' => 1,
			'min'  => 0,
			'max'  => 150,
		),
	) 
);

$wp_customize->add_setting('online_school_courses_show_first_caps', array(
	'default'           => false,
	'transport'         => 'refresh',
	'sanitize_callback' => 'online_school_courses_sanitize_switch',
));

$wp_customize->add_control(new Online_School_Courses_Toggle_Switch_Custom_Control(
	$wp_customize,
	'online_school_courses_show_first_caps',
	array(
		'label'   => esc_html__('First Cap (First Capital Letter)', 'online-school-courses'),
		'section' => 'online_school_courses_post_options',
	)
));