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

$default = rock_studio_get_default_theme_options();

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

// Enable Our Team 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_studio_sanitize_checkbox'
	)
);

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

// 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-studio'),
	'section'     => 'section_featured_albums',   
	'settings'    => 'theme_options[featured_albums_section_title]',	
	'active_callback' => 'rock_studio_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_studio_sanitize_number_range'
	)
);

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

$number_of_featured_albums_items = rock_studio_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_studio_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-studio'), $i),
		'section'     		=> 'section_featured_albums',   
		'settings'    		=> 'theme_options[featured_albums_image_'.$i.']',		
		'active_callback' 	=> 'rock_studio_featured_albums_active',
		'type'        		=> 'image',
		)
		)
	);

	// 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( __('Title #%1$s', 'rock-studio'), $i),
		'section'     => 'section_featured_albums',   
		'settings'    => 'theme_options[featured_albums_title_'.$i.']',		
		'active_callback' => 'rock_studio_featured_albums_active',		
		'type'        => 'text'
		)
	);

	// 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( __('Description #%1$s', 'rock-studio'), $i),
		'section'     => 'section_featured_albums',   
		'settings'    => 'theme_options[featured_albums_content_'.$i.']',		
		'active_callback' => 'rock_studio_featured_albums_active',		
		'type'        => 'text'
		)
	);

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

	$wp_customize->add_control('theme_options[featured_albums_button_label_'.$i.']', 
		array(
		'label'       => sprintf( __('Button Label #%1$s', 'rock-studio'), $i),
		'section'     => 'section_featured_albums',   
		'settings'    => 'theme_options[featured_albums_button_label_'.$i.']',		
		'active_callback' => 'rock_studio_featured_albums_active',		
		'type'        => 'text'
		)
	);

	// Button Url
	$wp_customize->add_setting('theme_options[featured_albums_button_url_'.$i.']', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'esc_url_raw'
		)
	);

	$wp_customize->add_control('theme_options[featured_albums_button_url_'.$i.']', 
		array(
		'label'       => sprintf( __('Button Url #%1$s', 'rock-studio'), $i),
		'section'     => 'section_featured_albums',   
		'settings'    => 'theme_options[featured_albums_button_url_'.$i.']',		
		'active_callback' => 'rock_studio_featured_albums_active',		
		'type'        => 'url'
		)
	);
}