<?php
/**
 * VW Blog Magazine Theme Customizer
 *
 * @package VW Blog Magazine
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function vw_blog_magazine_custom_controls() {

    load_template( trailingslashit( get_template_directory() ) . '/inc/custom-controls.php' );
}
add_action( 'customize_register', 'vw_blog_magazine_custom_controls' );

function vw_blog_magazine_customize_register( $wp_customize ) {

	load_template( trailingslashit( get_template_directory() ) . '/inc/icon-picker.php' );

	$wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; 
	$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';

	//Selective Refresh
	$wp_customize->selective_refresh->add_partial( 'blogname', array( 
		'selector' => '.logo .site-title a', 
	 	'render_callback' => 'vw_blog_magazine_customize_partial_blogname', 
	)); 

	$wp_customize->selective_refresh->add_partial( 'blogdescription', array( 
		'selector' => 'p.site-description', 
		'render_callback' => 'vw_blog_magazine_customize_partial_blogdescription', 
	));

	$VWBlogMagazineParentPanel = new VW_Blog_Magazine_WP_Customize_Panel( $wp_customize, 'vw_blog_magazine_panel_id', array(
		'capability' => 'edit_theme_options',
		'theme_supports' => '',
		'title' => esc_html__('VW Settings','vw-blog-magazine'),
		'priority' => 10,
	));

	$wp_customize->add_section( 'vw_blog_magazine_left_right', array(
    	'title'      => esc_html__('General Settings','vw-blog-magazine'),
		'priority'   => 30,
		'panel' => 'vw_blog_magazine_panel_id'
	) );

	$wp_customize->add_setting('vw_blog_magazine_width_option',array(
        'default' => 'Full Width',
        'sanitize_callback' => 'vw_blog_magazine_sanitize_choices'
	));
	$wp_customize->add_control(new VW_Blog_Magazine_Image_Radio_Control($wp_customize, 'vw_blog_magazine_width_option', array(
        'type' => 'select',
        'label' => __('Width Layouts','vw-blog-magazine'),
        'description' => __('Here you can change the width layout of Website.','vw-blog-magazine'),
        'section' => 'vw_blog_magazine_left_right',
        'choices' => array(
            'Full Width' => esc_url(get_template_directory_uri()).'/images/full-width.png',
            'Wide Width' => esc_url(get_template_directory_uri()).'/images/wide-width.png',
            'Boxed' => esc_url(get_template_directory_uri()).'/images/boxed-width.png',
    ))));

	// Add Settings and Controls for Layout
	$wp_customize->add_setting('vw_blog_magazine_theme_options',array(
        'default' => 'Right Sidebar',
        'sanitize_callback' => 'vw_blog_magazine_sanitize_choices'	        
	));
	$wp_customize->add_control('vw_blog_magazine_theme_options', array(
        'type' => 'select',
        'label' => __('Post Sidebar Layout','vw-blog-magazine'),
        'description' => __('Here you can change the sidebar layout for posts. ','vw-blog-magazine'),
        'section' => 'vw_blog_magazine_left_right',
        'choices' => array(
            'Left Sidebar' => __('Left Sidebar','vw-blog-magazine'),
            'Right Sidebar' => __('Right Sidebar','vw-blog-magazine'),
            'One Column' => __('One Column','vw-blog-magazine'),
            'Three Columns' => __('Three Columns','vw-blog-magazine'),
            'Four Columns' => __('Four Columns','vw-blog-magazine'),
            'Grid Layout' => __('Grid Layout','vw-blog-magazine')
        ),
	));

	$wp_customize->add_setting('vw_blog_magazine_page_layout',array(
        'default' => 'One Column',
        'sanitize_callback' => 'vw_blog_magazine_sanitize_choices'
	));
	$wp_customize->add_control('vw_blog_magazine_page_layout',array(
        'type' => 'select',
        'label' => __('Page Sidebar Layout','vw-blog-magazine'),
        'description' => __('Here you can change the sidebar layout for pages. ','vw-blog-magazine'),
        'section' => 'vw_blog_magazine_left_right',
        'choices' => array(
            'Left Sidebar' => __('Left Sidebar','vw-blog-magazine'),
            'Right Sidebar' => __('Right Sidebar','vw-blog-magazine'),
            'One Column' => __('One Column','vw-blog-magazine')
        ),
	) );

	//Sticky Header
	$wp_customize->add_setting( 'vw_blog_magazine_sticky_header',array(
        'default' => 0,
        'transport' => 'refresh',
        'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ) );
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_sticky_header',array(
        'label' => esc_html__( 'Sticky Header','vw-blog-magazine' ),
        'section' => 'vw_blog_magazine_left_right'
    )));

    $wp_customize->add_setting('vw_blog_magazine_sticky_header_padding',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_sticky_header_padding',array(
		'label'	=> __('Sticky Header Padding','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_left_right',
		'type'=> 'text'
	));

	//Pre-Loader
	$wp_customize->add_setting( 'vw_blog_magazine_loader_enable',array(
        'default' => 0,
        'transport' => 'refresh',
        'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ) );
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_loader_enable',array(
        'label' => esc_html__( 'Pre-Loader','vw-blog-magazine' ),
        'section' => 'vw_blog_magazine_left_right'
    )));

	$wp_customize->add_setting('vw_blog_magazine_preloader_bg_color', array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_hex_color',
	));
	$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'vw_blog_magazine_preloader_bg_color', array(
		'label'    => __('Pre-Loader Background Color', 'vw-blog-magazine'),
		'section'  => 'vw_blog_magazine_left_right',
	)));

	$wp_customize->add_setting('vw_blog_magazine_preloader_border_color', array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_hex_color',
	));
	$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'vw_blog_magazine_preloader_border_color', array(
		'label'    => __('Pre-Loader Border Color', 'vw-blog-magazine'),
		'section'  => 'vw_blog_magazine_left_right',
	)));

	//Our Blog Category section
  	$wp_customize->add_section('vw_blog_magazine_category_section',array(
	    'title' => __('Category Section','vw-blog-magazine'),
	    'description' => '',
	    'priority'  => null,
	    'panel' => 'vw_blog_magazine_panel_id',
	)); 

	//Selective Refresh
	$wp_customize->selective_refresh->add_partial( 'vw_blog_magazine_category', array( 
		'selector' => '.imagebox h2 a', 
		'render_callback' => 'vw_blog_magazine_customize_partial_vw_blog_magazine_category',
	));

	$categories = get_categories();
	$cats = array();
	$i = 0;
	$cat_pst[]= 'select';
	foreach($categories as $category){
		if($i==0){
			$default = $category->slug;
			$i++;
		}
		$cat_pst[$category->slug] = $category->name;
	}

	$wp_customize->add_setting('vw_blog_magazine_category',array(
	    'default' => 'select',
	    'sanitize_callback' => 'vw_blog_magazine_sanitize_choices',
  	));

  	$wp_customize->add_control('vw_blog_magazine_category',array(
	    'type'    => 'select',
	    'choices' => $cat_pst,
	    'label' => __('Select Category to display Latest Post','vw-blog-magazine'),
	    'section' => 'vw_blog_magazine_category_section',
	));

	//Category section 2
  	$wp_customize->add_section('vw_blog_magazine_cat_two_sec',array(
	    'title' => __('Category section 2','vw-blog-magazine'),
	    'description' => '',
	    'priority'  => null,
	    'panel' => 'vw_blog_magazine_panel_id',
	)); 

	//Selective Refresh
	$wp_customize->selective_refresh->add_partial( 'vw_blog_magazine_section_two', array( 
		'selector' => '#our_blog .box-content h3', 
		'render_callback' => 'vw_blog_magazine_customize_partial_vw_blog_magazine_section_two',
	));

	$categories = get_categories();
	$cats = array();
	$i = 0;
	$cat_pst1[]= 'select';
	foreach($categories as $category){
		if($i==0){
			$default = $category->slug;
			$i++;
		}
		$cat_pst1[$category->slug] = $category->name;
	}

	$wp_customize->add_setting('vw_blog_magazine_section_two',array(
	    'default' => 'select',
	    'sanitize_callback' => 'vw_blog_magazine_sanitize_choices',
  	));

  	$wp_customize->add_control('vw_blog_magazine_section_two',array(
	    'type'    => 'select',
	    'choices' => $cat_pst1,
	    'label' => __('Select Category to display Latest Post','vw-blog-magazine'),
	    'section' => 'vw_blog_magazine_cat_two_sec',
	));

	//Category 2 excerpt
	$wp_customize->add_setting( 'vw_blog_magazine_category_excerpt_number', array(
		'default'              => 30,
		'transport' 		   => 'refresh',
		'sanitize_callback'    => 'vw_blog_magazine_sanitize_number_range'
	));
	$wp_customize->add_control( 'vw_blog_magazine_category_excerpt_number', array(
		'label'       => esc_html__( 'Category Excerpt length','vw-blog-magazine' ),
		'section'     => 'vw_blog_magazine_cat_two_sec',
		'type'        => 'range',
		'settings'    => 'vw_blog_magazine_category_excerpt_number',
		'input_attrs' => array(
			'step'             => 5,
			'min'              => 0,
			'max'              => 50,
		),
	));

	//Blog Post
	$wp_customize->add_panel( $VWBlogMagazineParentPanel );

	$BlogPostParentPanel = new VW_Blog_Magazine_WP_Customize_Panel( $wp_customize, 'blog_post_parent_panel', array(
		'title' => __( 'Blog Post Settings', 'vw-blog-magazine' ),
		'panel' => 'vw_blog_magazine_panel_id',
	));

	$wp_customize->add_panel( $BlogPostParentPanel );

	// Add example section and controls to the middle (second) panel
	$wp_customize->add_section( 'vw_blog_magazine_post_settings', array(
		'title' => __( 'Post Settings', 'vw-blog-magazine' ),
		'panel' => 'blog_post_parent_panel',
	));

	//Selective Refresh
	$wp_customize->selective_refresh->add_partial('vw_blog_magazine_toggle_postdate', array( 
		'selector' => '.postbox h2 a', 
		'render_callback' => 'vw_blog_magazine_customize_partial_vw_blog_magazine_toggle_postdate', 
	));

	$wp_customize->add_setting( 'vw_blog_magazine_toggle_postdate',array(
        'default' => 1,
        'transport' => 'refresh',
        'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ));
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_toggle_postdate',array(
        'label' => esc_html__( 'Post Date','vw-blog-magazine' ),
        'section' => 'vw_blog_magazine_post_settings'
    )));

    $wp_customize->add_setting( 'vw_blog_magazine_toggle_author',array(
		'default' => 1,
		'transport' => 'refresh',
		'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ));
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_toggle_author',array(
		'label' => esc_html__( 'Author','vw-blog-magazine' ),
		'section' => 'vw_blog_magazine_post_settings'
    )));

    $wp_customize->add_setting( 'vw_blog_magazine_toggle_comments',array(
		'default' => 1,
		'transport' => 'refresh',
		'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ));
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_toggle_comments',array(
		'label' => esc_html__( 'Comments','vw-blog-magazine' ),
		'section' => 'vw_blog_magazine_post_settings'
    )));

    $wp_customize->add_setting( 'vw_blog_magazine_toggle_time',array(
		'default' => 1,
		'transport' => 'refresh',
		'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ) );
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_toggle_time',array(
		'label' => esc_html__( 'Time','vw-blog-magazine' ),
		'section' => 'vw_blog_magazine_post_settings'
    )));

    $wp_customize->add_setting( 'vw_blog_magazine_excerpt_number', array(
		'default'              => 30,
		'transport' 		   => 'refresh',
		'sanitize_callback'    => 'vw_blog_magazine_sanitize_number_range'
	));
	$wp_customize->add_control( 'vw_blog_magazine_excerpt_number', array(
		'label'       => esc_html__( 'Excerpt length','vw-blog-magazine' ),
		'section'     => 'vw_blog_magazine_post_settings',
		'type'        => 'range',
		'settings'    => 'vw_blog_magazine_excerpt_number',
		'input_attrs' => array(
			'step'             => 5,
			'min'              => 0,
			'max'              => 50,
		),
	));

	//Blog layout
    $wp_customize->add_setting('vw_blog_magazine_blog_layout_option',array(
        'default' => 'Default',
        'sanitize_callback' => 'vw_blog_magazine_sanitize_choices'
    ));
    $wp_customize->add_control(new VW_Blog_Magazine_Image_Radio_Control($wp_customize, 'vw_blog_magazine_blog_layout_option', array(
        'type' => 'select',
        'label' => __('Blog Layouts','vw-blog-magazine'),
        'section' => 'vw_blog_magazine_post_settings',
        'choices' => array(
            'Default' => esc_url(get_template_directory_uri()).'/images/blog-layout1.png',
            'Center' => esc_url(get_template_directory_uri()).'/images/blog-layout2.png',
            'Left' => esc_url(get_template_directory_uri()).'/images/blog-layout3.png',
    ))));

    $wp_customize->add_setting('vw_blog_magazine_excerpt_settings',array(
        'default' => 'Excerpt',
        'transport' => 'refresh',
        'sanitize_callback' => 'vw_blog_magazine_sanitize_choices'
	));
	$wp_customize->add_control('vw_blog_magazine_excerpt_settings',array(
        'type' => 'select',
        'label' => __('Post Content','vw-blog-magazine'),
        'section' => 'vw_blog_magazine_post_settings',
        'choices' => array(
        	'Content' => __('Content','vw-blog-magazine'),
            'Excerpt' => __('Excerpt','vw-blog-magazine'),
            'No Content' => __('No Content','vw-blog-magazine')
        ),
	));

	$wp_customize->add_setting('vw_blog_magazine_excerpt_suffix',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_excerpt_suffix',array(
		'label'	=> __('Add Excerpt Suffix','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '[...]', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_post_settings',
		'type'=> 'text'
	));

	$wp_customize->add_setting( 'vw_blog_magazine_blog_pagination_hide_show',array(
      'default' => 1,
      'transport' => 'refresh',
      'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ));  
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_blog_pagination_hide_show',array(
      'label' => esc_html__( 'Show / Hide Blog Pagination','vw-blog-magazine' ),
      'section' => 'vw_blog_magazine_post_settings'
    )));

	$wp_customize->add_setting( 'vw_blog_magazine_blog_pagination_type', array(
        'default'			=> 'blog-page-numbers',
        'sanitize_callback'	=> 'vw_blog_magazine_sanitize_choices'
    ));
    $wp_customize->add_control( 'vw_blog_magazine_blog_pagination_type', array(
        'section' => 'vw_blog_magazine_post_settings',
        'type' => 'select',
        'label' => __( 'Blog Pagination', 'vw-blog-magazine' ),
        'choices'		=> array(
            'blog-page-numbers'  => __( 'Numeric', 'vw-blog-magazine' ),
            'next-prev' => __( 'Older Posts/Newer Posts', 'vw-blog-magazine' ),
    )));

    // Button Settings
	$wp_customize->add_section( 'vw_blog_magazine_button_settings', array(
		'title' => __( 'Button Settings', 'vw-blog-magazine' ),
		'panel' => 'blog_post_parent_panel',
	));

	$wp_customize->add_setting('vw_blog_magazine_button_padding_top_bottom',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_button_padding_top_bottom',array(
		'label'	=> __('Padding Top Bottom','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_button_settings',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_button_padding_left_right',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_button_padding_left_right',array(
		'label'	=> __('Padding Left Right','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_button_settings',
		'type'=> 'text'
	));

	$wp_customize->add_setting( 'vw_blog_magazine_button_border_radius', array(
		'default'              => '',
		'transport' 		   => 'refresh',
		'sanitize_callback'    => 'vw_blog_magazine_sanitize_number_range'
	) );
	$wp_customize->add_control( 'vw_blog_magazine_button_border_radius', array(
		'label'       => esc_html__( 'Button Border Radius','vw-blog-magazine' ),
		'section'     => 'vw_blog_magazine_button_settings',
		'type'        => 'range',
		'input_attrs' => array(
			'step'             => 1,
			'min'              => 1,
			'max'              => 50,
		),
	) );

	//Selective Refresh
	$wp_customize->selective_refresh->add_partial('vw_blog_magazine_button_text', array( 
		'selector' => '.box-content .read-btn a', 
		'render_callback' => 'vw_blog_magazine_customize_partial_vw_blog_magazine_button_text', 
	));

    $wp_customize->add_setting('vw_blog_magazine_button_text',array(
		'default'=> esc_html__('Read Full','vw-blog-magazine'),
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_button_text',array(
		'label'	=> __('Add Button Text','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( 'Read Full', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_button_settings',
		'type'=> 'text'
	));

	// Related Post Settings
	$wp_customize->add_section( 'vw_blog_magazine_related_posts_settings', array(
		'title' => __( 'Related Posts Settings', 'vw-blog-magazine' ),
		'panel' => 'blog_post_parent_panel',
	));

	//Selective Refresh
	$wp_customize->selective_refresh->add_partial('vw_blog_magazine_related_post_title', array( 
		'selector' => '.related-post h3', 
		'render_callback' => 'vw_blog_magazine_customize_partial_vw_blog_magazine_related_post_title', 
	));

    $wp_customize->add_setting( 'vw_blog_magazine_related_post',array(
		'default' => 1,
		'transport' => 'refresh',
		'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ) );
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_related_post',array(
		'label' => esc_html__( 'Related Post','vw-blog-magazine' ),
		'section' => 'vw_blog_magazine_related_posts_settings'
    )));

    $wp_customize->add_setting('vw_blog_magazine_related_post_title',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_related_post_title',array(
		'label'	=> __('Add Related Post Title','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( 'Related Post', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_related_posts_settings',
		'type'=> 'text'
	));

   	$wp_customize->add_setting('vw_blog_magazine_related_posts_count',array(
		'default'=> '3',
		'sanitize_callback'	=> 'vw_blog_magazine_sanitize_float'
	));
	$wp_customize->add_control('vw_blog_magazine_related_posts_count',array(
		'label'	=> __('Add Related Post Count','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '3', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_related_posts_settings',
		'type'=> 'number'
	));

	// Single Posts Settings
	$wp_customize->add_section( 'vw_blog_magazine_single_blog_settings', array(
		'title' => __( 'Single Post Settings', 'vw-blog-magazine' ),
		'panel' => 'blog_post_parent_panel',
	));

	$wp_customize->add_setting( 'vw_blog_magazine_toggle_tags',array(
		'default' => 1,
		'transport' => 'refresh',
		'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
	));
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_toggle_tags', array(
		'label' => esc_html__( 'Tags','vw-blog-magazine' ),
		'section' => 'vw_blog_magazine_single_blog_settings'
    )));

	$wp_customize->add_setting( 'vw_blog_magazine_single_blog_post_navigation_show_hide',array(
		'default' => 1,
		'transport' => 'refresh',
		'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
	));
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_single_blog_post_navigation_show_hide', array(
		'label' => esc_html__( 'Post Navigation','vw-blog-magazine' ),
		'section' => 'vw_blog_magazine_single_blog_settings'
    )));

	//navigation text
	$wp_customize->add_setting('vw_blog_magazine_single_blog_prev_navigation_text',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_single_blog_prev_navigation_text',array(
		'label'	=> __('Post Navigation Text','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( 'PREVIOUS PAGE', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_single_blog_settings',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_single_blog_next_navigation_text',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_single_blog_next_navigation_text',array(
		'label'	=> __('Post Navigation Text','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( 'NEXT PAGE', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_single_blog_settings',
		'type'=> 'text'
	));

    //404 Page Setting
	$wp_customize->add_section('vw_blog_magazine_404_page',array(
		'title'	=> __('404 Page Settings','vw-blog-magazine'),
		'panel' => 'vw_blog_magazine_panel_id',
	));	

	$wp_customize->add_setting('vw_blog_magazine_404_page_title',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));

	$wp_customize->add_control('vw_blog_magazine_404_page_title',array(
		'label'	=> __('Add Title','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '404 Not Found', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_404_page',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_404_page_content',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));

	$wp_customize->add_control('vw_blog_magazine_404_page_content',array(
		'label'	=> __('Add Text','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( 'Looks like you have taken a wrong turn, Dont worry, it happens to the best of us.', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_404_page',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_404_page_button_text',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_404_page_button_text',array(
		'label'	=> __('Add Button Text','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( 'Return to Home Page', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_404_page',
		'type'=> 'text'
	));

	//Social Icon Setting
	$wp_customize->add_section('vw_blog_magazine_social_icon_settings',array(
		'title'	=> __('Social Icons Settings','vw-blog-magazine'),
		'panel' => 'vw_blog_magazine_panel_id',
	));	

	$wp_customize->add_setting('vw_blog_magazine_social_icon_font_size',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_social_icon_font_size',array(
		'label'	=> __('Icon Font Size','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_social_icon_settings',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_social_icon_padding',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_social_icon_padding',array(
		'label'	=> __('Icon Padding','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_social_icon_settings',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_social_icon_width',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_social_icon_width',array(
		'label'	=> __('Icon Width','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_social_icon_settings',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_social_icon_height',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_social_icon_height',array(
		'label'	=> __('Icon Height','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_social_icon_settings',
		'type'=> 'text'
	));

	$wp_customize->add_setting( 'vw_blog_magazine_social_icon_border_radius', array(
		'default'              => '',
		'transport' 		   => 'refresh',
		'sanitize_callback'    => 'vw_blog_magazine_sanitize_number_range'
	) );
	$wp_customize->add_control( 'vw_blog_magazine_social_icon_border_radius', array(
		'label'       => esc_html__( 'Icon Border Radius','vw-blog-magazine' ),
		'section'     => 'vw_blog_magazine_social_icon_settings',
		'type'        => 'range',
		'input_attrs' => array(
			'step'             => 1,
			'min'              => 1,
			'max'              => 50,
		),
	) );

	//Responsive Media Settings
	$wp_customize->add_section('vw_blog_magazine_responsive_media',array(
		'title'	=> __('Responsive Media','vw-blog-magazine'),
		'panel' => 'vw_blog_magazine_panel_id',
	));

    $wp_customize->add_setting( 'vw_blog_magazine_stickyheader_hide_show',array(
      'default' => 0,
      'transport' => 'refresh',
      'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ));  
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_stickyheader_hide_show',array(
      'label' => esc_html__( 'Sticky Header','vw-blog-magazine' ),
      'section' => 'vw_blog_magazine_responsive_media'
    )));

    $wp_customize->add_setting( 'vw_blog_magazine_sidebar_hide_show',array(
      'default' => 1,
      'transport' => 'refresh',
      'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ));  
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_sidebar_hide_show',array(
      'label' => esc_html__( 'Show / Hide Sidebar','vw-blog-magazine' ),
      'section' => 'vw_blog_magazine_responsive_media'
    )));

    $wp_customize->add_setting( 'vw_blog_magazine_resp_scroll_top_hide_show',array(
      'default' => 1,
      'transport' => 'refresh',
      'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ));  
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_resp_scroll_top_hide_show',array(
      'label' => esc_html__( 'Show / Hide Scroll To Top','vw-blog-magazine' ),
      'section' => 'vw_blog_magazine_responsive_media'
    )));

    $wp_customize->add_setting('vw_blog_magazine_res_menu_open_icon',array(
		'default'	=> 'fas fa-bars',
		'sanitize_callback'	=> 'sanitize_text_field'
	));	
	$wp_customize->add_control(new VW_Blog_Magazine_Fontawesome_Icon_Chooser(
        $wp_customize,'vw_blog_magazine_res_menu_open_icon',array(
		'label'	=> __('Add Open Menu Icon','vw-blog-magazine'),
		'transport' => 'refresh',
		'section'	=> 'vw_blog_magazine_responsive_media',
		'setting'	=> 'vw_blog_magazine_res_menu_open_icon',
		'type'		=> 'icon'
	)));

	$wp_customize->add_setting('vw_blog_magazine_res_close_menu_icon',array(
		'default'	=> 'fas fa-times',
		'sanitize_callback'	=> 'sanitize_text_field'
	));	
	$wp_customize->add_control(new VW_Blog_Magazine_Fontawesome_Icon_Chooser(
        $wp_customize,'vw_blog_magazine_res_close_menu_icon',array(
		'label'	=> __('Add Close Menu Icon','vw-blog-magazine'),
		'transport' => 'refresh',
		'section'	=> 'vw_blog_magazine_responsive_media',
		'setting'	=> 'vw_blog_magazine_res_close_menu_icon',
		'type'		=> 'icon'
	)));

	//footer
	$wp_customize->add_section('vw_blog_magazine_footer_section',array(
		'title'	=> __('Footer Text','vw-blog-magazine'),
		'description'	=> __('Add some text for footer like copyright etc.','vw-blog-magazine'),
		'priority'	=> null,
		'panel' => 'vw_blog_magazine_panel_id',
	));

	//Selective Refresh
	$wp_customize->selective_refresh->add_partial('vw_blog_magazine_footer_copy', array( 
		'selector' => '.copyright p', 
		'render_callback' => 'vw_blog_magazine_customize_partial_vw_blog_magazine_footer_copy', 
	));
	
	$wp_customize->add_setting('vw_blog_magazine_footer_copy',array(
		'default'	=> '',
		'sanitize_callback'	=> 'sanitize_text_field',
	));
	$wp_customize->add_control('vw_blog_magazine_footer_copy',array(
		'label'	=> __('Copyright Text','vw-blog-magazine'),
		'section'	=> 'vw_blog_magazine_footer_section',
		'type'		=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_copyright_alingment',array(
        'default' => 'center',
        'sanitize_callback' => 'vw_blog_magazine_sanitize_choices'
	));
	$wp_customize->add_control(new VW_Blog_Magazine_Image_Radio_Control($wp_customize, 'vw_blog_magazine_copyright_alingment', array(
        'type' => 'select',
        'label' => __('Copyright Alignment','vw-blog-magazine'),
        'section' => 'vw_blog_magazine_footer_section',
        'settings' => 'vw_blog_magazine_copyright_alingment',
        'choices' => array(
            'left' => esc_url(get_template_directory_uri()).'/images/copyright1.png',
            'center' => esc_url(get_template_directory_uri()).'/images/copyright2.png',
            'right' => esc_url(get_template_directory_uri()).'/images/copyright3.png'
    ))));

    $wp_customize->add_setting('vw_blog_magazine_copyright_padding_top_bottom',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_copyright_padding_top_bottom',array(
		'label'	=> __('Copyright Padding Top Bottom','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_footer_section',
		'type'=> 'text'
	));

	$wp_customize->add_setting( 'vw_blog_magazine_hide_show_scroll',array(
    	'default' => 1,
      	'transport' => 'refresh',
      	'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ));  
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_hide_show_scroll',array(
      	'label' => esc_html__( 'Show / Hide Scroll To Top','vw-blog-magazine' ),
      	'section' => 'vw_blog_magazine_footer_section'
    )));

    //Selective Refresh
	$wp_customize->selective_refresh->add_partial('vw_blog_magazine_scroll_top_icon', array( 
		'selector' => '.scrollup i', 
		'render_callback' => 'vw_blog_magazine_customize_partial_vw_blog_magazine_scroll_top_icon', 
	));

    $wp_customize->add_setting('vw_blog_magazine_scroll_top_icon',array(
		'default'	=> 'fas fa-long-arrow-alt-up',
		'sanitize_callback'	=> 'sanitize_text_field'
	));	
	$wp_customize->add_control(new VW_Blog_Magazine_Fontawesome_Icon_Chooser(
        $wp_customize,'vw_blog_magazine_scroll_top_icon',array(
		'label'	=> __('Add Scroll to Top Icon','vw-blog-magazine'),
		'transport' => 'refresh',
		'section'	=> 'vw_blog_magazine_footer_section',
		'setting'	=> 'vw_blog_magazine_scroll_top_icon',
		'type'		=> 'icon'
	)));

	$wp_customize->add_setting('vw_blog_magazine_scroll_to_top_font_size',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_scroll_to_top_font_size',array(
		'label'	=> __('Icon Font Size','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_footer_section',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_scroll_to_top_padding',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_scroll_to_top_padding',array(
		'label'	=> __('Icon Top Bottom Padding','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_footer_section',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_scroll_to_top_width',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_scroll_to_top_width',array(
		'label'	=> __('Icon Width','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_footer_section',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_scroll_to_top_height',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_scroll_to_top_height',array(
		'label'	=> __('Icon Height','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_footer_section',
		'type'=> 'text'
	));

	$wp_customize->add_setting( 'vw_blog_magazine_scroll_to_top_border_radius', array(
		'default'              => '',
		'transport' 		   => 'refresh',
		'sanitize_callback'    => 'vw_blog_magazine_sanitize_number_range'
	) );
	$wp_customize->add_control( 'vw_blog_magazine_scroll_to_top_border_radius', array(
		'label'       => esc_html__( 'Icon Border Radius','vw-blog-magazine' ),
		'section'     => 'vw_blog_magazine_footer_section',
		'type'        => 'range',
		'input_attrs' => array(
			'step'             => 1,
			'min'              => 1,
			'max'              => 50,
		),
	) );

	$wp_customize->add_setting('vw_blog_magazine_scroll_top_alignment',array(
        'default' => 'Right',
        'sanitize_callback' => 'vw_blog_magazine_sanitize_choices'
	));
	$wp_customize->add_control(new VW_Blog_Magazine_Image_Radio_Control($wp_customize, 'vw_blog_magazine_scroll_top_alignment', array(
        'type' => 'select',
        'label' => __('Scroll To Top','vw-blog-magazine'),
        'section' => 'vw_blog_magazine_footer_section',
        'settings' => 'vw_blog_magazine_scroll_top_alignment',
        'choices' => array(
            'Left' => esc_url(get_template_directory_uri()).'/images/layout1.png',
            'Center' => esc_url(get_template_directory_uri()).'/images/layout2.png',
            'Right' => esc_url(get_template_directory_uri()).'/images/layout3.png'
    ))));

   //Woocommerce settings
	$wp_customize->add_section('vw_blog_magazine_woocommerce_section', array(
		'title'    => __('WooCommerce Layout', 'vw-blog-magazine'),
		'priority' => null,
		'panel'    => 'woocommerce',
	));

	//Woocommerce Shop Page Sidebar
	$wp_customize->add_setting( 'vw_blog_magazine_woocommerce_shop_page_sidebar',array(
		'default' => 1,
		'transport' => 'refresh',
		'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ) );
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_woocommerce_shop_page_sidebar',array(
		'label' => esc_html__( 'Shop Page Sidebar','vw-blog-magazine' ),
		'section' => 'vw_blog_magazine_woocommerce_section'
    )));

    //Woocommerce Single Product page Sidebar
	$wp_customize->add_setting( 'vw_blog_magazine_woocommerce_single_product_page_sidebar',array(
		'default' => 1,
		'transport' => 'refresh',
		'sanitize_callback' => 'vw_blog_magazine_switch_sanitization'
    ) );
    $wp_customize->add_control( new VW_Blog_Magazine_Toggle_Switch_Custom_Control( $wp_customize, 'vw_blog_magazine_woocommerce_single_product_page_sidebar',array(
		'label' => esc_html__( 'Single Product Sidebar','vw-blog-magazine' ),
		'section' => 'vw_blog_magazine_woocommerce_section'
    )));

    //Products per page
    $wp_customize->add_setting('vw_blog_magazine_products_per_page',array(
		'default'=> '9',
		'sanitize_callback'	=> 'vw_blog_magazine_sanitize_float'
	));
	$wp_customize->add_control('vw_blog_magazine_products_per_page',array(
		'label'	=> __('Products Per Page','vw-blog-magazine'),
		'description' => __('Display on shop page','vw-blog-magazine'),
		'input_attrs' => array(
            'step'             => 1,
			'min'              => 0,
			'max'              => 50,
        ),
		'section'=> 'vw_blog_magazine_woocommerce_section',
		'type'=> 'number',
	));

    //Products per row
    $wp_customize->add_setting('vw_blog_magazine_products_per_row',array(
		'default'=> '3',
		'sanitize_callback'	=> 'vw_blog_magazine_sanitize_choices'
	));
	$wp_customize->add_control('vw_blog_magazine_products_per_row',array(
		'label'	=> __('Products Per Row','vw-blog-magazine'),
		'description' => __('Display on shop page','vw-blog-magazine'),
		'choices' => array(
            '2' => '2',
			'3' => '3',
			'4' => '4',
        ),
		'section'=> 'vw_blog_magazine_woocommerce_section',
		'type'=> 'select',
	));

	//Products padding
	$wp_customize->add_setting('vw_blog_magazine_products_padding_top_bottom',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_products_padding_top_bottom',array(
		'label'	=> __('Products Padding Top Bottom','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_woocommerce_section',
		'type'=> 'text'
	));

	$wp_customize->add_setting('vw_blog_magazine_products_padding_left_right',array(
		'default'=> '',
		'sanitize_callback'	=> 'sanitize_text_field'
	));
	$wp_customize->add_control('vw_blog_magazine_products_padding_left_right',array(
		'label'	=> __('Products Padding Left Right','vw-blog-magazine'),
		'description'	=> __('Enter a value in pixels. Example:20px','vw-blog-magazine'),
		'input_attrs' => array(
            'placeholder' => __( '10px', 'vw-blog-magazine' ),
        ),
		'section'=> 'vw_blog_magazine_woocommerce_section',
		'type'=> 'text'
	));

	//Products box shadow
	$wp_customize->add_setting( 'vw_blog_magazine_products_box_shadow', array(
		'default'              => '',
		'transport' 		   => 'refresh',
		'sanitize_callback'    => 'vw_blog_magazine_sanitize_number_range'
	) );
	$wp_customize->add_control( 'vw_blog_magazine_products_box_shadow', array(
		'label'       => esc_html__( 'Products Box Shadow','vw-blog-magazine' ),
		'section'     => 'vw_blog_magazine_woocommerce_section',
		'type'        => 'range',
		'input_attrs' => array(
			'step'             => 1,
			'min'              => 1,
			'max'              => 50,
		),
	) );

	//Products border radius
    $wp_customize->add_setting( 'vw_blog_magazine_products_border_radius', array(
		'default'              => '',
		'transport' 		   => 'refresh',
		'sanitize_callback'    => 'vw_blog_magazine_sanitize_number_range'
	) );
	$wp_customize->add_control( 'vw_blog_magazine_products_border_radius', array(
		'label'       => esc_html__( 'Products Border Radius','vw-blog-magazine' ),
		'section'     => 'vw_blog_magazine_woocommerce_section',
		'type'        => 'range',
		'input_attrs' => array(
			'step'             => 1,
			'min'              => 1,
			'max'              => 50,
		),
	) );
	
	// Has to be at the top
	$wp_customize->register_panel_type( 'VW_Blog_Magazine_WP_Customize_Panel' );
	$wp_customize->register_section_type( 'VW_Blog_Magazine_WP_Customize_Section' );
}
add_action( 'customize_register', 'vw_blog_magazine_customize_register' );

load_template( trailingslashit( get_template_directory() ) . '/inc/logo-resizer.php' );

if ( class_exists( 'WP_Customize_Panel' ) ) {
  	class VW_Blog_Magazine_WP_Customize_Panel extends WP_Customize_Panel {
	    public $panel;
	    public $type = 'vw_blog_magazine_panel';
	    public function json() {

	      $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'type', 'panel', ) );
	      $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
	      $array['content'] = $this->get_content();
	      $array['active'] = $this->active();
	      $array['instanceNumber'] = $this->instance_number;
	      return $array;
    	}
  	}
}

if ( class_exists( 'WP_Customize_Section' ) ) {
  	class VW_Blog_Magazine_WP_Customize_Section extends WP_Customize_Section {
	    public $section;
	    public $type = 'vw_blog_magazine_section';
	    public function json() {

	      $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'panel', 'type', 'description_hidden', 'section', ) );
	      $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
	      $array['content'] = $this->get_content();
	      $array['active'] = $this->active();
	      $array['instanceNumber'] = $this->instance_number;

	      if ( $this->panel ) {
	        $array['customizeAction'] = sprintf( 'Customizing &#9656; %s', esc_html( $this->manager->get_panel( $this->panel )->title ) );
	      } else {
	        $array['customizeAction'] = 'Customizing';
	      }
	      return $array;
    	}
  	}
}

// Enqueue our scripts and styles
function vw_blog_magazine_customize_controls_scripts() {
  wp_enqueue_script( 'customizer-controls', get_theme_file_uri( '/js/customizer-controls.js' ), array(), '1.0', true );
}
add_action( 'customize_controls_enqueue_scripts', 'vw_blog_magazine_customize_controls_scripts' );

/**
 * Singleton class for handling the theme's customizer integration.
 *
 * @since  1.0.0
 * @access public
 */
