PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/themes/OneMozilla/comments.php

https://github.com/fvignals/One-Mozilla-blog
PHP | 104 lines | 83 code | 15 blank | 6 comment | 25 complexity | 18a8526e04fe7c738fea8adb3ab8590b MD5 | raw file
  1. <?php // Do not delete these lines
  2. if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
  3. die ('Please do not load this page directly. Thanks!');
  4. /* This variable is for alternating comment background */
  5. $oddcomment = 'alt';
  6. ?>
  7. <?php /* You can start editing here. */ ?>
  8. <?php if ( have_comments() || comments_open() || pings_open() ) : // If there are comments OR comments are open OR pings are open ?>
  9. <section id="comments">
  10. <?php if ( post_password_required() ) : ?>
  11. <p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'onemozilla' ); ?></p>
  12. </section><!-- #comments -->
  13. <?php
  14. /* Stop the rest of comments.php from being processed,
  15. * but don't kill the script entirely -- we still have
  16. * to fully load the template.
  17. */
  18. return;
  19. endif;
  20. ?>
  21. <header class="comments-head">
  22. <h2><?php if($comment_count > 0) { printf(_n( 'One response', '%d responses', $comment_count, 'onemozilla'), $comment_count); } else { _e('No responses yet'); } ?></h2>
  23. <?php if (comments_open()) : ?><p class="cmt-post"><a href="#respond"><?php _e('Post a comment','onemozilla'); ?></a></p><?php endif; ?>
  24. </header>
  25. <?php if ( have_comments() ) : // If there are comments ?>
  26. <ol id="comment-list" class="hfeed <?php if (get_option('show_avatars')) echo 'av'; // provides a style hook when avatars are enabled ?>">
  27. <?php wp_list_comments('type=all&style=ol&callback=onemozilla_comment'); // Comment template is in functions.php ?>
  28. </ol>
  29. <?php if ( get_comment_pages_count() > 1 ) : // If comment paging is enabled and there are enough comments to paginate, show the comment paging ?>
  30. <p class="pages"><?php _e('More comments:', 'onemozilla'); paginate_comments_links(); ?></p>
  31. <?php endif; ?>
  32. <?php endif; ?>
  33. <?php if ( !comments_open() && pings_open() ) : // If comments are closed but pings are open ?>
  34. <p class="comments-closed pings-open">
  35. <?php
  36. /* L10N: 'trackbacks' are when another website refers to this blog post with a link notification */
  37. printf( __( 'Comments are closed, but <a href="%1$s" title="Trackback URL for this post">trackbacks</a> are open.', 'onemozilla' ), get_trackback_url() ); ?>
  38. </p>
  39. <?php endif; ?>
  40. <?php if (comments_open()) : ?>
  41. <div id="respond">
  42. <?php if ( get_option('comment_registration') ) : // If registration is required and you're not logged in, show a message ?>
  43. <p><?php printf( __('You must be <a href="%s">logged in</a> to post a comment.', 'onemozilla'), esc_attr(wp_login_url(get_permalink())) ); ?></p>
  44. <?php else : // else show the form ?>
  45. <form id="comment-form" action="<?php echo esc_attr(get_option('siteurl')); ?>/wp-comments-post.php" method="post">
  46. <fieldset>
  47. <legend><span><?php comment_form_title( __('Post Your Comment'), __('Reply to %s' ) ); ?></span></legend>
  48. <p id="cancel-comment-reply"><?php cancel_comment_reply_link('Cancel Reply'); ?></p>
  49. <ol>
  50. <?php if ( $user_ID ) : ?>
  51. <li class="self"><?php printf( __( 'You are logged in as <a href="%1$s">%2$s</a>. <a class="logout" href="%3$s">Log out?</a>', 'onemozilla' ), admin_url( 'profile.php' ), esc_html($user_identity), wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ); ?></li>
  52. <?php else : ?>
  53. <li id="cmt-name">
  54. <label for="author"><?php _e('Name', 'onemozilla'); ?> <?php if ($req) : ?><span class="note"><?php _e('(required)', 'onemozilla'); ?></span><?php endif; ?></label>
  55. <input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="25" <?php if ($req) echo "required aria-required='true'"; ?>>
  56. </li>
  57. <li id="cmt-email">
  58. <label for="email"><?php _e('E-mail', 'onemozilla'); ?> <?php if ($req) : ?><span class="note"><?php _e('(required, will not be published)', 'onemozilla'); ?></span><?php endif; ?></label>
  59. <input type="email" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="25" <?php if ($req) echo "required aria-required='true'"; ?>>
  60. </li>
  61. <li id="cmt-web">
  62. <label for="url"><?php _e('Website', 'onemozilla'); ?></label>
  63. <input type="url" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="25">
  64. </li>
  65. <?php endif; ?>
  66. <li id="cmt-cmt"><label for="comment"><?php _e('Your comment', 'onemozilla'); ?></label> <textarea name="comment" id="comment" cols="50" rows="10"></textarea></li>
  67. <li id="comment-submit"><button name="submit" class="button-blue" type="submit"><?php _e('Submit Comment', 'onemozilla'); ?></button>
  68. <?php comment_id_fields(); ?>
  69. <?php do_action('comment_form', $post->ID); ?></li>
  70. </ol>
  71. </fieldset>
  72. </form>
  73. <?php endif; // end if reg required and not logged in ?>
  74. </div><?php // end #respond ?>
  75. <?php if (get_option('require_name_email')) :
  76. wp_enqueue_script('fc-checkcomment', get_template_directory_uri() . '/js/fc-checkcomment.js');
  77. wp_localize_script('fc-checkcomment', 'objectL10n', array(
  78. 'nonameemail' => __('You must provide a name and e-mail (your e-mail address won’t be published).'),
  79. 'noname' => __('You must provide a name.'),
  80. 'noemail' => __('You must provide an e-mail address (it won’t be published).'),
  81. 'bademail' => __('The e-mail address you entered doesn’t look like a complete e-mail address. It should look like “yourname@example.com”.'),
  82. 'nocomment' => __('You must enter a comment.')
  83. ) );
  84. ?>
  85. <script type="text/javascript">jQuery("#comment-form").submit(function() { return fc_checkform(<?php if ($req) : echo "'req'"; endif; ?>); });</script>
  86. <?php endif; ?>
  87. <?php endif; // end if comments open ?>
  88. </section><?php // end #comments ?>
  89. <?php endif; // if you delete this the sky will fall on your head ?>