PageRenderTime 55ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/views/comments.php

https://github.com/tgharoutunian/wp-social
PHP | 159 lines | 147 code | 12 blank | 0 comment | 26 complexity | 1593cb80b35920c32fe923ff86fc05c4 MD5 | raw file
  1. <div id="social">
  2. <?php
  3. ob_start();
  4. ?>
  5. <?php if (post_password_required()): ?>
  6. <p class="nopassword"><?php _e('This post is password protected. Enter the password to view any comments.', 'social'); ?></p>
  7. <?php else: ?>
  8. <div class="social-post">
  9. <div id="loading" style="display:none">
  10. <input type="hidden" id="reload_url" value="<?php echo esc_url(home_url('index.php?social_controller=auth&social_action=reload_form&redirect_to='.get_permalink(get_the_ID()).'&post_id='.get_the_ID())); ?>" />
  11. <?php _e('Logging In...', 'social'); ?>
  12. </div>
  13. <?php
  14. if (comments_open()) {
  15. if (get_option('comment_registration') and !is_user_logged_in()) {
  16. ?>
  17. <p class="must-log-in"><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'social'), wp_login_url(apply_filters('the_permalink', get_permalink(get_the_ID())))); ?></p>
  18. <?php
  19. do_action('comment_form_must_log_in_after');
  20. }
  21. echo Social_Comment_Form::instance(get_the_ID());
  22. }
  23. else {
  24. do_action('comment_form_comments_closed');
  25. ?>
  26. <p class="nocomments"><?php _e('Comments are closed.', 'social'); ?></p>
  27. <?php
  28. }
  29. ?>
  30. </div>
  31. <?php
  32. $form = ob_get_clean();
  33. ob_start();
  34. ?>
  35. <div id="social-tabs-comments">
  36. <?php
  37. if (have_comments()):
  38. $groups = array();
  39. $social_items = array();
  40. if (get_comments_number()) {
  41. $comments = apply_filters('social_comments_array', $comments, $post->ID);
  42. if (isset($comments['social_items'])) {
  43. $social_items = $comments['social_items'];
  44. unset($comments['social_items']);
  45. }
  46. if (isset($comments['social_groups'])) {
  47. $groups = $comments['social_groups'];
  48. unset($comments['social_groups']);
  49. }
  50. }
  51. $last_reply_time = 0;
  52. if (count($comments)) {
  53. foreach ($comments as $key => $comment) {
  54. $time = strtotime($comment->comment_date_gmt);
  55. if ($time > $last_reply_time) {
  56. $last_reply_time = $time;
  57. }
  58. }
  59. }
  60. if (count($social_items)) {
  61. $latest_item = 0;
  62. foreach ($social_items as $service => $items) {
  63. foreach ($items as $comment) {
  64. if ($latest_item === 0) {
  65. $latest_item = strtotime($comment->comment_date_gmt);
  66. }
  67. else {
  68. $time = strtotime($comment->comment_date_gmt);
  69. if ($time > $latest_item) {
  70. $latest_item = $time;
  71. }
  72. }
  73. }
  74. }
  75. if ($latest_item > $last_reply_time) {
  76. $last_reply_time = $latest_item;
  77. }
  78. }
  79. Social::add_social_items_count($social_items, $groups);
  80. ?>
  81. <ul class="social-nav social-clearfix">
  82. <li class="social-all social-tab-main<?php echo (!isset($_GET['social_tab']) ? ' social-current-tab' : ''); ?>"><a href="#" rel="social-all"><span><?php comments_number(__('0 Replies', 'social'), __('1 Reply', 'social'), __('% Replies', 'social')); ?></span></a></li>
  83. <li class="social-wordpress<?php echo ((isset($_GET['social_tab']) and $_GET['social_tab'] == 'wordpress') ? ' social-current-tab' : ''); ?>"><a href="#" rel="wordpress"><span><?php printf(_n('1 Comment', '%1$s Comments', (isset($groups['wordpress']) ? $groups['wordpress'] : 0), 'social'), (isset($groups['wordpress']) ? $groups['wordpress'] : 0)); ?></span></a></li>
  84. <li class="social-twitter<?php echo ((isset($_GET['social_tab']) and $_GET['social_tab'] == 'social-twitter') ? ' social-current-tab' : ''); ?>"><a href="#" rel="social-twitter"><span><?php printf(_n('1 Tweet', '%1$s Tweets', (isset($groups['social-twitter']) ? $groups['social-twitter'] : 0), 'social'), (isset($groups['social-twitter']) ? $groups['social-twitter'] : 0)); ?></span></a></li>
  85. <li class="social-facebook<?php echo ((isset($_GET['social_tab']) and $_GET['social_tab'] == 'social-facebook') ? ' social-current-tab' : ''); ?>"><a href="#" rel="social-facebook"><span><?php printf(_n('1 Facebook', '%1$s Facebook', (isset($groups['social-facebook']) ? $groups['social-facebook'] : 0), 'social'), (isset($groups['social-facebook']) ? $groups['social-facebook'] : 0)); ?></span></a></li>
  86. <li class="social-pingback<?php echo ((isset($_GET['social_tab']) and $_GET['social_tab'] == 'social-pingback') ? ' social-current-tab' : ''); ?>"><a href="#" rel="social-pingback"><span><?php printf(_n('1 Pingback', '%1$s Pingbacks', (isset($groups['pingback']) ? $groups['pingback'] : 0), 'social'), (isset($groups['pingback']) ? $groups['pingback'] : 0)); ?></span></a></li>
  87. </ul>
  88. <!-- panel items -->
  89. <div id="social-comments-tab-all" class="social-tabs-panel social-tabs-first-panel">
  90. <div id="comments" class="social-comments">
  91. <?php
  92. if ($last_reply_time) {
  93. echo '<div class="social-last-reply-when">'.sprintf(__('Last reply was %s', 'social'), Social_Date::span_comment($last_reply_time)).'</div>';
  94. }
  95. if (count($social_items)) {
  96. echo '<div id="social-items-wrapper">';
  97. foreach ($social_items as $group => $items) {
  98. $service = Social::instance()->service($group);
  99. if ($service !== false and count($items)) {
  100. $avatar_size = apply_filters('social_items_avatar_size', array(
  101. 'width' => 24,
  102. 'height' => 24,
  103. ));
  104. echo Social_View::factory('comment/social_item', compact('items', 'service', 'avatar_size'));
  105. }
  106. }
  107. echo '</div>';
  108. }
  109. if ($last_reply_time or count($social_items)) {
  110. echo '<div class="cf-clearfix"></div>';
  111. }
  112. if (count($comments)) {
  113. ?>
  114. <ol class="social-commentlist">
  115. <?php
  116. wp_list_comments(array(
  117. 'callback' => array(Social::instance(), 'comment'),
  118. 'walker' => new Social_Walker_Comment,
  119. ), $comments);
  120. ?>
  121. </ol>
  122. <?php
  123. }
  124. if (get_comment_pages_count() > 1 and get_option('page_comments')):
  125. ?>
  126. <nav id="comment-nav-below">
  127. <h1 class="assistive-text"><?php _e('Comment navigation', 'social'); ?></h1>
  128. <div class="nav-previous"><?php previous_comments_link(__('&larr; Older Comments', 'social')); ?></div>
  129. <div class="nav-next"><?php next_comments_link(__('Newer Comments &rarr;', 'social')); ?></div>
  130. </nav>
  131. <?php endif; ?>
  132. </div>
  133. </div>
  134. <?php endif; ?>
  135. </div>
  136. <!-- #Comments Tabs -->
  137. <?php endif; ?>
  138. <?php
  139. $comments = ob_get_clean();
  140. $order = apply_filters('social_comment_block_order', array('form', 'comments'));
  141. foreach ($order as $block) {
  142. if (isset($$block)) {
  143. echo $$block;
  144. }
  145. }
  146. ?>
  147. </div>