<?php

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/*********************
Block Tiles settings.
*******************/
	$wp_customize->add_section('digital_blocktiles',
		array(
			'title'       => __( 'Block Tiles Posts - Style Block 2', 'digital' ),
			'capability'  => 'edit_theme_options',						
			'panel'			=> 'digital_theme_elements',
			'priority'    => apply_filters( 'digital_blocktiles_priority', 15 ),
		));		
		
		$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 Tiles Style', 'digital' ),
						'section'  => 'digital_blocktiles',
						'priority' => 15,
					)));
			$wp_customize->add_setting(
			'digital_blocktiles_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_blocktiles_style',
				array(
					'label'       => __( 'Block Tiles Style', 'digital' ),
					'section'     => 'digital_blocktiles',
					'choices'     => array(
						'styleone'  => get_template_directory_uri() . '/images/blocktiles/blocktilesone.png',
						//'styletwo' => get_template_directory_uri() . '/images/newsticker/newstickertwo.png',
					//	'stylethree' => get_template_directory_uri() . '/images/newsticker/newstickerthree.png',
					),
					'priority'    => apply_filters( 'digital_blocktiles_style_priority', 20 ),
				)
			));
		
		$wp_customize->add_setting(
				'digital_blocktiles_headingset',
				array(
					'sanitize_callback' => 'wp_kses',
				));

			$wp_customize->add_control(
				new digital_Customizer_Heading_Control(
					$wp_customize,
					'digital_blocktiles_headingset',
					array(
						'label'    => esc_html__( 'Block Tiles Settings', 'digital' ),
						'section'  => 'digital_blocktiles',
						'priority' => 25,
					)));
		
		$wp_customize->add_setting('digital_blocktiles_on',	
			array(
				'default'			=> 'enable',
				'type'				=> 'theme_mod',
				'capability'		=> 'edit_theme_options',
				'sanitize_callback'	=> 'digital_customize_sanitize_select'
			));
		$wp_customize->add_control('digital_blocktiles_on',
			 array (                             
				'type' => 'radio',
				'label' => __('Enable or Disable','digital'),
				'settings'   => 'digital_blocktiles_on',
				'section' => 'digital_blocktiles',
				'transport'   => 'refresh',
				'choices' => array(
					'enable' => __('Enable','digital'),
					'disable' => __('Disable','digital'),
				 ),
				 'priority'    => apply_filters( 'digital_blocktiles_on_priority', 30 ),
			 ));
		
		
		
		// Ticker Categories
		// Get categories
	$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_blocktiles_cat', array(
		'default'            => 'all', // Set the default value to 'all'
		'sanitize_callback'  => 'sanitize_text_field' // Use appropriate sanitization
	));

	$wp_customize->add_control('digital_blocktiles_cat', array(
		'settings' => 'digital_blocktiles_cat',
		'label'    => __('Choose Category', 'digital'),
		'type'     => 'select',
		'choices'  => $cats,
		'section'  => 'digital_blocktiles', // Depending on where you want it to be
		'priority' => 35,
	));
		
				
		//cat bg
		$wp_customize->add_setting( 'digital_blogtilescatbg' , array(
			'default'     => '#673AB7',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_blogtilescatbg', array(
		'description'        => __( 'Category Background Color', 'digital' ),
		'section'    => 'digital_blocktiles',
		'settings'   => 'digital_blogtilescatbg',
		'priority' => 45,
		) ) );
		//Cat fonts
		$wp_customize->add_setting( 'digital_blogtilescatfont' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_blogtilescatfont', 
		array(		
		'description'        => __( 'Category Font Color', 'digital' ),
		'section'    => 'digital_blocktiles',
		'settings'   => 'digital_blogtilescatfont',
		'priority' => 50,
		) ) );
		//Blog Tiles Link color
		$wp_customize->add_setting( 'digital_blogtileslink' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_blogtileslink', 
		array(		
		'description'        => __( 'Blog Tiles Link color', 'digital' ),
		'section'    => 'digital_blocktiles',
		'settings'   => 'digital_blogtileslink',
		'priority' => 60,
		) ) );
		
		// Visibility
		$wp_customize->add_setting('digital_blocktiles_location', array(
			'default' => 'all_pages',
			'sanitize_callback' => 'sanitize_text_field',
		));
		
		$wp_customize->add_control('digital_blocktiles_location', array(
			'label' => __('Visiblity on Page Types', 'digital'),
			'section' => 'digital_blocktiles',
			'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_blocktiles_location_priority', 100 ),
		));	