<?php
/**
 * Featured Albums options.
 *
 * @package Rock Singer
 */

$default = rock_singer_get_default_theme_options();

// Featured Albums Section
$wp_customize->add_section( 'section_featured_albums',
	array(
	'title'      => __( 'Latest Albums', 'rock-singer' ),
	'priority'   => 100,
	'capability' => 'edit_theme_options',
	'panel'      => 'home_page_panel',
	)
);

// Enable Section
$wp_customize->add_setting('theme_options[enable_featured_albums_section]', 
	array(
	'default' 			=> $default['enable_featured_albums_section'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'rock_singer_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[enable_featured_albums_section]', 
	array(		
	'label' 	=> __('Enable Section', 'rock-singer'),
	'section' 	=> 'section_featured_albums',
	'settings'  => 'theme_options[enable_featured_albums_section]',
	'type' 		=> 'checkbox',	
	)
);

// Background Image
$wp_customize->add_setting('theme_options[featured_album_background_image]', 
	array(
	'type'              => 'theme_mod',
	'default' 			=> $default['featured_album_background_image'],
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'rock_singer_sanitize_image'
	)
);

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize,
	'theme_options[featured_album_background_image]', 
	array(
	'label'       => __('Background Image', 'rock-singer'),
	'section'     => 'section_featured_albums',   
	'settings'    => 'theme_options[featured_album_background_image]',		
	'type'        => 'image',
	)
	)
);

// Section Subtitle
$wp_customize->add_setting('theme_options[featured_albums_section_subtitle]', 
	array(
	'default'           => $default['featured_albums_section_subtitle'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[featured_albums_section_subtitle]', 
	array(
	'label'       => __('Section Subtitle', 'rock-singer'),
	'section'     => 'section_featured_albums',   
	'settings'    => 'theme_options[featured_albums_section_subtitle]',	
	'active_callback' => 'rock_singer_featured_albums_active',		
	'type'        => 'text'
	)
);

// Section Title
$wp_customize->add_setting('theme_options[featured_albums_section_title]', 
	array(
	'default'           => $default['featured_albums_section_title'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[featured_albums_section_title]', 
	array(
	'label'       => __('Section Title', 'rock-singer'),
	'section'     => 'section_featured_albums',   
	'settings'    => 'theme_options[featured_albums_section_title]',	
	'active_callback' => 'rock_singer_featured_albums_active',		
	'type'        => 'text'
	)
);

// Number of items
$wp_customize->add_setting('theme_options[number_of_featured_albums_items]', 
	array(
	'default' 			=> $default['number_of_featured_albums_items'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'rock_singer_sanitize_number_range'
	)
);

$wp_customize->add_control('theme_options[number_of_featured_albums_items]', 
	array(
	'label'       => __('Number Of Items', 'rock-singer'),
	'description' => __('Save & Refresh the customizer to see its effect. Maximum is 50.', 'rock-singer'),
	'section'     => 'section_featured_albums',   
	'settings'    => 'theme_options[number_of_featured_albums_items]',		
	'type'        => 'number',
	'active_callback' => 'rock_singer_featured_albums_active',
	'input_attrs' => array(
			'min'	=> 1,
			'max'	=> 50,
			'step'	=> 1,
		),
	)
);

$number_of_featured_albums_items = rock_singer_get_option( 'number_of_featured_albums_items' );

for( $i=1; $i<=$number_of_featured_albums_items; $i++ ) {

	// Image
	$wp_customize->add_setting('theme_options[featured_albums_image_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'rock_singer_sanitize_image'
		)
	);

	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize,
		'theme_options[featured_albums_image_'.$i.']', 
		array(
		'label'       => sprintf( __('Image #%1$s', 'rock-singer'), $i),
		'section'     		=> 'section_featured_albums',   
		'settings'    		=> 'theme_options[featured_albums_image_'.$i.']',		
		'active_callback' 	=> 'rock_singer_featured_albums_active',
		'type'        		=> 'image',
		)
		)
	);

	// Content
	$wp_customize->add_setting('theme_options[featured_albums_content_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field'
		)
	);

	$wp_customize->add_control('theme_options[featured_albums_content_'.$i.']', 
		array(
		'label'       => sprintf( __('Singer Name #%1$s', 'rock-singer'), $i),
		'section'     => 'section_featured_albums',   
		'settings'    => 'theme_options[featured_albums_content_'.$i.']',		
		'active_callback' => 'rock_singer_featured_albums_active',		
		'type'        => 'text'
		)
	);

	// Title
	$wp_customize->add_setting('theme_options[featured_albums_title_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field'
		)
	);

	$wp_customize->add_control('theme_options[featured_albums_title_'.$i.']', 
		array(
		'label'       => sprintf( __('Track Title #%1$s', 'rock-singer'), $i),
		'section'     => 'section_featured_albums',   
		'settings'    => 'theme_options[featured_albums_title_'.$i.']',		
		'active_callback' => 'rock_singer_featured_albums_active',		
		'type'        => 'text'
		)
	);
}