Skip to content

Instantly share code, notes, and snippets.

@mustafix
Created July 5, 2020 16:32
Show Gist options
  • Save mustafix/dd360c01847d26243df881e246e8e304 to your computer and use it in GitHub Desktop.
Save mustafix/dd360c01847d26243df881e246e8e304 to your computer and use it in GitHub Desktop.
<?php
/**
* The template for displaying comments
*
* This is the template that displays the area of the page that contains both the current comments
* and the comment form.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package theme
*/
/*
* 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;
}
/*-------------------------------------------------------
Comment From message field position change
--------------------------------------------------------*/
/*
// Using this script in funcitons.php
function verum_comment_form_field($fields){
$comment_field = $fields['comment'];
unset($fields['comment']);
$fields['comment'] = $comment_field;
return $fields;
}
add_filter('comment_form_fields','verum_comment_form_field');
*/
?>
<div id="comments" class="comments-area">
<?php
// You can start editing here -- including this comment!
if ( have_comments() ) :
?>
<h2 class="comments-title">
<?php
$theme_comment_count = get_comments_number();
if ( '1' === $theme_comment_count ) {
printf(
/* translators: 1: title. */
esc_html__( 'One thought on &ldquo;%1$s&rdquo;', 'theme' ),
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
);
} else {
printf(
/* translators: 1: comment count number, 2: title. */
esc_html( _nx( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', $theme_comment_count, 'comments title', 'theme' ) ),
number_format_i18n( $theme_comment_count ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'<span>' . wp_kses_post( get_the_title() ) . '</span>'
);
}
?>
</h2><!-- .comments-title -->
<?php the_comments_navigation(); ?>
<ol class="comment-list">
<?php
wp_list_comments(
array(
'style' => 'ol',
'short_ping' => true,
'avatar_size' => 128,
)
);
?>
</ol><!-- .comment-list -->
<?php
the_comments_navigation();
// If comments are closed and there are comments, let's leave a little note, shall we?
if ( ! comments_open() ) :
?>
<p class="no-comments"><?php esc_html_e( 'Comments are closed.', 'theme' ); ?></p>
<?php
endif;
endif; // Check for have_comments().
?>
<?php
$theme_comment_fields = array();
$theme_name_field_placeholder = __('Name','theme');
$theme_email_field_placeholder = __('Email','theme');
$theme_website_field_placeholder = __('Website','theme');
$theme_comment_field_placeholder = __('Comment','theme');
$theme_send_field_placeholder = __('Submit','theme');
$theme_comment_fields['name']=<<<EOD
<div class="row">
<div class=" col-md-4">
<div class="form-group">
<input type="text" id="name" name="name" class="form-control" placeholder="{$theme_name_field_placeholder}*" required="">
</div>
</div>
EOD;
$theme_comment_fields['email'] = <<<EOD
<div class=" col-md-4">
<div class="form-group ">
<input type="email" id="email" name="email" class="form-control" placeholder="{$theme_email_field_placeholder}*" required="">
</div>
</div>
EOD;
$theme_comment_fields['website'] = <<<EOD
<div class=" col-md-4">
<div class="form-group">
<input type="text" id="website" name="website" class="form-control" placeholder="{$theme_website_field_placeholder}" required="">
</div>
</div>
</div>
EOD;
$theme_comment_field = <<<EOD
<div class="form-group">
<div class="controls">
<textarea id="comment" name="comment" rows="6" placeholder="{$theme_comment_field_placeholder}*" class="form-control" required=""></textarea>
</div>
</div>
EOD;
$theme_comment_submit_button = <<<EOD
<div class="text-center mt-md-5">
<button type="submit" class="btn btn-black">{$theme_send_field_placeholder}</button>
</div>
EOD;
$theme_comment_form_arguments = array(
'fields' => $theme_comment_fields,
'comment_field' => $theme_comment_field,
'submit_button' => $theme_comment_submit_button,
'class_form' => 'comments-form text-left',
'comment_notes_before' =>'<p></p>',
'comment_notes_after' =>'<p>'.__('Your email address will not be published. Required fields are marked','theme').' *</p>',
'title_reply' =>''
);
comment_form($theme_comment_form_arguments);
?>
</div><!-- #comments -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment