<?php
/**
 * RetroTale Theme Customizer.
 * @package RetroTale
 * @since RetroTale 2.0.0
*/

/**
 * Default values - backwards compatibility for older RetroTale versions.
 *  
*/ 
function retrotale_default_options($key) {

$retrotale_theme_options = get_option('retrotale_options');

/* Define the array of defaults */ 
$retrotale_defaults = array(
			'retrotale_css' => 'Red (default)',
      'retrotale_layout' => 'Boxed',
			'retrotale_display_breadcrumb' => 'Display',
      'retrotale_display_scroll_top' => 'Display',
      'retrotale_display_sidebar' => 'Display',
      'retrotale_display_sidebar_archives' => 'Display',
			'retrotale_display_header_image' => 'Everywhere',
			'retrotale_logo_url' => '',
      'retrotale_display_site_description' => 'Display',
      'retrotale_fixed_menu' => 'Enable',
      'retrotale_header_address' => '',
			'retrotale_header_email' => '',
			'retrotale_header_phone' => '',
			'retrotale_header_skype' => '',
			'retrotale_display_image_post' => 'Display',
			'retrotale_display_meta_post' => 'Display',
			'retrotale_next_preview_post' => 'Display',
			'retrotale_display_image_page' => 'Display',
      'retrotale_post_entry_format' => 'One Column',
      'retrotale_display_meta_post_entry' => 'Display',
      'retrotale_content_archives' => 'Excerpt',
      'retrotale_excerpt_length' => '40',
      'retrotale_latest_posts_headline' => 'Latest Posts',
			'retrotale_character_set' => 'latin',
      'retrotale_body_google_fonts' => 'default',
			'retrotale_headings_google_fonts' => 'default',
      'retrotale_description_google_fonts' => 'default',
			'retrotale_headline_google_fonts' => 'default',
			'retrotale_postentry_google_fonts' => 'default',
			'retrotale_sidebar_google_fonts' => 'default',
			'retrotale_menu_google_fonts' => 'default',
			'retrotale_own_css' => '' );

$retrotale_theme_options = wp_parse_args( $retrotale_theme_options, $retrotale_defaults );

if ( isset($retrotale_theme_options[$key]) ) {
return $retrotale_theme_options[$key]; } else {
return false;
}}

