<?php

function bexplore_section_settings_register( $wp_customize ) {

	// Panel: Basic.
	$wp_customize->add_panel('bexplore_sections_panel', array(
		'priority' => 10,
		'title' => __('Sections', 'bexplore'),
		'description' => __('Panel Description', 'bexplore'),
		'capability' => 'edit_theme_options'
	));

	// Setting: Select.
	$wp_customize->add_setting('bexplore_select', array(
		'type' => 'theme_mod',
		'default' => 'enable',
		'transport' => 'refresh', // Options: refresh or postMessage.
		'capability' => 'edit_theme_options',
		'sanitize_callback' => 'bexplore_sanitize_select' // Custom function in customizer-sanitization.php file.
	));

	// Control: Select.
	$wp_customize->add_control('bexplore_select', array(
		'label' => __('Select', 'bexplore'),
		'description' => __('Description', 'bexplore'),
		'section' => 'bexplore_section_basic',
		'type' => 'select',
		'choices' => array(
			'enable' => 'Enable',
			'disable' => 'Disable'
		)
	));


	$wp_customize->add_section('slider_select_category', [
		'title' => __('Select Category', 'bexplore'),
		'panel' => 'bexplore_sections_panel',
		'priority' => 30
	]);

	$wp_customize->add_setting('bexplore_select_cat', [
		'default' => 'uncategorized',
		'transport' => 'refresh',
		'sanitize_callback' => 'bexplore_sanitize_select'
	]);

	$teh_cats = get_categories(array('orderby' => 'name',));
	$results  = array();
	$count    = count($teh_cats);
	for ($i = 0; $i < $count; $i++) {
		if (isset($teh_cats[$i]))
			$results[$teh_cats[$i]->slug] = $teh_cats[$i]->name;
		else
			$count++;
	}

	$wp_customize->add_control('bexplore_select_cat', array(
		'type' => 'select',
		'section' => 'slider_select_category', // Required, core or custom.
		'label' => __('Select category', 'bexplore'),
		'description' => __('Select category', 'bexplore'),
		'choices' => $results,
	));

}
add_action( 'customize_register', 'bexplore_section_settings_register' );