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

$default = rock_studio_get_default_theme_options();

// Our Gallery Section
$wp_customize->add_section( 'section_our_gallery',
	array(
	'title'      => __( 'Latest Galleries', 'rock-studio' ),
	'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_studio_sanitize_checkbox'
	)
);

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

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

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

$number_of_our_gallery_items = rock_studio_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_studio_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-studio'), $i ),
		'section'     => 'section_our_gallery',   
		'settings'    => 'theme_options[our_gallery_image_' . $i .']',		
		'active_callback' => 'rock_studio_our_gallery_active',			
		'type'        => 'image'
		)
		)
	);

}