<?php
/**
 * Theme Options.
 *
 * @package rubik_news
 */

// Add Panel.
$wp_customize->add_panel( 'theme_option_panel',
	array(
	'title'      => __( 'Theme Options', 'rubik-news' ),
	'priority'   => 100,
	'capability' => 'edit_theme_options',
	)
);

// Logo Width.
$wp_customize->add_setting(
	'logo_width',
	array(
		'default'           => 300,
		'sanitize_callback' => 'rubik_news_sanitize_number_range',
		'transport'         => 'refresh',
	)
);

$wp_customize->add_control(
	'logo_width',
	array(
		'label'       => __( 'Logo Width', 'rubik-news' ),
		'description' => __( 'Adjust the logo width in pixels. (Max:500)', 'rubik-news' ),
		'section'     => 'title_tagline',
		'type'        => 'number',
		'priority'    => 9,
		'input_attrs' => array(
			'min'  => 50,
			'max'  => 500,
			'step' => 1,
		),
	)
);

// Site Title Font Size.
$wp_customize->add_setting(
	'site_title_font_size',
	array(
		'default'           => 48,
		'sanitize_callback' => 'rubik_news_sanitize_number_range',
		'transport'         => 'refresh',
	)
);

$wp_customize->add_control(
	'site_title_font_size',
	array(
		'label'       => __( 'Site Title Font Size', 'rubik-news' ),
		'description' => __( 'Adjust the site title font size in pixels. (Max:100)', 'rubik-news' ),
		'section'     => 'title_tagline',
		'type'        => 'number',
		'priority'    => 50,
		'input_attrs' => array(
			'min'  => 10,
			'max'  => 100,
			'step' => 1,
		),
	)
);

// Site Width section.
$wp_customize->add_section(
	'section_site_width',
	array(
		'title'    => __( 'Site Width', 'rubik-news' ),
		'panel'    => 'theme_option_panel',
		'priority' => 10,
	)
);

// Site Width setting.
$wp_customize->add_setting(
	'site_width',
	array(
		'default'           => 1300,
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'rubik_news_sanitize_number_range',
		'transport'         => 'refresh',
	)
);

// Site Width control.
$wp_customize->add_control(
	'site_width',
	array(
		'label'       => __( 'Site Width', 'rubik-news' ),
		'description' => __( 'Min:500 | Max:2500 (in pixels)', 'rubik-news' ),
		'section'     => 'section_site_width',
		'type'        => 'number',
		'input_attrs' => array(
			'min'  => 500,
			'max'  => 2500,
			'step' => 1,
		),
	)
);

// Sidebar section
$wp_customize->add_section('section_sidebar', array(    
	'title'       => __('Sidebar Options', 'rubik-news'),
	'panel'       => 'theme_option_panel'    
));

// Blog Sidebar Option
$wp_customize->add_setting('blog_sidebar', 
	array(
	'default' 			=> 'right-sidebar',
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rubik_news_sanitize_select',
	'transport'         => 'refresh',
	)
);

$wp_customize->add_control('blog_sidebar', 
	array(		
	'label' 	=> __('Blog Sidebar', 'rubik-news'),
	'section' 	=> 'section_sidebar',
	'settings'  => 'blog_sidebar',
	'type' 		=> 'radio',
	'choices' 	=> array(		
		'left-sidebar' 	=> __( 'Left Sidebar', 'rubik-news'),						
		'right-sidebar' => __( 'Right Sidebar', 'rubik-news'),	
		'no-sidebar' 	=> __( 'No Sidebar', 'rubik-news'),	
		),	
	)
);

// Single Post Sidebar Option
$wp_customize->add_setting('single_post_sidebar', 
	array(
	'default' 			=> 'right-sidebar',
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rubik_news_sanitize_select',
	'transport'         => 'refresh',
	)
);

$wp_customize->add_control('single_post_sidebar', 
	array(		
	'label' 	=> __('Single Post Sidebar', 'rubik-news'),
	'section' 	=> 'section_sidebar',
	'settings'  => 'single_post_sidebar',
	'type' 		=> 'radio',
	'choices' 	=> array(		
		'left-sidebar' 	=> __( 'Left Sidebar', 'rubik-news'),						
		'right-sidebar' => __( 'Right Sidebar', 'rubik-news'),	
		'no-sidebar' 	=> __( 'No Sidebar', 'rubik-news'),	
		),	
	)
);

