<?php 
/**
 * Customizer functions.
 *
 * @package Sunset
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Attach hooks
 */
add_action( 'customize_register', 'sunset_customizer_init' );
add_action( 'customize_preview_init', 'sunset_customizer_js_file' );
add_action( 'customize_controls_enqueue_scripts', 'sunset_customizer_controls_js' );
add_action( 'customize_controls_enqueue_scripts', 'sunset_customizer_controls_css' );
add_action( 'customize_register', 'sunset_register_partials' );

/**
 * Include scripts for customizer front-end
 */
function sunset_customizer_js_file(){
	wp_enqueue_script( 'sunset-customizer', get_template_directory_uri() . '/assets/js/theme-customizer.js', [ 'jquery', 'customize-preview' ], null, true );
}

/**
 * Include scripts for customizer controls sidebar
 */
function sunset_customizer_controls_js(){
	wp_enqueue_script( 'sunset-customizer-controls', get_template_directory_uri() . '/assets/js/theme-customizer-controls.js', [ 'jquery', 'customize-preview' ], null, true );
	wp_enqueue_script( 'sunset-jquery-blockUI', get_template_directory_uri() . '/assets/js/jquery.blockUI.js', [ 'jquery', 'customize-preview' ], null, true );
	wp_enqueue_script( 'sunset-select2', get_template_directory_uri() . '/assets/js/select2.min.js', [ 'jquery', 'customize-preview' ], null, true );
	
	wp_enqueue_style( 'sunset-select2-css', get_template_directory_uri() . '/assets/css/select2.min.css', array(), null );
	wp_enqueue_style( 'sunset-jquery-ui-css', get_template_directory_uri() . '/assets/css/jquery-ui.css', array(), null );

	wp_localize_script( 'sunset-customizer-controls', 'sunset_ajax',
		array(
			'url' => admin_url('admin-ajax.php'),
			'nonce' => wp_create_nonce('sunset_nonce')
		)
	);
	wp_enqueue_editor();
}

/**
 * Include styles for cistomizer controls
 */
function sunset_customizer_controls_css() {
    wp_enqueue_style( 'sunset-customizer-css', get_template_directory_uri() . '/assets/css/customizer.css' );
	wp_enqueue_style( 'font-awesome', get_template_directory_uri() . "/assets/css/fa/font-awesome.css", false, '5.6', 'all' );
	wp_enqueue_style( 'font-awesome-brands', get_template_directory_uri() . "/assets/css/fa/brands.css", false, '5.6', 'all' );	
}

/**
 * Register partials for Customizer
 */
