<?php
/**
 * The template for displaying comments.
 *
 * The area of the page that contains both current comments
 * and the comment form.
 *
 * @package _spx
 */
/*
 * If the current post is protected by a password and
 * the visitor has not yet entered the password we will
 * return early without loading the comments.
 */
if (post_password_required()) {
    return;
}
?>

<div id="comments" class="comments-area">

    <?php // You can start editing here -- including this comment!  ?>

    <?php if (have_comments()) : ?>
        <h2 class="comments-title">
            <?php
            printf(_nx('One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', 'xs'), number_format_i18n(get_comments_number()), '<span>' . get_the_title() . '</span>');
            ?>
        </h2>

        <?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : // are there comments to navigate through  ?>
            <nav id="comment-nav-above" class="comment-navigation" role="navigation">
                <h1 class="screen-reader-text"><?php _e('Comment navigation', 'xs'); ?></h1>
                <div class="nav-previous"><?php previous_comments_link(__('&larr; Older Comments', 'xs')); ?></div>
                <div class="nav-next"><?php next_comments_link(__('Newer Comments &rarr;', 'xs')); ?></div>
            </nav><!-- #comment-nav-above -->
        <?php endif; // check for comment navigation  ?>

        <ol class="comment-list">
            <?php
            wp_list_comments(array(
                'style' => 'ol',
                'short_ping' => true,
            ));
            ?>
        </ol><!-- .comment-list -->

        <?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : // are there comments to navigate through  ?>
            <nav id="comment-nav-below" class="comment-navigation" role="navigation">
                <h1 class="screen-reader-text"><?php _e('Comment navigation', 'xs'); ?></h1>
                <div class="nav-previous"><?php previous_comments_link(__('&larr; Older Comments', 'xs')); ?></div>
                <div class="nav-next"><?php next_comments_link(__('Newer Comments &rarr;', 'xs')); ?></div>
            </nav><!-- #comment-nav-below -->
        <?php endif; // check for comment navigation  ?>

    <?php endif; // have_comments() ?>


    <?php
// If comments are closed and there are comments, let's leave a little note, shall we?
    if (!comments_open() && '0' != get_comments_number() && post_type_supports(get_post_type(), 'comments')) :
        ?>
        <p class="no-comments"><?php _e('Comments are closed.', 'xs'); ?></p>
    <?php endif; ?>



    <?php
    $post_id = '';
    if (null === $post_id)
        $post_id = get_the_ID();
    else
        $id = $post_id;

    $commenter = wp_get_current_commenter();
    $user = wp_get_current_user();
    $user_identity = $user->exists() ? $user->display_name : '';


    $req = get_option('require_name_email');
    $aria_req = ( $req ? " aria-required='true'" : '' );

    $fields = array(
        'author' => '<div class="row"><div class="col-md-4 col-sm-12">
                                                    <label for="com_author">Name <span class="required">*</span></label>
                                                    <input type="text" id="com_author" name="author" placeholder="Name" aria-required="true" class="form-control" value="' . esc_attr($commenter['comment_author']) . '" size="30"' . $aria_req . ' ></div>',
        'email' => '<div class="col-md-4 col-sm-12">
                                                    <label for="com_email">Email <span class="required">*</span></label>
                                                    <input type="email" id="com_email" name="email" placeholder="Email" aria-required="true" class="form-control" value="' . esc_attr($commenter['comment_author_email']) . '" size="30"' . $aria_req . ' ></div>',
        'url' => ' <div class="col-md-4 col-sm-12">
                                                    <label for="com_url">Website </label>
                                                    <input type="text" id="com_url" name="url" placeholder="Website" aria-required="true" class="form-control" value="' . esc_attr($commenter['comment_author_url']) . '" size="30" ></div></div>',
    );

            if(is_user_logged_in())
            {
                $cl = 'loginformuser';
            }
            else
            {
                $cl = '';
            }
    $defaults = array(
        'fields' => $fields,
        'comment_field' => '<div><textarea name="comment" id="comment" cols="30" rows="5" placeholder="add your comment..." class="form-control"></textarea></div>',
        /** This filter is documented in wp-includes/link-template.php */
        'must_log_in' => '<p class="must-log-in">' . sprintf(__('You must be <a href="%s">logged in</a> to post a comment.'), wp_login_url(apply_filters('the_permalink', get_permalink($post_id)))) . '</p>',
        /** This filter is documented in wp-includes/link-template.php */
        'logged_in_as' => '<p class="logged-in-as">' . sprintf(__('Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>'), get_edit_user_link(), $user_identity, wp_logout_url(apply_filters('the_permalink', get_permalink($post_id)))) . '</p>',
        'id_form' => 'commentform',
        'id_submit' => 'submit',
        'title_reply' => __('Leave a Reply', 'xs'),
        'title_reply_to' => __('Leave a Reply to %s', 'xs'),
        'cancel_reply_link' => __('Cancel reply', 'xs'),
        'label_submit' => __('Post Comment', 'xs'),
        'format' => 'xhtml',
        'comment_notes_after' => '',
    );

    comment_form($defaults);
    
    
    ?>

</div><!-- #comments -->


<!--jQuery(document).ready(function($) { //noconflict wrapper
    $('#commentform input#submit').addClass('btn btn-default');
});//end noconflict-->