<?php
/**
 * Homepage Settings
 *
 * @package Doo
 */

// Add new panel
$wp_customize->add_panel( 'homepage_panel', array(
  'title'              => esc_html__( 'Homepage Settings', 'doo' ),
  'priority'           => 26,
) );

// Add new section
$wp_customize->add_section( 'homepage_section', array(
  'title'                => esc_html__( 'Homepage Layout', 'doo' ),
  'panel'                => 'homepage_panel',
  'priority'             => 10,
) );

// Sidebar
$wp_customize->add_setting( 'homepage_sidebar', array(
  'default'              => 'right',
  'sanitize_callback'    => 'vs_sanitize_sidebar',
) );
$wp_customize->add_control( 'homepage_sidebar', array(
  'label'                => esc_html__( 'Sidebar', 'doo' ),
  'section'              => 'homepage_section',
  'type'                 => 'radio',
  'choices'              => array(
    'right'              => esc_html__( 'Right Sidebar', 'doo' ),
    'left'               => esc_html__( 'Left Sidebar', 'doo' ),
    'disabled'           => esc_html__( 'No Sidebar', 'doo' ),
  ),
) );

// Display preview images
$wp_customize->add_setting( 'homepage_preview_image', array(
  'default'              => 1,
  'sanitize_callback'    => 'vs_sanitize_checkbox',
) );
$wp_customize->add_control( 'homepage_preview_image', array(
  'label'                => esc_html__( 'Display preview images', 'doo' ),
  'section'              => 'homepage_section',
  'type'                 => 'checkbox',
) );

// Post Summary
$wp_customize->add_setting( 'homepage_summary', array(
  'default'              => 'excerpt',
  'sanitize_callback'    => 'vs_sanitize_summary',
) );
$wp_customize->add_control( 'homepage_summary', array(
  'label'                => esc_html__( 'Post Summary', 'doo' ),
  'section'              => 'homepage_section',
  'type'                 => 'radio',
  'choices'              => array(
    'excerpt'            => esc_html__( 'Use Excerpts', 'doo' ),
    'content'            => esc_html__( 'Use Read More Tag', 'doo' ),
  ),
) );

// Excerpt Length (Number Of Words)
$wp_customize->add_setting( 'homepage_excerpt_length', array(
  'default'              => 50,
  'sanitize_callback'    => 'vs_sanitize_number',
) );
$wp_customize->add_control( new vs_customize_number_control( $wp_customize, 'homepage_excerpt_length', array(
  'label'                => esc_html__( 'Excerpt Length (Number of Words)', 'doo' ),
  'section'              => 'homepage_section',
) ) );

// Pagination
$wp_customize->add_setting( 'homepage_pagination_type', array(
  'default'              => 'load-more',
  'sanitize_callback'    => 'vs_sanitize_pagination_type',
) );
$wp_customize->add_control( 'homepage_pagination_type', array(
  'label'                => esc_html__( 'Pagination', 'doo' ),
  'section'              => 'homepage_section',
  'type'                 => 'radio',
  'choices'              => array(
    'standard'           => esc_html__( 'Standard', 'doo' ),
    'navigation'         => esc_html__( 'Navigation', 'doo' ),
    'load-more'          => esc_html__( 'Load More Button', 'doo' ),
    'infinite'           => esc_html__( 'Infinite Load', 'doo' ),
  ),
) );

// Heading
$wp_customize->add_setting( 'homepage_heading_post_meta', array(
  'sanitize_callback'    => 'esc_html',
) );
$wp_customize->add_control( new vs_customize_control_heading( $wp_customize, 'homepage_heading_post_meta', array(
  'label'                => esc_html__( 'Post Meta', 'doo' ),
  'section'              => 'homepage_section',
) ) );

// Display Date
$wp_customize->add_setting( 'homepage_date', array(
  'default'              => 1,
  'sanitize_callback'    => 'vs_sanitize_checkbox',
) );
$wp_customize->add_control( 'homepage_date', array(
  'label'                => esc_html__( 'Display Date', 'doo' ),
  'section'              => 'homepage_section',
  'type'                 => 'checkbox',
) );

// Display Categorys
$wp_customize->add_setting( 'homepage_categorys', array(
  'default'              => 1,
  'sanitize_callback'    => 'vs_sanitize_checkbox',
) );
$wp_customize->add_control( 'homepage_categorys', array(
  'label'                => esc_html__( 'Display Categorys', 'doo' ),
  'section'              => 'homepage_section',
  'type'                 => 'checkbox',
) );

// Display Comments
$wp_customize->add_setting( 'homepage_comments', array(
  'default'              => 1,
  'sanitize_callback'    => 'vs_sanitize_checkbox',
) );
$wp_customize->add_control( 'homepage_comments', array(
  'label'                => esc_html__( 'Display Comments', 'doo' ),
  'section'              => 'homepage_section',
  'type'                 => 'checkbox',
) );

if ( class_exists( 'Post_Views_Counter' ) ) {
  // Display Post Views
  $wp_customize->add_setting( 'homepage_post_views', array(
    'default'              => 1,
    'sanitize_callback'    => 'vs_sanitize_checkbox',
  ) );
  $wp_customize->add_control( 'homepage_post_views', array(
    'label'                => esc_html__( 'Display Post Views', 'doo' ),
    'section'              => 'homepage_section',
    'type'                 => 'checkbox',
  ) );
}

// Display Read More
$wp_customize->add_setting( 'homepage_read_more', array(
  'default'              => 0,
  'sanitize_callback'    => 'vs_sanitize_checkbox',
) );
$wp_customize->add_control( 'homepage_read_more', array(
  'label'                => esc_html__( 'Display Read More', 'doo' ),
  'section'              => 'homepage_section',
  'type'                 => 'checkbox',
) );

// Static Front Page
$static_front_page = $wp_customize->get_section( 'static_front_page' );
$wp_customize->remove_section( 'static_front_page' );
$wp_customize->add_section( 'static_front_page', array(
  'title'                => esc_html__( 'Static Front Page', 'doo' ),
  'description'          => $static_front_page->description,
  'panel'                => 'homepage_panel',
  'active_callback'      => $static_front_page->active_callback,
  'priority'             => 25,
) );
