Guest User

comments

a guest
Apr 25th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.36 KB | None | 0 0
  1. <?php
  2.  
  3. //removing the comments sidewide
  4. if ((td_util::get_option('tds_disable_comments_sidewide') == '') && post_type_supports(get_post_type(), 'comments')) {
  5.  
  6. if (post_password_required()) {
  7. return;
  8. }
  9. ?>
  10. <div class="comments" id="comments">
  11. <?php
  12. comment_form($defaults);
  13. //comment_form();
  14. if (have_comments()) {
  15.  
  16. // on Newspaper the css class 'td-pb-padding-side' is not applied
  17. $td_css_cls_pb_padding_side = '';
  18. $td_css_cls_block_title = '';
  19. $global_block_template_id = td_options::get('tds_global_block_template', 'td_block_template_1');
  20.  
  21. if ('Newsmag' == TD_THEME_NAME) {
  22. $td_css_cls_pb_padding_side = 'td-pb-padding-side ';
  23. } else if ('Newspaper' == TD_THEME_NAME) {
  24. $td_css_cls_block_title = 'td-block-title';
  25.  
  26. if ($global_block_template_id === 'td_block_template_1') {
  27. $td_css_cls_block_title = 'block-title';
  28. }
  29. }
  30.  
  31. $num_comments = get_comments_number(); // get_comments_number returns only a numeric value
  32. if ($num_comments > 1) {
  33. $td_comments_no_text = $num_comments . ' ' . __td('COMMENTS', TD_THEME_NAME);
  34. } else {
  35. $td_comments_no_text = __td('1 COMMENT', TD_THEME_NAME);
  36. }
  37. ?>
  38.  
  39. <div class="td-comments-title-wrap <?php echo $td_css_cls_pb_padding_side . $global_block_template_id?>">
  40. <h4 class="td-comments-title <?php echo $td_css_cls_block_title?>"><span><?php echo $td_comments_no_text?></span></h4>
  41. </div>
  42.  
  43. <ol class="comment-list <?php echo $td_css_cls_pb_padding_side ?>">
  44. <?php wp_list_comments(array('callback' => 'td_comment')); ?>
  45. </ol>
  46. <div class="comment-pagination">
  47. <?php previous_comments_link(); ?>
  48. <?php next_comments_link(); ?>
  49. </div>
  50.  
  51. <?php }
  52.  
  53. if (!comments_open() and (get_comments_number() > 0)) { ?>
  54. <p class="td-pb-padding-side"><?php _etd( 'Comments are closed.', TD_THEME_NAME ); ?></p>
  55. <?php }
  56.  
  57. $commenter = wp_get_current_commenter();
  58. $req = get_option( 'require_name_email' );
  59. $aria_req = ( $req ? " aria-required='true'" : '' );
  60.  
  61. $user = wp_get_current_user();
  62. $user_identity = $user->exists() ? $user->display_name : '';
  63.  
  64. $fields = array(
  65. 'author' =>
  66. '<div class="comment-form-input-wrap td-form-author">
  67. <input class="" id="author" name="author" placeholder="' . __td('Name:', TD_THEME_NAME) . ( $req ? '*' : '' ) . '" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" ' . $aria_req . ' />
  68. <div class="td-warning-author">' . __td('Please enter your name here', TD_THEME_NAME) . '</div>
  69. </div>',
  70.  
  71. 'email' =>
  72. '<div class="comment-form-input-wrap td-form-email">
  73. <input class="" id="email" name="email" placeholder="' . __td('Email:', TD_THEME_NAME) . ( $req ? '*' : '' ) . '" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" ' . $aria_req . ' />
  74. <div class="td-warning-email-error">' . __td('You have entered an incorrect email address!', TD_THEME_NAME) . '</div>
  75. <div class="td-warning-email">' . __td('Please enter your email address here', TD_THEME_NAME) . '</div>
  76. </div>',
  77.  
  78. 'url' =>
  79. '<div class="comment-form-input-wrap td-form-url">
  80. <input class="" id="url" name="url" placeholder="' . __td('Website:', TD_THEME_NAME) . '" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" />
  81. </div>',
  82. );
  83.  
  84. $defaults = array('fields' => apply_filters('comment_form_default_fields', $fields));
  85. $defaults['comment_field'] =
  86. '<div class="clearfix"></div>
  87. <div class="comment-form-input-wrap td-form-comment">
  88. <textarea placeholder="' . __td('Comment:', TD_THEME_NAME) . '" id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>
  89. <div class="td-warning-comment">' . __td('Please enter your comment!', TD_THEME_NAME) . '</div>
  90. </div>
  91. ';
  92.  
  93. $defaults['comment_notes_before'] = '';
  94. $defaults['comment_notes_after'] = '';
  95. $defaults['title_reply'] = __td('LEAVE A REPLY', TD_THEME_NAME);
  96. $defaults['label_submit'] = __td('Post Comment', TD_THEME_NAME);
  97. $defaults['cancel_reply_link'] = __td('Cancel reply', TD_THEME_NAME);
  98.  
  99. // login with our login modal when you want to write a comment
  100.  
  101. if (td_util::get_option('tds_login_sign_in_widget') == 'show') {
  102. $url = '#login-form';
  103. } else {
  104. $post_id = get_the_ID();
  105. $url = wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) );
  106. }
  107. $defaults['must_log_in'] = '<p class="must-log-in td-login-comment"><a class="td-login-modal-js" data-effect="mpf-td-login-effect" href="' . $url .'">' . __td('Log in to leave a comment', TD_THEME_NAME) . ' </a></p>';
  108.  
  109. $defaults['logged_in_as'] = '<p class="logged-in-as">' . sprintf(
  110. /* 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */
  111. '<a href="%1$s" aria-label="%2$s">' . __td('Logged in as', TD_THEME_NAME) . ' %3$s</a>. <a href="%4$s">' . __td('Log out?', TD_THEME_NAME) . '</a>',
  112. get_edit_user_link(),
  113. /* %s: user name */
  114. esc_attr( sprintf( __td( 'Logged in as %s. Edit your profile.' , TD_THEME_NAME), $user_identity ) ),
  115. $user_identity,
  116. wp_logout_url( apply_filters( 'the_permalink', get_permalink( get_the_ID() ) ) )
  117. ) . '</p>';
  118.  
  119.  
  120.  
  121. ?>
  122. </div> <!-- /.content -->
  123. <?php
  124. }
  125.  
  126.  
  127. //end removing the comments sidewide
  128. /**
  129. * Custom callback for outputting comments
  130. *
  131. * @return void
  132. * @author tagdiv
  133. */
  134. function td_comment( $comment, $args, $depth ) {
  135. $GLOBALS['comment'] = $comment;
  136.  
  137. $td_isPingTrackbackClass = '';
  138.  
  139. if($comment->comment_type == 'pingback') {
  140. $td_isPingTrackbackClass = 'pingback';
  141. }
  142.  
  143. if($comment->comment_type == 'trackback') {
  144. $td_isPingTrackbackClass = 'trackback';
  145. }
  146.  
  147. if (!empty($comment->comment_author_email)) {
  148. $td_comment_auth_email = $comment->comment_author_email;
  149. } else {
  150. $td_comment_auth_email = '';
  151. }
  152.  
  153. $td_article_date_unix = @strtotime("{$comment->comment_date_gmt} GMT");
  154. //print_r($td_article_date_unix);
  155.  
  156.  
  157. ?>
  158. <li class="comment <?php echo $td_isPingTrackbackClass ?>" id="comment-<?php comment_ID() ?>">
  159. <article>
  160. <footer>
  161. <?php
  162. //echo get_template_directory_uri() . "/images/avatar.jpg";
  163. //echo get_avatar($td_comment_auth_email, 50, get_template_directory_uri() . "/images/avatar.jpg");
  164. echo get_avatar($td_comment_auth_email, 50);
  165. ?>
  166. <cite><?php comment_author_link() ?></cite>
  167.  
  168. <a class="comment-link" href="#comment-<?php comment_ID() ?>">
  169. <time pubdate="<?php echo $td_article_date_unix ?>"><?php comment_date() ?> at <?php comment_time() ?></time>
  170. </a>
  171. </footer>
  172.  
  173. <div class="comment-content">
  174. <?php if ($comment->comment_approved == '0') { ?>
  175. <em><?php echo __td('Your comment is awaiting moderation', TD_THEME_NAME); ?></em>
  176. <?php }
  177. comment_text(); ?>
  178. </div>
  179.  
  180. <div class="comment-meta" id="comment-<?php comment_ID() ?>">
  181. <?php comment_reply_link(array_merge( $args, array(
  182. 'depth' => $depth,
  183. 'max_depth' => $args['max_depth'],
  184. 'reply_text' => __td('Reply', TD_THEME_NAME),
  185. 'login_text' => __td('Log in to leave a comment', TD_THEME_NAME)
  186. )))
  187. ?>
  188. </div>
  189. </article>
  190. <?php
  191.  
  192. }
  193. ?>
Advertisement
Add Comment
Please, Sign In to add comment