<?php
    get_template_part( 'lib/main' );

    add_action( 'after_setup_theme', 	array( 'mythemes_setup', 	'support' ) );

	add_action( 'admin_init', 			array( 'mythemes_boxes', 	'add' ) );
	add_action( 'admin_init', 			array( 'mythemes_gallery', 	'admin_init' ), 20 );
	add_action( 'admin_init', 			array( 'mythemes_scripts', 	'backend' ) );
    
	add_action( 'admin_menu', 			array( 'mythemes_admin', 	'pageMenu' ) );

	add_action( 'widgets_init', 		array( 'mythemes_setup', 	'sidebars' ) );
	add_action( 'init', 				array( 'mythemes_setup', 	'menus' ) );

	
	add_action( 'wp_enqueue_scripts', 	array( 'mythemes_scripts', 	'frontend' ), 0 );
	add_action( 'wp_head', 				array( 'mythemes_header', 	'head' ) );
	
    add_filter( 'the_excerpt_rss', 		array( 'mythemes_tools', 	'rss_with_thumbnail' ) );
    add_filter( 'the_content_feed', 	array( 'mythemes_tools', 	'rss_with_thumbnail' ) );
    add_filter( 'post_gallery', 		array( 'mythemes_gallery', 	'shortcode'), null, 2 );

    /* BLOG TITLE */
    function mythemes_title_setup() {
        add_theme_support( 'title-tag' );
    }
    add_action( 'after_setup_theme', 'mythemes_title_setup' );

    /* CUSTOMIZER */
    function mythemes_customize_register( $wp_customize )
	{
		{   /* BRANDING */

    		$wp_customize -> add_section( 'branding', array(
            	'title' 		    => __( 'Branding' , 'treeson' ),
            	'priority' 		    => 30,
                'capability'        => 'edit_theme_options'
        	));

        	$wp_customize -> add_setting( 'favicon', array(
            	'default' 		    => '',
            	'transport' 	    => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
        	));
    		$wp_customize -> add_control( new WP_Customize_Upload_Control(
    			$wp_customize,
    			'favicon',
    			array(
    				'label'         => __( 'Preview Favicon', 'treeson' ),
    				'section'       => 'branding',
    				'settings' 	    => 'favicon',
    			)
    		));

    		$wp_customize -> add_setting( 'logo', array(
            	'default'           => '',
            	'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
        	));
    		$wp_customize -> add_control( new WP_Customize_Upload_Control(
    			$wp_customize,
    			'logo',
    			array(
    				'label'         => __( 'Preview Logo', 'treeson' ),
    				'section'       => 'branding',
    				'settings' 	    => 'logo',
    			)
    		));
        }


		{   /* COLORS */

        	$wp_customize -> add_section( 'colors', array(
                'title'             => __( 'Colors' , 'treeson' ),
                'priority'          => 30,
                'capability'        => 'edit_theme_options'
        	));

            $wp_customize -> add_setting( 'first-color', array(
                'default'           => '#343b43',
                'transport'         => 'postMessage',
                'priority'          => 0,
                'sanitize_callback' => 'sanitize_hexcolor',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( new WP_Customize_Color_Control(
                $wp_customize,
                'first-color',
                array(
                    'label'         => __( 'First Color', 'treeson' ),
                    'section'       => 'colors',
                    'settings'      => 'first-color',
                )
            ));

            $wp_customize -> add_setting( 'second-color', array(
                'default'           => '#5f992f',
                'transport'         => 'postMessage',
                'priority'          => 0,
                'sanitize_callback' => 'sanitize_hexcolor',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( new WP_Customize_Color_Control(
                $wp_customize,
                'second-color',
                array(
                    'label'         => __( 'Second Color', 'treeson' ),
                    'section'       => 'colors',
                    'settings'      => 'second-color',
                )
            ));

            $wp_customize -> add_setting( 'third-color', array(
                'default'           => '#416a9d',
                'transport'         => 'postMessage',
                'priority'          => 0,
                'sanitize_callback' => 'sanitize_hexcolor',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( new WP_Customize_Color_Control(
                $wp_customize,
                'third-color',
                array(
                    'label'         => __( 'Third Color', 'treeson' ),
                    'section'       => 'colors',
                    'settings'      => 'third-color',
                )
            ));
        }



    	{   /* HEADER */

            $wp_customize -> add_panel( 'header-panel', array(
                'title'             => __( 'Header', 'treeson' ),
                'description'       => sprintf( __( 'Discover the differences between the Treeson free WordPress theme and the Treeson Premium version. %s' , 'treeson' ) , '<br/><br/><a href="' . esc_url( admin_url( '/themes.php?page=mythemes-treeson-faqs' ) ) . '">' . __( 'See the Differences' , 'treeson' ) . ' &rarr;</a>' ),
                'priority'          => 31,
                'capability'        => 'edit_theme_options'
            ));


            {   /* GENERAL */

            	$wp_customize -> add_section( 'header', array(
                    'title'             => __( 'General' , 'treeson' ),
                    'panel'             => 'header-panel',
                    'priority'          => 30,
                    'capability'        => 'edit_theme_options'
            	));

                /* FRONT PAGE */
                $wp_customize -> add_setting( 'header-front-page', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'header-front-page', array(
                    'label'             => __( 'Display Header on Front Page', 'treeson' ),
                    'section'           => 'header',
                    'settings'          => 'header-front-page',
                    'type'              => 'checkbox',
                ));

                /* FRONT PAGE */
                $wp_customize -> add_setting( 'header-blog-page', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'header-blog-page', array(
                    'label'             => __( 'Display Header on Blog Page', 'treeson' ),
                    'section'           => 'header',
                    'settings'          => 'header-blog-page',
                    'type'              => 'checkbox',
                ));

                /* TEMPLATES */
                $wp_customize -> add_setting( 'header-templates', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'header-templates', array(
                    'label'             => __( 'Display Header on Templates', 'treeson' ),
                    'description'       => __( 'enabale / disable header on: Archives, Categories, Tags, Author, 404 and Search Results.' , 'treeson' ),
                    'section'           => 'header',
                    'settings'          => 'header-templates',
                    'type'              => 'checkbox',
                ));

                /* SINGLE POSTS */
                $wp_customize -> add_setting( 'header-single-posts', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'header-single-posts', array(
                    'label'             => __( 'Display Header on Single Posts', 'treeson' ),
                    'section'           => 'header',
                    'settings'          => 'header-single-posts',
                    'type'              => 'checkbox',
                ));

                /* SINGLE PAGES */
                $wp_customize -> add_setting( 'header-single-pages', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'header-single-pages', array(
                    'label'             => __( 'Display Header on Single Pages', 'treeson' ),
                    'section'           => 'header',
                    'settings'          => 'header-single-pages',
                    'type'              => 'checkbox',
                ));

                /* HEIGHT */
                $wp_customize -> add_setting( 'header-height', array(
                    'default'           => 350,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_number',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'header-height', array(
                    'label'             => __( 'Header height ( in pixels )', 'treeson' ),
                    'section'           => 'header',
                    'settings'          => 'header-height',
                    'type'              => 'number',
                    'input_attrs'       => array(
                        'min'   => 0,
                        'max'   => 500,
                        'step'  => 1
                    ),
                ));

                /* IMAGE */
                $wp_customize -> add_setting( 'header-image', array(
                    'default'           => get_template_directory_uri() . '/media/img/bkg.jpg',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'esc_url_raw',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( new WP_Customize_Upload_Control(
                    $wp_customize,
                    'header-image',
                    array(
                        'label'         => __( 'Preview Header Image', 'treeson' ),
                        'section'       => 'header',
                        'settings'      => 'header-image'
                    )
                ));

                /* HEADER BACKGROUND COLOR */
                $wp_customize -> add_setting( 'header-background-color', array(
                    'default'           => '#000000',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_hexcolor',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( new WP_Customize_Color_Control(
                    $wp_customize,
                    'header-background-color',
                    array(
                        'label'         => __( 'Background Color', 'treeson' ),
                        'section'       => 'header',
                        'settings'      => 'header-background-color',
                    )
                ));

                /* MASK COLOR */
                $wp_customize -> add_setting( 'header-mask-color', array(
                    'default'           => '#000000',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_hexcolor',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( new WP_Customize_Color_Control(
                    $wp_customize,
                    'header-mask-color',
                    array(
                        'label'         => __( 'Mask Color', 'treeson' ),
                        'section'       => 'header',
                        'settings'      => 'header-mask-color',
                    )
                ));

                /* MASK OPACITY */
                $wp_customize -> add_setting( 'header-mask-opacity', array(
                    'default'           => 80,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_number',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'header-mask-opacity', array(
                    'label'             => __( 'Mask Opacity ( % )', 'treeson' ),
                    'description'       => __( 'by default the mask is a dark transparent foil over the header background image.' , 'treeson' ),
                    'section'           => 'header',
                    'settings'          => 'header-mask-opacity',
                    'type'              => 'range',
                    'input_attrs' => array(
                        'min'   => 0,
                        'max'   => 100,
                        'step'  => 1
                    ),
                ));
            }


            {   /* CONTENT */

                $wp_customize -> add_section( 'header-content', array(
                    'title'             => __( 'Content' , 'treeson' ),
                    'panel'             => 'header-panel',
                    'priority'          => 30,
                    'capability'        => 'edit_theme_options'
                ));

                /* DISPLAY TITLE ON HEADER */
                $wp_customize -> add_setting( 'header-title', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'header-title', array(
                    'label'             => __( 'Display title on header', 'treeson' ),
                    'section'           => 'header-content',
                    'settings'          => 'header-title',
                    'type'              => 'checkbox',
                ));

                /* TITLE COLOR */
                $wp_customize -> add_setting( 'header-title-color', array(
                    'default'           => '#ffffff',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_hexcolor',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( new WP_Customize_Color_Control(
                    $wp_customize,
                    'header-title-color',
                    array(
                        'label'         => __( 'Title color', 'treeson' ),
                        'section'       => 'header-content',
                        'settings'      => 'header-title-color',
                    )
                ));

                /* DISPLAY DESCRIPTION ON HEADER */
                $wp_customize -> add_setting( 'header-description', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'header-description', array(
                    'label'             => __( 'Display description on header', 'treeson' ),
                    'section'           => 'header-content',
                    'settings'          => 'header-description',
                    'type'              => 'checkbox',
                ));

                /* DESCRIPTION COLOR */
                $wp_customize -> add_setting( 'header-description-color', array(
                    'default'           => '#ffffff',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_hexcolor',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( new WP_Customize_Color_Control(
                    $wp_customize,
                    'header-description-color',
                    array(
                        'label'         => __( 'Description color', 'treeson' ),
                        'section'       => 'header-content',
                        'settings'      => 'header-description-color',
                    )
                ));
            }


            {   /* FIRST BUTTON */

                $wp_customize -> add_section( 'header-first-btn', array(
                    'title'             => __( 'First Button' , 'treeson' ),
                    'panel'             => 'header-panel',
                    'priority'          => 30
                ));

                /* DISPLAY */
                $wp_customize -> add_setting( 'first-btn', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'first-btn', array(
                    'label'             => __( 'Display first button', 'treeson' ),
                    'section'           => 'header-first-btn',
                    'settings'          => 'first-btn',
                    'type'              => 'checkbox',
                ));

                /* COLOR */
                $wp_customize -> add_setting( 'first-btn-color', array(
                    'default'           => '#ffffff',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_hexcolor',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( new WP_Customize_Color_Control(
                    $wp_customize,
                    'first-btn-color',
                    array(
                        'label'         => __( 'Color', 'treeson' ),
                        'section'       => 'header-first-btn',
                        'settings'      => 'first-btn-color',
                    )
                ));

                /* URL */
                $wp_customize -> add_setting( 'first-btn-url', array(
                    'default'           => esc_url( home_url( '#' ) ),
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'esc_url_raw',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'first-btn-url', array(
                    'label'             => __( 'URL', 'treeson' ),
                    'description'       => __( 'Link for first button', 'treeson' ),
                    'section'           => 'header-first-btn',
                    'settings'          => 'first-btn-url',
                    'type'              => 'url',
                ));

                /* LABEL */
                $wp_customize -> add_setting( 'first-btn-label', array(
                    'default'           => __( 'First Button', 'treeson' ),
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_text_field',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'first-btn-label', array(
                    'label'             => __( 'Label', 'treeson' ),
                    'description'       => __( 'Text for first button', 'treeson' ),
                    'section'           => 'header-first-btn',
                    'settings'          => 'first-btn-label',
                    'type'              => 'text',
                ));

                /* DESCRIPTION */
                $wp_customize -> add_setting( 'first-btn-description', array(
                    'default'           => __( 'first button link description...', 'treeson' ),
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_text_field',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'first-btn-description', array(
                    'label'             => __( 'Description', 'treeson' ),
                    'description'       => __( 'link description for first button', 'treeson' ),
                    'section'           => 'header-first-btn',
                    'settings'          => 'first-btn-description',
                    'type'              => 'textarea',
                ));

                /* LINK TARGET */
                $wp_customize -> add_setting( 'first-btn-target', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'first-btn-target', array(
                    'label'             => __( 'Open url in new window', 'treeson' ),
                    'description'       => __( 'enable / disable link attribut target="_blank"', 'treeson' ),
                    'section'           => 'header-first-btn',
                    'settings'          => 'first-btn-target',
                    'type'              => 'checkbox',
                ));
            }


            {   /* SECOND BUTTON */

                $wp_customize -> add_section( 'header-second-btn', array(
                    'title'             => __( 'Second Button' , 'treeson' ),
                    'panel'             => 'header-panel',
                    'priority'          => 30,
                    'capability'        => 'edit_theme_options'
                ));

                /* DISPLAY */
                $wp_customize -> add_setting( 'second-btn', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'second-btn', array(
                    'label'             => __( 'Display second button', 'treeson' ),
                    'section'           => 'header-second-btn',
                    'settings'          => 'second-btn',
                    'type'              => 'checkbox',
                ));

                /* COLOR */
                $wp_customize -> add_setting( 'second-btn-color', array(
                    'default'           => '#ffffff',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_hexcolor',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( new WP_Customize_Color_Control(
                    $wp_customize,
                    'second-btn-color',
                    array(
                        'label'         => __( 'Color', 'treeson' ),
                        'section'       => 'header-second-btn',
                        'settings'      => 'second-btn-color'
                    )
                ));

                /* URL */
                $wp_customize -> add_setting( 'second-btn-url', array(
                    'default'           => esc_url( home_url( '#' ) ),
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'esc_url_raw',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'second-btn-url', array(
                    'label'             => __( 'URL', 'treeson' ),
                    'description'       => __( 'Link for second button', 'treeson' ),
                    'section'           => 'header-second-btn',
                    'settings'          => 'second-btn-url',
                    'type'              => 'url',
                ));

                /* LABEL */
                $wp_customize -> add_setting( 'second-btn-label', array(
                    'default'           => __( 'Second Button', 'treeson' ),
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_text_field',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'second-btn-label', array(
                    'label'             => __( 'Label', 'treeson' ),
                    'description'       => __( 'Text for second button', 'treeson' ),
                    'section'           => 'header-second-btn',
                    'settings'          => 'second-btn-label',
                    'type'              => 'text',
                ));

                /* DESCRIPTION */
                $wp_customize -> add_setting( 'second-btn-description', array(
                    'default'           => __( 'second button link description...', 'treeson' ),
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_text_field',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'second-btn-description', array(
                    'label'             => __( 'Description', 'treeson' ),
                    'description'       => __( 'link description for second button', 'treeson' ),
                    'section'           => 'header-second-btn',
                    'settings'          => 'second-btn-description',
                    'type'              => 'textarea',
                ));

                /* LINK TARGET */
                $wp_customize -> add_setting( 'second-btn-target', array(
                    'default'           => true,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_logic',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'second-btn-target', array(
                    'label'             => __( 'Open url in new window', 'treeson' ),
                    'description'       => __( 'enable / disable link attribut target="_blank"', 'treeson' ),
                    'section'           => 'header-second-btn',
                    'settings'          => 'second-btn-target',
                    'type'              => 'checkbox',
                ));
            }
        }


        {   /* BREADCRUMBS */

            $wp_customize -> add_section( 'breadcrumbs', array(
                'title'             => __( 'Breadcrumbs' , 'treeson' ),
                'priority'          => 32,
                'capability'        => 'edit_theme_options'
            ));

            /* DISPLAY BREADCRUMBS */
            $wp_customize -> add_setting( 'breadcrumbs', array(
                'default'           => true,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'mythemes_validate_logic',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'breadcrumbs', array(
                'label'             => __( 'Display breadcrumbs', 'treeson' ),
                'section'           => 'breadcrumbs',
                'settings'          => 'breadcrumbs',
                'type'              => 'checkbox',
            ));

            /* LABEL */
            $wp_customize -> add_setting( 'home-label', array(
                'default'           => __( 'Home', 'treeson' ),
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_text_field',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'home-label', array(
                'label'             => __( '"Home" label', 'treeson' ),
                'description'       => __( 'breadcrumbs "Home" link label.', 'treeson' ),
                'section'           => 'breadcrumbs',
                'settings'          => 'home-label',
                'type'              => 'text',
            ));

            /* DESCRIPTION */
            $wp_customize -> add_setting( 'home-link-description', array(
                'default'           => __( 'go to home', 'treeson' ),
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_text_field',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'home-link-description', array(
                'label'             => __( '"Home" link description', 'treeson' ),
                'description'       => __( 'breadcrumbs "Home" link description.', 'treeson' ),
                'section'           => 'breadcrumbs',
                'settings'          => 'home-link-description',
                'type'              => 'textarea',
            ));

            /* SPACE */
            $wp_customize -> add_setting( 'breadcrumbs-space', array(
                'default'           => 60,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'mythemes_validate_number',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'breadcrumbs-space', array(
                'label'             => __( 'Space ( in pixels )', 'treeson' ),
                'description'       => __( 'inner top and bottom space allow you to change breadcrumbs height.', 'treeson' ),
                'section'           => 'breadcrumbs',
                'settings'          => 'breadcrumbs-space',
                'type'              => 'number',
                'input_attrs'       => array(
                    'min'   => 0,
                    'max'   => 100,
                )
            ));
        }
        

        {   /* ADDITIONAL */

            $wp_customize -> add_section( 'additional', array(
                'title'             => __( 'Additional' , 'treeson' ),
                'priority'          => 33,
                'capability'        => 'edit_theme_options'

            ));

            /* LABEL "BLOG PAGE" */
            $wp_customize -> add_setting( 'blog-title', array(
                'default'           => __( 'Blog', 'treeson' ),
                'transport'         => 'postMessage',
                'sanitize_callback' => 'sanitize_text_field',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'blog-title', array(
                'label'             => __( 'Title for Blog Page', 'treeson' ),
                'section'           => 'additional',
                'settings'          => 'blog-title',
                'type'              => 'text'
            ));

            /* DISPLAY DEFAULT CONTENT */
            $wp_customize -> add_setting( 'default-content', array(
                'default'           => true,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'mythemes_validate_logic',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'default-content', array(
                'label'             => __( 'Display default content', 'treeson' ),
                'description'       => __( 'enable / disable default content from sidebars.', 'treeson' ),
                'section'           => 'additional',
                'settings'          => 'default-content',
                'type'              => 'checkbox',
            ));

            /* DISPLAY TOP META */
            $wp_customize -> add_setting( 'top-meta', array(
                'default'           => true,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'mythemes_validate_logic',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'top-meta', array(
                'label'             => __( 'Display top meta', 'treeson' ),
                'description'       => __( 'enable / disable top meta from single posts ( all posts ).', 'treeson' ),
                'section'           => 'additional',
                'settings'          => 'top-meta',
                'type'              => 'checkbox',
            ));

            /* DISPLAY BOTTOM META */
            $wp_customize -> add_setting( 'bottom-meta', array(
                'default'           => true,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'mythemes_validate_logic',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'bottom-meta', array(
                'label'             => __( 'Display bottom meta', 'treeson' ),
                'description'       => __( 'enable / disable bottom meta from single posts ( all posts ).', 'treeson' ),
                'section'           => 'additional',
                'settings'          => 'bottom-meta',
                'type'              => 'checkbox',
            ));

            /* HTML SUGGESTIONS */
            $wp_customize -> add_setting( 'html-suggestions', array(
                'default'           => true,
                'transport'         => 'postMessage',
                'sanitize_callback' => 'mythemes_validate_logic',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'html-suggestions', array(
                'label'             => __( 'HTML Suggestions', 'treeson' ),
                'description'       => __( 'enable / disable HTML Suggestions after comments form ( all posts ).', 'treeson' ),
                'section'           => 'additional',
                'settings'          => 'html-suggestions',
                'type'              => 'checkbox',
            ));
        }


        {   /* LAYOUTS */

            $wp_customize -> add_panel( 'layout-panel', array(
                'title'             => __( 'Layout' , 'treeson' ),
                'description'       => sprintf( __( 'On the premium version for each page, post or / and portfolio you can overwrite the Layout options with custom settings. %s' , 'treeson' ) , '<br/><br/><a href="' . esc_url( mythemes_core::theme( 'premium' ) ) . '" target="_blank" title="Treeson Premium Multipurpose Wordpress Theme">' . __( 'Upgrade to Premium' , 'treeson' ) . ' &rarr;</a>' ),
                'priority'          => 34,
                'capability'        => 'edit_theme_options'
            ));


            $sidebars   = array(
                'main'              => __( 'Main Sidebar' , 'treeson' ),
                'front-page'        => __( 'Front Page Sidebar' , 'treeson' ),
                'page'              => __( 'Page Sidebar' , 'treeson' ),
                'post'              => __( 'Post Sidebar' , 'treeson' ),
                'special-page'      => __( 'Special Page Sidebar' , 'treeson' )
            );


            {   /* DEFAULT */

                $wp_customize -> add_section( 'layout', array(
                    'title'             => __( 'Default' , 'treeson' ),
                    'description'       => __( 'Default Layout is used for the next templates: Blog, Archives, Categories, Tags, Author and Search Results.' , 'treeson' ),
                    'panel'             => 'layout-panel',
                    'capability'        => 'edit_theme_options'
                ));

                /* LAYOUT */
                $wp_customize -> add_setting( 'layout', array(
                    'default'           => 'right',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_layout',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'layout', array(
                    'label'             => __( 'Layout' , 'treeson' ),
                    'section'           => 'layout',
                    'settings'          => 'layout',
                    'type'              => 'select',
                    'choices'           => array(
                        'left'  => __( 'Left Sidebar', 'treeson' ),
                        'full'  => __( 'Full Width', 'treeson' ),
                        'right' => __( 'Right Sidebar', 'treeson' )
                    )
                ));

                /* SIDEBAR */
                $wp_customize -> add_setting( 'sidebar', array(
                    'default'           => 'main',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_sidebar',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'sidebar', array(
                    'label'             => __( 'Sidebar' , 'treeson' ),
                    'description'       => __( 'on the premium version you can create unlimited number of sidebars' , 'treeson' ),
                    'section'           => 'layout',
                    'settings'          => 'sidebar',
                    'type'              => 'select',
                    'choices'           => $sidebars
                ));
            }


            {   /* FRONT PAGE */

                $wp_customize -> add_section( 'front-page-layout', array(
                    'title'             => __( 'Front Page' , 'treeson' ),
                    'description'       => __( 'In order to use this option set you need to activate a staic page on Front Page from - "Static Front Page" tab' , 'treeson' ),
                    'panel'             => 'layout-panel',
                    'capability'        => 'edit_theme_options'
                ));

                /* LAYOUT */
                $wp_customize -> add_setting( 'front-page-layout', array(
                    'default'           => 'right',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_layout',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'front-page-layout', array(
                    'label'             => __( 'Layout' , 'treeson' ),
                    'section'           => 'front-page-layout',
                    'settings'          => 'front-page-layout',
                    'type'              => 'select',
                    'choices'           => array(
                        'left'  => __( 'Left Sidebar', 'treeson' ),
                        'full'  => __( 'Full Width', 'treeson' ),
                        'right' => __( 'Right Sidebar', 'treeson' )
                    )
                ));

                /* SIDEBAR */
                $wp_customize -> add_setting( 'front-page-sidebar', array(
                    'default'           => 'front-page',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_sidebar',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'front-page-sidebar', array(
                    'label'             => __( 'Sidebar' , 'treeson' ),
                    'description'       => __( 'on the premium version you can create unlimited number of sidebars' , 'treeson' ),
                    'section'           => 'front-page-layout',
                    'settings'          => 'front-page-sidebar',
                    'type'              => 'select',
                    'choices'           => $sidebars
                ));
            }
            

            {   /* SINGLE PAGE */

                $wp_customize -> add_section( 'page-layout', array(
                    'title'             => __( 'Single Page' , 'treeson' ),
                    'description'       => __( 'On the premium version for the each page you can overwrite the Layout options with the custom settings.' , 'treeson' ),
                    'panel'             => 'layout-panel'
                ));

                /* LAYOUT */
                $wp_customize -> add_setting( 'page-layout', array(
                    'default'           => 'full',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_layout',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'page-layout', array(
                    'label'             => __( 'Layout' , 'treeson' ),
                    'section'           => 'page-layout',
                    'settings'          => 'page-layout',
                    'type'              => 'select',
                    'choices'           => array(
                        'left'  => __( 'Left Sidebar', 'treeson' ),
                        'full'  => __( 'Full Width', 'treeson' ),
                        'right' => __( 'Right Sidebar', 'treeson' )
                    )
                ));

                /* SIDEBAR */
                $wp_customize -> add_setting( 'page-sidebar', array(
                    'default'           => 'page',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_sidebar',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'page-sidebar', array(
                    'label'             => __( 'Sidebar' , 'treeson' ),
                    'description'       => __( 'on the premium version you can create unlimited number of sidebars' , 'treeson' ),
                    'section'           => 'page-layout',
                    'settings'          => 'page-sidebar',
                    'type'              => 'select',
                    'choices'           => $sidebars
                ));
            }
            

            {   /* SINGLE POST */

                $wp_customize -> add_section( 'post-layout', array(
                    'title'             => __( 'Single Post' , 'treeson' ),
                    'description'       => __( 'On the premium version for the each post you can overwrite the Layout options with the custom settings.' , 'treeson' ),
                    'panel'             => 'layout-panel',
                    'capability'        => 'edit_theme_options'
                ));

                /* LAYOUT */
                $wp_customize -> add_setting( 'post-layout', array(
                    'default'           => 'right',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_layout',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'post-layout', array(
                    'label'             => __( 'Layout' , 'treeson' ),
                    'section'           => 'post-layout',
                    'settings'          => 'post-layout',
                    'type'              => 'select',
                    'choices'           => array(
                        'left'  => __( 'Left Sidebar', 'treeson' ),
                        'full'  => __( 'Full Width', 'treeson' ),
                        'right' => __( 'Right Sidebar', 'treeson' )
                    )
                ));

                /* SIDEBAR */
                $wp_customize -> add_setting( 'post-sidebar', array(
                    'default'           => 'post',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_sidebar',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'post-sidebar', array(
                    'label'             => __( 'Sidebar' , 'treeson' ),
                    'description'       => __( 'on the premium version you can create unlimited number of sidebars' , 'treeson' ),
                    'section'           => 'post-layout',
                    'settings'          => 'post-sidebar',
                    'type'              => 'select',
                    'choices'           => $sidebars
                ));
            }
            

            {   /* SPECIAL PAGE */

                $wp_customize -> add_section( 'special-page-layout', array(
                    'title'             => __( 'Special Page' , 'treeson' ),
                    'description'       => __( 'On the premium version for each page you can overwrite the Layout options with custom settings.' , 'treeson' ),
                    'panel'             => 'layout-panel',
                    'capability'        => 'edit_theme_options'
                ));

                /* SPECIAL PAGE */
                $wp_customize -> add_setting( 'special-page', array(
                    'default'           => 2,
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_number',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'special-page', array(
                    'label'             => __( 'Special page' , 'treeson' ),
                    'description'       => __( 'for selected page you can overwrite default page layout settings with special layout settings', 'treeson' ),
                    'section'           => 'special-page-layout',
                    'settings'          => 'special-page',
                    'type'              => 'dropdown-pages'
                ));

                /* LAYOUT */
                $wp_customize -> add_setting( 'special-page-layout', array(
                    'default'           => 'right',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_layout',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'special-page-layout', array(
                    'label'             => __( 'Layout' , 'treeson' ),
                    'section'           => 'special-page-layout',
                    'settings'          => 'special-page-layout',
                    'type'              => 'select',
                    'choices'           => array(
                        'left'  => __( 'Left Sidebar', 'treeson' ),
                        'full'  => __( 'Full Width', 'treeson' ),
                        'right' => __( 'Right Sidebar', 'treeson' )
                    )
                ));

                /* SIDEBAR */
                $wp_customize -> add_setting( 'special-page-sidebar', array(
                    'default'           => 'special-page',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'mythemes_validate_sidebar',
                    'capability'        => 'edit_theme_options'
                ));
                $wp_customize -> add_control( 'special-page-sidebar', array(
                    'label'             => __( 'Sidebar' , 'treeson' ),
                    'description'       => __( 'on the premium version you can create unlimited number of sidebars' , 'treeson' ),
                    'section'           => 'special-page-layout',
                    'settings'          => 'special-page-sidebar',
                    'type'              => 'select',
                    'choices'           => $sidebars
                ));
            }
        
        }


        {   /* SOCIAL */

            $wp_customize -> add_section( 'social', array(
                'title'             => __( 'Social' , 'treeson' ),
                'priority'          => 35,
                'capability'        => 'edit_theme_options'
            ));

            /* VIMEO */
            $wp_customize -> add_setting( 'vimeo', array(
                'default'           => 'http://vimeo.com/#',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'vimeo', array(
                'label'             => __( 'Vimeo', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'vimeo',
                'type'              => 'url',
            ));

            /* TWITTER */
            $wp_customize -> add_setting( 'twitter', array(
                'default'           => 'http://twitter.com/#',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'twitter', array(
                'label'             => __( 'Twitter', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'twitter',
                'type'              => 'url'
            ));

            /* SKYPE */
            $wp_customize -> add_setting( 'skype', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'skype', array(
                'label'             => __( 'Skype', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'skype',
                'type'              => 'url'
            ));

            /* RENREN */
            $wp_customize -> add_setting( 'renren', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'renren', array(
                'label'             => __( 'Renren', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'renren',
                'type'              => 'url',
            ));

            /* GITHUB */
            $wp_customize -> add_setting( 'github', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'github', array(
                'label'             => __( 'Github', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'github',
                'type'              => 'url'
            ));

            /* RDIO */
            $wp_customize -> add_setting( 'rdio', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'rdio', array(
                'label'             => __( 'Rdio', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'rdio',
                'type'              => 'url'
            ));

            /* LINKEDIN */
            $wp_customize -> add_setting( 'linkedin', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'linkedin', array(
                'label'             => __( 'Linkedin', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'linkedin',
                'type'              => 'url',
            ));

            /* BEHANCE */
            $wp_customize -> add_setting( 'behance', array(
                'default'           => 'http://behance.com/#',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'behance', array(
                'label'             => __( 'Behance', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'behance',
                'type'              => 'url',
            ));

            /* DROPBOX */
            $wp_customize -> add_setting( 'dropbox', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'dropbox', array(
                'label'             => __( 'Dropbox', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'dropbox',
                'type'              => 'url',
            ));

            /* FLICKR */
            $wp_customize -> add_setting( 'flickr', array(
                'default'           => 'http://flickr.com/#',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'flickr', array(
                'label'             => __( 'Flickr', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'flickr',
                'type'              => 'url',
            ));

            /* TUMBLR */
            $wp_customize -> add_setting( 'tumblr', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'tumblr', array(
                'label'             => __( 'Tumblr', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'tumblr',
                'type'              => 'url',
            ));

            /* INSTAGRAM */
            $wp_customize -> add_setting( 'instagram', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'instagram', array(
                'label'             => __( 'Instagram', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'instagram',
                'type'              => 'url',
            ));

            /* VKONTAKTE */
            $wp_customize -> add_setting( 'vkontakte', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'vkontakte', array(
                'label'             => __( 'Vkontakte', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'vkontakte',
                'type'              => 'url',
            ));

            /* FACEBOOK */
            $wp_customize -> add_setting( 'facebook', array(
                'default'           => 'http://facebook.com/#',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'facebook', array(
                'label'             => __( 'Facebook', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'facebook',
                'type'              => 'url',
            ));

            /* EVERNOTE */
            $wp_customize -> add_setting( 'evernote', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'evernote', array(
                'label'             => __( 'Evernote', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'evernote',
                'type'              => 'url',
            ));

            /* FLATTR */
            $wp_customize -> add_setting( 'flattr', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'flattr', array(
                'label'             => __( 'Flattr', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'flattr',
                'type'              => 'url',
            ));

            /* PICASA */
            $wp_customize -> add_setting( 'picasa', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'picasa', array(
                'label'             => __( 'Picasa', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'picasa',
                'type'              => 'url',
            ));

            /* DRIBBBLE */
            $wp_customize -> add_setting( 'dribbble', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'dribbble', array(
                'label'             => __( 'Dribbble', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'dribbble',
                'type'              => 'url',
            ));

            /* MIXI */
            $wp_customize -> add_setting( 'mixi', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'mixi', array(
                'label'             => __( 'Mixi', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'mixi',
                'type'              => 'url',
            ));

            /* STUMBLEUPON */
            $wp_customize -> add_setting( 'stumbleupon', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'stumbleupon', array(
                'label'             => __( 'Stumbleupon', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'stumbleupon',
                'type'              => 'url',
            ));

            /* LASTFM */
            $wp_customize -> add_setting( 'lastfm', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'lastfm', array(
                'label'             => __( 'Lastfm', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'lastfm',
                'type'              => 'url',
            ));

            /* GPLUS */
            $wp_customize -> add_setting( 'gplus', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'gplus', array(
                'label'             => __( 'GPlus', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'gplus',
                'type'              => 'url',
            ));

            /* GOOGLE CIRCLES */
            $wp_customize -> add_setting( 'google-circles', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'google-circles', array(
                'label'             => __( 'Google circles', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'google-circles',
                'type'              => 'url',
            ));

            /* PINTEREST */
            $wp_customize -> add_setting( 'pinterest', array(
                'default'           => 'http://pinterest.com/#',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'pinterest', array(
                'label'             => __( 'Pinterest', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'pinterest',
                'type'              => 'url',
            ));

            /* SMASHING */
            $wp_customize -> add_setting( 'smashing', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'smashing', array(
                'label'             => __( 'Smashing', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'smashing',
                'type'              => 'url',
            ));

            /* SOUNDCLOUD */
            $wp_customize -> add_setting( 'soundcloud', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'soundcloud', array(
                'label'             => __( 'Soundcloud', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'soundcloud',
                'type'              => 'url',
            ));

            /* RSS */
            $wp_customize -> add_setting( 'rss', array(
                'default'           => esc_url( get_bloginfo('rss2_url') ),
                'transport'         => 'postMessage',
                'sanitize_callback' => 'esc_url_raw',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'rss', array(
                'label'             => __( 'Rss', 'treeson' ),
                'section'           => 'social',
                'settings'          => 'rss',
                'type'              => 'url',
            ));
        }
    	

        {   /* OTHERS */
            $wp_customize -> add_section( 'others', array(
                'title'             => __( 'Others' , 'treeson' ),
                'priority'          => 36,
                'capability'        => 'edit_theme_options'
            ));

            /* CUSTOM CSS */
            $wp_customize -> add_setting( 'custom-css', array(
                'default'           => '',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'mythemes_validate_css',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'custom-css', array(
                'label'             => __( 'Custom css', 'treeson' ),
                'section'           => 'others',
                'settings'          => 'custom-css',
                'type'              => 'textarea',
            ));

            /* COPYRIGHT */
            $wp_customize -> add_setting( 'copyright', array(
                'default'           => sprintf( __( 'Copyright &copy; 2015. Powered by %s.' , 'treeson' ) , '<a href="http://wordpress.org/">WordPress</a>' ),
                'transport'         => 'postMessage',
                'sanitize_callback' => 'mythemes_validate_copyright',
                'capability'        => 'edit_theme_options'
            ));
            $wp_customize -> add_control( 'copyright', array(
                'label'             => __( 'Copyright', 'treeson' ),
                'description'       => __( 'You can change only the first side of copyright. With the premium version you can change all the footer text.' , 'treeson' ),
                'section'           => 'others',
                'settings'          => 'copyright',
                'type'              => 'textarea',
            ));
        }
	}
 
	add_action( 'customize_register' , 'mythemes_customize_register' );

	function mythemes_customizer_live_preview()
	{
        $mythemes_js_ajaxurl = esc_url( admin_url( '/admin-ajax.php' ) );
    	wp_register_script( 'mythemes-themecustomizer', get_template_directory_uri() . '/media/_backend/js/customizer.js', array( 'jquery', 'customize-preview' ), '',  true );
        wp_localize_script( 'mythemes-themecustomizer', 'mythemes_js_ajaxurl', $mythemes_js_ajaxurl );
        wp_enqueue_script( 'mythemes-themecustomizer' );
	}

	add_action( 'customize_preview_init', 'mythemes_customizer_live_preview' );

    if( is_user_logged_in() ){
        add_action( 'wp_ajax_mythemes_layout_load_sidebar' , array( 'mythemes_layout', 'load_sidebar' ), 100 );
    }

    /* FUNCTIONS FOR VALIDATE */
    function mythemes_validate_logic( $value )
    {
        $rett = true;

        if( absint( $value ) == 0 ){
            $rett = false;
        }

        return $rett;
    }

    function mythemes_validate_number( $value )
    {
        return absint( $value );
    }

    function mythemes_validate_layout( $value )
    {
        if( !in_array( $value , array( 'left' , 'full' , 'right' ) ) ){
            $value = 'right';
        }

        return $value;
    }

    function mythemes_validate_sidebar( $value )
    {
        if( !in_array( $value , array( 'main', 'front-page', 'page', 'post', 'special-page' ) ) ){
            $value = 'main';
        }

        return $value;
    }

    function mythemes_validate_copyright( $value )
    {
        return wp_kses( $value, array(
            'a' => array(
                'href'  => array(),
                'title' => array(),
                'class' => array(),
                'id'    => array()
            ),
            'br'        => array(),
            'em'        => array(),
            'strong'    => array(),
            'span'      => array()
        ));
    }

    function mythemes_validate_css( $value )
    {
        return stripslashes( strip_tags( $value ) );
    }
?>