<?php // Widgetized Sidebar.
function likeFacebook_widgets_init() {
	register_sidebar(array(
		'name' => __('The Left Widget area','likeFacebook'),
		'id' => 'left-widget-area',
		'description' => __('The Left widget area','likeFacebook'),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widgettitle">',
		'after_title' => '</h3>'
	));
	register_sidebar(array(
		'name' => __('The Right Widget Area','likeFacebook'),
		'id' => 'right-widget-area',
		'description' => __('The Right widget area','likeFacebook'),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widgettitle">',
		'after_title' => '</h3>'
	));
}
add_action( 'widgets_init', 'likeFacebook_widgets_init' );

// WP nav menu
if (function_exists('wp_nav_menu')) {
register_nav_menus(array('page_navigation' => __('Page Navigation','likeFacebook')));
register_nav_menus(array('cats_navigation' => __('Categories Navigation','likeFacebook')));
}

// LOCALIZATION
load_theme_textdomain('likeFacebook', get_template_directory() . '/lang');

// Custom Comments List.
function mytheme_comment($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment;
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
	<div id="comment-<?php comment_ID(); ?>">
		<div class="comment-author vcard">
			<?php echo get_avatar($comment,$size='40',$default='' ); ?>
			<cite class="fn"><?php comment_author_link() ?></cite>
			<span class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?></a><?php edit_comment_link(__('Edit','likeFacebook'),' [ ',' ] ') ?></span>
		</div>
		<?php if ($comment->comment_approved == '0') : ?>
		<em class="approved"><?php _e('Your comment is awaiting moderation.','likeFacebook') ?></em>
		<br />
		<?php endif; ?>
		<div class="comment-text">
			<?php comment_text() ?>
		</div>
		<div class="reply">
			<?php comment_reply_link(array_merge( $args, array('reply_text' => __('Reply','likeFacebook'), 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
		</div>
	</div>
<?php }

/* likeFacebook Options */
$items = array (
	array(
		'id' => 'rss_url',
		'name' => __('Rss Url', 'likeFacebook'),
		'desc' => __('Put your full rss subscribe address here.(with http://)', 'likeFacebook')
	),
	array(
		'id' => 'twitter_url',
		'name' => __('twitter Url', 'likeFacebook'),
		'desc' => __('Put your full twitter address here.(with http:// , leave it blank for display none.)', 'likeFacebook')
	),
	array(
		'id' => 'facebook_url',
		'name' => __('facebook Url', 'likeFacebook'),
		'desc' => __('Put your full facebook address here.(with http:// , leave it blank for no display none.)', 'likeFacebook')
	),
	array(
		'id' => 'tqq_url',
		'name' => __('tqq Url', 'likeFacebook'),
		'desc' => __('Put your full QQ MicroBlog address here.(with http:// , leave it blank for no display none.)', 'likeFacebook')
	),
	array(
		'id' => 'renren_url',
		'name' => __('renren Url', 'likeFacebook'),
		'desc' => __('Put your full renren address here.(with http:// , leave it blank for no display none.)', 'likeFacebook')
	),
	array(
		'id' => 'sitemap_url',
		'name' => __('sitemap Url', 'likeFacebook'),
		'desc' => __('Put your full sitemap address here.(with http:// , leave it blank for no display none.)', 'likeFacebook')
	),
	array(
		'id' => 'tagpage_url',
		'name' => __('tagpage Url', 'likeFacebook'),
		'desc' => __('Put your full tagpage address here.(with http:// , leave it blank for no display none.)', 'likeFacebook')
	),
	array(
		'id' => 'excerpt_check',
		'name' => __('Excerpt?', 'likeFacebook'),
		'desc' => __('If the home page and archive pages to display excerpt of post, check.', 'likeFacebook')
	),
	array(
		'id' => 'comment_notes',
		'name' => __('Disable the comment notes','likeFacebook'),
		'desc' => __('Disabling this will remove the note text that displays with more options for adding to comments (html).', 'likeFacebook')
	),
	array(
		'id' => 'smilies',
		'name' => __('Disable the comments smilies','likeFacebook'),
		'desc' => __('Disabling this will remove the comments smilies.', 'likeFacebook')
	)
);

class likeFacebookOptions {
	function getOptions() {
		global $items;
		$options = get_option('likeFacebook_options');
		if (!is_array($options)) {
			foreach ($items as $item) {
				$options[$item['id']] = '';
			}
			update_option('likeFacebook_options', $options);
		}
		return $options;
	}
	function init() {
		global $items;
		if(isset($_POST['likeFacebook_save'])) {
			$options = likeFacebookOptions::getOptions();
			foreach ($items as $item) {
				$options[$item['id']] = stripslashes($_POST[$item['id']]);
			}
			update_option('likeFacebook_options', $options);
		} elseif(isset($_POST['likeFacebook_reset'])) {
			foreach ($items as $item) {
				$options[$item['id']] = '';
			}
			update_option('likeFacebook_options', $options);
		} else {
			likeFacebookOptions::getOptions();
		}
		add_theme_page(__('likeFacebook Options','likeFacebook'), __('likeFacebook Options','likeFacebook'), 'edit_themes', basename(__FILE__), array('likeFacebookOptions', 'display'));
	}
	function display() {
		global $items;
		$options = likeFacebookOptions::getOptions();
?>
<form action="#" method="post" enctype="multipart/form-data" name="likeFacebook_form" id="likeFacebook_form">
	<div class="wrap" style="width:700px;">
		<h2 style="border-bottom:1px solid #ddd;padding-bottom:20px;"><?php _e('likeFacebook Options', 'likeFacebook'); ?></h2>
		<table class="form-table">
			<tbody>
	<?php foreach ($items as $item) { ?>
		<?php if ($item['id'] == 'excerpt_check' || $item['id'] == 'comment_notes' || $item['id'] == 'smilies') { ?>
				<tr valign="top" style="margin:0 10px;border-bottom:1px solid #ddd;">
					<th scope="row" style="width:260px;">
						<span style="font-weight:bold;"><?php _e($item['name'],'likeFacebook'); ?></span>
					</th>
					<td>
						<input name="<?php echo $item['id']; ?>" id="<?php echo $item['id']; ?>" type="checkbox" <?php if($options[$item['id']]){ $checked = "checked=\"checked\""; }else{ $checked = ""; } echo $checked; ?> value="true" />
						<br/>
						<label><?php _e($item['desc'],'likeFacebook'); ?></label>
					</td>
				</tr>
		<?php } else { ?>
				<tr valign="top" style="margin:0 10px;border-bottom:1px solid #ddd;">
					<th scope="row" style="width:260px;">
						<span style="font-weight:bold;"><?php _e($item['name'],'likeFacebook'); ?></span>
					</th>
					<td>
						<input name="<?php echo $item['id']; ?>" id="<?php echo $item['id']; ?>" type="html" value="<?php if ( $options[$item['id']] != "") { echo $options[$item['id']]; } else { echo ''; } ?>" size="80" />
						<br/>
						<label><?php _e($item['desc'],'likeFacebook'); ?></label>
					</td>
				</tr>
		<?php } ?>
	<?php } ?>
			</tbody>
		</table>
		<!-- Submit -->
		<p class="submit">
			<input type="submit" name="likeFacebook_save" value="<?php _e('Update Options &raquo;', 'likeFacebook'); ?>" />
			<input type="submit" name="likeFacebook_reset" value="<?php _e('Reset Options &raquo;', 'likeFacebook'); ?>" />
		</p>
	</div>
</form>
<?php
	}
}
add_action('admin_menu', array('likeFacebookOptions', 'init')); //End: zBench Option

?>
