<?php
/**
 * Category Colors
 * @package MatrixAddons
 * @subpackage trainifyframework
 * @since 1.0.0
 */
$wp_customize->add_section(
	'trainify_framework_categories_color_options',
	array(
		'priority'      => 20,
		'title'         => esc_html__( 'Category Colors', 'trainify' ),
		'panel'         => 'site_color_options',
	)
);

$priority = 10;

$categories = get_categories( array( 'hide_empty' => 0 ) );

foreach ( $categories as $category_list ) {

	$wp_customize->add_setting( 
		'trainify_framework_category_color_'.esc_attr( strtolower( $category_list->slug ) ),
		array(
			'default'              => '#0056D2',
			'capability'           => 'edit_theme_options',
			'sanitize_callback'    => 'sanitize_hex_color'
		)
	);

	$wp_customize->add_control( 
		new WP_Customize_Color_Control(
			$wp_customize, 
			'trainify_framework_category_color_'.esc_attr( strtolower( $category_list->slug ) ),
			array(
				/* translators: %s: Category Name */
				'label'    => sprintf( esc_html__( ' %s Button Background', 'trainify' ), esc_attr( $category_list->name ) ),
				'section'  => 'trainify_framework_categories_color_options',
				'priority' => $priority
			)
		)
	);

	$priority+=10;

}