<?php

/*

 * 

 * Require the framework class before doing anything else, so we can use the defined urls and dirs

 * Also if running on windows you may have url problems, which can be fixed by defining the framework url first

 *

 */

//define('NHP_OPTIONS_URL', site_url('path the options folder'));

if(!class_exists('NHP_Options')){

	require_once( dirname( __FILE__ ) . '/options/options.php' );

}

function add_another_section($sections){

	

	$sections[] = array(

				'title' => __('A Section added by hook', 'nhp-opts'),

				'desc' => __('<p class="description">This is a section created by adding a filter to the sections array, great to allow child themes, to add/remove sections from the options.</p>', 'nhp-opts'),

				'icon' => trailingslashit(get_template_directory_uri()).'options/img/glyphicons/glyphicons_062_attach.png',

				'fields' => array()

				);
	return $sections;

	

}

function change_framework_args($args){

	return $args;

}

function setup_framework_options(){

$args = array();

$args['dev_mode'] = true;

$args['intro_text'] = __('<p></p>', 'nhp-opts');

$args['opt_name'] = 'eep';

$args['menu_title'] = __('Theme Options', 'nhp-opts');

$args['page_title'] = __('Theme Options', 'nhp-opts');

$args['page_slug'] = 'nhp_theme_options';

$args['page_position'] = 27;

$sections[] = array(

				'title' => __('Header  ', 'nhp-opts'),

				'desc' => __('<p class="description"></p>', 'nhp-opts'),
				'fields' => array(
						
				array(
						'id' => 'logo',
						'type' => 'upload', 
						'title' => __('Logo Upload', 'nhp-opts'),
						'desc' => __('Upload Logo For Header', 'nhp-opts'),
							),
				array(
						'id' => 'add',
						'type' => 'editor', 
						'title' => __('Advertisement Banner ', 'nhp-opts'),
						'desc' => __('Enter Advertisement Banner', 'nhp-opts'),
							),
	array(
						'id' => 'favicon', 
						'type' => 'upload',										  
						'title' => __('Favicon Upload', 'nhp-opts'),
						'desc' => __('Click to upload favicon', 'nhp-opts'),
							),

							)
					);
				$sections[] = array(

				'title' => __('Footer  ', 'nhp-opts'),

				'desc' => __('<p class="description"></p>', 'nhp-opts'),
				'fields' => array(
						
				array(
						'id' => 'footer_logo',
						'type' => 'upload', 
						'title' => __('Footer Upload', 'nhp-opts'),
						'desc' => __('Upload Logo For Footer', 'nhp-opts'),
							),
				array(
						'id' => 'copyright',
						'type' => 'editor', 
						'title' => __('Copyright Text', 'nhp-opts'),
						'desc' => __('Enter Copyright Text', 'nhp-opts'),
							),
	

							)
			              	);

	$tabs = array();

	if (function_exists('wp_get_theme')){

		$theme_data = wp_get_theme();

		$theme_uri = $theme_data->get('ThemeURI');

		$description = $theme_data->get('Description');

		$author = $theme_data->get('Author');

		$version = $theme_data->get('Version');

		$tags = $theme_data->get('Tags');

	}else{

		$theme_data = wp_get_theme(trailingslashit(get_stylesheet_directory()).'style.css');

		$theme_uri = $theme_data['URI'];

		$description = $theme_data['Description'];

		$author = $theme_data['Author'];

		$version = $theme_data['Version'];

		$tags = $theme_data['Tags'];

	}	

	$theme_info = '<div class="nhp-opts-section-desc">';

	$theme_info .= '<p class="nhp-opts-theme-data description theme-uri">'.__('<strong>Theme URL:</strong> ', 'nhp-opts').'<a href="'.$theme_uri.'" target="_blank">'.$theme_uri.'</a></p>';

	$theme_info .= '<p class="nhp-opts-theme-data description theme-author">'.__('<strong>Author:</strong> ', 'nhp-opts').$author.'</p>';

	$theme_info .= '<p class="nhp-opts-theme-data description theme-version">'.__('<strong>Version:</strong> ', 'nhp-opts').$version.'</p>';

	$theme_info .= '<p class="nhp-opts-theme-data description theme-description">'.$description.'</p>';

	$theme_info .= '<p class="nhp-opts-theme-data description theme-tags">'.__('<strong>Tags:</strong> ', 'nhp-opts').implode(', ', $tags).'</p>';

	$theme_info .= '</div>';

	$tabs['theme_info'] = array(

					'icon' => NHP_OPTIONS_URL.'img/glyphicons/glyphicons_195_circle_info.png',

					'title' => __('Theme Information', 'nhp-opts'),

					'content' => $theme_info

					);

	if(file_exists(trailingslashit(get_stylesheet_directory()).'README.html')){

		$tabs['theme_docs'] = array(

						'icon' => NHP_OPTIONS_URL.'img/glyphicons/glyphicons_071_book.png',

						'title' => __('Documentation', 'nhp-opts'),

						'content' => nl2br(WP_Filesystem(trailingslashit(get_stylesheet_directory()).'README.html'))

						);

	}//if

	global $NHP_Options;

	$NHP_Options = new NHP_Options($sections, $args, $tabs);



}

add_action('init', 'setup_framework_options', 0);

function my_custom_field($field, $value){

	print_r($field);

	print_r($value);

}

function validate_callback_function($field, $value, $existing_value){

	

	$error = false;

	$value =  'just testing';

	$return['value'] = $value;

	if($error == true){

		$return['error'] = $field;

	}

	return $return;

	

}

?>