<?php
$themename = "لوحة التحكم للقالب 2";
$shortname = "nt";
$categories = get_categories('hide_empty=0&orderby=name');
$wp_cats = array();
foreach ($categories as $category_list ) {
       $wp_cats[$category_list->cat_ID] = $category_list->cat_name;
}
array_unshift($wp_cats, "اختار القسم"); 

$options = array (
 
array( "name" => $themename." Options",
	"type" => "title"),
/******************************************/










 
/******************************************/

array( "name" => "إعدادات عامة",
	"type" => "section"),
array( "type" => "open"),
/*
array( "name" => "Colour Scheme",
	"desc" => "Select the colour scheme for the theme",
	"id" => $shortname."_color_scheme",
	"type" => "select",
	"options" => array("blue", "red", "green"),
	"std" => "blue"),
	
	
	array( "name" => "Custom CSS",
	"desc" => "Want to add any custom CSS code? Put in here, and the rest is taken care of. This overrides any other stylesheets. eg: a.button{color:green}",
	"id" => $shortname."_custom_css",
	"type" => "textarea",
	"std" => ""),
*/	
array( "name" => "رابط لوجو الموقع",
	"desc" => "رابط اللوجو",
	"id" => $shortname."_logo",
	"type" => "text",
	"std" => ""),
	
array( "name" => "رابطة خلفية الموقع",
	"desc" => "رابطة خلفية الموقع",
	"id" => $shortname."_backgg",
	"type" => "text",
	"std" => ""),
	
	array( "name" => "القسم الذى يعرض فى السلايدر",
	"desc" => "القسم الذى يعرض فى السلايدر",
	"id" => $shortname."_feat_slider",
	"type" => "select",
	"options" => $wp_cats,
	"std" => "Choose a category"),

	
					array( "name" =>"عدد شريط اخر الاخبار",
	"desc" => "عدد شريط اخر الاخبار",
	"id" => $shortname."_feat_last_num",
	"type" => "text",
	"std" => ""),
					array( "name" =>"قسم شريط اخر الاخبار ",
	"desc" => "قسم شريط اخر الاخبار ",
	"id" => $shortname."_feat_last",
	"type" => "select",
	"options" => $wp_cats,
	"std" => "Choose a category"),


		
	
array( "type" => "close"),
array( "name" => "الصفحة الرئيسية",
	"type" => "section"),
array( "type" => "open"),
/*
array( "name" => "Homepage header image",
	"desc" => "Enter the link to an image used for the homepage header.",
	"id" => $shortname."_header_img",
	"type" => "text",
	"std" => ""),

	
	
		array( "name" => "رابط يوتيوب الصفحة الرئيسية",
	"desc" => "رابط يوتيوب الصفحة الرئيسية",
	"id" => $shortname."_youtybe_vedio",
	"type" => "text",
	"std" => ""),
	
	
		*/
		
				array( "name" =>"رابط اعلان الهيدر",
	"desc" => "رابط اعلان الهيدر",
	"id" => $shortname."_top_ads_link",
	"type" => "text",
	"std" => ""),
					array( "name" =>"رابط صورة اعلان الهيدر",
	"desc" => "رابط صورة اعلان الهيدر",
	"id" => $shortname."_top_ads_img",
	"type" => "text",
	"std" => ""),


		
		
		array( "name" =>"رابط صورة اعلان الرئيسية",
	"desc" => "رابط صورة اعلان الرئيسية",
	"id" => $shortname."_ads_img",
	"type" => "text",
	"std" => ""),
	
		array( "name" => "رابط اعلان اعلان الرئيسية",
	"desc" => "رابط اعلان اعلان الرئيسية",
	"id" => $shortname."_ads_link",
	"type" => "text",
	"std" => ""),
	

	
	
	
	
	
/**/


array( "type" => "close"),
array( "name" => "اسفل الموقع",
	"type" => "section"),
array( "type" => "open"),
	
array( "name" => "الكتابة بالفوتر",
	"desc" => "لكتابة بالفوتر",
	"id" => $shortname."_footer_text",
	"type" => "text",
	"std" => ""),
	
array( "name" => "كود جوجل انلايستيك",
	"desc" => "يمكنك لصق حسابك في Google Analytics أو غيرها من شفرة تتبع في هذا المربع. هذا وستضاف تلقائيا إلى تذييل.",
	"id" => $shortname."_ga_code",
	"type" => "textarea",
	"std" => ""),	
	
array( "name" => " Favicon",
	"desc" => "A فافيكون هو الرمز الذي يمثل بكسل 16X16 موقعك؛ لصق عنوان URL إلى ملف. صورة منظمة البن الدولية التي تريد استخدامها كصورة",
	"id" => $shortname."_favicon",
	"type" => "text",
	"std" => get_bloginfo('url') ."/favicon.ico"),	
	
array( "name" => "رابط الفيس بوك",
	"desc" => "",
	"id" => $shortname."_facebok",
	"type" => "text",
	"std" => "" ),

 array( "name" => "رابط تويتر",
	"desc" => "",
	"id" => $shortname."_twitter",
	"type" => "text",
	"std" => "" ),

 array( "name" => "رابط جوجل بلاس",
	"desc" => "",
	"id" => $shortname."_google_pluse",
	"type" => "text",
	"std" => "" ),

 array( "name" => "رابط اليوتيوب",
	"desc" => "",
	"id" => $shortname."_youtube_url",
	"type" => "text",
	"std" => "" ),

 
 
 
 
 
 
 
 
 
 
array( "type" => "close")
 
);