// Archive Sidebar Option
$wp_customize->add_setting('archive_sidebar', 
	array(
	'default' 			=> 'no-sidebar',
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rubik_news_sanitize_select',
	'transport'         => 'refresh',
	)
);

$wp_customize->add_control('archive_sidebar', 
	array(		
	'label' 	=> __('Archive Sidebar', 'rubik-news'),
	'section' 	=> 'section_sidebar',
	'settings'  => 'archive_sidebar',
	'type' 		=> 'radio',
	'choices' 	=> array(		
		'left-sidebar' 	=> __( 'Left Sidebar', 'rubik-news'),						
		'right-sidebar' => __( 'Right Sidebar', 'rubik-news'),	
		'no-sidebar' 	=> __( 'No Sidebar', 'rubik-news'),	
		),	
	)
);

// Page Sidebar Option
$wp_customize->add_setting('page_sidebar', 
	array(
	'default' 			=> 'no-sidebar',
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rubik_news_sanitize_select',
	'transport'         => 'refresh',
	)
);

$wp_customize->add_control('page_sidebar', 
	array(		
	'label' 	=> __('Page Sidebar', 'rubik-news'),
	'section' 	=> 'section_sidebar',
	'settings'  => 'page_sidebar',
	'type' 		=> 'radio',
	'choices' 	=> array(		
		'left-sidebar' 	=> __( 'Left Sidebar', 'rubik-news'),						
		'right-sidebar' => __( 'Right Sidebar', 'rubik-news'),	
		'no-sidebar' 	=> __( 'No Sidebar', 'rubik-news'),	
		),	
	)
);

// Excerpt Length
$wp_customize->add_section('section_excerpt_length', 
	array(    
	'title'       => __('Excerpt Length', 'rubik-news'),
	'panel'       => 'theme_option_panel'    
	)
);

$wp_customize->add_setting( 'excerpt_length', array(
	'default'           => '18',
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rubik_news_sanitize_number_range',
	'transport'         => 'refresh',
) );

$wp_customize->add_control( 'excerpt_length', array(
	'label'       => __( 'Excerpt Length', 'rubik-news' ),
	'description' => __( 'Note: Min 5 & Max 100.', 'rubik-news' ),
	'section'     => 'section_excerpt_length',
	'type'        => 'number',
	'input_attrs' => array( 'min' => 5, 'max' => 100, 'style' => 'width: 55px;' ),
) );

// Scroll To Top section.
$wp_customize->add_section(
	'section_scroll_to_top',
	array(
		'title' => __( 'Scroll To Top', 'rubik-news' ),
		'panel' => 'theme_option_panel',
	)
);

// Enable Scroll To Top.
$wp_customize->add_setting(
	'enable_scroll_to_top',
	array(
		'default'           => true,
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
		'transport'         => 'refresh',
	)
);

$wp_customize->add_control(
	'enable_scroll_to_top',
	array(
		'label'   => __( 'Enable Scroll To Top', 'rubik-news' ),
		'section' => 'section_scroll_to_top',
		'type'    => 'checkbox',
	)
);

// Show Header Image on Homepage.
$wp_customize->add_setting(
	'show_header_image_homepage',
	array(
		'default'           => true,
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'show_header_image_homepage',
	array(
		'label'   => __( 'Show on Homepage', 'rubik-news' ),
		'section' => 'header_image',
		'type'    => 'checkbox',
	)
);

// Show Header Image on Pages.
$wp_customize->add_setting(
	'show_header_image_pages',
	array(
		'default'           => true,
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'show_header_image_pages',
	array(
		'label'   => __( 'Show on Pages', 'rubik-news' ),
		'section' => 'header_image',
		'type'    => 'checkbox',
	)
);

// Show Header Image on Posts.
$wp_customize->add_setting(
	'show_header_image_posts',
	array(
		'default'           => true,
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'show_header_image_posts',
	array(
		'label'   => __( 'Show on Posts', 'rubik-news' ),
		'section' => 'header_image',
		'type'    => 'checkbox',
	)
);