Advertisement
srikat

Untitled

Oct 20th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. remove_action( 'genesis_list_comments', 'genesis_default_list_comments' );
  2. add_action( 'genesis_list_comments', 'sk_default_list_comments' );
  3. /**
  4. * Output the list of comments.
  5. *
  6. * Applies the `genesis_comment_list_args` filter.
  7. *
  8. * @since 1.0.0
  9. *
  10. * @see genesis_html5_comment_callback() HTML5 callback.
  11. * @see genesis_comment_callback() XHTML callback.
  12. */
  13. function sk_default_list_comments() {
  14.  
  15. $defaults = array(
  16. 'type' => 'comment',
  17. 'avatar_size' => 48,
  18. 'format' => 'html5', // Not necessary, but a good example.
  19. 'callback' => genesis_html5() ? 'sk_html5_comment_callback' : 'genesis_comment_callback',
  20. );
  21.  
  22. $args = apply_filters( 'genesis_comment_list_args', $defaults );
  23.  
  24. wp_list_comments( $args );
  25.  
  26. }
  27.  
  28. /**
  29. * Comment callback for {@link genesis_default_list_comments()} if HTML5 is active.
  30. *
  31. * Does `genesis_before_comment` and `genesis_after_comment` actions.
  32. *
  33. * Applies `comment_author_says_text` and `genesis_comment_awaiting_moderation` filters.
  34. *
  35. * @since 2.0.0
  36. *
  37. * @param stdClass $comment Comment object.
  38. * @param array $args Comment args.
  39. * @param int $depth Depth of current comment.
  40. */
  41. function sk_html5_comment_callback( $comment, array $args, $depth ) {
  42.  
  43. $GLOBALS['comment'] = $comment; ?>
  44.  
  45. <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
  46. <article <?php echo genesis_attr( 'comment' ); ?>>
  47.  
  48. <?php do_action( 'genesis_before_comment' ); ?>
  49.  
  50. <header <?php echo genesis_attr( 'comment-header' ); ?>>
  51. <p <?php echo genesis_attr( 'comment-author' ); ?>>
  52. <?php
  53. echo get_avatar( $comment, $args['avatar_size'] );
  54.  
  55. $author = get_comment_author();
  56. $url = get_comment_author_url();
  57.  
  58. if ( ! empty( $url ) && 'http://' !== $url ) {
  59. $author = sprintf( '<a href="%s" %s>%s</a>', esc_url( $url ), genesis_attr( 'comment-author-link' ), $author );
  60. }
  61.  
  62. /**
  63. * Filter the "comment author says" text.
  64. *
  65. * Allows developer to filter the "comment author says" text so it can say something different, or nothing at all.
  66. *
  67. * @since unknown
  68. *
  69. * @param string $text Comment author says text.
  70. */
  71. $comment_author_says_text = apply_filters( 'comment_author_says_text', __( 'says', 'genesis' ) );
  72.  
  73. if ( ! empty( $comment_author_says_text ) ) {
  74. $comment_author_says_text = '<span class="says">' . $comment_author_says_text . '</span>';
  75. }
  76.  
  77. printf( '<span itemprop="name">%s</span> %s', $author, $comment_author_says_text );
  78. ?>
  79. </p>
  80.  
  81. <?php
  82. /**
  83. * Allows developer to control whether to print the comment date.
  84. *
  85. * @since 2.2.0
  86. *
  87. * @param bool $comment_date Whether to print the comment date.
  88. * @param string $post_type The current post type.
  89. */
  90. $comment_date = apply_filters( 'genesis_show_comment_date', true, get_post_type() );
  91.  
  92. if ( $comment_date ) {
  93. printf( '<p %s>', genesis_attr( 'comment-meta' ) );
  94. printf( '<time %s>', genesis_attr( 'comment-time' ) );
  95. printf( '<a href="%s" %s>', esc_url( get_comment_link( $comment->comment_ID ) ), genesis_attr( 'comment-time-link' ) );
  96. echo esc_html( get_comment_date() );
  97. echo '</a></time></p>';
  98. }
  99.  
  100. edit_comment_link( __( '(Edit)', 'genesis' ), ' ' );
  101. ?>
  102. </header>
  103.  
  104. <div <?php echo genesis_attr( 'comment-content' ); ?>>
  105. <?php if ( ! $comment->comment_approved ) : ?>
  106. <?php
  107. /**
  108. * Filter the "comment awaiting moderation" text.
  109. *
  110. * Allows developer to filter the "comment awaiting moderation" text so it can say something different, or nothing at all.
  111. *
  112. * @since unknown
  113. *
  114. * @param string $text Comment awaiting moderation text.
  115. */
  116. $comment_awaiting_moderation_text = apply_filters( 'genesis_comment_awaiting_moderation', __( 'Your comment is awaiting moderation.', 'genesis' ) );
  117. ?>
  118. <p class="alert"><?php echo $comment_awaiting_moderation_text; ?></p>
  119. <?php endif; ?>
  120.  
  121. <?php comment_text(); ?>
  122. </div>
  123.  
  124. <?php
  125. comment_reply_link( array_merge( $args, array(
  126. 'depth' => $depth,
  127. 'before' => sprintf( '<div %s>', genesis_attr( 'comment-reply' ) ),
  128. 'after' => '</div>',
  129. ) ) );
  130. ?>
  131.  
  132. <?php do_action( 'genesis_after_comment' ); ?>
  133.  
  134. </article>
  135. <?php
  136. // No ending </li> tag because of comment threading.
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement