<?php 
add_action( 'customize_register', 'eatingplace_customize_register_custom_controls', 9 );
function eatingplace_customize_register_custom_controls( $wp_customize ) {
    get_template_part( 'libcore/proupgrade/eatingplace','sectionpro');
}
function eatingplace_customize_controls_js() {
    $theme = wp_get_theme();
    wp_enqueue_script( 'eatingplace-customizer-section-pro-jquery', get_template_directory_uri() . '/libcore/proupgrade/eatingplace-customize-controls.js', array( 'customize-controls' ), $theme->get( 'Version' ), true );
    wp_enqueue_style( 'eatingplace-customizer-section-pro', get_template_directory_uri() . '/libcore/proupgrade/eatingplace-customize-controls.css', $theme->get( 'Version' ) );
}
add_action( 'customize_controls_enqueue_scripts', 'eatingplace_customize_controls_js' );
?>
<?php
function eatingplace_enqueue_comments_reply() {
if( get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'comment_form_before', 'eatingplace_enqueue_comments_reply' );
?>
<?php 
if ( ! function_exists( 'eatingplace_sanitize_page' ) ) :
    function eatingplace_sanitize_page( $page_id, $setting ) {
        // Ensure $input is an absolute integer.
        $page_id = absint( $page_id );
        // If $page_id is an ID of a published page, return it; otherwise, return the default.
        return ( 'publish' === get_post_status( $page_id ) ? $page_id : $setting->default );
    }

endif;
function eatingplace_customize_register($wp_customize){

    // Register custom section types.
    $wp_customize->register_section_type( 'eatingplace_Customize_Section_Pro' );

    // Register sections.
    $wp_customize->add_section( new eatingplace_Customize_Section_Pro(
        $wp_customize,
        'theme_go_pro',
        array(
            'priority' => 1,
            'title'    => esc_html__( 'EatingPlace Pro', 'eatingplace' ),
            'pro_text' => esc_html__( 'Upgrade To Pro', 'eatingplace' ),
            'pro_url'  => 'https://themestulip.com/themes/eatingplace-restaurant-wordpress-theme/',
        )
    ) );

//  =============================
    //  = welcome section              =
    //  =============================
    $wp_customize->add_section('eatingplace_welcome_to_homepage', array(
        'title'    => esc_html__('EatingPlace HomePage Welcome Section', 'eatingplace'),
        'description' => esc_html__('It will shows on homepage, upload image size width:450px','eatingplace'),
        'priority' => 36,
    ));
   
    $wp_customize->add_setting('welcome_section',array(
            'default'   => '0',         
            'capability' => 'edit_theme_options',
            'sanitize_callback' => 'eatingplace_sanitize_page'
    ));
    
    $wp_customize->add_control('welcome_section',array(
            'type'  => 'dropdown-pages',
            'label' => esc_html__('Select Page For HomePage Welcome:','eatingplace'),
            'section'   => 'eatingplace_welcome_to_homepage'
    )); 


//  =============================
    //  = box section              =
    //  =============================
    $wp_customize->add_section('eatingplace_box', array(
        'title'    => esc_html__('EatingPlace HomePage Box', 'eatingplace'),
        'description' => esc_html__('Upload image, it will auto crop with 400*250.','eatingplace'),
        'priority' => 36,
    ));

    // Box Heading
    $wp_customize->add_setting('box_heading',array(
            'default'   => null,
            'sanitize_callback' => 'sanitize_text_field'    
    ));
    
    $wp_customize->add_control('box_heading',array( 
            'type'  => 'text',
            'label' => esc_html__('Add heading for four boxes','eatingplace'),
            'section'   => 'eatingplace_box',
            'setting'   => 'box_heading'
    )); // Slider Read More Button Text

   
    $wp_customize->add_setting('box1',array(
            'default'   => '0',         
            'capability' => 'edit_theme_options',
            'sanitize_callback' => 'eatingplace_sanitize_page'
    ));
    
    $wp_customize->add_control('box1',array(
            'type'  => 'dropdown-pages',
            'label' => esc_html__('Select page for box first:','eatingplace'),
            'section'   => 'eatingplace_box'
    )); 

    $wp_customize->add_setting('box2',array(
            'default'   => '0',         
            'capability' => 'edit_theme_options',
            'sanitize_callback' => 'eatingplace_sanitize_page'
    ));
    
    $wp_customize->add_control('box2',array(
            'type'  => 'dropdown-pages',
            'label' => esc_html__('Select page for box second:','eatingplace'),
            'section'   => 'eatingplace_box'
    )); 

    $wp_customize->add_setting('box3',array(
            'default'   => '0',         
            'capability' => 'edit_theme_options',
            'sanitize_callback' => 'eatingplace_sanitize_page'
    ));
    
    $wp_customize->add_control('box3',array(
            'type'  => 'dropdown-pages',
            'label' => esc_html__('Select page for box third:','eatingplace'),
            'section'   => 'eatingplace_box'
    )); 

     $wp_customize->add_setting('box4',array(
            'default'   => '0',         
            'capability' => 'edit_theme_options',
            'sanitize_callback' => 'eatingplace_sanitize_page'
    ));
    
    $wp_customize->add_control('box4',array(
            'type'  => 'dropdown-pages',
            'label' => esc_html__('Select page for box fourth:','eatingplace'),
            'section'   => 'eatingplace_box'
    )); 


  //  =============================
    //  = Footer              =
    //  =============================

    $wp_customize->add_section('eatingplace_footer', array(
        'title'    => esc_html__('EatingPlace Footer', 'eatingplace'),
        'description' => '',
        'priority' => 37,
    ));

	// Footer design and developed
	 $wp_customize->add_setting('eatingplace_design', array(
        'default'        => '',
		'sanitize_callback' => 'sanitize_textarea_field'
    ));
 
    $wp_customize->add_control('eatingplace_design', array(
        'label'      => esc_html__('Design and developed', 'eatingplace'),
        'section'    => 'eatingplace_footer',
        'setting'   => 'eatingplace_design',
		'type'	   =>'textarea'
    ));
	// Footer copyright
	 $wp_customize->add_setting('eatingplace_copyright', array(
        'default'        => '',
		'sanitize_callback' => 'sanitize_textarea_field'       
    ));
 
    $wp_customize->add_control('eatingplace_copyright', array(
        'label'      => esc_html__('Copyright', 'eatingplace'),
        'section'    => 'eatingplace_footer',
        'setting'   => 'eatingplace_copyright',
		'type'	   =>'textarea'
    ));	
}
add_action('customize_register', 'eatingplace_customize_register');
?>