• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / Files / comments.php


Lines:

1 to 100 of 129
<?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 WordPress
 * @subpackage Twenty_Nineteen
 * @since Twenty Nineteen 1.0
 */

/*
 * 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;
}

$discussion = twentynineteen_get_discussion_data();
?>

<div id="comments" class="<?php echo comments_open() ? 'comments-area' : 'comments-area comments-closed'; ?>">
	<div class="<?php echo $discussion->responses > 0 ? 'comments-title-wrap' : 'comments-title-wrap no-responses'; ?>">
		<h2 class="comments-title">
		<?php
    if ( comments_open() ) {
      if ( have_comments() ) {
        _e( 'Join the Conversation', 'twentynineteen' );
      } else {
        _e( 'Leave a comment', 'twentynineteen' );
      }
    } else {
      if ( '1' == $discussion->responses ) {
        /* translators: %s: Post title. */
        printf( _x( 'One reply on &ldquo;%s&rdquo;', 'comments title', 'twentynineteen' ), get_the_title() );
      } else {
        printf(
          /* translators: 1: Number of comments, 2: Post title. */
          _nx(
            '%1$s reply on &ldquo;%2$s&rdquo;',
            '%1$s replies on &ldquo;%2$s&rdquo;',
            $discussion->responses,
            'comments title',
            'twentynineteen'
          ),
          number_format_i18n( $discussion->responses ),
          get_the_title()
        );
      }
    }
    ?>
		</h2><!-- .comments-title -->
		<?php
    // Only show discussion meta information when comments are open and available.
    if ( have_comments() && comments_open() ) {
      get_template_part( 'template-parts/post/discussion', 'meta' );
    }
    ?>
	</div><!-- .comments-title-wrap -->
	<?php
  if ( have_comments() ) :

    // Show comment form at top if showing newest comments at the top.
    if ( comments_open() ) {
      twentynineteen_comment_form( 'desc' );
    }

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

    // Show comment navigation.
    if ( have_comments() ) :
      $prev_icon     = twentynineteen_get_icon_svg( 'chevron_left', 22 );
      $next_icon     = twentynineteen_get_icon_svg( 'chevron_right', 22 );
      $comments_text = __( 'Comments', 'twentynineteen' );
      the_comments_navigation(
        array(
          'prev_text' => sprintf( '%s <span class="nav-prev-text"><span class="primary-text">%s</span> <span class="secondary-text">%s</span></span>', $prev_icon, __( 'Previous', 'twentynineteen' ), __( 'Comments', 'twentynineteen' ) ),
          'next_text' => sprintf( '<span class="nav-next-text"><span class="primary-text">%s</span> <span class="secondary-text">%s</span></span> %s', __( 'Next', 'twentynineteen' ), __( 'Comments', 'twentynineteen' ), $next_icon ),
        )
      );
    endif;
[1] [2] Next »

 View on GitHub View on Trac

Called by

    Invoked by

      Calls

      1 to 4 of 4
      • twentynineteen_comment_form() – Documentation for function.
      • twentynineteen_get_avatar_size() – Returns the size for avatars used in the theme.
      • twentynineteen_get_discussion_data() – Returns information about the current post’s discussion, with cache support.
      • twentynineteen_get_icon_svg() – Gets the SVG code for a given icon.

      Call hooks

      File name: comments.php
      Plugin ref: Twenty Nineteen
      Version: 2.4
      Deprecated?: No
      API Letters: C,P

      Published: 25th November 2019 | Last updated: 9th June 2022

      Primary Sidebar

      Information

      File name: comments.php
      Plugin ref: Twenty Nineteen
      Version: 2.4
      Deprecated?: No
      API Letters: C,P

      Footer

      WordPress a2z
      WordPress a2z
      WordPress Dynamic API Reference
      WordPress 6.1.1. PHP: 8.0.27
      WordPress a2z
      WordPress core a2z
      Genesis Theme Framework a2z
      Jetpack a2z
      WordPress develop tests
      Easy Digital Downloads a2z
      WooCommerce a2z
      Yoast SEO a2z
      WordPress Blocks

      Site:  wp-a2z.org
      © Copyright WordPress a2z 2014-2023. All rights reserved.


      Website designed and developed by Herb Miller
      Proudly powered by WordPress and oik plugins

      • Home
      • Blog
      • Sitemap
      • Sites