<?php

add_action( 'init' , 'fashion_freak_featured' );
function fashion_freak_featured(){

	Kirki::add_section( 'fashion_freak_featured_posts', array(
	    'title'          => esc_html__( 'Featured Posts', 'fashion-freak' ),
	    'section'        => 'homepage',
	    'priority'       => 2,
	) );

	Kirki::add_field( 'bizberg', array(
	    'type'        => 'advanced-repeater',
	    'label'       => esc_html__( 'Pages', 'fashion-freak' ),
	    'section'     => 'fashion_freak_featured_posts',
	    'settings'    => 'fashion_freak_featured_posts_pages',
	    'choices' => [
	        'row_label' => [
	            'value' => esc_html__( 'Page', 'fashion-freak' ),
	        ],
	        'fields' => [
	        	'page_id'  => [
	                'type'        => 'select',
	                'label'       => esc_html__( 'Select Page', 'fashion-freak' ),
	               	'choices'     => bizberg_get_all_pages()
	            ],
	        ]
	    ],
	) );

	Kirki::add_field( 'bizberg', array(
		'type'        => 'simple-gradient',
		'label'       => esc_html__( 'Background', 'fashion-freak' ),
		'description' => esc_html__( 'This background will only be visible if there is no image.', 'fashion-freak' ),
		'section'     => 'fashion_freak_featured_posts',
		'settings'    => 'fashion_freak_featured_posts_background_gradient',
		'default'     => 'linear-gradient(291deg, #fff, #e8e8e8)', // Use only hex colors
		'transport'   => 'auto',
		'output' => array(
			array(
				'element'       => '.featured-posts .post-main-item-image.no_image',
				'property'      => 'background-image',
				'value_pattern' => '$ !important'
			)
		),
	) );

	Kirki::add_field( 'bizberg', [
		'type'        => 'slider',
		'settings'    => 'fashion_freak_featured_posts_height',
		'label'       => esc_html__( 'Height', 'fashion-freak' ),
		'section'     => 'fashion_freak_featured_posts',
		'default'     => 400,
		'choices'     => [
			'min'  => 200,
			'max'  => 500,
			'step' => 25
		],
		'transport'   => 'auto',
		'output' => array(
			array(
				'element'       => '.post-main-item-image',
				'property'      => 'height',
				'value_pattern' => '$px'
			)
		),
	] );

}