<?php
// Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'home-comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die('Please do not load this page directly. Thanks!');

if (post_password_required()) {
    ?>

    <?php
    return;
}
?>

<?php
/* * ************************* Comment Template ************************** */

global $current_user, $gp_settings, $post, $user_identity;
require(ghostpool_inc . 'options.php');

$comment_array = array_reverse(get_approved_comments(get_the_ID()));
$count = 1;
?>

<?php if ($comment_array) { ?>
    <div id="comments">
        <ol id="commentlist">
            <?php foreach ($comment_array as $comment) { ?>
                <?php if ($count++ <= 2) { ?>
                    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
                        <div id="comment-<?php comment_ID() ?>" class="comment-box">
                            <div class="comment-avatar">
                                <?php echo get_avatar($comment, $size = '50'); ?>
                            </div>

                            <div class="comment-meta">
                                <span class="comment-author">
                                    <?php printf(__('%s', 'gp_lang'), comment_author_link()) ?>
                                </span>

                                <div class="clear"></div>
                                <div class="comment-date">
                                    <?php comment_time(get_option('date_format')); ?>, <?php comment_time(get_option('time_format')); ?>
                                </div>
                                <div class="clear"></div>
                                <div class="comment-text">
                                    <?php comment_text(); ?>
                                    <?php if ($comment->comment_approved == '0') { ?>
                                        <div class="moderation">
                                            <?php _e('Your comment is awaiting moderation.', 'gp_lang'); ?>
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                            <div class="clear"></div>
                        </div>
                    </li>
                <?php } ?>
            <?php } ?>
        </ol>
        <?php if (count($comment_array) > 0) : ?>
        <div class="more-comments">
            <a href="<?php the_permalink(); ?>" class="read-more" title="<?php _e('See More', 'gp_lang'); ?>"><?php _e('See More', 'gp_lang'); ?> &raquo;</a>
        </div>
        <?php endif; ?>
    </div>
<?php } else { ?>
    <?php if ( comments_open() ) : ?>
        <div id="respond" class="homepage">
        <h3><?php comment_form_title( __('Make a comment'), __('Respond to %s' ) ); ?></h3>
        <div id="cancel-comment-reply">
                <small><?php cancel_comment_reply_link() ?></small>
        </div>
        <?php if(get_option('comment_registration') && !$user_ID) : ?>
                <p><?php _e('You must be logged in to post a comment.', 'gp_lang'); ?></p>
        <?php else : ?>
            <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" class="commentform">
                <?php if ( is_user_logged_in() ) : ?>

                <p><?php printf(__('Logged in as <a href="%1$s">%2$s</a>.'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php esc_attr_e('Log out of this account'); ?>"><?php _e('Log out &raquo;'); ?></a></p>

                <?php else : ?>

                <p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
                <label for="author"><small><?php _e('Name'); ?> <?php if ($req) _e('(required)'); ?></small></label></p>

                <p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
                <label for="email"><small><?php _e('Mail (will not be published)'); ?> <?php if ($req) _e('(required)'); ?></small></label></p>

                <p><input type="text" name="url" id="url" value="<?php echo  esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
                <label for="url"><small><?php _e('Website'); ?></small></label></p>

                <?php endif; ?>

                <p><textarea name="comment" id="comment" cols="58" rows="5" tabindex="4"></textarea></p>

                <p><input name="submit" type="submit" class="submit" id="submit" tabindex="5" value="<?php esc_attr_e('Submit Comment'); ?>" />
                <?php comment_id_fields(); ?>
                </p>
                <?php do_action('comment_form', $post->ID); ?>
            </form>
                <div class="clear"></div>
        <?php endif; // If registration required and not logged in ?>
    </div>
    <?php endif; ?>
<?php } ?>