function mytheme_add_admin() {
 
global $themename, $shortname, $options;
 
if ( $_GET['page'] == basename(__FILE__) ) {
 
	if ( 'save' == $_REQUEST['action'] ) {
 
		foreach ($options as $value) {
		update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
 
foreach ($options as $value) {
	if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
 
	header("Location: admin.php?page=functions.php&saved=true");
die;
 
} 
else if( 'reset' == $_REQUEST['action'] ) {
 
	foreach ($options as $value) {
		delete_option( $value['id'] ); }
 
	header("Location: admin.php?page=functions.php&reset=true");
die;
 
}
}
 
add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin');
}

function mytheme_add_init() {

$file_dir=get_bloginfo('template_directory');
wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
wp_enqueue_script("rm_script", $file_dir."/functions/rm_script.js", false, "1.0");

}
function mytheme_admin() {
 
global $themename, $shortname, $options;
$i=0;
 
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' تم الحفظ.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' تم استعادة البيانات.</strong></p></div>';
 
?>
<div class="wrap rm_wrap">
<h2><span class="icon-dd"></span><?php echo $themename; ?> </h2>
 
<div class="rm_opts">
<form method="post">
<?php foreach ($options as $value) {
switch ( $value['type'] ) {
 
case "open":
?>
 
<?php break;
 
case "close":
?>
 
</div>
</div>
<br />

 
<?php break;
 
case "title":
?>
<p> <?php echo $themename;?></p>

 
<?php break;
 
case 'text':
?>

<div class="rm_input rm_text">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
 	<input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?>" />
 <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
 
 </div>
<?php
break;
 
case 'textarea':
?>

<div class="rm_input rm_textarea">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
 	<textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>
 <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
 
 </div>
  
<?php
break;
 
case 'select':
?>

<div class="rm_input rm_select">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
	
<select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
<?php foreach ($value['options'] as $option) { ?>
		<option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?>
</select>

	<small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
</div>
<?php
break;
 
case "checkbox":
?>

<div class="rm_input rm_checkbox">
	<label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
	
<?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />


	<small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
 </div>
<?php break; 
case "section":

$i++;

?>

<div class="rm_section">
<div class="rm_title"><h3><img src="<?php bloginfo('template_directory')?>/functions/images/trans.gif" class="inactive" alt="""><?php echo $value['name']; ?></h3><span class="submit"><input name="save<?php echo $i; ?>" type="submit" value="حفظ التغييرات" />
</span><div class="clearfix"></div></div>
<div class="rm_options">

 
<?php break;
 
}
}
?>
 
<input type="hidden" name="action" value="save" />
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="استعادة" />
<input type="hidden" name="action" value="reset" />
</p>
</form>
<div style="font-size:9px; margin-bottom:10px;">بواسطة: <a href="http://www.al-yasser.com.sa">مجموعة الياسر</a></div>
 </div> 
 

<?php
}
?>
<?php
add_action('admin_init', 'mytheme_add_init');
add_action('admin_menu', 'mytheme_add_admin');
?>