<?php
/**
 * A unique identifier is defined to store the options in the database and reference them from the theme.
 * By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
 * If the identifier changes, it'll appear as if the options have been reset.
 *
 * @package Camise
 */

function optionsframework_option_name() {

	// This gets the theme name from the stylesheet
	$themename = wp_get_theme();
	$themename = preg_replace("/\W/", "_", strtolower($themename) );

	$optionsframework_settings = get_option( 'optionsframework' );
	$optionsframework_settings['id'] = $themename;
	update_option( 'optionsframework', $optionsframework_settings );
}

/**
 * Defines an array of options that will be used to generate the settings page and be saved in the database.
 * When creating the 'id' fields, make sure to use all lowercase and no spaces.
 *
 * @returns array $options
 */

function optionsframework_options() {

	// If using image radio buttons, define a directory path
	$imagepath =  get_template_directory_uri() . '/images/';

	$options = array();
	
		/* General Settings */

		$options[] = array(
			"name" => __( 'General Settings', 'camise' ),
			"type" => "heading"
		);

		$options['logo'] = array(
			"name" => __( 'Custom Logo', 'camise' ),
			"desc" => __( 'Upload a logo for your theme if you would like to use one.','camise' ),
			"id" => "logo",
			"type" => "upload");

		$options[] = array(
			"name" => __( 'Custom Favicon', 'camise' ),
			"desc" => __( 'Upload a 16px x 16px png/gif image to represent your website.' , 'camise' ),
			"id" => "custom_favicon",
			"type" => "upload"
		);
			
		$options['display_intro_text'] = array(
			'name' => __( 'Display intro text on portfolio page', 'camise' ),
			'desc' => __( 'Display the intro text above on your portfolio page.', 'camise' ),
			'id' => 'display_intro_text',
			'std' => '0',
				'type' => 'checkbox'
			);
			
		$options[] = array(
			'name' => __('Portfolio Intro Text', 'camise'),
			'desc' => __('Add custom intro text to the portfolio page. HTML links can be used in this box.', 'camise'),
			'id' => 'intro_text',
			'type' => 'textarea');
		
		$options[] = array(
			'name' => __('Custom Footer Text', 'camise'),
			'desc' => __('Add custom footer text and site credits. HTML links can be used in this box.', 'camise'),
			'id' => 'footer_text',
			'type' => 'textarea');


		/* Style and Layout */

		$options[] = array(
			"name" => __( 'Style and Layout','camise' ),
			"type" => "heading");

		$options['layout'] = array(
			'name' => __( 'Main Layout','camise' ),
			'desc' => __( 'Select main content and sidebar alignment.','camise' ),
			'id' => 'layout',
			'std' => 'layout-2cr',
			'type' => 'images',
			'options' => array(
			'layout-2cr' => $imagepath . '2cr.png',
			'layout-2cl' => $imagepath . '2cl.png',
			'layout-1col' => $imagepath . '1cl.png')
			);

		 $options['camise_dark_style_css'] = array(
				'name' => __( 'Use Dark Header Theme Style', 'camise' ),
				'desc' => __( 'Use the dark header option for dark header.', 'camise' ),
				'id' => 'camise_dark_style_css',
				'std' => '0',
				'type' => 'checkbox'
			);
		
		$options['search_form'] = array(
			'name' => __( 'Display Search Form in Site Header', 'camise' ),
			'desc' => __( 'Display search form in site header instead of site description.', 'camise' ),
			'id' => 'search_form',
			'std' => '0',
			'type' => 'checkbox'
		);
		

         $options[] = array(
			"name" => __( 'Display Image Formats on Post/Blog Page', 'camise' ),
			"desc" => __( 'Display all post formats (including images) on posts page.', 'camise' ),
			"id" => "display_image_gallery_post_formats",
			"std" => "1",
			"type" => "checkbox"
		);


		/* Help */

		$options[] = array(
			"name" => __( 'Theme Support', 'camise' ),
			"type" => "heading"
		);

			$options[] = array(
			'name' => __( 'Theme Support', 'camise' ),
			'desc' => sprintf(
					'<p>%s</p>',
					sprintf(
						__( 'Camise is a WordPress theme for photographers, and creatives wanting to showcase their work. If you need further help installing Camise, please see our full theme <a href="%s">documentation</a>.', 'camise' ),
						esc_url( 'http://www.mixamedia.com/camise/docs' )
					)
				),
			'type' => 'info'
		);

		$options[] = array(
			'name' => __( 'Options Requests', 'camise' ),
			'desc' => sprintf(
					'<p>%s</p><p>%s</p><ul><li>-- %s</li><li>-- %s</li><li>-- %s</li></ul><p>%s</p>',
					sprintf(
						__( 'If you like this theme and wish to request further options, please do so by submitting a comment @ <a href="%s">Mixamedia</a>.', 'camise' ),
						esc_url( 'http://www.mixamedia.com/camise-wordpress-theme' )
					),
					__( 'Please follow the guidelines below when commenting:', 'camise' ),
					__( 'Make your request clear and specific.', 'camise' ),
					__( 'Please do not submit customization requests.', 'camise' ),
					__( 'Read our theme documentation before submitting.', 'camise' ),

                                 	sprintf(
						__( '<a href="%s">Read More &rarr;</a>', 'camise' ),
						esc_url( 'http://www.mixamedia.com/camise-wordpress-theme' )
					)
				),
			'type' => 'info'
		);

		return $options;
	}

	/**
	 * Additional content to display after the options panel
	 */
	function camise_panel_info() { ?>
	    <p style="color: #777;">
	    <?php printf(
	    	'Theme <a href="%s">documentation</a>.  For the For additional options, visit <a href="%s">WordPress</a>.',
	    	esc_url( 'http://www.mixamedia.com/camise/docs' ),
	    	esc_url( 'http://wordpress.org/' )
	    );
	    ?>
	    </p>
	<?php }

	add_action( 'optionsframework_after', 'camise_panel_info', 100 );