<?php
if ( ! isset( $content_width ) )
	$content_width = 600;
add_action( 'after_setup_theme', 'greenhope_theme_setup' );
function greenhope_theme_setup() {
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'post-thumbnails' );
	add_action( 'init', 'greenhope_register_menus' );
}
function greenhope_register_menus() {
	register_nav_menus( array(
		'primary' => __('Primary Navigation', 'greenhope')
	) );
}
function greenhope_menu() { ?>
<ul class="menu">
	<li><a href="<?php echo home_url(); ?>" title="<?php _e('Home', 'greenhope'); ?>"><?php _e('Home', 'greenhope'); ?></a></li>
	<?php wp_list_pages('depth=1&title_li='); ?>
</ul>
<?php } ?>
<?php
add_action ('init','greenhope_theme_init');
function greenhope_theme_init ()
{
load_theme_textdomain ('greenhope');
}
function greenhope_widgets_init() {
	register_sidebar(array(
		'id' => 'top_sidebar',
		'name' => __( 'Top Sidebar', 'greenhope' ),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	));
	register_sidebar(array(
		'id' => 'left_sidebar',
		'name' => __( 'Left Sidebar', 'greenhope' ),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	));
	register_sidebar(array(
		'id' => 'right_sidebar',
		'name' => __( 'Right Sidebar', 'greenhope' ),
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
		'before_title' => '<h3 class="widget_title">',
		'after_title' => '</h3>',
	));
}
add_action( 'widgets_init', 'greenhope_widgets_init' );
if ( ! function_exists( 'greenhope_comment' ) ) :
function greenhope_comment($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment;
	switch ( $comment->comment_type ) :
		case '' :
	?>
	<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
		<div class="comment-body group">
			<div class="comment-meta commentmetadata">
				<?php printf('<span class="fn">%s</span> ', get_comment_author_link()) ?> <?php printf(__('%1$s at %2$s', 'greenhope'), get_comment_date(),  get_comment_time()) ?> <?php edit_comment_link(__('(Edit)', 'greenhope'),'  ','') ?>
			</div>
			<?php echo get_avatar($comment,$size='32'); ?>
			<?php if ($comment->comment_approved == '0') : ?>
				<p class="moderation"><em><?php _e('Your comment is awaiting moderation.', 'greenhope') ?></em></p>
			<?php endif; ?>
			<?php comment_text() ?>
			<p class="reply">
				<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
			</p>
		</div>
	<?php
			break;
		case 'pingback'  :
		case 'trackback' :
	?>
	<li id="comment-<?php comment_ID( ); ?>" class="trackback"><strong><?php comment_author_link(); ?></strong>
	<?php
			break;
	endswitch;
}
endif;
if ( ! function_exists( 'greenhope_posted_on' ) ) :
function greenhope_posted_on() {
	printf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s<span class="day">%4$s</span></a>',
		get_permalink(),
		esc_attr( get_the_time() ),
		get_the_date('Y-m'),
		get_the_date('d')
	);
}
endif;

function greenhope_comment_fields ($fields) {
		foreach ($fields as $name => $field) {
			$fields[$name] = preg_replace('/(<label(?:.*?)>(?:.*?)<\/label>)\s*(<span class="required">\*<\/span>)?\s*(<input(?:.*?)\/>)/','\3\1\2',$field);
		}
		return $fields;
	}
	add_filter('comment_form_default_fields', 'greenhope_comment_fields');