Advertisement
MrPauloeN

WP Less is More comments.php file content

Sep 11th, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.29 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The template for displaying comments
  4.  *
  5.  * This is the template that displays the area of the page that contains both the current comments
  6.  * and the comment form.
  7.  *
  8.  * @link https://codex.wordpress.org/Template_Hierarchy
  9.  *
  10.  * @package WordPress
  11.  * @subpackage Twenty_Seventeen
  12.  * @since 1.0
  13.  * @version 1.0
  14.  */
  15.  
  16. /*
  17.  * If the current post is protected by a password and
  18.  * the visitor has not yet entered the password we will
  19.  * return early without loading the comments.
  20.  */
  21.  
  22. if ( post_password_required() ) {
  23.     return;
  24. }
  25.  
  26.     $commenter      = wp_get_current_commenter();
  27.     $req            = get_option( 'require_name_email' );
  28.     $aria_req       = ( $req ? " aria-required='true'" : '' );
  29.     $required_text  = sprintf( ' ' . __( 'Required fields are marked %s', 'wp-less-is-more' ), '<span class="required label label-danger">*</span>' );
  30.     $user           = wp_get_current_user();
  31.     $user_identity  = $user->exists() ? $user->display_name : '';
  32.    
  33.     $fields =  array(
  34.  
  35.     'author' => '
  36.     <div class="form-group">
  37.     <label for="author" class="col-sm-2 control-label">' . __( 'Name:', 'wp-less-is-more') . ( $req ? ' <span class="required label label-danger">*</span>' : '' ) . '</label>
  38.     <div class="col-sm-9">
  39.     <input type="text" name="author" id="author" value="' . esc_attr( $commenter['comment_author'] ) . '" size="22" tabindex="3" ' . $aria_req . ' class="form-control" '. ( $req ? 'required' : '' ) .'>
  40.     </div>
  41.     </div>',
  42.  
  43.     'email' =>
  44.     '<div class="form-group">
  45.     <label for="email" class="col-sm-2 control-label">' . __( 'Email:', 'wp-less-is-more') . ( $req ? ' <span class="required label label-danger">*</span>' : '' ) . '</label>
  46.     <div class="col-sm-9">
  47.     <input type="text" name="email" id="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="22" tabindex="2" ' . $aria_req . ' class="form-control" '. ( $req ? 'required' : '' ) .'>
  48.     </div>
  49.     </div>',
  50.  
  51.     'url' =>
  52.     '<div class="form-group">
  53.     <label for="url" class="col-sm-2 control-label">' . __( 'Website:', 'wp-less-is-more' ) . '</label>
  54.     <div class="col-sm-9">
  55.     <input type="text" name="url" id="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="22" tabindex="1" class="form-control">
  56.     </div>
  57.     </div>',
  58. );
  59.     $comments_args = array(
  60.     'id_form'               => 'commentform',
  61.     'class_form'            => 'comment-form form-horizontal',
  62.     'id_submit'             => 'submit',
  63.     'class_submit'          => 'btn btn-default active',
  64.     'name_submit'           => __('Submit Response', 'wp-less-is-more' ),
  65.     'title_reply'       => __( 'Write a Reply or Comment', 'wp-less-is-more' ),
  66.     'title_reply_to'    => __( 'Write a Reply or Comment to %s', 'wp-less-is-more' ),
  67.     'title_reply_before'    => '<hr style="margin-top: 0px;"/><strong>',
  68.     'title_reply_after'     => '</strong><hr/>',
  69.     'cancel_reply_before'   => '<p class="cancel-comment-reply">',
  70.     'cancel_reply_after'    => '</p>',
  71.     'cancel_reply_link'     => __( 'Cancel reply', 'wp-less-is-more' ) . ' <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>' ,
  72.     'submit_button'         => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" >',
  73.     'submit_field'          => '<div class="form-group">
  74.     <div class="col-sm-offset-2 col-sm-10">%1$s %2$s</div>
  75.     </div>',
  76.     'format'                => 'xhtml',
  77.    
  78.     'must_log_in'           => '<p class="must-log-in">' .
  79.         sprintf(
  80.             __( 'You must be <a href="%s">logged in</a> to post a comment.', 'wp-less-is-more' ),
  81.             wp_login_url(
  82.                 apply_filters( 'the_permalink', get_permalink() )
  83.             )
  84.         ) . '</p>',
  85.  
  86.     'logged_in_as'          => '<p class="logged-in-as">' .
  87.         sprintf(
  88.             __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', 'wp-less-is-more'),
  89.                 admin_url( 'profile.php' ), $user_identity, wp_logout_url(
  90.                     apply_filters( 'the_permalink', get_permalink( ) )
  91.                 )
  92.         ) . '</p>',
  93.  
  94.     'comment_notes_before'  => '<p class="comment-notes">' .
  95.     __( 'Your email address will not be published.', 'wp-less-is-more') . ( $req ? $required_text : '' ) .
  96.     '</p>',
  97.  
  98.     'comment_notes_after'   => '<div class="form-group"><div class="col-sm-9 col-sm-offset-2">' .
  99.         sprintf(
  100.             __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s', 'wp-less-is-more'),
  101.               '<code>' . allowed_tags() . '</code>'
  102.         ) . '</div></div>',
  103.    
  104.     'fields'                => apply_filters( 'comment_form_default_fields', $fields ),
  105.     'comment_field'         =>
  106.     '<div class="form-group">
  107.     <div class="col-sm-9 col-sm-offset-2">
  108.     <textarea name="comment" class="form-control" rows="3" ' . $aria_req . ' '. ( $req ? 'required' : '' ) .'></textarea>
  109.     </div>
  110.     </div>',
  111.  
  112. );
  113.  
  114.     // If comments are closed and there are no comments, let's leave a little note, shall we?
  115.     if ( !comments_open() && !get_comments_number() ) : ?>
  116.         <div class="well well-sm"><?php _e( 'Comments are closed for this post.', 'wp-less-is-more' ); ?></div>
  117.     <?php
  118.     endif;
  119.  
  120.     // You can start editing here -- including this comment!
  121.     if ( have_comments() ) : ?>
  122.    
  123. <div id="comments" class="comments-area panel panel-info"> 
  124.    
  125.     <div class="panel-heading" role="button" data-toggle="collapse" href="#collapseListComments" aria-expanded="true" aria-controls="collapseListComments">
  126.        
  127.         <h2 class="comments-title panel-title">
  128.             <?php
  129.                 $comments_number = get_comments_number();
  130.                 if ( '1' === $comments_number ) {
  131.                     /* translators: %s: post title */
  132.                     printf( _x( 'One Reply to %s', 'comments title', 'wp-less-is-more' ), '&ldquo;' . get_the_title() . '&rdquo;' );
  133.                 } else {
  134.                     printf(
  135.                         /* translators: %s 1: number of comments, %s 2: post title */
  136.                         _nx(
  137.                             '%s Reply to %s',
  138.                             '%s Replies to %s',
  139.                             $comments_number,
  140.                             'comments title',
  141.                             'wp-less-is-more'
  142.                         ),
  143.                         '<span class="badge">' . number_format_i18n( get_comments_number() ) . '</span>',
  144.                         '&ldquo;' . get_the_title() . '&ldquo;'
  145.                     );
  146.                 }
  147.             ?>&nbsp;<span class="glyphicon glyphicon-chevron-up pull-right" aria-hidden="true"></span><span class="glyphicon glyphicon-chevron-down pull-right" aria-hidden="true"></span>&nbsp;
  148.         </h2>      
  149.     </div> 
  150. <div id="collapseListComments" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="collapseListComments" aria-expanded="true">
  151.     <div id="comments-list" class="panel-body ">
  152.         <ul class="comment-list media-list list-group list-unstyled">
  153.             <?php
  154.                 wp_list_comments( array(
  155.                     'avatar_size' => 40,
  156.                     'style'       => 'ul',
  157.                     'short_ping'  => true,
  158.                     'reply_text'  => __( 'Reply', 'wp-less-is-more' ),
  159.                     'callback'      => 'wp_less_is_more__custom_comments_list_template',
  160.                 ) );
  161.             ?>
  162.         </ul>
  163.  
  164. <?php // Are there comments to navigate through?
  165.        if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) {
  166. ?>
  167.         <nav aria-label="...">
  168.         <ul class="pager">
  169.             <li><?php previous_comments_link( __( 'Older Comments', 'wp-less-is-more'  ) ); ?></li>
  170.             <li><?php next_comments_link( __( 'Newer Comments', 'wp-less-is-more'  ) ); ?></li>
  171.         </ul>
  172.         </nav><!-- .comment-navigation -->
  173.        
  174.        <?php } // Check for comment navigation?>
  175.     </div> 
  176. </div><!-- .collapse comments list -->
  177. <?php
  178.     endif; // Check for have_comments().
  179.    
  180.     comment_form( $comments_args );
  181.    
  182. // You have to close panel block anyway by checking of comments status
  183.     if  ( have_comments() ):
  184.    
  185. echo '</div>
  186. <!-- End panel panel-info if comments are closed but have some -->';
  187. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement