comments.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. if (!isset($post))
  3. global $post;
  4. $duoshuoPlugin = Duoshuo_WordPress::getInstance();
  5. $duoshuoPlugin->printScripts();
  6. $topPost = $duoshuoPlugin->topPost($post);
  7. if ($intro = get_option('duoshuo_comments_wrapper_intro'))
  8. echo $intro;
  9. ?>
  10. <a name="comments"></a>
  11. <?php
  12. if (current_user_can('moderate_comments')):
  13. $threadId = get_post_meta($topPost->ID, 'duoshuo_thread_id', true);
  14. if (empty($threadId)):?>
  15. <p>这篇文章的评论尚未同步到多说,<a href="<?php echo admin_url('admin.php?page=duoshuo-settings');?>">点此同步</a></p>
  16. <?php endif;
  17. endif;
  18. $data = array(
  19. 'thread-key'=> $topPost->ID,
  20. 'author-key'=> $topPost->post_author,
  21. 'title' => $topPost->post_title,
  22. 'url' => get_permalink($topPost->ID),
  23. //'order' => 'desc',
  24. //'limit' => 20,
  25. );
  26. $attribs = '';
  27. foreach ($data as $key => $value)
  28. $attribs .= ' data-' . $key . '="' . esc_attr($value) . '"';
  29. ?>
  30. <div class="ds-thread"<?php echo $attribs;?>></div>
  31. <?php
  32. static $threadInitialized = false;
  33. if (!$threadInitialized):
  34. $threadInitialized = true;?>
  35. <script type="text/javascript">
  36. if (typeof DUOSHUO !== 'undefined')
  37. DUOSHUO.EmbedThread('.ds-thread');
  38. </script>
  39. <?php endif;
  40. if (get_option('duoshuo_seo_enabled')): //直接输出HTML评论
  41. require 'comments-seo.php';
  42. endif;
  43. if ($outro = get_option('duoshuo_comments_wrapper_outro'))
  44. echo $outro;