<?php

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/*********************
Posts Blocks
*******************/
		$wp_customize->add_section('digital_list_block_posts',
			array(
				'title'       => __( 'List Block - Style Block 1', 'digital' ),
				'description'       => __( 'Control List Block Posts also available as WIDGET', 'digital' ),
				'capability'  => 'edit_theme_options',						
				'panel'			=> 'digital_theme_elements',
				'priority'    => apply_filters( 'digital_list_block_posts_priority', 10 ),
			));
			
		$wp_customize->add_setting(
				'digital_header_heading',
				array(
					'sanitize_callback' => 'wp_kses',
				));

			$wp_customize->add_control(
				new digital_Customizer_Heading_Control(
					$wp_customize,
					'digital_header_heading',
					array(
						'label'    => esc_html__( 'Block Posts Style', 'digital' ),
						'section'  => 'digital_list_block_posts',
						'priority' => 15,
					)));
			$wp_customize->add_setting(
			'digital_blockposts_style',
			array(
				'default'           => 'styleone',
				'type'              => 'theme_mod',
				'sanitize_callback' => 'digital_customize_sanitize_select',
				'capability'        => 'edit_theme_options',
			)
		);

		$wp_customize->add_control(
			new digital_Image_Radio_Control(
				$wp_customize,
				'digital_blockposts_style',
				array(
					'label'       => __( 'Block Posts Style', 'digital' ),
					'description' => __( 'Choose Theme Header Style. After Choosing & Publish You need to REFRESH Website', 'digital' ),
					'section'     => 'digital_list_block_posts',
					'choices'     => array(
						'styleone'  => get_template_directory_uri() . '/images/block-posts-list/blockpostslist1.png',
					),
					'priority'    => apply_filters( 'digital_authorprofile_style_priority', 20 ),
				)
			));
			
			$wp_customize->add_setting(
				'digital_blockposts_headingset',
				array(
					'sanitize_callback' => 'wp_kses',
				));

			$wp_customize->add_control(
				new digital_Customizer_Heading_Control(
					$wp_customize,
					'digital_blockposts_headingset',
					array(
						'label'    => esc_html__( 'Block Posts Settings', 'digital' ),
						'section'  => 'digital_list_block_posts',
						'priority' => 25,
					)));
			
		$wp_customize->add_setting('digital_list_block_posts_on',	
			array(
				'default'			=> 'enable',
				'type'				=> 'theme_mod',
				'capability'		=> 'edit_theme_options',
				'sanitize_callback'	=> 'digital_customize_sanitize_select'
			));
		$wp_customize->add_control('digital_list_block_posts_on',
			 array (                             
				'type' => 'radio',
				'label' => __('Enable or Disable Block Posts','digital'),
				'settings'   => 'digital_list_block_posts_on',
				'section' => 'digital_list_block_posts',
				'transport'   => 'refresh',
				'choices' => array(
					'enable' => __('Enable','digital'),
					'disable' => __('Disable','digital'),
				 ),
				 'priority'    => apply_filters( 'digital_authorpro_on_priority', 30 ),
			 ));
		
			 
			$categories = get_categories();
			// Prepare categories for dropdown
			$cats = array();
			foreach ($categories as $category) {
				$cats[$category->term_id] = $category->name;
			}
			// Add an "All Categories" option
			$cats['all'] = __('All Categories', 'digital');
			 
			 $wp_customize->add_setting('digital_list_block_posts_cat', array(
				'default'            => 'all', // Set the default value to 'all'
				'sanitize_callback'  => 'sanitize_text_field' // Use appropriate sanitization
			));

			$wp_customize->add_control('digital_list_block_posts_cat', array(
				'settings' => 'digital_list_block_posts_cat',
				'label'    => __('Choose Category', 'digital'),
				'type'     => 'select',
				'choices'  => $cats,
				'section'  => 'digital_list_block_posts', // Depending on where you want it to be
				'priority' => 35,
			));
			
			// Posts Numbers
		$wp_customize->add_setting('digital_listblock_posts_count',array(
			'default'		=> '5',
			'sanitize_callback'	=> 'absint'
		));
		$wp_customize->add_control('digital_listblock_posts_count',array(
			'section' => 'digital_list_block_posts',
			'label'	=> __('Numbers of Posts to show','digital'),
			'settings' => 'digital_listblock_posts_count',
			'priority' => 40,
			'type' => 'number'
		));	
		// Posts title character
		$wp_customize->add_setting('digital_listblock_posts_title',array(
			'default'		=> '45',
			'sanitize_callback'	=> 'absint'
		));
		$wp_customize->add_control('digital_listblock_posts_title',array(
			'section' => 'digital_list_block_posts',
			'label'	=> __('Posts Title Character Length','digital'),
			'settings' => 'digital_listblock_posts_title',
			'priority' => 45,
			'type' => 'number'
		));
		
		$wp_customize->add_setting('digital_list_block_posts_location', array(
			'default' => 'index',
			'sanitize_callback' => 'sanitize_text_field',
		));
		
		$wp_customize->add_control('digital_list_block_posts_location', array(
			'label' => __('Visiblity on Page Types', 'digital'),
			'section' => 'digital_list_block_posts',
			'type' => 'select',
			'choices' => array(
				'all_pages' => __('Everywhere', 'digital'),
				'single' => __('Single Posts', 'digital'),
				'page' => __('Pages', 'digital'),
				'archive' => __('Archive Pages', 'digital'),
				'index' => __('Index and Home', 'digital'),
			),
			'priority'    => apply_filters( 'digital_list_block_posts_location_priority', 60 ),
		));	