if ( ! class_exists ( 'VW_Blog_Magazine_Customize' ) ) {
final class VW_Blog_Magazine_Customize {

	/**
	 * Returns the instance.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return object
	 */
	public static function get_instance() {

		static $instance = null;

		if ( is_null( $instance ) ) {
			$instance = new self;
			$instance->setup_actions();
		}

		return $instance;
	}

	/**
	 * Constructor method.
	 *
	 * @since  1.0.0
	 * @access private
	 * @return void
	 */
	private function __construct() {}

	/**
	 * Sets up initial actions.
	 *
	 * @since  1.0.0
	 * @access private
	 * @return void
	 */
	private function setup_actions() {

		// Register panels, sections, settings, controls, and partials.
		add_action( 'customize_register', array( $this, 'sections' ) );

		// Register scripts and styles for the controls.
		add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ), 0 );
	}

	/**
	 * Sets up the customizer sections.
	 *
	 * @since  1.0.0
	 * @access public
	 * @param  object  $manager
	 * @return void
	 */
	public function sections( $manager ) {

		// Load custom sections.
		load_template( trailingslashit( get_template_directory() ) . '/inc/section-pro.php' );

		// Register custom section types.
		$manager->register_section_type( 'VW_Blog_Magazine_Customize_Section_Pro' );

		// Register sections.
		$manager->add_section(new VW_Blog_Magazine_Customize_Section_Pro($manager,'vw_blog_magazine_upgrade_pro_link',array(
			'priority'   => 1,
			'title'    => esc_html__( 'Premium Blog Theme', 'vw-blog-magazine' ),
			'pro_text' => esc_html__( 'Upgrade Pro','vw-blog-magazine' ),
			'pro_url'  => esc_url('https://www.vwthemes.com/themes/best-premium-wordpress-blog-theme/')
		)));

		// Register sections.
		$manager->add_section(new VW_Blog_Magazine_Customize_Section_Pro($manager,'vw_blog_magazine_get_started_link',array(
			'priority'   => 1,
			'title'    => esc_html__( 'Documentation', 'vw-blog-magazine' ),
			'pro_text' => esc_html__( 'Docs', 'vw-blog-magazine' ),
			'pro_url'  => esc_url( 'themes.php?page=vw_blog_magazine_guide' )
		)));
	}

	/**
	 * Loads theme customizer CSS.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return void
	 */
	public function enqueue_control_scripts() {

		wp_enqueue_script( 'vw-blog-magazine-customize-controls', trailingslashit( esc_url(get_template_directory_uri()) ) . '/js/customize-controls.js', array( 'customize-controls' ) );

		wp_enqueue_style( 'vw-blog-magazine-customize-controls', trailingslashit( esc_url(get_template_directory_uri()) ) . '/css/customize-controls.css' );
	}
}

// Doing this customizer thang!
VW_Blog_Magazine_Customize::get_instance();
}