/**
 * Register Customizer sections and options.
 *  
*/
function retrotale_customize_register($wp_customize){

$retrotale_fonts = array(
			'default' => 'default',	
			'Abel' => 'Abel',			
			'Aclonica' => 'Aclonica',
			'Actor' => 'Actor',
			'Adamina' => 'Adamina',
			'Aldrich' => 'Aldrich',
			'Alice' => 'Alice',
			'Alike' => 'Alike',
			'Allan' => 'Allan',
			'Allerta' => 'Allerta',
      'Amarante' => 'Amarante',
			'Amaranth' => 'Amaranth',
      'Andika' => 'Andika',
			'Antic' => 'Antic',
			'Arimo' => 'Arimo',	
			'Artifika' => 'Artifika',
			'Arvo' => 'Arvo',
			'Brawler' => 'Brawler',
			'Buda' => 'Buda',	
      'Butcherman' => 'Butcherman',	
			'Cantarell' => 'Cantarell',	
      'Cherry Swash' => 'Cherry Swash',				
			'Chivo' => 'Chivo',			
			'Coda' => 'Coda',	
      'Concert One' => 'Concert One',		
			'Copse' => 'Copse',
			'Corben' => 'Corben',
			'Cousine' => 'Cousine',			
			'Coustard' => 'Coustard',
			'Covered By Your Grace' => 'Covered By Your Grace',
			'Crafty Girls' => 'Crafty Girls',
			'Crimson Text' => 'Crimson Text',
			'Crushed' => 'Crushed',
			'Cuprum' => 'Cuprum',
			'Damion' => 'Damion',
			'Dancing Script' => 'Dancing Script',
			'Dawning of a New Day' => 'Dawning of a New Day',
			'Days One' => 'Days One',
			'Delius' => 'Delius',
			'Delius Swash Caps' => 'Delius Swash Caps',
			'Delius Unicase' => 'Delius Unicase',
			'Didact Gothic' => 'Didact Gothic',
			'Dorsa' => 'Dorsa',
			'Droid Sans' => 'Droid Sans',
			'Droid Sans Mono' => 'Droid Sans Mono',
      'Droid Serif' => 'Droid Serif',
			'EB Garamond' => 'EB Garamond',
			'Expletus Sans' => 'Expletus Sans',
			'Fanwood Text' => 'Fanwood Text',
			'Federo' => 'Federo',
			'Fontdiner Swanky' => 'Fontdiner Swanky',
			'Forum' => 'Forum',
			'Francois One' => 'Francois One',
			'Gentium Basic' => 'Gentium Basic',
			'Gentium Book Basic' => 'Gentium Book Basic',
			'Geo' => 'Geo',
			'Geostar' => 'Geostar',
			'Geostar Fill' => 'Geostar Fill',
      'Gilda Display' => 'Gilda Display',
			'Give You Glory' => 'Give You Glory',
			'Gloria Hallelujah' => 'Gloria Hallelujah',
			'Goblin One' => 'Goblin One',
			'Goudy Bookletter 1911' => 'Goudy Bookletter 1911',
			'Gravitas One' => 'Gravitas One',
			'Gruppo' => 'Gruppo',
			'Hammersmith One' => 'Hammersmith One',
			'Holtwood One SC' => 'Holtwood One SC',
			'Homemade Apple' => 'Homemade Apple',
			'Inconsolata' => 'Inconsolata',
			'Indie Flower' => 'Indie Flower',
      'IM Fell English' => 'IM Fell English',
			'Irish Grover' => 'Irish Grover',
			'Irish Growler' => 'Irish Growler',
			'Istok Web' => 'Istok Web',
			'Judson' => 'Judson',
			'Julee' => 'Julee',
			'Just Another Hand' => 'Just Another Hand',
			'Just Me Again Down Here' => 'Just Me Again Down Here',
			'Kameron' => 'Kameron',
			'Kelly Slab' => 'Kelly Slab',
			'Kenia' => 'Kenia',
			'Kranky' => 'Kranky',
			'Kreon' => 'Kreon',
			'Kristi' => 'Kristi',
			'La Belle Aurore' => 'La Belle Aurore',
      'Lato' => 'Lato',
			'League Script' => 'League Script',
			'Leckerli One' => 'Leckerli One',
			'Lekton' => 'Lekton',
      'Lily Script One' => 'Lily Script One',
			'Limelight' => 'Limelight',
			'Lobster' => 'Lobster',
			'Lobster Two' => 'Lobster Two',
			'Lora' => 'Lora',
			'Love Ya Like A Sister' => 'Love Ya Like A Sister',
			'Loved by the King' => 'Loved by the King',
      'Lovers Quarrel' => 'Lovers Quarrel',
			'Luckiest Guy' => 'Luckiest Guy',
			'Maiden Orange' => 'Maiden Orange',
			'Mako' => 'Mako',
			'Marvel' => 'Marvel',
			'Maven Pro' => 'Maven Pro',
			'Meddon' => 'Meddon',
			'MedievalSharp' => 'MedievalSharp',
      'Medula One' => 'Medula One',
			'Megrim' => 'Megrim',
			'Merienda One' => 'Merienda One',
			'Merriweather' => 'Merriweather',
			'Metrophobic' => 'Metrophobic',
			'Michroma' => 'Michroma',
			'Miltonian Tattoo' => 'Miltonian Tattoo',
			'Miltonian' => 'Miltonian',
			'Modern Antiqua' => 'Modern Antiqua',
			'Molengo' => 'Molengo',
      'Monofett' => 'Monofett',
			'Monoton' => 'Monoton',
      'Montaga' => 'Montaga',
			'Montez' => 'Montez',
      'Montserrat' => 'Montserrat',
			'Mountains of Christmas' => 'Mountains of Christmas',
			'Muli' => 'Muli',
			'Neucha' => 'Neucha',
			'Neuton' => 'Neuton',
			'News Cycle' => 'News Cycle',
			'Nixie One' => 'Nixie One',
			'Nobile' => 'Nobile',
			'Nova Cut' => 'Nova Cut',
			'Nova Flat' => 'Nova Flat',
			'Nova Mono' => 'Nova Mono',
			'Nova Oval' => 'Nova Oval',
			'Nova Round' => 'Nova Round',
			'Nova Script' => 'Nova Script',
			'Nova Slim' => 'Nova Slim',
			'Nova Square' => 'Nova Square',
			'Numans' => 'Numans',
			'Nunito' => 'Nunito',
      'Open Sans' => 'Open Sans',
			'Oswald' => 'Oswald',
			'Over the Rainbow' => 'Over the Rainbow',
			'Ovo' => 'Ovo',
			'Pacifico' => 'Pacifico',
			'Passero One' => 'Passero One',
			'Patrick Hand' => 'Patrick Hand',
			'Paytone One' => 'Paytone One',
			'Permanent Marker' => 'Permanent Marker',
			'Philosopher' => 'Philosopher',
			'Play' => 'Play',
			'Playfair Display' => 'Playfair Display',
			'Podkova' => 'Podkova',
			'Poller One' => 'Poller One',
			'Pompiere' => 'Pompiere',
			'Prata' => 'Prata',
			'Prociono' => 'Prociono',
			'PT Sans' => 'PT Sans',
			'PT Sans Caption' => 'PT Sans Caption',
			'PT Sans Narrow' => 'PT Sans Narrow',
			'PT Serif' => 'PT Serif',
			'PT Serif Caption' => 'PT Serif Caption',
			'Puritan' => 'Puritan',
			'Quattrocento' => 'Quattrocento',
			'Quattrocento Sans' => 'Quattrocento Sans',
			'Questrial' => 'Questrial',
			'Radley' => 'Radley',
			'Raleway' => 'Raleway', 
      'Rationale' => 'Rationale',
			'Redressed' => 'Redressed',
      'Reenie Beanie' => 'Reenie Beanie', 
      'Roboto' => 'Roboto',
      'Roboto Condensed' => 'Roboto Condensed',
			'Rock Salt' => 'Rock Salt',
			'Rochester' => 'Rochester',
			'Rokkitt' => 'Rokkitt',
			'Rosario' => 'Rosario',
			'Ruslan Display' => 'Ruslan Display',
      'Sancreek' => 'Sancreek',
			'Sansita One' => 'Sansita One',
			'Schoolbell' => 'Schoolbell',
			'Shadows Into Light' => 'Shadows Into Light',
			'Shanti' => 'Shanti',
			'Short Stack' => 'Short Stack',
			'Sigmar One' => 'Sigmar One',
			'Six Caps' => 'Six Caps',
			'Slackey' => 'Slackey',
			'Smokum' => 'Smokum',
			'Smythe' => 'Smythe',
			'Sniglet' => 'Sniglet',
			'Snippet' => 'Snippet',
			'Sorts Mill Goudy' => 'Sorts Mill Goudy',
			'Special Elite' => 'Special Elite',
			'Spinnaker' => 'Spinnaker',
			'Stardos Stencil' => 'Stardos Stencil',
			'Sue Ellen Francisco' => 'Sue Ellen Francisco',
			'Sunshiney' => 'Sunshiney',
			'Swanky and Moo Moo' => 'Swanky and Moo Moo',
			'Syncopate' => 'Syncopate',
			'Tangerine' => 'Tangerine',
			'Tenor Sans' => 'Tenor Sans',
			'Terminal Dosis Light' => 'Terminal Dosis Light',
			'Tinos' => 'Tinos',
			'Tulpen One' => 'Tulpen One',
			'Ubuntu' => 'Ubuntu',
			'Ultra' => 'Ultra',
      'UnifrakturCook' => 'UnifrakturCook',
			'UnifrakturMaguntia' => 'UnifrakturMaguntia',
      'Unkempt' => 'Unkempt',
			'Unna' => 'Unna',
			'Varela' => 'Varela',
			'Varela Round' => 'Varela Round',
			'Vibur' => 'Vibur',
			'Vidaloka' => 'Vidaloka',
			'Volkhov' => 'Volkhov',
			'Vollkorn' => 'Vollkorn',
			'Voltaire' => 'Voltaire',
			'VT323' => 'VT323',
			'Waiting for the Sunrise' => 'Waiting for the Sunrise',
			'Wallpoet' => 'Wallpoet',
			'Walter Turncoat' => 'Walter Turncoat',
			'Wire One' => 'Wire One',
			'Yanone Kaffeesatz' => 'Yanone Kaffeesatz',
			'Yellowtail' => 'Yellowtail',
			'Yeseva One' => 'Yeseva One',
			'Zeyada' => 'Zeyada');
      
/**
 * Textarea custom control.
 *  
*/ 
class retrotale_customize_textarea_control extends WP_Customize_Control {
    public $type = 'textarea'; 
    public function render_content() { ?>
        <label>
        <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
        <textarea rows="5" style="width:100%;" <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea>
        </label>
<?php }}

/**
 * Sections and Options.
 *  
*/     
    $wp_customize->add_section('retrotale_general_settings', array(
        'title'    => __('RetroTale General Settings', 'retrotale'),
        'description' => '',
        'priority' => 120,
    ));
    $wp_customize->add_section('retrotale_header_settings', array(
        'title'    => __('RetroTale Header Settings', 'retrotale'),
        'description' => '',
        'priority' => 130,
    ));
    $wp_customize->add_section('retrotale_posts_settings', array(
        'title'    => __('RetroTale Posts/Pages Settings', 'retrotale'),
        'description' => '',
        'priority' => 140,
    ));
    $wp_customize->add_section('retrotale_post_entries_settings', array(
        'title'    => __('RetroTale Post Entries/Blog Page Settings', 'retrotale'),
        'description' => '',
        'priority' => 150,
    ));
    $wp_customize->add_section('retrotale_font_settings', array(
        'title'    => __('RetroTale Font Settings', 'retrotale'),
        'description' => '',
        'priority' => 160,
    ));
 
    //  =============================
    //  = Color Scheme              =
    //  =============================
    $wp_customize->add_setting('retrotale_css', array(
        'default'        => retrotale_default_options('retrotale_css'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_css_control', array(
        'label'      => __('Color Scheme', 'retrotale'),
        'section'    => 'retrotale_general_settings',
        'settings'   => 'retrotale_css',
        'type'       => 'radio',
        'choices'    => array(
            'Red (default)' => __( 'Red (default)' , 'retrotale' ),
            'Blue' => __( 'Blue' , 'retrotale' ),
            'Green' => __( 'Green' , 'retrotale' ),
        ),
    ));
    
    //  =============================
    //  = Layout Style              =
    //  =============================
    $wp_customize->add_setting('retrotale_layout', array(
        'default'        => retrotale_default_options('retrotale_layout'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_layout_control', array(
        'label'      => __('Layout Style', 'retrotale'),
        'section'    => 'retrotale_general_settings',
        'settings'   => 'retrotale_layout',
        'type'       => 'radio',
        'choices'    => array(
            'Boxed' => __( 'Boxed' , 'retrotale' ),
            'Wide' => __( 'Wide' , 'retrotale' ),
        ),
    ));
    
    //  =================================
    //  = Display Breadcrumb Navigation =
    //  =================================
    $wp_customize->add_setting('retrotale_display_breadcrumb', array(
        'default'        => retrotale_default_options('retrotale_display_breadcrumb'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_breadcrumb_control', array(
        'label'      => __('Display Breadcrumb Navigation', 'retrotale'),
        'section'    => 'retrotale_general_settings',
        'settings'   => 'retrotale_display_breadcrumb',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  =================================
    //  = Display Scroll-top Button     =
    //  =================================
    $wp_customize->add_setting('retrotale_display_scroll_top', array(
        'default'        => retrotale_default_options('retrotale_display_scroll_top'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_scroll_top_control', array(
        'label'      => __('Display Scroll-top Button', 'retrotale'),
        'section'    => 'retrotale_general_settings',
        'settings'   => 'retrotale_display_scroll_top',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  ==================================
    //  = Display Sidebar on Posts/Pages =
    //  ==================================
    $wp_customize->add_setting('retrotale_display_sidebar', array(
        'default'        => retrotale_default_options('retrotale_display_sidebar'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_sidebar_control', array(
        'label'      => __('Display Sidebar on Posts/Pages', 'retrotale'),
        'section'    => 'retrotale_general_settings',
        'settings'   => 'retrotale_display_sidebar',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  ==================================
    //  = Display Sidebar on Archives    =
    //  ==================================
    $wp_customize->add_setting('retrotale_display_sidebar_archives', array(
        'default'        => retrotale_default_options('retrotale_display_sidebar_archives'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_sidebar_archives_control', array(
        'label'      => __('Display Sidebar on Archives', 'retrotale'),
        'section'    => 'retrotale_general_settings',
        'settings'   => 'retrotale_display_sidebar_archives',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  ==================================
    //  = Display Header Image           =
    //  ==================================
    $wp_customize->add_setting('retrotale_display_header_image', array(
        'default'        => retrotale_default_options('retrotale_display_header_image'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_header_image_control', array(
        'label'      => __('Display Header Image', 'retrotale'),
        'section'    => 'retrotale_header_settings',
        'settings'   => 'retrotale_display_header_image',
        'type'       => 'radio',
        'choices'    => array(
            'Everywhere' => __( 'Everywhere' , 'retrotale' ),
            'Only on Homepage' => __( 'Only on Homepage' , 'retrotale' ),
        ),
    ));
    
    //  =============================
    //  = Header Logo               =
    //  =============================
    $wp_customize->add_setting('retrotale_logo_url', array(
        'default'        => retrotale_default_options('retrotale_logo_url'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_uri',
    ));
 
    $wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, 'retrotale_logo_url_control', array(
        'label'    => __('Header Logo', 'retrotale'),
        'section'  => 'retrotale_header_settings',
        'settings' => 'retrotale_logo_url',
    )));
    
    //  ====================================
    //  = Display Site Description         =
    //  ====================================
    $wp_customize->add_setting('retrotale_display_site_description', array(
        'default'        => retrotale_default_options('retrotale_display_site_description'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_site_description_control', array(
        'label'      => __('Display Site Description', 'retrotale'),
        'section'    => 'retrotale_header_settings',
        'settings'   => 'retrotale_display_site_description',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  ====================================
    //  = Fixed Menu                       =
    //  ====================================
    $wp_customize->add_setting('retrotale_fixed_menu', array(
        'default'        => retrotale_default_options('retrotale_fixed_menu'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_fixed_menu_control', array(
        'label'      => __('Fixed Menu', 'retrotale'),
        'section'    => 'retrotale_header_settings',
        'settings'   => 'retrotale_fixed_menu',
        'type'       => 'radio',
        'choices'    => array(
            'Enable' => __( 'Enable' , 'retrotale' ),
            'Disable' => __( 'Disable' , 'retrotale' ),
        ),
    ));
    
    //  =============================
    //  = Postal Address            =
    //  =============================
    $wp_customize->add_setting('retrotale_header_address', array(
        'default'        => retrotale_default_options('retrotale_header_address'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_header_address_control', array(
        'label'      => __('Postal Address', 'retrotale'),
        'section'    => 'retrotale_header_settings',
        'settings'   => 'retrotale_header_address',
    ));
    
    //  =============================
    //  = Email Address             =
    //  =============================
    $wp_customize->add_setting('retrotale_header_email', array(
        'default'        => retrotale_default_options('retrotale_header_email'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_header_email_control', array(
        'label'      => __('Email Address', 'retrotale'),
        'section'    => 'retrotale_header_settings',
        'settings'   => 'retrotale_header_email',
    ));
    
    //  =============================
    //  = Phone Number              =
    //  =============================
    $wp_customize->add_setting('retrotale_header_phone', array(
        'default'        => retrotale_default_options('retrotale_header_phone'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_header_phone_control', array(
        'label'      => __('Phone Number', 'retrotale'),
        'section'    => 'retrotale_header_settings',
        'settings'   => 'retrotale_header_phone',
    ));
    
    //  =============================
    //  = Skype Name                =
    //  =============================
    $wp_customize->add_setting('retrotale_header_skype', array(
        'default'        => retrotale_default_options('retrotale_header_skype'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_header_skype_control', array(
        'label'      => __('Skype Name', 'retrotale'),
        'section'    => 'retrotale_header_settings',
        'settings'   => 'retrotale_header_skype',
    ));
    
    //  ==========================================
    //  = Display Featured Image on single posts =
    //  ==========================================
    $wp_customize->add_setting('retrotale_display_image_post', array(
        'default'        => retrotale_default_options('retrotale_display_image_post'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_image_post_control', array(
        'label'      => __('Display Featured Image on single posts', 'retrotale'),
        'section'    => 'retrotale_posts_settings',
        'settings'   => 'retrotale_display_image_post',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  ====================================
    //  = Display Meta Box on single posts =
    //  ====================================
    $wp_customize->add_setting('retrotale_display_meta_post', array(
        'default'        => retrotale_default_options('retrotale_display_meta_post'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_meta_post_control', array(
        'label'      => __('Display Meta Box on single posts', 'retrotale'),
        'section'    => 'retrotale_posts_settings',
        'settings'   => 'retrotale_display_meta_post',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  =================================
    //  = Next/Previous Post Navigation =
    //  =================================
    $wp_customize->add_setting('retrotale_next_preview_post', array(
        'default'        => retrotale_default_options('retrotale_next_preview_post'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_next_preview_post_control', array(
        'label'      => __('Next/Previous Post Navigation', 'retrotale'),
        'section'    => 'retrotale_posts_settings',
        'settings'   => 'retrotale_next_preview_post',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  ==========================================
    //  = Display Featured Image on pages        =
    //  ==========================================
    $wp_customize->add_setting('retrotale_display_image_page', array(
        'default'        => retrotale_default_options('retrotale_display_image_page'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_image_page_control', array(
        'label'      => __('Display Featured Image on pages', 'retrotale'),
        'section'    => 'retrotale_posts_settings',
        'settings'   => 'retrotale_display_image_page',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  ==================================
    //  = Post Entries Format            =
    //  ==================================
    $wp_customize->add_setting('retrotale_post_entry_format', array(
        'default'        => retrotale_default_options('retrotale_post_entry_format'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_post_entry_format_control', array(
        'label'      => __('Post Entries Format', 'retrotale'),
        'section'    => 'retrotale_post_entries_settings',
        'settings'   => 'retrotale_post_entry_format',
        'type'       => 'radio',
        'choices'    => array(
            'One Column' => __( 'One Column' , 'retrotale' ),
            'Grid - Masonry' => __( 'Grid - Masonry' , 'retrotale' ),
        ),
    ));
    
    //  ====================================
    //  = Display Meta Box on Post Entries =
    //  ====================================
    $wp_customize->add_setting('retrotale_display_meta_post_entry', array(
        'default'        => retrotale_default_options('retrotale_display_meta_post_entry'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_display_meta_post_entry_control', array(
        'label'      => __('Display Meta Box on Post Entries', 'retrotale'),
        'section'    => 'retrotale_post_entries_settings',
        'settings'   => 'retrotale_display_meta_post_entry',
        'type'       => 'radio',
        'choices'    => array(
            'Display' => __( 'Display' , 'retrotale' ),
            'Hide' => __( 'Hide' , 'retrotale' ),
        ),
    ));
    
    //  ===============================
    //  = Content/Excerpt Displaying  =
    //  ===============================
    $wp_customize->add_setting('retrotale_content_archives', array(
        'default'        => retrotale_default_options('retrotale_content_archives'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_content_archives_control', array(
        'label'      => __('Content/Excerpt Displaying', 'retrotale'),
        'section'    => 'retrotale_post_entries_settings',
        'settings'   => 'retrotale_content_archives',
        'type'       => 'radio',
        'choices'    => array(
            'Excerpt' => __( 'Excerpt' , 'retrotale' ),
            'Content' => __( 'Content' , 'retrotale' ),
        ),
    ));
    
    //  =============================
    //  = Excerpt Length            =
    //  =============================
    $wp_customize->add_setting('retrotale_excerpt_length', array(
        'default'        => retrotale_default_options('retrotale_excerpt_length'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_excerpt_length_control', array(
        'label'      => __('Excerpt Length (number of words)', 'retrotale'),
        'section'    => 'retrotale_post_entries_settings',
        'settings'   => 'retrotale_excerpt_length',
    ));
    
    //  =================================
    //  = Latest Posts section headline =
    //  =================================
    $wp_customize->add_setting('retrotale_latest_posts_headline', array(
        'default'        => retrotale_default_options('retrotale_latest_posts_headline'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_latest_posts_headline_control', array(
        'label'      => __('Latest Posts (Blog) page headline', 'retrotale'),
        'section'    => 'retrotale_post_entries_settings',
        'settings'   => 'retrotale_latest_posts_headline',
    ));
    
    //  ==============================
    //  = Character Set              =
    //  ==============================
    $wp_customize->add_setting('retrotale_character_set', array(
        'default'        => retrotale_default_options('retrotale_character_set'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
    ));
 
    $wp_customize->add_control('retrotale_character_set_control', array(
        'label'      => __('Character Set', 'retrotale'),
        'section'    => 'retrotale_font_settings',
        'settings'   => 'retrotale_character_set',
        'type'       => 'radio',
        'choices'    => array(
            'latin' => __( 'Latin' , 'retrotale' ),
            'latin-ext' => __( 'Latin Extended' , 'retrotale' ),
            'cyrillic' => __( 'Cyrillic' , 'retrotale' ),
            'cyrillic-ext' => __( 'Cyrillic Extended' , 'retrotale' ),
            'greek' => __( 'Greek' , 'retrotale' ),
            'greek-ext' => __( 'Greek Extended' , 'retrotale' ),
            'vietnamese' => __( 'Vietnamese' , 'retrotale' ),
        ),
    ));
    
    //  =============================
    //  = Body font                 =
    //  =============================
     $wp_customize->add_setting('retrotale_body_google_fonts', array(
        'default'        => retrotale_default_options('retrotale_body_google_fonts'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
 
    ));
    $wp_customize->add_control( 'retrotale_body_google_fonts_control', array(
        'settings' => 'retrotale_body_google_fonts',
        'label'   => __('Body font', 'retrotale'),
        'section' => 'retrotale_font_settings',
        'type'    => 'select',
        'choices'    => $retrotale_fonts,
    ));
    
    //  =============================
    //  = Site Title font           =
    //  =============================
     $wp_customize->add_setting('retrotale_headings_google_fonts', array(
        'default'        => retrotale_default_options('retrotale_headings_google_fonts'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
 
    ));
    $wp_customize->add_control( 'retrotale_headings_google_fonts_control', array(
        'settings' => 'retrotale_headings_google_fonts',
        'label'   => __('Site Title font', 'retrotale'),
        'section' => 'retrotale_font_settings',
        'type'    => 'select',
        'choices'    => $retrotale_fonts,
    ));
    
    //  =============================
    //  = Site Description font     =
    //  =============================
     $wp_customize->add_setting('retrotale_description_google_fonts', array(
        'default'        => retrotale_default_options('retrotale_description_google_fonts'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
 
    ));
    $wp_customize->add_control( 'retrotale_description_google_fonts_control', array(
        'settings' => 'retrotale_description_google_fonts',
        'label'   => __('Site Description font', 'retrotale'),
        'section' => 'retrotale_font_settings',
        'type'    => 'select',
        'choices'    => $retrotale_fonts,
    ));
    
    //  =============================
    //  = Page/Post Headlines font  =
    //  =============================
     $wp_customize->add_setting('retrotale_headline_google_fonts', array(
        'default'        => retrotale_default_options('retrotale_headline_google_fonts'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
 
    ));
    $wp_customize->add_control( 'retrotale_headline_google_fonts_control', array(
        'settings' => 'retrotale_headline_google_fonts',
        'label'   => __('Page/Post Headlines (h1 - h6) font', 'retrotale'),
        'section' => 'retrotale_font_settings',
        'type'    => 'select',
        'choices'    => $retrotale_fonts,
    ));
    
    //  =============================
    //  = Post Entry Headline font  =
    //  =============================
     $wp_customize->add_setting('retrotale_postentry_google_fonts', array(
        'default'        => retrotale_default_options('retrotale_postentry_google_fonts'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
 
    ));
    $wp_customize->add_control( 'retrotale_postentry_google_fonts_control', array(
        'settings' => 'retrotale_postentry_google_fonts',
        'label'   => __('Post Entry Headline font', 'retrotale'),
        'section' => 'retrotale_font_settings',
        'type'    => 'select',
        'choices'    => $retrotale_fonts,
    ));
    
    //  ========================================
    //  = Sidebar/Footer Widget Headlines font =
    //  ========================================
     $wp_customize->add_setting('retrotale_sidebar_google_fonts', array(
        'default'        => retrotale_default_options('retrotale_sidebar_google_fonts'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
 
    ));
    $wp_customize->add_control( 'retrotale_sidebar_google_fonts_control', array(
        'settings' => 'retrotale_sidebar_google_fonts',
        'label'   => __('Sidebar/Footer Widget Headlines font', 'retrotale'),
        'section' => 'retrotale_font_settings',
        'type'    => 'select',
        'choices'    => $retrotale_fonts,
    ));
    
    //  =============================
    //  = Main Header Menu font     =
    //  =============================
     $wp_customize->add_setting('retrotale_menu_google_fonts', array(
        'default'        => retrotale_default_options('retrotale_menu_google_fonts'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'retrotale_sanitize_text',
 
    ));
    $wp_customize->add_control( 'retrotale_menu_google_fonts_control', array(
        'settings' => 'retrotale_menu_google_fonts',
        'label'   => __('Main Header Menu font', 'retrotale'),
        'section' => 'retrotale_font_settings',
        'type'    => 'select',
        'choices'    => $retrotale_fonts,
    ));
    
    //  =============================
    //  = Custom CSS                =
    //  =============================
    $wp_customize->add_setting('retrotale_own_css', array(
        'default'        => retrotale_default_options('retrotale_own_css'),
        'capability'     => 'edit_theme_options',
        'type'           => 'theme_mod',
        'sanitize_callback' => 'wp_filter_nohtml_kses',
    ));
 
    $wp_customize->add_control( new retrotale_customize_textarea_control($wp_customize, 'retrotale_own_css_control', array(
        'label'    => __('Custom CSS', 'retrotale'),
        'section'  => 'retrotale_general_settings',
        'settings' => 'retrotale_own_css',
    )));
}

add_action('customize_register', 'retrotale_customize_register');

/**
 * Sanitize URIs
*/
function retrotale_sanitize_uri($uri) {
	if('' === $uri){
		return '';
	}
	return esc_url_raw($uri);
}

/**
 * Sanitize Texts
*/
function retrotale_sanitize_text($str) {
	if('' === $str){
		return '';
	}
	return sanitize_text_field( $str);
} ?>