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

if ( ! function_exists( 'nevo_customizer_header_html_config' ) ) {
	function nevo_customizer_header_html_config($configs = array()) {
		$section  = 'header_html';
		$name     = 'header_html';
		$selector = '.item-html-1';
		$config = array(
			array(
				'name'     => $section,
				'type'     => 'section',
				'panel'    => 'nevo_header',
				'priority' => 90,
				'title'    => __( 'HTML', 'nevo' ),
			),
			
			array(
				'name'            => $name .'_1',
				'type'            => 'textarea',
				'section'         => $section,
				'selector'        => $selector,
				'priority' 		  => 5,
				'theme_supports'  => '',
				'render_callback' => 'nevo_refresh_header_html_1_partials',
				'default'         => __( 'Add anything here or just remove it...', 'nevo' ),
				'title'           => __( 'HTML 1', 'nevo' ),
				'description'     => __( 'HTML code and Shortcode is allowed.', 'nevo' ),
			),
			array(
				'name'            => $name .'_2',
				'type'            => 'textarea',
				'section'         => $section,
				'selector'        => '.item-html-2',
				'priority' 		  => 6,
				'theme_supports'  => '',
				'render_callback' => 'nevo_refresh_header_html_2_partials',
				'default'         => __( '2 Add anything here or just remove it...', 'nevo' ),
				'title'           => __( 'HTML 2', 'nevo' ),
				'description'     => __( 'HTML code and Shortcode is allowed.', 'nevo' ),
			),
			
			array(
				'name'     => 'date_format',
				'type'     => 'section',
				'panel'    => 'nevo_header',
				'priority' => 95,
				'title'    => __( 'Date Format', 'nevo' ),
			),
			array(
				'name'            => 'header_date_format',
				'type'            => 'text',
				'section'         => 'date_format',
				'selector'        => '.header-date-format',
				'priority' 		  => 5,
				'render_callback' => 'nevo_refresh_header_date_format_partials',
				'default'         => 'l, F j Y',
				'title'           => __( 'Date Format', 'nevo' ),
				'description'     => sprintf(
					__( '%sTo format the date, please refer to the online documentation for detailed instructions%s.', 'nevo' ),
					'<a href="' . esc_url( 'https://wordpress.org/support/article/formatting-date-and-time' ) . '" target="_blank">',
					'</a>'
				),
			),
			/* 
			array(
				'name'     => 'header_posts',
				'type'     => 'section',
				'panel'    => 'nevo_header',
				'priority' => 96,
				'title'    => __( 'Trending Posts', 'nevo' ),
			),
			array(
				'name'        => 'trending_posts_label',
				'type'        => 'text',
				'section'     => 'header_posts',
				'selector'    => '.trending-posts',
				'label'       => __( 'Label', 'nevo' ),
				'placeholder' => 'Trending',
				'default'     => 'Trending',
				'render_callback' => 'nevo_refresh_header_trending_posts_partials',
			),
			array(
				'name'            => "trending_posts_number",
				'type'            => 'number',
				'section'   	  => 'header_posts',
				'selector'        => '.trending-posts',
				'default'         => '5',
				'label'           => __( 'Number posts to show', 'nevo' ),
				'render_callback' => 'nevo_refresh_header_trending_posts_partials',
			),
			array(
				'name'      => 'trending_posts_cat',
				'type'      => 'select',
				'section'   => 'header_posts',
				'selector'  => '.trending-posts',
				'label'     => __( 'Categories', 'nevo' ),
				'default'   => '',
				'choices'   => nevo_get_dropdown_categories('category', 'slug'),
				'render_callback' => 'nevo_refresh_header_trending_posts_partials',
			),
			array(
				'name'    => 'trending_posts_order_by',
				'type'    => 'select',
				'section' => 'header_posts',
				'selector' => '.trending-posts',
				'label'   => __( 'Order By', 'nevo' ),
				'choices' => array(
					'title' 	 	=> __( 'Title', 'nevo' ),
					'date' 		 	=> __( 'Date', 'nevo' ),
					'rand' 		 	=> __( 'Rand', 'nevo' ),
					'comment_count' => __( 'Comment Count', 'nevo' ),
				),
				'render_callback' => 'nevo_refresh_header_trending_posts_partials',
			),
			array(
				'name'    => 'trending_posts_sort_order',
				'type'    => 'select',
				'section' => 'header_posts',
				'selector' => '.trending-posts',
				'label'   => __( 'Sort Order', 'nevo' ),
				'choices' => array(
					'DESC' => __( 'Descending (DESC)', 'nevo' ),
					'ASC'  => __( 'Ascending (ASC)', 'nevo' ),
				),
				'render_callback' => 'nevo_refresh_header_trending_posts_partials',
			),
			 *//* 
			array(
				'name'       => $name . '_typo',
				'type'       => 'typography',
				'section'    => $section,
				'priority' 	 => 100,
				'selector'   => '.header-section .header-html, .header-html .html-inner',
				'css_format' => 'typography',
				'title'      => __( 'Typography', 'nevo' ),
			), */

		);
		
		return array_merge( $configs, $config );
	}
}
add_filter( 'nevo/customizer/config', 'nevo_customizer_header_html_config', 399 );

function nevo_refresh_header_html_1_partials() {
	nevo_header_element( 'html-1');
}
function nevo_refresh_header_html_2_partials() {
	nevo_header_element( 'html-2');
}
function nevo_refresh_header_date_format_partials() {
	nevo_header_element( 'date-format');
}
function nevo_refresh_header_trending_posts_partials() {
	nevo_header_element( 'trending-posts');
}