<?php
/**
 * Our Gallery options.
 *
 * @package Rock Singer
 */

$default = rock_singer_get_default_theme_options();

// Our Gallery Section
$wp_customize->add_section( 'section_our_gallery',
	array(
	'title'      => __( 'Latest Galleries', 'rock-singer' ),
	'priority'   => 100,
	'capability' => 'edit_theme_options',
	'panel'      => 'home_page_panel',
	)
);

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

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

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

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

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

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

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

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

$number_of_our_gallery_items = rock_singer_get_option( 'number_of_our_gallery_items' );

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

	// Image
	$wp_customize->add_setting('theme_options[our_gallery_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[our_gallery_image_' . $i .']', 
		array(
		'label'       => sprintf( __('Image #%1$s', 'rock-singer'), $i ),
		'section'     => 'section_our_gallery',   
		'settings'    => 'theme_options[our_gallery_image_' . $i .']',		
		'active_callback' => 'rock_singer_our_gallery_active',			
		'type'        => 'image'
		)
		)
	);

}