PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/Wordpress/warp/systems/wordpress/layouts/comments.php

https://github.com/dominikkucharski/Warp-Framework
PHP | 167 lines | 104 code | 61 blank | 2 comment | 20 complexity | b4dd65971d1b35d7adff3b8af4844145 MD5 | raw file
  1. <?php if (comments_open()) : ?>
  2. <section id="comments">
  3. <?php if (get_comments_number() > 0) : ?>
  4. <h3 class="comments-meta"><?php comments_open() ? printf(__('Comments (%s)', 'warp'), get_comments_number()) : _e('Comments are closed', 'warp'); ?></h3>
  5. <?php endif; ?>
  6. <?php if (have_comments()) : ?>
  7. <?php
  8. $classes = array("level1");
  9. if (get_option('comment_registration') && !is_user_logged_in()) {
  10. $classes[] = "no-response";
  11. }
  12. if (get_option('thread_comments')) {
  13. $classes[] = "nested";
  14. }
  15. ?>
  16. <ul class="<?php echo implode(" ", $classes);?>">
  17. <?php
  18. // single comment
  19. function mytheme_comment($comment, $args, $depth) {
  20. global $user_identity;
  21. $GLOBALS['comment'] = $comment;
  22. $warp = Warp::getInstance();
  23. $_GET['replytocom'] = get_comment_ID();
  24. ?>
  25. <li>
  26. <article id="comment-<?php comment_ID(); ?>" class="comment <?php echo ($comment->user_id > 0) ? 'comment-byadmin' : '';?>">
  27. <header class="comment-head">
  28. <?php echo get_avatar($comment, $size='50', get_bloginfo('template_url').'/images/comments_avatar.png'); ?>
  29. <h4 class="author"><?php echo get_comment_author_link(); ?></h4>
  30. <p class="meta">
  31. <time datetime="<?php echo get_comment_date('Y-m-d'); ?>" pubdate><?php printf(__('%1$s at %2$s', 'warp'), get_comment_date(), get_comment_time()) ?></time>
  32. | <a class="permalink" href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)) ?>">#</a>
  33. <?php edit_comment_link(__('Edit'),'| ','') ?>
  34. </p>
  35. </header>
  36. <div class="comment-body">
  37. <div class="content"><?php comment_text(); ?></div>
  38. <?php if (comments_open()) : ?>
  39. <p class="reply"><a href="#" rel="<?php comment_ID(); ?>"><?php echo __('Reply', 'warp'); ?></a></p>
  40. <?php endif; ?>
  41. <?php if ($comment->comment_approved == '0') : ?>
  42. <p class="moderation"><?php _e('Your comment is awaiting moderation.', 'warp'); ?></p>
  43. <?php endif; ?>
  44. </div>
  45. </article>
  46. <?php
  47. unset($_GET['replytocom']);
  48. // </li> is rendered by system
  49. }
  50. wp_list_comments('type=all&callback=mytheme_comment');
  51. ?>
  52. </ul>
  53. <?php echo $this->render("_pagination", array("type"=>"comments")); ?>
  54. <?php endif; ?>
  55. <div id="respond">
  56. <h3><?php comment_form_title(__('Leave a comment', 'warp')); ?></h3>
  57. <?php if (get_option('comment_registration') && !is_user_logged_in()) : ?>
  58. <p class="user"><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'warp'), wp_login_url(get_permalink())); ?></p>
  59. <?php else : ?>
  60. <form class="short style" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post">
  61. <?php if (is_user_logged_in()) : ?>
  62. <?php global $user_identity; ?>
  63. <p class="user"><?php printf(__('Logged in as <a href="%s">%s</a>.', 'warp'), get_option('siteurl').'/wp-admin/profile.php', $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php _e('Log out of this account', 'warp'); ?>"><?php _e('Log out &raquo;', 'warp'); ?></a></p>
  64. <?php else : ?>
  65. <?php $req = get_option('require_name_email');?>
  66. <div class="author <?php if ($req) echo "required"; ?>">
  67. <input type="text" name="author" placeholder="<?php _e('Name', 'warp'); ?> <?php if ($req) echo "*"; ?>" value="<?php echo esc_attr($comment_author); ?>" size="22" <?php if ($req) echo "aria-required='true'"; ?> />
  68. </div>
  69. <div class="email <?php if ($req) echo "required"; ?>">
  70. <input type="text" name="email" placeholder="<?php _e('E-mail', 'warp'); ?> <?php if ($req) echo "*"; ?>" value="<?php echo esc_attr($comment_author_email); ?>" size="22" <?php if ($req) echo "aria-required='true'"; ?> />
  71. </div>
  72. <div class="url">
  73. <input type="text" name="url" placeholder="<?php _e('Website', 'warp'); ?>" value="<?php echo esc_attr($comment_author_url); ?>" size="22" />
  74. </div>
  75. <?php endif; ?>
  76. <div class="content">
  77. <textarea name="comment" id="comment" cols="58" rows="10" tabindex="4"></textarea>
  78. </div>
  79. <div class="actions">
  80. <input name="submit" type="submit" id="submit" tabindex="5" value="<?php _e('Submit Comment', 'warp'); ?>" />
  81. <?php comment_id_fields(); ?>
  82. </div>
  83. <?php do_action('comment_form', $post->ID); ?>
  84. </form>
  85. <?php endif; ?>
  86. </div>
  87. </section>
  88. <script type="text/javascript">
  89. jQuery(function($) {
  90. var respond = $("#respond");
  91. $("p.reply > a").bind("click", function(){
  92. var id = $(this).attr('rel');
  93. respond.find(".comment-cancelReply:first").remove();
  94. var cancel = $('<a><?php echo __("Cancel");?></a>').addClass('comment-cancelReply').attr('href', "#respond").bind("click", function(){
  95. respond.find(".comment-cancelReply:first").remove();
  96. respond.appendTo($('#comments')).find("[name=comment_parent]").val(0);
  97. return false;
  98. }).appendTo(respond.find(".actions:first"));
  99. respond.find("[name=comment_parent]").val(id);
  100. respond.appendTo($("#comment-"+id));
  101. return false;
  102. })
  103. $('form.short input[placeholder]').placeholder();
  104. });
  105. </script>
  106. <?php endif;