function sunset_register_partials( WP_Customize_Manager $wp_customize ) {
 
    // Abort if selective refresh is not available.
    if ( ! isset( $wp_customize->selective_refresh ) ) {
        return;
    }
 
    $wp_customize->selective_refresh->add_partial( 'header_logo', array(
        'selector' => '.logo',
        'settings' => array( 'custom_logo' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'header_logo_dark_mode', array(
        'selector' => '.logo-img.logo-img--dark-mode',
        'settings' => array( 'custom_logo_dark_mode' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'burger', array(
        'selector' => '.burger',
        'settings' => array( 'sunset_header_auto_responsive' ),
		'container_inclusive' => false,
    ) );

	$social_links = sunset_get_social_links();
	foreach ($social_links as $key => $network) {
		$wp_customize->selective_refresh->add_partial( 'social_links_'.$key, array(
			'selector' => '.social-menu__item--'.sanitize_title($network->text),
			'settings' => array( 'sunset_social_links' ),
			'container_inclusive' => true,
		) );
	}

	$wp_customize->selective_refresh->add_partial( 'header_add_search', array(
        'selector' => '.main-nav-menu--search',
        'settings' => array( 'sunset_header_add_search' ),
		'container_inclusive' => true,
		'fallback_refresh'    => false,
    ) );
	
	$wp_customize->selective_refresh->add_partial( 'topbar', array(
        'selector' => '.topbar__inner__content',
        'settings' => array( 'sunset_topbar_content' ),
		'container_inclusive' => false,
		'render_callback' => function() {
            return sunset_get_option( 'sunset_topbar_content' );
        },
    ) );

	$wp_customize->selective_refresh->add_partial( 'page_breadcrumbs', array(
        'selector' => 'body.page .breadcrumbs',
        'settings' => array( 'sunset_page_show_breadcrumbs' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'page_title', array(
        'selector' => 'body.page .title.title--primary',
        'settings' => array( 'sunset_page_header_type' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'archive_title', array(
        'selector' => 'body.archive .heading-section.with-siblings .title.title--primary.title--current, 
			body.archive .heading-section:not(.with-siblings) .title.title--primary',
        'settings' => array( 'sunset_blog_title_type' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'archive_posts_count', array(
        'selector' => '.posts-found',
        'settings' => array( 'sunset_blog_title_show_posts_count' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'archive_breadcrumbs', array(
        'selector' => 'body.archive .breadcrumbs',
        'settings' => array( 'sunset_blog_title_show_breadcrumbs' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'archive_tags', array(
        'selector' => 'body.archive .loop-post__tags',
        'settings' => array( 'sunset_blog_show_tags' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'archive_categories', array(
        'selector' => 'body.archive .loop-post__categories',
        'settings' => array( 'sunset_blog_show_categories' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'archive_excerpt', array(
        'selector' => 'body.archive .loop-post__excerpt',
        'settings' => array( 'sunset_blog_show_excerpt' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'archive_date', array(
        'selector' => 'body.archive .loop-post__meta__date',
        'settings' => array( 'sunset_blog_show_date' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'archive_read-time', array(
        'selector' => 'body.archive .loop-post__meta__read-time',
        'settings' => array( 'sunset_blog_show_read_time' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'post_breadcrumbs', array(
        'selector' => 'body.single-post .breadcrumbs',
        'settings' => array( 'sunset_post_show_breadcrumbs' ),
		'container_inclusive' => false,
    ) );
	
	$wp_customize->selective_refresh->add_partial( 'post_toc', array(
        'selector' => 'body.single-post .post__contents',
        'settings' => array( 'sunset_post_toc_enable' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'post_date', array(
        'selector' => 'body.single-post .post-date__date',
        'settings' => array( 'sunset_post_show_date' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'post_read-time', array(
        'selector' => 'body.single-post .post-date__read-time',
        'settings' => array( 'sunset_post_show_read_time' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'post_meta', array(
        'selector' => 'body.single-post .post-meta',
        'settings' => array( 'sunset_post_meta_show' ),
		'container_inclusive' => false,
    ) );

	$wp_customize->selective_refresh->add_partial( 'related_title', array(
        'selector' => 'body.single-post .related-posts .related-posts__title',
        'settings' => array( 'sunset_post_related_title_text' ),
		'container_inclusive' => false,
    ) );
}

/**
 * Init Customizer options
 */
function sunset_customizer_init( WP_Customize_Manager $wp_customize ){

	/**
	 * Force boolean value 
	 * @see https://stackoverflow.com/a/29277952
	 */
	class Sunset_Force_Boolean_Settings extends WP_Customize_Setting {

		public function value() {
			return (bool) parent::value();
		}
	}

	/**
	 * Multiple select customize control class.
	 */
	class Sunset_Customize_Control_Multiple_Select extends WP_Customize_Control {

		/**
		 * The type of customize control being rendered.
		 */
		public $type = 'multiple-select';

		/**
		 * Displays the multiple select on the customize screen.
		 */
		public function render_content() {

			if ( empty( $this->choices ) )
				return;

			$values = $this->value();
			?>
			<label for="_customize-input-<?php echo esc_html( $this->id ); ?>" class="customize-control-title">
				<?php echo esc_html( $this->label ); ?>
			</label>
			<span id="_customize-description-<?php echo esc_html( $this->id ); ?>" class="description customize-control-description">
				<?php echo esc_html( $this->description ); ?>
			</span>
			<select name="<?php echo esc_attr( $this->id ); ?>" id="_customize-input-<?php echo esc_html( $this->id ); ?>" class="customize-control-select-multiple" multiple="multiple" style="height: 100%;" <?php $this->link(); ?>>
				<?php
					foreach ( $this->choices as $value => $label ) {
						$selected = selected( $label, $values[$value], false );
						echo '<option value="' . esc_attr( $value ) . '"' . $selected . '>' . $label . '</option>';
					}
				?>
			</select>
			
		<?php }
	}

	/**
	 * Media upload customize control class.
	 */
	class Sunset_Customize_Control_Media extends WP_Customize_Control {

		/**
		 * The type of customize control being rendered.
		 */
		public $type = 'media-upload';

		/**
		 * Displays the media button on the customize screen.
		 */
		public function render_content() {
			$media = wp_get_attachment_image($this->value());
			?>
			<label for="_customize-input-<?php echo esc_html( $this->id ); ?>" class="customize-control-title">
				<?php echo esc_html( $this->label ); ?>
			</label>
			<span id="_customize-description-<?php echo esc_html( $this->id ); ?>" class="description customize-control-description">
				<?php echo esc_html( $this->description ); ?>
			</span>

			<button type="button" id="sunset-media-button-<?php echo esc_attr( $this->id ); ?>" class="sunset-upload-media-button button"><?php _e("Upload image", 'my-sunset'); ?></button>
   			<input type="hidden" class="sunset-media-id" name="<?php echo esc_attr( $this->id ); ?>" id="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); ?> />
			<p>
				<?php if ($media) {
					echo $media;
				} else {
					echo '<img src="" alt="" style="display: none" />';
				} ?>
			</p>
			<button type="button" style="<?php echo !$media ? 'display: none' : ''; ?>" class="button-link button-link-delete item-delete submitdelete deletion sunset-delete-media-button"><?php esc_html_e('Remove', 'my-sunset')?></button>
			
			<?php 
		}
	}

	/**
	 * TinyMCE Editor field control class
	 */
	class Sunset_Customize_Control_Rich_Text extends WP_Customize_Control {

		/**
		 * The type of control being rendered
		 */
		public $type = 'tinymce_editor';
		/**
		 * Enqueue our scripts and styles
		 */
		public function enqueue() {			
			wp_enqueue_editor();
		}
		/**
		 * Pass our TinyMCE toolbar config to JavaScript
		 */
		public function to_json() {
			parent::to_json();

			$this->json['sunset_tinymce_toolbar1'] = isset( $this->input_attrs['toolbar1'] ) ? esc_attr( $this->input_attrs['toolbar1'] ) : 'bold italic bullist numlist alignleft aligncenter alignright link';

			$this->json['sunset_tinymce_toolbar2'] = isset( $this->input_attrs['toolbar2'] ) ? esc_attr( $this->input_attrs['toolbar2'] ) : '';

			$this->json['sunset_tinymce_mediabuttons'] = isset( $this->input_attrs['mediaButtons'] ) && ( $this->input_attrs['mediaButtons'] === true ) ? true : false;

			$this->json['sunset_tinymce_height'] = isset( $this->input_attrs['height'] ) ? esc_attr( $this->input_attrs['height'] ) : 200;
		}
		/**
		 * Render the control in the customizer
		 */
		public function render_content() {
			?>
			<div class="tinymce-control">
				<span class="customize-control-title">
					<?php echo esc_html( $this->label ); ?>
				</span>

				<?php if ( ! empty( $this->description ) ) { ?>
					<span class="customize-control-description">
						<?php echo esc_html( $this->description ); ?>
					</span>
				<?php } ?>

				<textarea id="<?php echo esc_attr( $this->id ); ?>" class="customize-control-tinymce-editor" <?php $this->link(); ?>><?php echo wp_kses_post( $this->value() ); ?></textarea>
			</div>
			<?php
		}
	};

	/**
	 * Dynamic social link field  control class.
	 */
	class Sunset_Customize_Control_Social_Link extends WP_Customize_Control {

		/**
		 * The type of customize control being rendered.
		 */
		public $type = 'social-link';

		public $social_networks = array();
		
		public function __construct( $manager, $id, $args = array(), $options = array() ) {
			parent::__construct( $manager, $id, $args );

			$this->social_networks = sunset_get_social_icons_names();
		}
		

		private function social_item_html($key, $val) {
			ob_start();
			?> 
			<li class="customizer-social-link-control customizer-social-link-control-droppable customize-control customize-control-nav_menu_item menu-item menu-item-depth-0 menu-item-page menu-item-edit-active move-left-disabled  move-right-disabled">
				<div class="menu-item-bar">
					<div class="menu-item-handle ui-sortable-handle">
						<span class="item-type" aria-hidden="true"><?php echo esc_html( $this->label ); ?></span>
						<span class="item-title" aria-hidden="true">
							<span class="spinner"></span>
							<span class="menu-item-title"><?php echo esc_html($val->text); ?></span>
						</span>
						<span class="item-controls">
							<button type="button" class="button-link item-edit" aria-expanded="false"><span class="screen-reader-text">
							<?php
								/* translators: 1: Title of a menu item, 2: Type of a menu item. */
								printf( __( 'Edit menu item: %1$s (%2$s)', 'my-sunset' ), '', esc_html( $this->label ) );
							?>
							</span><span class="toggle-indicator" aria-hidden="true"></span></button>
							<button type="button" class="button-link item-delete submitdelete deletion"><span class="screen-reader-text">
							<?php
								/* translators: 1: Title of a menu item, 2: Type of a menu item. */
								printf( __( 'Remove Menu Item: %1$s (%2$s)', 'my-sunset' ), '', esc_html( $this->label ) );
							?></span></button>
						</span>
						<div class="menu-item-reorder-nav">
							<button type="button" class="menus-move-up" tabindex="0" aria-hidden="false"><?php esc_html_e('Move up', 'my-sunset')?></button>
							<button type="button" class="menus-move-down" tabindex="0" aria-hidden="false"><?php esc_html_e('Move down', 'my-sunset')?></button>	
						</div>
				
					</div>
				</div>	
				<div class="menu-item-settings">
					<label for="_customize-input-<?php echo esc_html( $this->id ); ?>-name-<?php echo esc_attr($key); ?>" class="customize-control-title">
						<?php echo esc_html( $this->label ); ?>
					</label>
					<p class="field-name description description-thin">
						<label><?php _e('Title', 'my-sunset'); ?><br>
							<input placeholder="<?php _e('e.g. My profile.', 'my-sunset'); ?>" value="<?php echo esc_html($val->text); ?>" id="_customize-input-<?php echo esc_html( $this->id ); ?>-name-<?php echo $key; ?>" class="customize-control-social-link-input customize-control-social-link-name" type="text"  />
						</label>
					</p>
					<p class="field-url description description-thin">
						<label><?php _e('URL', 'my-sunset'); ?><br>
							<input placeholder="<?php _e('URL of the social network', 'my-sunset'); ?>" value="<?php echo esc_html($val->link); ?>" id="_customize-input-<?php echo esc_html( $this->id ); ?>-url-<?php echo $key; ?>" class="customize-control-social-link-input customize-control-social-link-url" type="url" />
						</label>
					</p>
					<div class="customizer-repeater-image-control">
						<p class="field-icon description description-thin">
							<?php _e('Icon', 'my-sunset'); ?><br>

							<fieldset>
								<ul class="customize-control-icons-set">
									<?php foreach ($this->social_networks as $network_slug) : ?>
									<li>
										<label>
											<input type="radio" name="customize-control-icons-set-<?php echo esc_html($key); ?>" value="<?php echo esc_html($network_slug); ?>" <?php if ($val->icon_type === $network_slug) echo 'checked' ?> />
											<i class="fab fa-<?php echo esc_html($network_slug); ?>"></i>
										</label>
									</li>
									<?php endforeach; ?>
									<li>
										<label>
											<input type="hidden" class="customize-control-social-link-input customize-control-social-link-icon-url" value="<?php echo esc_html($val->icon); ?>">
											<input type="hidden" class="customize-control-social-link-input customize-control-social-link-icon-type" value="<?php echo esc_html($val->icon_type); ?>">
										
										</label>
									</li>
								</ul>
							</fieldset>
						</p>
					</div>
					<p class="field-color field-color--color description description-thin">
						<label><?php _e('Color', 'my-sunset'); ?><br></label>
						<input value="<?php echo esc_html($val->icon_color); ?>" id="_customize-input-<?php echo esc_html( $this->id ); ?>-color-<?php echo esc_html($key); ?>" class="customize-control-social-link-input customize-control-social-link-icon-color" type="text" />
						
					</p>
					<p class="field-color field-color--hover-color description description-thin">
						<label><?php _e('Hover Color', 'my-sunset'); ?><br></label>
						<input value="<?php echo esc_html($val->icon_hover_color); ?>" id="_customize-input-<?php echo esc_html( $this->id ); ?>-hover-color-<?php echo esc_html($key); ?>" class="customize-control-social-link-input customize-control-social-link-icon-hover-color" type="text" />
						
					</p>
					<button type="button" class="button-link button-link-delete item-delete submitdelete deletion customizer-remove-social-link"><?php esc_html_e('Remove', 'my-sunset')?></button>
				</div>
			</li>
			<?php
			return ob_get_clean();
		}

		/**
		 * Displays the social link on the customize screen.
		 */
		public function render_content() {

			?>

			<div class="customizer-social-link-control-container customize-control-nav_menu">
			<ul class="menu wp-clearfix ui-sortable">

			<?php if ( empty( $this->value() ) || $this->value() === '[]' ) : 
				echo $this->social_item_html(null, null);	
				?>
				</ul>
				<input name="<?php echo esc_attr( $this->id ); ?>" class="customizer-social-link-colector" type="hidden" <?php $this->link(); ?> />
			
			<?php 
			else :
				$values = html_entity_decode(stripslashes($this->value()));
				$json = json_decode( $values );

				if ( ! is_array( $json ) ) {
					$json = array( $values );
				}
				
				foreach ($json as $key => $val) {
					echo $this->social_item_html($key, $val);
				}
				?>

				</ul>
				<input name="<?php echo esc_attr( $this->id ); ?>" class="customizer-social-link-colector" type="hidden" <?php $this->link(); ?> />
				
				<?php

			endif;
			?>
				<div class="customize-control-social-link-buttons customize-control-nav_menu-buttons">
					<button type="button" class="button add-new-menu-item add_field customizer-add-new-social-link" aria-label="<?php esc_attr_e( 'Add or remove menu items', 'my-sunset' ); ?>" aria-expanded="false" aria-controls="available-social-link-items">
						<?php _e('Add item', 'my-sunset'); ?>
					</button>
					<button type="button" class="button-link reorder-toggle" aria-label="<?php esc_attr_e( 'Reorder menu items', 'my-sunset' ); ?>">
						<span class="reorder"><?php _e( 'Reorder', 'my-sunset' ); ?></span>
						<span class="reorder-done"><?php _e( 'Done', 'my-sunset' ); ?></span>
					</button>
				</div>
			</div>
			<?php
		}
	}

	/**
	 * Font selection control (family, size, weight, transform, style)
	 */
	class Sunset_Customize_Control_Font extends WP_Customize_Control {

		/**
		 * The type of customize control being rendered.
		 */
		public $type = 'font';

		/**
		 * The type of tag to be modified. 
		 * Use "primary" for "body".
		 * Use "menu" for menu items.
		 * Use "widget_title" for widget titles.
		 */
		public $tag = 'h1';

		/**
		 * Default labels
		 */
		public $label = 'Select font family';

		/**
		 * Custom attributes
		 */
		public $font_size_attrs = array();

		/**
		 * The saved font values decoded from json
		 */
		private $fontValues = [];

		/**
		 * Save font options to json
		 */
		public function __construct( $manager, $id, $args = array(), $options = array() ) {
			parent::__construct( $manager, $id, $args );

			// Decode the default json font value
			$this->fontValues = json_decode( $this->value() );
		}

		/**
		 * Displays the font selection on the customize screen.
		 */
		public function render_content() {

			if ( empty( $this->tag ) )
				return;

			$fonts = sunset_get_customizer_fonts();
			$font_json = json_decode($this->value(), true);
			$font_weights = sunset_get_font_weight( $font_json['font'] );
			$font_transforms = sunset_get_all_text_transforms();

			$font_size_attrs = '';
			if ( !empty( $this->font_size_attrs ) ) {
				foreach ($this->font_size_attrs as $attr_name => $attr_value) {
					$font_size_attrs .= " $attr_name='$attr_value'";
				}
			}

			?>
			<input type="hidden" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value='<?php echo esc_attr( $this->value() ); ?>' class="customize-control-google-font-selection" <?php $this->link(); ?> />
			
			<p>
			<label for="_customize-input-<?php echo esc_html( $this->id ); ?>-font-family" class="customize-control-title">
				<?php echo esc_html( $this->label ); ?>
			</label>
			<span id="_customize-description-<?php echo esc_html( $this->id ); ?>-font" class="description customize-control-description">
				<?php echo esc_html( $this->description ); ?>
			</span>
			<select id="_customize-input-<?php echo esc_html( $this->id ); ?>-font-family" class="customize-control-font-family" style="height: 100%;">
				<option value=""><?php _e('Default font', 'my-sunset'); ?></option>
				<?php
					foreach ( $fonts as $value => $label ) {
						$selected = selected( $value, $font_json['font'], false );
						echo '<option value="' . esc_attr( $value ) . '"' . $selected . '>' . $label . '</option>';
					}
				?>
			</select>
			</p>
			
			<p>
			<label for="_customize-input-<?php echo esc_html( $this->id ); ?>-font-weight" class="customize-control-title">
				<?php echo __( 'Font weight', 'my-sunset' ); ?>
			</label>
			<select id="_customize-input-<?php echo esc_html( $this->id ); ?>-font-weight" class="customize-control-font-weight" style="height: 100%;">
				<?php
					foreach ( $font_weights as $value => $label ) {
						$selected = selected( $value, $font_json['weight'], false );
						echo '<option class="font-weight-'.esc_attr( $value ).'" value="' . esc_attr( $value ) . '"' . $selected . '>' . $label . '</option>';
					}
				?>
			</select>
			</p>
			
			<p>
			<label for="_customize-input-<?php echo esc_html( $this->id ); ?>-font-transform" class="customize-control-title">
				<?php echo __( 'Text transform', 'my-sunset' ); ?>
			</label>
			<select id="_customize-input-<?php echo esc_html( $this->id ); ?>-font-transform" class="customize-control-font-transform" style="height: 100%;">
				<?php
					foreach ( $font_transforms as $value => $label ) {
						$selected = selected( $value, $font_json['transform'], false );
						echo '<option class="text-transform-'.esc_attr( $value ).'" value="' . esc_attr( $value ) . '"' . $selected . '>' . $label . '</option>';
					}
				?>
			</select>
			</p>
			
			<p>
			<label for="_customize-input-<?php echo esc_html( $this->id ); ?>-font-size" class="customize-control-title">
				<?php echo __( 'Font size (px)', 'my-sunset' ); ?>
			</label>
			<input type="number" <?php echo esc_attr($font_size_attrs); ?> id="_customize-input-<?php echo esc_html( $this->id ); ?>-font-size" class="customize-control-font-size" value="<?php echo $font_json['size']; ?>" />
			</p>
			<?php
		}
	}

	/**
	 * Separator between customizer options
	 */
	class Sunset_Customize_Control_Separator extends WP_Customize_Control {

		public function render_content() {
			?>
				<hr id="_customize-separator-<?php echo esc_html( $this->id ); ?>-font-transform" class="customize-control-separator" />
			<?php
		}
	}

	$default_colors = sunset_get_color_defaults();
	$default_values = sunset_get_defaults();
	$default_fonts = sunset_get_default_fonts();

	$panel = 'sunset_topbar_panel';

	if ( ! $wp_customize->get_panel( $panel ) ) {
		
		$wp_customize->add_panel(
			$panel,
			array(
				'priority' => 21,
				'title' => __( 'Top bar', 'my-sunset' ),
			)
		);
	}

	if ($section = 'sunset_topbar_options' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Top bar options', 'my-sunset'),
				'priority' => 1,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_topbar_enable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Enable top bar', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_topbar_full_width';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => _x('Full width', 'topbar', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_topbar_enabled',
			) 
		);

		$setting = 'sunset_topbar_runline';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => _x('Enable running line', 'topbar', 'my-sunset'),
				'description'    => __('Exit customizer to see the animation.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_topbar_enabled',
			)
		);

		$setting = 'sunset_topbar_runline_duration';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint',
				'validate_callback' => function( $validity, $value, $setting ) {
					return ( 
						sunset_setting_prevent_empty( $validity, $value, $setting )
						&&
						sunset_setting_set_values_range( $validity, $value, $setting, array('min' => 1, 'max' => 10) )
					);
				},
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Running line speed', 'my-sunset'),
				'description'    => __('Enter a value from 1 to 10.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_topbar_enabled( $control )
						&&
						sunset_flag_is_topbar_runline_enabled( $control )
					);
				},
			)
		);

		$setting = 'sunset_topbar_sticky';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Sticky top bar', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_topbar_enabled( $control )
						&&
						sunset_flag_is_header_fixed_enabled( $control )
					);
				},
			)
		);

		$setting = 'sunset_topbar_align';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'left'   => __('Align left', 'my-sunset'),
					'right'   => __('Align right', 'my-sunset'),
					'center'   => __('Align center', 'my-sunset'),
					'spread'   => __('Spread', 'my-sunset'),
				),
				'label'    => __('Top bar alignment', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_topbar_enabled( $control ) 
						&& 
						!sunset_flag_is_topbar_runline_enabled( $control )
					);
				},
			)
		);

		$setting = 'sunset_topbar_add_border';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'postMessage',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Add border', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_topbar_enabled( $control ) 
					);
				},
			)
		);

		$setting = 'sunset_topbar_border_height';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_values[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'absint',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Border height (px)', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_topbar_enabled( $control ) 
						&& 
						sunset_flag_is_topbar_border_enabled( $control )
					);
				},
			)
		);

		$setting = 'sunset_topbar_content';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'postMessage', //'refresh',
				'sanitize_callback' => 'wp_kses_post',
			)
		);
		
		$wp_customize->add_control(
			new Sunset_Customize_Control_Rich_Text (
				$wp_customize,
				$setting, 
				array (
					'label'    => __('Content of the top bar', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => function( $control ) {
						return ( 
							sunset_flag_is_topbar_enabled( $control )
						);
					},
					'input_attrs' => array(
						//'toolbar1'     => 'formatselect bold italic link bullist',
						'mediaButtons' => true,
						'height'       => 200,
					)
				)
			)
		);

	}

	if ($section = 'sunset_topbar_colors' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Top bar colors', 'my-sunset'),
				'priority' => 2,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_topbar_background_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Background color', 'my-sunset'),
					'description'    => __('Leave blank for the transparent background.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_topbar_enabled',
				)
			)
		);

		$setting = 'sunset_topbar_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Font color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_topbar_enabled',
				)
			)
		);

		$setting = 'sunset_topbar_border_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Border color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => function( $control ) {
						return ( 
							sunset_flag_is_topbar_enabled( $control ) 
							&& 
							sunset_flag_is_topbar_border_enabled( $control )
						);
					},
				)
			)
		);

	}

	if ($section = 'sunset_topbar_typo' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Top bar typography', 'my-sunset'),
				'priority' => 3,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_topbar_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'topbar',
					'type' => 'font',
					'label'    => __('Top bar font', 'my-sunset'),
					'description'    => __('Set the font of the Top bar.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_topbar_enabled',
				)
			)
		);

	}

	if ($section = 'sunset_topbar_mobile_options' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Top bar mobile options', 'my-sunset'),
				'priority' => 4,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_topbar_mobile_hide';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Disable top bar on mobile', 'my-sunset'),
				'description'    => sprintf( _x('This will be hide if screen size is less than %d px', 'topbar', 'my-sunset'), SUNSET_MOBILE_BREAKPOINT),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_topbar_enabled',
			) 
		);
	}

	$panel = 'sunset_header_panel';

	if ( ! $wp_customize->get_panel( $panel ) ) {
		
		$wp_customize->add_panel(
			$panel,
			array(
				'priority' => 21,
				'title' => __( 'Header', 'my-sunset' ),
			)
		);
	}

	if ($section = 'sunset_header_options' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Header options', 'my-sunset' ),
				'priority' => 1,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_header_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'header_1'   => __('Logo on the left - menu on the right', 'my-sunset' ),
					'header_2'   => __('Logo on the center - menu on the sides', 'my-sunset' ),
					'header_3'   => __('Logo and menu on the left', 'my-sunset' ),
					'header_4'   => __('Logo on the left - burger menu on the right', 'my-sunset' ),
				),
				'label'    => __('Header type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_header_add_search';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting,
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Add search', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_header_fixed';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Sticky header', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			) 
		);

		$setting = 'sunset_header_fixed_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'visible'   => __('Visible always', 'my-sunset'),
					'hide-on-scroll'   => __('Hide on scroll down, visible on scroll up', 'my-sunset'),
				),
				'label'    => __('Type of the sticky header', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_header_fixed_enabled',
			)
		);

		$setting = 'sunset_header_full_width';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => _x('Full width', 'header', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_header_add_social';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Add social links', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_header_add_shadow';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'postMessage',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Add shadow', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_header_add_border';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'postMessage',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Add border', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_header_border_height';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_values[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'absint',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Border height (px)', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_header_border_enabled',
			)
		);

		$setting = 'sunset_header_menu_hover_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
		 	) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'underlined'     => __('Underline', 'my-sunset'),
					'buttoned'   => __('Colored background', 'my-sunset'),
					'colored'   => __('Color', 'my-sunset'),
					'bordered'   => __('Frame', 'my-sunset'),
					'stroked'   => __('Stroke', 'my-sunset'),
					'shadowed'   => __('Drop shadow', 'my-sunset'),
				),
				'label'    => __('Menu hover type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

	}

	if ($section = 'sunset_header_colors' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Header colors', 'my-sunset'),
				'priority' => 2,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_header_background_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Header background color', 'my-sunset'),
					'description'    => __('Leave blank for the transparent background.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_header_border_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Header border color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_header_border_enabled',
				)
			)
		);

		$setting = 'sunset_header_menu_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Menu item color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_header_menu_hover_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Menu item hover color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_header_menu_hover_bg_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Menu item hover background color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_hover_buttoned_enabled',
				)
			)
		);

		$setting = 'sunset_header_menu_hover_border_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Menu item hover border color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_hover_bordered_enabled',
				)
			)
		);

		$setting = 'sunset_header_mobile_menu_background';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Mobile menu background color', 'my-sunset'),
					'description'    => __('Leave blank for the transparent background.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_header_mobile_menu_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Mobile menu item color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_header_mobile_menu_hover_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Mobile menu item hover color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

	}

	if ($section = 'sunset_header_typo' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Header typography', 'my-sunset'),
				'priority' => 3,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_header_dynamic_font_size';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Enable dynamic font sizes', 'my-sunset'),
				'description'    => __('Font sizes will be scaled depending on screen size. You provide the maximum value.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			) 
		);

		$setting = 'sunset_menu_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'menu',
					'type' => 'font',
					'label'    => __('Menu font', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);

		$setting = 'sunset_menu_mobile_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'menu',
					'type' => 'font',
					'label'    => __('Mobile menu font', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);	

	}

	if ( $section = 'sunset_header_mobile_options' ) {

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Header mobile options', 'my-sunset'),
				'priority' => 4,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_header_auto_responsive';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Automatically switch to mobile menu', 'my-sunset'),
				'description' => __('Menu will be switched into mobile when menu items cannot be fitted into a single line.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			) 
		);

		$setting = 'sunset_header_mobile_breakpoint';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint', //converts value to a non-negative integer
				'validate_callback'   => 'sunset_setting_prevent_empty',
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Mobile menu breakpoint', 'my-sunset'),
				'description'    => __('Set the breakpoint when the main menu will be switched to the mobile version.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_header_auto_responsive_disabled',
			)
		);

		$setting = 'sunset_header_mobile_sticky_disable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Disable sticky header', 'my-sunset'),
				'description'    => __('Disable sticky header when menu switched to mobile version.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_header_burger_icon_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
		 	) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'burger'     => __('Burger', 'my-sunset'),
					'kebab'   => __('Kebab', 'my-sunset'),
					'kebab_2'   => __('Kebab horizontal', 'my-sunset'),
					'text'   => __('Text', 'my-sunset'),
					
				),
				'label'    => __('Menu icon type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_header_burger_icon_text';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'wp_filter_nohtml_kses', //removes all HTML from content
				'validate_callback'   => 'sunset_setting_prevent_empty',
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'text',
				'label'    => __('Menu icon text', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_header_burger_icon_type_text',
			)
		);

		$setting = 'sunset_header_menu_mobile_hover_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
		 	) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'underlined'     => __('Underline', 'my-sunset'),
					'buttoned'   => __('Colored background', 'my-sunset'),
					'colored'   => __('Color', 'my-sunset'),
					'bordered'   => __('Frame', 'my-sunset'),
					'stroked'   => __('Stroke', 'my-sunset'),
					'shadowed'   => __('Drop shadow', 'my-sunset'),
				),
				'label'    => __('Mobile menu hover type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_header_menu_mobile_align_x';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
		 	) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'left'   => __('Align left', 'my-sunset'),
					'right'   => __('Align right', 'my-sunset'),			
				),
				'label'    => __('Mobile menu items alignment', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

	}

	if ($section = 'title_tagline' ){

		$setting = 'sunset_logo_dark_mode';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint'
			) 
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Media(
				$wp_customize,
				$setting, 
				array (
					'type' => 'media-upload',
					'label'    => __('Logo for dark mode', 'my-sunset'),
					'description'    => __('Using when dark mode enabled or logo is on the dark background.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'priority' => 8,
				)
			)
		);

		$setting = 'sunset_logo_width';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'absint', //converts value to a non-negative integer
				'validate_callback' => function( $validity, $value, $setting ) {
					return ( 
						sunset_setting_prevent_empty( $validity, $value, $setting )
						&&
						sunset_setting_set_values_range( $validity, $value, $setting, array('min' => 50, 'max' => 400) )
					);
				},
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Logo width', 'my-sunset'),
				'description'    => __('Set number between 50 and 400 (px)', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'priority' => 8,
				'input_attrs' => array(
					'min' => 50,
					'max' => 400
				)
			)
		);

		$setting = 'sunset_preloader_enable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Enable preloader', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		
	}

	$panel = 'sunset_footer_panel';

	if ( ! $wp_customize->get_panel( $panel ) ) {
		
		$wp_customize->add_panel(
			$panel,
			array(
				'priority' => 21,
				'title' => __( 'Footer', 'my-sunset' ),
			)
		);
	}

	if ($section = 'sunset_footer_options' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Footer options', 'my-sunset'),
				'priority' => 1,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_footer_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'footer_1'     => __('Columns', 'my-sunset'),
					'footer_2'   => __('Cross', 'my-sunset'),
				),
				'label'    => __('Footer type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_footer_columns';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint',
				'validate_callback' => function( $validity, $value, $setting ) {
					return ( 
						sunset_setting_prevent_empty( $validity, $value, $setting )
						&&
						sunset_setting_set_values_range( $validity, $value, $setting, array('min' => 1, 'max' => 6) )
					);
				},
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Number of columns', 'my-sunset'),
				'description'    => __('A number from 1 to 6', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_footer_columns_enabled',
			)
		);

		$setting = 'sunset_footer_full_width';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox',
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => _x('Full width', 'footer', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			) 
		);

		$setting = 'sunset_footer_add_border';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'postMessage',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Add border', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			)
		);

		$setting = 'sunset_footer_border_height';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_values[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'absint',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Border height (px)', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_footer_border_enabled( $control )
					);
				},
			)
		);

	}

	if ($section = 'sunset_footer_colors' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Footer colors', 'my-sunset'),
				'priority' => 2,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_footer_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Font color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_footer_widget_title_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Footer title color', 'my-sunset'),
					'description'    => __('Color of the footer widgets titles.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_footer_background_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Background color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_footer_border_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Footer border color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_footer_border_enabled',
				)
			)
		);
	}

	if ($section = 'sunset_footer_typo' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Footer typography', 'my-sunset'),
				'priority' => 3,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_footer_dynamic_font_size';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Enable dynamic font sizes', 'my-sunset'),
				'description'    => __('Font sizes will be scaled depending on screen size. You provide the maximum value.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			) 
		);

		$setting = 'sunset_footer_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'footer',
					'type' => 'font',
					'label'    => __('Footer font', 'my-sunset'),
					'description'    => __('Set the font of the footer.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_footer_widget_title_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'widget_title',
					'type' => 'font',
					'label'    => __('Footer title font', 'my-sunset'),
					'description'    => __('Set the font of the footer titles.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);

	}

	if ($section = 'sunset_footer_mobile_options' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Footer mobile options', 'my-sunset'),
				'priority' => 4,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_footer_mobile_font_size';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint', //converts value to a non-negative integer
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Footer mobile font size (px)', 'my-sunset'),
				'description'    => __('Leave blank to inherit font size from desktop value.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_footer_dynamic_font_size_disabled',
			)
		);

		$setting = 'sunset_footer_widget_mobile_font_size';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint', //converts value to a non-negative integer
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Footer title mobile font size (px)', 'my-sunset'),
				'description'    => __('Leave blank to inherit font size from desktop value.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_footer_dynamic_font_size_disabled',
			)
		);

	}

	$panel = 'sunset_copyright_panel';

	if ( ! $wp_customize->get_panel( $panel ) ) {
		
		$wp_customize->add_panel(
			$panel,
			array(
				'priority' => 21,
				'title' => __( 'Copyright', 'my-sunset' ),
			)
		);
	}

	if ($section = 'sunset_copyright_options' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Copyright options', 'my-sunset'),
				'priority' => 1,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_copyright_enable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Enable copyright bar', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_copyright_full_width';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => _x('Full width', 'copyright', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_copyright_enabled',
			) 
		);

		$setting = 'sunset_copyright_align';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'left'   => __('Align left', 'my-sunset'),
					'right'   => __('Align right', 'my-sunset'),
					'center'   => __('Align center', 'my-sunset'),
					'spread'   => __('Spread', 'my-sunset'),
				),
				'label'    => __('Copyright alignment', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_copyright_enabled',
			)
		);

		$setting = 'sunset_copyright_runline';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => _x('Enable running line', 'topbar', 'my-sunset'),
				'description'    => __('Exit customizer to see the animation.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_copyright_enabled',
			)
		);

		$setting = 'sunset_copyright_runline_duration';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint', //converts value to a non-negative integer
				'validate_callback'   => 'sunset_setting_prevent_empty',
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Running line speed', 'my-sunset'),
				'description'    => __('Enter a value from 1 to 10.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_copyright_runline_enabled( $control )
						&&
						sunset_flag_is_copyright_enabled( $control )
					);
				},
			)
		);

		$setting = 'sunset_copyright_add_border';

		$wp_customize->add_setting(
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'postMessage',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Add border', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_copyright_enabled( $control )
					);
				},
			)
		);

		$setting = 'sunset_copyright_border_height';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_values[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'absint',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Border height', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_copyright_enabled( $control )
						&&
						sunset_flag_is_copyright_border_enabled( $control )
					);
				},
			)
		);
	}

	if ($section = 'sunset_copyright_colors' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Copyright colors', 'my-sunset'),
				'priority' => 2,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_copyright_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Font color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_copyright_enabled',
				)
			)
		);

		$setting = 'sunset_copyright_background_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Background color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_copyright_enabled',
				)
			)
		);

		$setting = 'sunset_copyright_border_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Copyright border color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_copyright_border_enabled',
				)
			)
		);

	}

	if ($section = 'sunset_copyright_typo' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Copyright typography', 'my-sunset'),
				'priority' => 3,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_copyright_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'copyright',
					'type' => 'font',
					'label'    => __('Copyright font', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_copyright_enabled',
				)
			)
		);

	}

	if ($section = 'sunset_copyright_mobile_options' ){

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Copyright mobile options', 'my-sunset'),
				'priority' => 4,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_copyright_mobile_align';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'flex-start'   => __('Align left', 'my-sunset'),
					'flex-end'   => __('Align right', 'my-sunset'),
					'center'   => __('Align center', 'my-sunset'),
				),
				'label'    => __('Copyright mobile alignment', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						!sunset_flag_is_copyright_runline_enabled( $control )
						&&
						sunset_flag_is_copyright_enabled( $control )
					);
				},
			)
		);

	}

	if ($section = 'sunset_social_links' ){
		
		$wp_customize->add_section( 
			$section, 
			array (
				'title'    => __('Social links', 'my-sunset'),
				'priority' => 22,
			)
		);

		$setting = 'sunset_social_links';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'wp_filter_nohtml_kses' //removes all HTML from content
			)
		);

		$wp_customize->add_control(
			new Sunset_Customize_Control_Social_Link(
				$wp_customize,
				$setting, 
				array (
					'type' => 'social-link',
					'label'    => __('Social network', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

	}

	$panel = 'sunset_content_panel';
	
	if ( ! $wp_customize->get_panel( $panel ) ) {
		
		$wp_customize->add_panel(
			$panel,
			array(
				'priority' => 21,
				'title' => __( 'Content', 'my-sunset' ),
			)
		);
	}

	if ( $section = 'sunset_content_layout' ) {

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Page options', 'my-sunset'),
				'priority' => 1,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_layout_width';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint',
				'validate_callback' => function( $validity, $value, $setting ) {
					return ( 
						sunset_setting_prevent_empty( $validity, $value, $setting )
						&&
						sunset_setting_set_values_range( $validity, $value, $setting, array('min' => 768, 'max' => 2560) )
					);
				},
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Container width', 'my-sunset'),
				'description'    => __('Maximum width for content, if container layout enabled. Provide value between 768 and 2560 (px).', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			)
		);

		$setting = 'sunset_layout_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'boxed'   => __('Container', 'my-sunset'),
					'full'   => __('Full width', 'my-sunset'),
				),
				'label'    => _x('Layout type', 'page', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_page_header_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'default'   => __('Default', 'my-sunset'),
					'cover'   => __('Cover', 'my-sunset'),
					'split'   => __('Split', 'my-sunset'),
					'big-text'   => __('Big text', 'my-sunset'),
				),
				'label'    => __('Page header type', 'my-sunset'),
				'description'    => _x('This setting can be overwritten for each post manually.', 'page', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			)
		);

		$setting = 'sunset_page_stroke_title';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Stroke title', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						!sunset_flag_is_title_hidden( $control )
					);
				},			
			) 
		);

		$setting = 'sunset_page_hide_title';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Hide page title', 'my-sunset'),
				'description'    => _x('This setting can be overwritten for each post manually.', 'page', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_default_page_header_enabled',
			) 
		);

		$setting = 'sunset_page_hide_paddings';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Hide page paddings', 'my-sunset'),
				'description'    => _x('This setting can be overwritten for each post manually.', 'page', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_page_show_breadcrumbs';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show page breadcrumbs', 'my-sunset'),
				'description'    => _x('This setting can be overwritten for each post manually.', 'page', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_page_header_animation_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'none'   => __('None', 'my-sunset'),
					'slide-up'   => __('Slide Up', 'my-sunset'),
					'slide-down'   => __('Slide Down', 'my-sunset'),
					'typing'   => __('Typing', 'my-sunset'),
					'zoom-in'   => __('Zoom In', 'my-sunset'),
					'fade-in'   => __('Fade In', 'my-sunset'),
				),
				'label'    => __('Page header animation type', 'my-sunset'),
				'description'    => _x('This setting can be overwritten for each post manually.', 'page', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return (
						!sunset_flag_is_title_hidden( $control )
					);
				},
			)
		);

	}

	if ( $section = 'sunset_blog_options' ) {

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Archive options', 'my-sunset'),
				'priority' => 2,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_blog_layout_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'boxed'   => __('Container', 'my-sunset'),
					'full'   => __('Full width', 'my-sunset'),
				),
				'label'    => __('Archive layout type', 'my-sunset'),
				'description'    => __('Applied to categories, tags, archive pages and blog index page.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_blog_grid_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'grid'   => __('Grid', 'my-sunset'),
					'grid-fluid'   => __('Grid Masonry', 'my-sunset'),
					'sticky'   => __('With sticky post', 'my-sunset'),
					'full'   => __('Full width', 'my-sunset'),
				),
				'label'    => __('Archive grid type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_blog_grid_columns';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint',
				'validate_callback' => function( $validity, $value, $setting ) {
					return ( 
						sunset_setting_prevent_empty( $validity, $value, $setting )
						&&
						sunset_setting_set_values_range( $validity, $value, $setting, array('min' => 1, 'max' => 6) )
					);
				},
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Grid columns', 'my-sunset'),
				'description'    => __('Set number between 1 and 6.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_blog_grid_enabled',
			)
		);

		$setting = 'sunset_blog_add_border';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Add border to posts', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						!sunset_flag_is_blog_grid_fluid_enabled( $control )
					);
				},
			) 
		);

		$setting = 'sunset_blog_add_shadow';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Add shadow to thumbnails', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_blog_show_tags';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show tags on posts', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_blog_show_categories';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show categories on posts', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_blog_show_default_category';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show default category', 'my-sunset'),
				'description'    => sprintf(__('You can change default category <a href="%s" target="_blank">here</a>', 'my-sunset'), get_admin_url().'options-writing.php'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_blog_show_categories'
			) 
		);

		$setting = 'sunset_blog_show_excerpt';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show excerpt on posts', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_blog_show_date';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show date on posts', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_blog_show_read_time';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show read time on posts', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_layout_default_image';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint'
			) 
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Media(
				$wp_customize,
				$setting, 
				array (
					'type' => 'media-upload',
					'label'    => __('Default image for post', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_blog_title_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'simple'   => __('Simple', 'my-sunset'),
					'siblings'   => __('With Siblings', 'my-sunset'),
				),
				'label'    => __('Archive title type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_blog_title_show_posts_count';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show posts count', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_blog_title_show_breadcrumbs';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show archive breadcrumbs', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);


		$setting = 'sunset_blog_sidebar_position';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'left'   => __('Left side', 'my-sunset'),
					'right'   => __('Right side', 'my-sunset'),
					'none'   => __('No sidebar', 'my-sunset'),
				),
				'label'    => __('Archive sidebar position', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_blog_sidebar_sticky';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Sticky sidebar', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,				
				'active_callback' => 'sunset_flag_is_blog_sidebar_enabled'
			) 
		);

		$setting = 'sunset_blog_sidebar_sticky_position';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'left'   => __('Left sticky', 'my-sunset'),
					'right'   => __('Right sticky', 'my-sunset'),
				),
				'label'    => __('Sticky sidebar position', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_blog_sticky_sidebar_enabled( $control )
						&&
						sunset_flag_is_blog_sticky_both_sidebar_enabled( $control )
					);
				},
			)
		);

		$setting = 'sunset_blog_pagination';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'pages'   => __('Pages', 'my-sunset'),
					'infinite'   => __('Infinite scroll', 'my-sunset'),
					'loadmore'   => __('Load more button', 'my-sunset'),
				),
				'label'    => __('Pagination type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_blog_image_ratio';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'16-9'   => '16 / 9',
					'4-3'   => '4 / 3',
					'1-1'   => __('1 / 1 (square)', 'my-sunset'),
					'none'   => __('no crop', 'my-sunset'),
				),
				'label'    => __('Aspect ratio for thumbnails', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

	}

	if ( $section = 'sunset_posts_options' ) {

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Posts options', 'my-sunset'),
				'priority' => 2,
				'panel' => $panel,
			) 
		);


		$setting = 'sunset_post_layout_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'boxed'   => __('Container', 'my-sunset'),
					'full'   => __('Full width', 'my-sunset'),
				),
				'label'    => __('Post layout type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			)
		);

		$setting = 'sunset_post_content_width';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint',
				'validate_callback' => function( $validity, $value, $setting ) {
					return ( 
						sunset_setting_prevent_empty( $validity, $value, $setting )
						&&
						sunset_setting_set_values_range( $validity, $value, $setting, array('min' => 768, 'max' => 2560) )
					);
				},
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Post content width', 'my-sunset'),
				'description'    => __('Maximum width for the single post content, if container layout enabled. Provide value between 768 and 2560 (px).', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_post_layout_container_enabled'
			)
		);

		$setting = 'sunset_post_sidebar_position';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'left'   => __('Left side', 'my-sunset'),
					'right'   => __('Right side', 'my-sunset'),
					'none'   => __('No sidebar', 'my-sunset'),
				),
				'label'    => __('Post sidebar position', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			)
		);

		$setting = 'sunset_post_sidebar_sticky';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Sticky sidebar', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,				
				'active_callback' => 'sunset_flag_is_post_sidebar_enabled'
			) 
		);

		$setting = 'sunset_post_sidebar_sticky_position';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'left'   => __('Left sticky', 'my-sunset'),
					'right'   => __('Right sticky', 'my-sunset'),
				),
				'label'    => __('Sticky sidebar position', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_post_sticky_sidebar_enabled( $control )
						&&
						sunset_flag_is_post_sticky_both_sidebar_enabled( $control )
					);
				},
			)
		);

		$setting = 'sunset_post_show_breadcrumbs';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show post breadcrumbs', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_post_toc_enable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Enable Table of Contents', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_post_toc_tags';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => function( $value ) {
					return array_map( 'esc_attr', $value );
				},
				'validate_callback'   => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Multiple_Select(
				$wp_customize,
				$setting, 
				array (
					'type' => 'muliple-select',
					'choices'  => sunset_get_h1_h6_tags(),
					'label'    => __('Tags for the Table of Contents', 'my-sunset'),
					'description'    => __('Select tags from your posts which will be used for the Table of Contents.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => function( $control ) {
						return ( 
							sunset_flag_is_toc_enabled( $control )
						);
					},
				)
			)
		);

		$setting = 'sunset_post_show_date';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show date of the post', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_post_show_read_time';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show read time of the post', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_post_meta_show';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show meta of the post', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_post_meta_position';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'top'   => __('Top', 'my-sunset'),
					'bottom'   => __('Bottom', 'my-sunset'),
				),
				'label'    => __('Meta position', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_post_meta_enabled'
			)
		);

		$setting = 'sunset_post_show_default_category';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show default category', 'my-sunset'),
				'description'    => sprintf(__('You can change default category <a href="%s" target="_blank">here</a>', 'my-sunset'), get_admin_url().'options-writing.php'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_post_meta_enabled'
			) 
		);

		$setting = 'sunset_post_header_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'default'   => __('Default', 'my-sunset'),
					'cover'   => __('Cover', 'my-sunset'),
					'split'   => __('Split', 'my-sunset'),
					'big-text'   => __('Big text', 'my-sunset'),
				),
				'label'    => __('Post header type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			)
		);

		$setting = 'sunset_post_header_animation_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'none'   => __('None', 'my-sunset'),
					'slide-up'   => __('Slide Up', 'my-sunset'),
					'slide-down'   => __('Slide Down', 'my-sunset'),
					'typing'   => __('Typing', 'my-sunset'),
					'zoom-in'   => __('Zoom In', 'my-sunset'),
					'fade-in'   => __('Fade In', 'my-sunset'),
				),
				'label'    => __('Post header animation type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return (
						!sunset_flag_is_title_hidden( $control )
					);
				},
			)
		);

		$setting = 'sunset_post_stroke_title';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Stroke title', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_post_related_show';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show related posts', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_post_related_type';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'grid'   => __('Grid', 'my-sunset'),
					'slider'   => __('Slider', 'my-sunset'),
				),
				'label'    => __('Related posts type', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_post_related_enabled'
			)
		);

		$setting = 'sunset_post_related_number';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint',
				'validate_callback'   => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Related posts number', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_post_related_enabled'
			)
		);

		$setting = 'sunset_post_related_columns';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint',
				'validate_callback' => function( $validity, $value, $setting ) {
					return ( 
						sunset_setting_prevent_empty( $validity, $value, $setting )
						&&
						sunset_setting_set_values_range( $validity, $value, $setting, array('min' => 1, 'max' => 6) )
					);
				},
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Related posts columns number', 'my-sunset'),				
				'description'    => __('Set number between 1 and 6.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_post_related_enabled'
			)
		);

		$setting = 'sunset_post_related_title_show';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Show related posts title', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_post_related_enabled'
			) 
		);

		$setting = 'sunset_post_related_title_text';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'wp_filter_nohtml_kses' //removes all HTML from content
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'text',
				'label'    => __('Related posts title', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => function( $control ) {
					return ( 
						sunset_flag_is_post_related_enabled( $control )
						&&
						sunset_flag_is_post_related_title_enabled( $control )
					);
				},
			)
		);

	}

	if ( $section = 'sunset_style_options' ) {

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Styling options', 'my-sunset'),
				'priority' => 3,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_style_select2_enable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting,
			array (
				'type' => 'checkbox',
				'label'    => __('Enable fancy dropdowns', 'my-sunset'),
				'description'    => __('Fancy and UI-friendly select-elements using select2 plugin.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_style_custom_checkbox_enable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting,
			array (
				'type' => 'checkbox',
				'label'    => __('Enable fancy checkboxes and radio buttons', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_style_lightbox_enable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting,
			array (
				'type' => 'checkbox',
				'label'    => __('Enable lightbox for images', 'my-sunset'),
				'description'    => __('Open link-wrapped images in a popup.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_style_bg_noise_enable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting,
			array (
				'type' => 'checkbox',
				'label'    => __('Add noise to background', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_style_custom_cursor_enable';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting,
			array (
				'type' => 'checkbox',
				'label'    => __('Enable fancy cursor', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			) 
		);

		$setting = 'sunset_style_custom_cursor_style';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'disc'   => __('Disc', 'my-sunset'),
					'circle'   => __('Circle', 'my-sunset'),
					'blurry'   => __('Blurry', 'my-sunset'),
				),
				'label'    => __('Cursor style', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_custom_cursor_enabled',
			)
		);

		$setting = 'sunset_style_input_style';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			) 
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'radio',
				'choices'  => array (
					'bold'   => __('Bold', 'my-sunset'),
					'light'   => __('Light', 'my-sunset'),
					'minimal'   => __('Minimal', 'my-sunset'),
				),
				'label'    => __('Inputs style', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
			)
		);

	}

	if ($section = 'sunset_content_colors' ){ 
		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Content colors', 'my-sunset'),
				'priority' => 4,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_content_bg_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Background color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_sidebars_bg_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Sidebar background color', 'my-sunset'),
					'description'    => __('Leave blank for the transparent background.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_blog_sidebar_enabled'
				)
			)
		);

		$setting = 'sunset_content_primary_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',				
				'validate_callback'   => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Primary color', 'my-sunset'),
					'description'    => __('Basic color of the content.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_secondary_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Secondary color', 'my-sunset'),
					'description'    => __('The color of dates, metas etc.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_link_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback'   => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Link color', 'my-sunset'),
					'description'    => __('Color of links in post/page content. Links outside content area (e.g. in widgets, header, footer) will not be affected.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_link_hover_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback'   => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Link hover color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_h1_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Heading (H1) color', 'my-sunset'),
					'description'    => __('Color of the H1 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_h2_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Heading (H2) color', 'my-sunset'),
					'description'    => __('Color of the H2 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_h3_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Heading (H3) color', 'my-sunset'),
					'description'    => __('Color of the H3 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_h4_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Heading (H4) color', 'my-sunset'),
					'description'    => __('Color of the H4 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_h5_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Heading (H5) color', 'my-sunset'),
					'description'    => __('Color of the H5 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_h6_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Heading (H6) color', 'my-sunset'),
					'description'    => __('Color of the H6 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_content_widget_title_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Widget title color', 'my-sunset'),
					'description'    => __('Color of the widget title.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_buttons_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Buttons background color', 'my-sunset'),
					'description'    => __('Leave blank for the transparent background.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_buttons_hover_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Buttons background hover color', 'my-sunset'),
					'description'    => __('Leave blank for the transparent background.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_buttons_text_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Buttons text color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_buttons_hover_text_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Buttons hover text color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_buttons_border_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Buttons border color', 'my-sunset'),
					'description'    => __('Leave blank for the transparent border.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_inputs_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Inputs background color', 'my-sunset'),
					'description'    => __('Leave blank for the transparent background.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_inputs_text_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Inputs text color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);

		$setting = 'sunset_inputs_border_color';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default' => $default_colors[$setting],
				'transport'   => 'postMessage',
				'sanitize_callback' => 'sanitize_hex_color',
				'validate_callback' => 'sunset_setting_prevent_empty',
			) 
		);

		$wp_customize->add_control(
			new WP_Customize_Color_Control( 
				$wp_customize,	
				$setting, 
				array (
					'label'    => __('Inputs border color', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
				)
			)
		);
	}

	if ($section = 'sunset_content_typography' ){
		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Content typography', 'my-sunset'),
				'priority' => 4,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_content_dynamic_font_size';

		$wp_customize->add_setting( 
			new Sunset_Force_Boolean_Settings(
				$wp_customize,
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'sunset_sanitize_checkbox'
				)
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'checkbox',
				'label'    => __('Dynamic content font sizes', 'my-sunset'),
				'description'    => __('Fonts will scale dynamically between mobile and desktop.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting
			) 
		);

		$setting = 'sunset_primary_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'primary',
					'type' => 'font',
					'label'    => __('Primary font', 'my-sunset'),
					'description'    => __('Set the font of the body text.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);

		$setting = 'sunset_h1_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'h1',
					'type' => 'font',
					'label'    => __('Heading (H1) font', 'my-sunset'),
					'description'    => __('Set the font of the H1 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);

		$setting = 'sunset_h2_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'h2',
					'type' => 'font',
					'label'    => __('Heading (H2) font', 'my-sunset'),
					'description'    => __('Set the font of the H2 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);

		$setting = 'sunset_h3_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'h3',
					'type' => 'font',
					'label'    => __('Heading (H3) font', 'my-sunset'),
					'description'    => __('Set the font of the H3 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);

		$setting = 'sunset_h4_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'h4',
					'type' => 'font',
					'label'    => __('Heading (H4) font', 'my-sunset'),
					'description'    => __('Set the font of the H4 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);

		$setting = 'sunset_h5_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'h5',
					'type' => 'font',
					'label'    => __('Heading (H5) font', 'my-sunset'),
					'description'    => __('Set the font of the H5 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);

		$setting = 'sunset_h6_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'h6',
					'type' => 'font',
					'label'    => __('Heading (H6) font', 'my-sunset'),
					'description'    => __('Set the font of the H6 tag.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);	

		$setting = 'sunset_widget_title_font';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_fonts[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'sanitize_text_field'
			)
		);

		$wp_customize->add_control( 
			new Sunset_Customize_Control_Font (
				$wp_customize,
				$setting, 
				array (
					'tag' => 'widget_title',
					'type' => 'font',
					'label'    => __('Widget title font', 'my-sunset'),
					'description'    => __('Set the font of the widget title.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting
				)
			)
		);

	}

	if ( $section = 'sunset_mobile_options' ) {

		$wp_customize->add_section( 
			$section,
			array (
				'title'    => __('Mobile options', 'my-sunset'),
				'priority' => 5,
				'panel' => $panel,
			) 
		);

		$setting = 'sunset_content_mobile_font_size';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint',
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Primary mobile font size (px)', 'my-sunset'),
				'description'    => __('Leave blank to inherit font size from desktop value.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_content_dynamic_font_size_disabled',
			)
		);

		for ($i = 1; $i <= 6; $i +=1) {
			$setting = 'sunset_h'.$i.'_mobile_font_size';

			$wp_customize->add_setting( 
				$setting, 
				array (
					'type'     => 'option',
					'default'     => $default_values[$setting],
					'transport'   => 'refresh',
					'sanitize_callback' => 'absint',
				)
			);

			$wp_customize->add_control(
				$setting, 
				array (
					'type' => 'number',
					'label'    => 'H' .$i.__(' mobile font size (px)', 'my-sunset'),
					'description'    => __('Leave blank to inherit font size from desktop value.', 'my-sunset'),
					'section'  => $section,
					'settings' => $setting,
					'active_callback' => 'sunset_flag_is_content_dynamic_font_size_disabled',
				)
			);
		}

		$setting = 'sunset_widget_title_mobile_font_size';

		$wp_customize->add_setting( 
			$setting, 
			array (
				'type'     => 'option',
				'default'     => $default_values[$setting],
				'transport'   => 'refresh',
				'sanitize_callback' => 'absint',
			)
		);

		$wp_customize->add_control(
			$setting, 
			array (
				'type' => 'number',
				'label'    => __('Widgets title mobile font size (px)', 'my-sunset'),
				'description'    => __('Leave blank to inherit font size from desktop value.', 'my-sunset'),
				'section'  => $section,
				'settings' => $setting,
				'active_callback' => 'sunset_flag_is_content_dynamic_font_size_disabled',
			)
		);

	}
	
}

function sunset_flag_is_header_auto_responsive_disabled () {
	$sunset_header_auto_responsive = sunset_get_option( 'sunset_header_auto_responsive') ? true : false;
	return !$sunset_header_auto_responsive; // revert the value, so don't show option if auto-responsive enabled
}
function sunset_flag_is_footer_auto_font_sizes_disabled () {
	$sunset_footer_auto_font_sizes = sunset_get_option( 'sunset_footer_auto_font_sizes') ? true : false;
	return !$sunset_footer_auto_font_sizes; // revert the value, so don't show option if auto-responsive enabled
}

function sunset_flag_is_hover_buttoned_enabled(){
    $header_menu_hover_type = sunset_get_option( 'sunset_header_menu_hover_type');
    if( $header_menu_hover_type !== 'buttoned' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_hover_bordered_enabled () {
	$header_menu_hover_type = sunset_get_option( 'sunset_header_menu_hover_type');
    if( $header_menu_hover_type !== 'bordered' && $header_menu_hover_type !== 'ellipse_bordered' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_header_fixed_enabled( $control ) {
	$sunset_header_fixed = sunset_get_option( 'sunset_header_fixed') ? true : false;
	return $sunset_header_fixed;
}

function sunset_flag_is_header_search_enabled() {
	$sunset_header_add_search = sunset_get_option( 'sunset_header_add_search') ? true : false;
    return $sunset_header_add_search;
}

function sunset_flag_is_boxed_layout_enabled(){
    $sunset_layout_type = sunset_get_option( 'sunset_layout_type');
    if( $sunset_layout_type !== 'boxed' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_boxed_blog_layout_enabled(){
    $sunset_blog_layout_type = sunset_get_option( 'sunset_blog_layout_type');
    if( $sunset_blog_layout_type !== 'boxed' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_header_border_enabled() {
	$sunset_header_add_border = sunset_get_option( 'sunset_header_add_border') ? true : false;
    return $sunset_header_add_border;
}

function sunset_flag_is_topbar_enabled () {
	$sunset_topbar_enable = sunset_get_option( 'sunset_topbar_enable') ? true : false;
    return $sunset_topbar_enable;
}

function sunset_flag_is_topbar_runline_enabled () {
	$sunset_topbar_enable = sunset_get_option( 'sunset_topbar_runline') ? true : false;
    return $sunset_topbar_enable;
}

function sunset_flag_is_copyright_runline_enabled () {
	$sunset_copyright_enable = sunset_get_option( 'sunset_copyright_runline') ? true : false;
    return $sunset_copyright_enable;
}

function sunset_flag_is_footer_columns_enabled(){
    $footer_type = sunset_get_option( 'sunset_footer_type');
    if( $footer_type !== 'footer_1' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_copyright_enabled () {
	$sunset_copyright_enable = sunset_get_option( 'sunset_copyright_enable') ? true : false;
    return $sunset_copyright_enable;
}

function sunset_flag_is_copyright_border_enabled () {
	$sunset_copyright_border_enable = sunset_get_option( 'sunset_copyright_add_border') ? true : false;
    return $sunset_copyright_border_enable;
}

function sunset_flag_is_footer_border_enabled () {
	$sunset_footer_border_enable = sunset_get_option( 'sunset_footer_add_border') ? true : false;
    return $sunset_footer_border_enable;
}

function sunset_flag_is_topbar_border_enabled () {
	$sunset_topbar_border_enable = sunset_get_option( 'sunset_topbar_add_border') ? true : false;
    return $sunset_topbar_border_enable;
}

function sunset_flag_is_blog_sidebar_enabled () {
	$sunset_blog_sidebar_position = sunset_get_option( 'sunset_blog_sidebar_position');
    if( $sunset_blog_sidebar_position === 'none' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_blog_grid_enabled () {
	$sunset_blog_grid_type = sunset_get_option( 'sunset_blog_grid_type');
    if( $sunset_blog_grid_type !== 'grid' && $sunset_blog_grid_type !== 'grid-fluid' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_blog_grid_fluid_enabled () {
	$sunset_blog_grid_type = sunset_get_option( 'sunset_blog_grid_type');
    if( $sunset_blog_grid_type !== 'grid-fluid' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_blog_sticky_both_sidebar_enabled () {
	$sunset_blog_sidebar_position = sunset_get_option( 'sunset_blog_sidebar_position');
    if( $sunset_blog_sidebar_position !== 'both' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_blog_sticky_sidebar_enabled () {
	$sunset_blog_sidebar_sticky = sunset_get_option( 'sunset_blog_sidebar_sticky') ? true : false;
    return $sunset_blog_sidebar_sticky;
}

function sunset_flag_is_post_sidebar_enabled () {
	$sunset_post_sidebar_position = sunset_get_option( 'sunset_post_sidebar_position');
    if( $sunset_post_sidebar_position === 'none' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_post_sidebar_right_enabled () {
	$sunset_post_sidebar_position = sunset_get_option( 'sunset_post_sidebar_position');
    if( $sunset_post_sidebar_position === 'right' ) {
        return true;
    }
    return false;
}

function sunset_flag_is_post_sticky_both_sidebar_enabled () {
	$sunset_post_sidebar_position = sunset_get_option( 'sunset_post_sidebar_position');
    if( $sunset_post_sidebar_position !== 'both' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_post_sticky_sidebar_enabled () {
	$sunset_post_sidebar_sticky = sunset_get_option( 'sunset_post_sidebar_sticky') ? true : false;
    return $sunset_post_sidebar_sticky;
}

function sunset_flag_is_post_meta_enabled () {
	$sunset_post_meta_enabled = sunset_get_option( 'sunset_post_meta_show') ? true : false;
    return $sunset_post_meta_enabled;
}

function sunset_flag_is_post_related_enabled () {
	$sunset_post_related_enabled = sunset_get_option( 'sunset_post_related_show') ? true : false;
    return $sunset_post_related_enabled;
}

function sunset_flag_is_post_related_title_enabled () {
	$sunset_post_related_title_enabled = sunset_get_option( 'sunset_post_related_title_show') ? true : false;
    return $sunset_post_related_title_enabled;
}

function sunset_flag_is_toc_enabled () {
	$sunset_post_toc_enable = sunset_get_option( 'sunset_post_toc_enable') ? true : false;
    return $sunset_post_toc_enable;
}

function sunset_flag_is_footer_dynamic_font_size_disabled () {
	$sunset_footer_dynamic_font_size = sunset_get_option( 'sunset_footer_dynamic_font_size') ? true : false;
    return !$sunset_footer_dynamic_font_size;
}

function sunset_flag_is_content_dynamic_font_size_disabled () {
	$sunset_content_dynamic_font_size = sunset_get_option( 'sunset_content_dynamic_font_size') ? true : false;
    return !$sunset_content_dynamic_font_size;
}

function sunset_flag_is_custom_cursor_enabled () {
	$is_cursor_enabled = sunset_get_option( 'sunset_style_custom_cursor_enable') ? true : false;
    return $is_cursor_enabled;
}

function sunset_flag_is_header_burger_icon_type_text () {
	$header_burger_icon_type = sunset_get_option( 'sunset_header_burger_icon_type');
    if( $header_burger_icon_type !== 'text' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_default_page_header_enabled () {
	$page_header_type = sunset_get_option( 'sunset_page_header_type');
	if( $page_header_type !== 'default' ) {
        return false;
    }
    return true;
}

function sunset_flag_is_title_hidden () {
	$page_header_type = sunset_get_option( 'sunset_page_header_type');
	$is_page_hide_title = sunset_get_option( 'sunset_page_hide_title') ? true : false;
	if( $page_header_type === 'default' && $is_page_hide_title ) {
        return true;
    }
    return false;
}

function sunset_flag_is_post_layout_container_enabled () {
	$post_layout_type = sunset_get_option( 'sunset_post_layout_type');
	if( $post_layout_type === 'boxed' ) {
        return true;
    }
    return false;
}

function sunset_flag_is_blog_show_categories () {
	$is_blog_show_categories = sunset_get_option( 'sunset_blog_show_categories') ? true : false;
	
    return $is_blog_show_categories;
}

function sunset_setting_prevent_empty( $validity, $value, $setting ){
	if ( empty($value) ) {
		return false;
	} 
	return $value;
}

function sunset_setting_set_values_range( $validity, $value, $setting, $args = array() ) {
	if ( !empty($args) ) {
		if ( $value < $args['min'] || $value > $args['max'] ) {
			return false;
		}
	} 
	return $validity;
}



//checkbox sanitization function
function sunset_sanitize_checkbox( $checked ){
              
	//returns true if checkbox is checked
	return ( ( isset( $checked ) && true == $checked ) ? true : 0 ); // if false set 0 to prevent empty value in DB
}

/**
 * Sanitize file input
 */
function sunset_sanitize_file ($file, $setting) {
	//allowed file types
	$mimes = array(
		'jpg|jpeg|jpe' => 'image/jpeg',
		'gif'          => 'image/gif',
		'png'          => 'image/png',
		'svg'          => 'image/svg+xml',
	);
	  
	//check file type from file name
	$file_ext = wp_check_filetype( $file, $mimes );
	  
	//if file has a valid mime type return it, otherwise return default
	return ( $file_ext['ext'] ? $file : $setting->default );
}

/**
 * Validate image file
 */
function sunset_valid_image ($validity, $value, $setting) {
	if ( empty($value) ) {
		return true; // allow no image
	}
	//allowed file types
	$mimes = array(
		'jpg|jpeg|jpe' => 'image/jpeg',
		'gif'          => 'image/gif',
		'png'          => 'image/png',
		'svg'          => 'image/svg+xml',
	);
	  
	//check file type from file name
	$file_ext = wp_check_filetype( $value, $mimes );
	  
	//if file has a valid mime type return it, otherwise return default
	return ( $file_ext['ext'] ? $value : false );
}

/**
 * Add preview devices to Customizer anr re-order them
 */
function sunset_manage_previewable_devices($devices) {
	$devices['tablet-landscape'] = array(
		'label' => __('Enter tablet preview mode (landscape)', 'my-sunset')
	);
	$devices_order = array(
		'desktop',
		'tablet-landscape',
		'tablet',
		'mobile',
	);
	$devices = array_filter(array_replace(array_fill_keys($devices_order, null), $devices));

    return $devices;
}
add_filter('customize_previewable_devices', 'sunset_manage_previewable_devices');