<?php
function wp_perblog_menu() {
	// Top Menu Features:
	    add_theme_page(__('Per Panel','perblog'), __('Per Panel','perblog'), 6, basename(__FILE__) , 'wp_perblog_admin', '');
	// Bottom Menu Features:
	add_theme_support( $feature );
		
}

add_action('admin_menu', 'wp_perblog_menu');

function new_menu() {
   	wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );
}
$perblog_options = (
	array(
array(__('Per Blog Settings','perblog'), array(	
		array('menu', 'yes', __('Homepage use this theme','perblog'),__('If Show is selected, it is active.','perblog'),'yesno'),
		array('twitterileti', 'yes', __('Twitter Message','perblog'),__('If you choose yes, you will see the last twitter message at the bottom.','perblog'),'yesno'),
		array('etiketler', 'yes', __('Labels','perblog'),__('If yes, the text labels will appear.','perblog'),'yesno'),
		array('analytics', __('','perblog'), __('Analytics code::','perblog'),__('Analytics code here','perblog'),'textarea'),
		)	
		),	
		));
foreach($perblog_options as $section) {
	foreach($section[1] as $option) {
		add_option($option[0], $option[1]);
	}
}
function wp_perblog_admin() {
	global $perblog_options;
	if ($_POST['save_perblog_options']) {
		foreach($perblog_options as $section) {
			foreach($section[1] as $option) {
				update_option($option[0],stripslashes($_POST[$option[0]]));
			}
		}
		/* Başarılı */
		echo '<div id="message" class="updated fade"><p><strong>'.__('Settings saved.','perblog').'</strong></p></div>';
	}
	?>
	<div class="wrap">
		<h2><?php _e('Per Blog Settings', 'perblog'); ?></h2>
		<form method="post" action="admin.php?page=temapaneli.php" id="perblog_form">
			<?php
			foreach($perblog_options as $section) {
				echo '<h3>'.$section[0].'</h3><div class="perblog_section"><table cellspacing="0" cellpadding="0" class="form-table">';
				foreach($section[1] as $option) {
					echo '<tr valign="top">';
					echo '<th><label for="'.$option[0].'">'.$option[2].'</label></th><td>';
					if ($option[4]=='yesno') {
						$yes = '';
						$no = '';
						if (get_option($option[0])=='yes') $yes='selected="selected"'; else $no='selected="selected"';
						echo '<select name="'.$option[0].'">
							<option value="yes" '.$yes.'>'.__('Yes','perblog').'</option>
							<option value="no" '.$no.'>'.__('No','perblog').'</option>
						</select>';
					} elseif ($option[4]=='textarea') {
						echo '<textarea id="'.$option[0].'" name="'.$option[0].'" cols="40" rows="4">'.get_option($option[0]).'</textarea>';
					} elseif ($option[4]=='select_options') {
						$selected = '';
						echo '<select name="'.$option[0].'">';
						$names = explode('|', $option[5]);
						$values = explode('|', $option[6]);
						$selected = get_option($option[0]);
						$loop = 0;
						if ($names) {
							foreach ($names as $name) {
								echo '<option value="'.$values[$loop].'" ';
								if ($selected==$values[$loop]) echo 'selected="selected"';
								echo '>'.$name.'</option>';
								$loop++;
							}
						}
						echo '</select>';
					} else {
						echo '<input type="text" id="'.$option[0].'" name="'.$option[0].'" size="50" value="'.get_option($option[0]).'" />';
					}
					if ($option[3]) echo '<br/><span class="setting-description">'.$option[3].'</span>';
					echo '</td></tr>';
				}
				echo '</table></div><br class="clear" />';
			}
			?>
			<p class="submit" style="text-align:right"><input type="submit" value="<?php _e('Kaydet', 'perblog'); ?>" name="save_perblog_options" /></p>
		</form>
	</div>
<?php } ?>