Simplify comments, use core comment form and list
This commit is contained in:
@@ -19,7 +19,6 @@ $roots_includes = array(
|
|||||||
'lib/titles.php', // Page titles
|
'lib/titles.php', // Page titles
|
||||||
'lib/nav.php', // Custom nav modifications
|
'lib/nav.php', // Custom nav modifications
|
||||||
'lib/gallery.php', // Custom [gallery] modifications
|
'lib/gallery.php', // Custom [gallery] modifications
|
||||||
'lib/comments.php', // Custom comments modifications
|
|
||||||
'lib/scripts.php', // Scripts and stylesheets
|
'lib/scripts.php', // Scripts and stylesheets
|
||||||
'lib/extras.php', // Custom functions
|
'lib/extras.php', // Custom functions
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Use Bootstrap's media object for listing comments
|
|
||||||
*
|
|
||||||
* @link http://getbootstrap.com/components/#media
|
|
||||||
*/
|
|
||||||
class Roots_Walker_Comment extends Walker_Comment {
|
|
||||||
function start_lvl(&$output, $depth = 0, $args = array()) {
|
|
||||||
$GLOBALS['comment_depth'] = $depth + 1; ?>
|
|
||||||
<ul <?php comment_class('media list-unstyled comment-' . get_comment_ID()); ?>>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function end_lvl(&$output, $depth = 0, $args = array()) {
|
|
||||||
$GLOBALS['comment_depth'] = $depth + 1;
|
|
||||||
echo '</ul>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_el(&$output, $comment, $depth = 0, $args = array(), $id = 0) {
|
|
||||||
$depth++;
|
|
||||||
$GLOBALS['comment_depth'] = $depth;
|
|
||||||
$GLOBALS['comment'] = $comment;
|
|
||||||
|
|
||||||
if (!empty($args['callback'])) {
|
|
||||||
call_user_func($args['callback'], $comment, $args, $depth);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
extract($args, EXTR_SKIP); ?>
|
|
||||||
|
|
||||||
<li id="comment-<?php comment_ID(); ?>" <?php comment_class('media comment-' . get_comment_ID()); ?>>
|
|
||||||
<?php include(locate_template('templates/comment.php')); ?>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
|
|
||||||
function end_el(&$output, $comment, $depth = 0, $args = array()) {
|
|
||||||
if (!empty($args['end-callback'])) {
|
|
||||||
call_user_func($args['end-callback'], $comment, $args, $depth);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Close ".media-body" <div> located in templates/comment.php, and then the comment's <li>
|
|
||||||
echo "</div></li>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function roots_get_avatar($avatar, $type) {
|
|
||||||
if (!is_object($type)) { return $avatar; }
|
|
||||||
|
|
||||||
$avatar = str_replace("class='avatar", "class='avatar pull-left media-object", $avatar);
|
|
||||||
return $avatar;
|
|
||||||
}
|
|
||||||
add_filter('get_avatar', 'roots_get_avatar', 10, 2);
|
|
||||||
@@ -25,7 +25,7 @@ function roots_setup() {
|
|||||||
|
|
||||||
// Add HTML5 markup for captions
|
// Add HTML5 markup for captions
|
||||||
// http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5
|
// http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5
|
||||||
add_theme_support('html5', array('caption'));
|
add_theme_support('html5', array('caption', 'comment-form', 'comment-list'));
|
||||||
|
|
||||||
// Tell the TinyMCE editor to use a custom stylesheet
|
// Tell the TinyMCE editor to use a custom stylesheet
|
||||||
add_editor_style('/assets/css/editor-style.css');
|
add_editor_style('/assets/css/editor-style.css');
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php echo get_avatar($comment, $size = '64'); ?>
|
|
||||||
<div class="media-body">
|
|
||||||
<h4 class="media-heading"><?php echo get_comment_author_link(); ?></h4>
|
|
||||||
<time datetime="<?php echo get_comment_date('c'); ?>"><a href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)); ?>"><?php printf(__('%1$s', 'roots'), get_comment_date(), get_comment_time()); ?></a></time>
|
|
||||||
<?php edit_comment_link(__('(Edit)', 'roots'), '', ''); ?>
|
|
||||||
|
|
||||||
<?php if ($comment->comment_approved == '0') : ?>
|
|
||||||
<div class="alert alert-info">
|
|
||||||
<?php _e('Your comment is awaiting moderation.', 'roots'); ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php comment_text(); ?>
|
|
||||||
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
|
|
||||||
@@ -4,12 +4,12 @@
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<section id="comments">
|
<section id="comments" class="comments">
|
||||||
<?php if (have_comments()) : ?>
|
<?php if (have_comments()) : ?>
|
||||||
<h3><?php printf(_n('One Response to “%2$s”', '%1$s Responses to “%2$s”', get_comments_number(), 'roots'), number_format_i18n(get_comments_number()), get_the_title()); ?></h3>
|
<h2><?php printf(_nx('One response to “%2$s”', '%1$s responses to “%2$s”', get_comments_number(), 'comments title', 'roots'), number_format_i18n(get_comments_number()), '<span>' . get_the_title() . '</span>'); ?></h2>
|
||||||
|
|
||||||
<ol class="media-list">
|
<ol class="comment-list">
|
||||||
<?php wp_list_comments(array('walker' => new Roots_Walker_Comment)); ?>
|
<?php wp_list_comments(array('style' => 'ol', 'short_ping' => true)); ?>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : ?>
|
<?php if (get_comment_pages_count() > 1 && get_option('page_comments')) : ?>
|
||||||
@@ -24,54 +24,13 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
<?php endif; // have_comments() ?>
|
||||||
|
|
||||||
<?php if (!comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) : ?>
|
<?php if (!comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments')) : ?>
|
||||||
<div class="alert alert-warning">
|
|
||||||
<?php _e('Comments are closed.', 'roots'); ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php elseif(!comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) : ?>
|
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
<?php _e('Comments are closed.', 'roots'); ?>
|
<?php _e('Comments are closed.', 'roots'); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</section><!-- /#comments -->
|
|
||||||
|
|
||||||
<section id="respond">
|
<?php comment_form(); ?>
|
||||||
<?php if (comments_open()) : ?>
|
</section>
|
||||||
<h3><?php comment_form_title(__('Leave a Reply', 'roots'), __('Leave a Reply to %s', 'roots')); ?></h3>
|
|
||||||
<p class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></p>
|
|
||||||
<?php if (get_option('comment_registration') && !is_user_logged_in()) : ?>
|
|
||||||
<p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'roots'), wp_login_url(get_permalink())); ?></p>
|
|
||||||
<?php else : ?>
|
|
||||||
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
|
|
||||||
<?php if (is_user_logged_in()) : ?>
|
|
||||||
<p>
|
|
||||||
<?php printf(__('Logged in as <a href="%s/wp-admin/profile.php">%s</a>.', 'roots'), get_option('siteurl'), $user_identity); ?>
|
|
||||||
<a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php _e('Log out of this account', 'roots'); ?>"><?php _e('Log out »', 'roots'); ?></a>
|
|
||||||
</p>
|
|
||||||
<?php else : ?>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="author"><?php _e('Name', 'roots'); if ($req) _e(' (required)', 'roots'); ?></label>
|
|
||||||
<input type="text" class="form-control" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" <?php if ($req) echo 'aria-required="true"'; ?>>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="email"><?php _e('Email (will not be published)', 'roots'); if ($req) _e(' (required)', 'roots'); ?></label>
|
|
||||||
<input type="email" class="form-control" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" <?php if ($req) echo 'aria-required="true"'; ?>>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="url"><?php _e('Website', 'roots'); ?></label>
|
|
||||||
<input type="url" class="form-control" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22">
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="comment"><?php _e('Comment', 'roots'); ?></label>
|
|
||||||
<textarea name="comment" id="comment" class="form-control" rows="5" aria-required="true"></textarea>
|
|
||||||
</div>
|
|
||||||
<p><input name="submit" class="btn btn-primary" type="submit" id="submit" value="<?php _e('Submit Comment', 'roots'); ?>"></p>
|
|
||||||
<?php comment_id_fields(); ?>
|
|
||||||
<?php do_action('comment_form', $post->ID); ?>
|
|
||||||
</form>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</section><!-- /#respond -->
|
|
||||||
|
|||||||
Reference in New Issue
Block a user