Advertisement
Guest User

Untitled

a guest
Sep 20th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.10 KB | None | 0 0
  1. <?
  2. /* Real Time Comments ToDo List
  3. * 1 Change timer to check for new posts every 30 seconds
  4. * 2 Change system to use a template for both ajax and comment creation
  5. * 3 Use
  6. */
  7. ?>
  8.  
  9.  
  10. <div id="respond">
  11. <div class="literal twelve columns alpha omega comments-wrapper" id="comments">
  12. <? $comments_count = wp_count_comments(get_the_id()); ?>
  13. <div class="literal columns alpha omega"><p class='comment-reply-title'>Comments </p></div>
  14. <div class="literal columns alpha omega"><p class="comm-count"><? echo $comments_count->approved; ?></p></div>
  15. </div>
  16. <div class="clear"></div>
  17. <?
  18. if(get_current_user_id() > 0){ ?>
  19. <form action="http://gamelust.com/wp-comments-post.php" method="post" id="commentform" class="comment-form">
  20. <p class="comment-form-comment">
  21. <?
  22. ?><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea><?/*
  23. $settings = array(
  24. 'wpautop' => false,
  25. 'textarea_rows' => 8,
  26. 'textarea_cols' => 45,
  27. 'media_buttons' => false
  28. );
  29. wp_editor('', "comment", $settings);*/
  30. ?>
  31. </p>
  32. <p class="form-submit">
  33. <input name="submit" type="submit" id="submit_comment" class="submit" value="Post Comment" />
  34. <input type='hidden' name='comment_post_ID' value='<? echo get_the_id(); ?>' id='comment_post_ID' />
  35. <input type='hidden' name='comment_parent' id='comment_parent' value='0' />
  36. <input type='hidden' name='current_user' id='current_user_ID' value='<? echo get_current_user_id(); ?>' />
  37. </p>
  38. <!--<input type="hidden" id="_wp_unfiltered_html_comment_disabled" name="_wp_unfiltered_html_comment_disabled" value="e9a412a3bc" />-->
  39. <script>
  40. (function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();
  41. </script>
  42. </form><?
  43. } else { ?>
  44. <p class="comment-login-required">You must be <span class="comment-login">logged in</span> to leave a comment</p><?
  45. }
  46. ?>
  47. </div>
  48. <div class="mstarAjax" id="commentCounter" post_id="<? echo get_the_id(); ?>" delay="4000" count="<? echo $comments_count->approved; ?>"></div>
  49. <div class="literal twelve columns alpha omega comments-area">
  50. <div class="literal twelve columns alpha omega comment-anchor" id="comments-top"></div>
  51. <?
  52. //try this method. get all comments order asc
  53. $the_id = get_the_id();
  54. $comment_args = array(
  55. 'post_id' => get_the_id(),
  56. 'status' => 'approve',
  57. //'orderby' => 'comment_type',
  58. //'order' => 'asc',
  59. 'parent' => 0,
  60. );
  61. $comments = get_comments($comment_args);
  62. //var_viewer($comments);
  63. foreach($comments as $comment){ ?>
  64. <div class="literal twelve columns alpha omega single-comment"><?
  65. if($comment->comment_parent == 0) {
  66. //var_viewer($comment);
  67. $comm_id = $comment->comment_ID;
  68. $commenter = $comment->user_id;
  69. $user_data = get_userdata($commenter);
  70. $current_likes = get_comment_meta($comm_id,'user_likes',true);
  71. $current_dislikes = get_comment_meta($comm_id,'user_dislikes',true); ?>
  72. <div class="literal twelve columns alpha omega parent-comment" id="comment-<? echo $comm_id; ?>">
  73. <div class="literal one column alpha omega user-gravatar"><?
  74. echo get_avatar($commenter, 50); ?>
  75. </div>
  76. <div class="literal seven columns alpha omega comment-by">
  77. <p>Posted by <? echo $user_data->display_name; ?></p>
  78. </div>
  79. <div class="literal eleven columns alpha omega comment">
  80. <p class="comment-content"><? echo apply_filters('the_content',$comment->comment_content); ?></p>
  81. <div class="clear"></div>
  82. <div class="literal three columns alpha omega user-data"><?
  83. if(get_current_user_id() > 0){ ?>
  84. <a href="" class="reply-link" com_id="<? echo $comm_id; ?>">Reply</a>
  85. <!--<a href="" class="flag-link" com_id="<? echo $comm_id; ?>">Flag</a>-->
  86. <a href="#" class="upvote-link" com_id="<? echo $comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/greenarrow.png" /><span class="upvote"><? echo $current_likes; ?></span></a>
  87. <a href="#" class="downvote-link" com_id="<? echo $comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/redarrow.png" /><span class="downvote"><? echo $current_dislikes; ?></span></a><?
  88. } else { ?>
  89. <p class="news add-news">You must <a href="<? echo bloginfo('url').'/wp-login.php'; ?>"><span class="comment-login">log in</span></a> or <a href="<? echo bloginfo('url').'/wp-login.php?action=register'; ?>"><span class="comment-login">register</span></a> to reply.</p><?
  90. } ?>
  91. </div>
  92. <div class="literal four columns alpha omega likes-area"></div>
  93. <div class="literal four columns alpha omega dislikes-area"></div>
  94. </div>
  95. </div>
  96. <div class="clear"></div>
  97. <div class="literal twelve columns alpha omega" id="reply-form-<? echo $comm_id; ?>" parent="<? echo $comm_id; ?>"></div><?
  98. }
  99. if($comm_id){
  100. $child_args = array(
  101. 'order' => 'ASC',
  102. 'parent' => $comm_id,
  103. 'status' => 'approve',
  104. );
  105. $comm_children = get_comments($child_args);
  106. if($comm_children){
  107. foreach($comm_children as $child_comment){
  108. $child_comm_id = $child_comment->comment_ID;
  109. $child_commenter = $child_comment->user_id;
  110. $child_user_data = get_userdata($child_commenter);
  111. $child_current_likes = get_comment_meta($child_comm_id,'user_likes',true);
  112. $child_current_dislikes = get_comment_meta($child_comm_id,'user_dislikes',true); ?>
  113. <div class="literal twelve columns alpha omega child-comment" id="comment-<? echo $child_comm_id; ?>">
  114. <div class="literal one column alpha omega user-gravatar"><?
  115. echo get_avatar($child_commenter, 50); ?>
  116. </div>
  117. <div class="literal seven columns alpha omega comment-by">
  118. <p>Posted by <? echo $child_user_data->display_name; ?></p>
  119. </div>
  120. <div class="literal eleven columns alpha omega comment">
  121. <p class="comment-content"><? echo apply_filters('the_content',$child_comment->comment_content); ?></p>
  122. <div class="clear"></div>
  123. <div class="literal four columns alpha omega user-data"><?
  124. if(get_current_user_id() > 0){ ?>
  125. <a class="reply-link" com_id="<? echo $child_comm_id; ?>">Reply</a>
  126. <a class="upvote-link" com_id="<? echo $child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/greenarrow.png" /><span class="upvote"><? echo $child_current_likes; ?></span></a>
  127. <a class="downvote-link" com_id="<? echo $child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/redarrow.png" /><span class="downvote"><? echo $child_current_dislikes; ?></span></a><?
  128. } else { ?>
  129. <p class="news add-news">You must <a href="<? echo bloginfo('url').'/wp-login.php'; ?>"><span class="comment-login">log in</span></a> or <a href="<? echo bloginfo('url').'/wp-login.php?action=register'; ?>"><span class="comment-login">register</span></a> to reply.</p><?
  130. } ?>
  131. </div>
  132. </div>
  133. </div>
  134. <div class="clear"></div>
  135. <div class="literal twelve columns alpha omega" id="reply-form-<? echo $child_comm_id; ?>" parent="<? echo $child_comm_id; ?>"></div><?
  136. if($child_comm_id){
  137. $grand_child_args = array(
  138. 'order' => 'ASC',
  139. 'parent' => $child_comm_id,
  140. 'status' => 'approve',
  141. );
  142. $comm_grand_children = get_comments($grand_child_args);
  143. if($comm_grand_children){
  144. foreach($comm_grand_children as $grand_child_comment){
  145. $grand_child_comm_id = $grand_child_comment->comment_ID;
  146. $grand_child_commenter = $grand_child_comment->user_id;
  147. $grand_child_user_data = get_userdata($grand_child_commenter);
  148. $grand_child_current_likes = get_comment_meta($comm_id,'user_likes',true);
  149. $grand_child_current_dislikes = get_comment_meta($comm_id,'user_dislikes',true); ?>
  150. <div class="literal twelve columns alpha omega grand-child-comment" id="comment-<? echo $grand_child_comm_id; ?>">
  151. <div class="literal one column alpha omega user-gravatar"><?
  152. echo get_avatar($grand_child_commenter, 50); ?>
  153. </div>
  154. <div class="literal seven columns alpha omega comment-by">
  155. <p>Posted by <? echo $grand_child_user_data->display_name; ?></p>
  156. </div>
  157. <div class="literal eleven columns alpha omega comment">
  158. <p class="comment-content"><? echo $grand_child_comment->comment_content; ?></p>
  159. <div class="clear"></div>
  160. <div class="literal four columns alpha omega user-data"><?
  161. if(get_current_user_id() > 0){ ?>
  162. <a class="reply-link" com_id="<? echo $grand_child_comm_id; ?>">Reply</a>
  163. <a class="upvote-link" com_id="<? echo $grand_child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/greenarrow.png" /><span class="upvote"><? echo $grand_child_current_likes; ?></span></a>
  164. <a class="downvote-link" com_id="<? echo $grand_child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/redarrow.png" /><span class="downvote"><? echo $grand_child_current_dislikes; ?></span></a><?
  165. } else { ?>
  166. <p class="news add-news">You must <a href="<? echo bloginfo('url').'/wp-login.php'; ?>"><span class="comment-login">log in</span></a> or <a href="<? echo bloginfo('url').'/wp-login.php?action=register'; ?>"><span class="comment-login">register</span></a> to reply.</p><?
  167. } ?>
  168. </div>
  169. </div>
  170. </div>
  171. <div class="clear"></div>
  172. <div class="literal twelve columns alpha omega" id="reply-form-<? echo $grand_child_comm_id; ?>" parent="<? echo $grand_child_comm_id; ?>"></div><?
  173. if($grand_child_comm_id){
  174. $great_child_args = array(
  175. 'order' => 'ASC',
  176. 'parent' => $grand_child_comm_id,
  177. 'status' => 'approve',
  178. );
  179. $comm_great_children = get_comments($great_child_args);
  180. if($comm_great_children){
  181. foreach($comm_great_children as $great_child_comment){
  182. $great_child_comm_id = $great_child_comment->comment_ID;
  183. $great_child_commenter = $great_child_comment->user_id;
  184. $great_child_user_data = get_userdata($great_child_commenter);
  185. $great_child_current_likes = get_comment_meta($comm_id,'user_likes',true);
  186. $great_child_current_dislikes = get_comment_meta($comm_id,'user_dislikes',true); ?>
  187. <div class="literal twelve columns alpha omega great-child-comment" id="comment-<? echo $great_child_comm_id; ?>">
  188. <div class="literal one column alpha omega user-gravatar"><?
  189. echo get_avatar($great_child_commenter, 50); ?>
  190. </div>
  191. <div class="literal seven columns alpha omega comment-by">
  192. <p>Posted by <? echo $great_child_user_data->display_name; ?></p>
  193. </div>
  194. <div class="literal eleven columns alpha omega comment">
  195. <p class="comment-content"><? echo apply_filters('the_content', $great_child_comment->comment_content); ?></p>
  196. <div class="clear"></div>
  197. <div class="literal four columns alpha omega user-data"><?
  198. if(get_current_user_id() > 0){ ?>
  199. <a class="reply-link" com_id="<? echo $great_child_comm_id; ?>">Reply</a>
  200. <a class="upvote-link" com_id="<? echo $great_child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/greenarrow.png" /><span class="upvote"><? echo $great_child_current_likes; ?></span></a>
  201. <a class="downvote-link" com_id="<? echo $great_child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/redarrow.png" /><span class="downvote"><? echo $great_child_current_dislikes; ?></span></a><?
  202. } else { ?>
  203. <p class="news add-news">You must <a href="<? echo bloginfo('url').'/wp-login.php'; ?>"><span class="comment-login">log in</span></a> or <a href="<? echo bloginfo('url').'/wp-login.php?action=register'; ?>"><span class="comment-login">register</span></a> to reply.</p><?
  204. } ?>
  205. </div>
  206. </div>
  207. </div>
  208. <div class="clear">
  209. </div><div class="literal twelve columns alpha omega" id="reply-form-<? echo $great_child_comm_id; ?>" parent="<? echo $great_child_comm_id; ?>"></div><?
  210. if($great_child_comm_id){
  211. $scnd_great_child_args = array(
  212. 'order' => 'ASC',
  213. 'parent' => $great_child_comm_id,
  214. 'status' => 'approve',
  215. );
  216. $comm_scnd_great_children = get_comments($scnd_great_child_args);
  217. if($comm_scnd_great_children){
  218. foreach($comm_scnd_great_children as $scnd_great_child_comment){
  219. $scnd_great_child_comm_id = $scnd_great_child_comment->comment_ID;
  220. $scnd_great_child_commenter = $scnd_great_child_comment->user_id;
  221. $scnd_great_child_user_data = get_userdata($scnd_great_child_commenter);
  222. $scnd_great_child_current_likes = get_comment_meta($scnd_great_child_comm_id,'user_likes',true);
  223. $scnd_great_child_current_dislikes = get_comment_meta($scnd_great_child_comm_id,'user_dislikes',true); ?>
  224. <div class="literal twelve columns alpha omega great-child-comment" id="comment-<? echo $scnd_great_child_comm_id; ?>">
  225. <div class="literal one column alpha omega user-gravatar"><?
  226. echo get_avatar($scnd_great_child_commenter, 50); ?>
  227. </div>
  228. <div class="literal seven columns alpha omega comment-by">
  229. <p>2gPosted by <? echo $scnd_great_child_user_data->display_name; ?></p>
  230. </div>
  231. <div class="literal eleven columns alpha omega comment">
  232. <p class="comment-content"><? echo apply_filters('the_content', $scnd_great_child_comment->comment_content); ?></p>
  233. <div class="clear"></div>
  234. <div class="literal four columns alpha omega user-data"><?
  235. if(get_current_user_id() > 0){ ?>
  236. <a class="reply-link" com_id="<? echo $scnd_great_child_comm_id; ?>">Reply</a>
  237. <a class="upvote-link" com_id="<? echo $scnd_great_child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/greenarrow.png" /><span class="upvote"><? echo $scnd_great_child_current_likes; ?></span></a>
  238. <a class="downvote-link" com_id="<? echo $scnd_great_child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/redarrow.png" /><span class="downvote"><? echo $scnd_great_child_current_dislikes; ?></span></a><?
  239. } else { ?>
  240. <p class="news add-news">You must <a href="<? echo bloginfo('url').'/wp-login.php'; ?>"><span class="comment-login">log in</span></a> or <a href="<? echo bloginfo('url').'/wp-login.php?action=register'; ?>"><span class="comment-login">register</span></a> to reply.</p><?
  241. } ?>
  242. </div>
  243. </div>
  244. </div>
  245. <div class="clear"></div>
  246. <div class="literal twelve columns alpha omega" id="reply-form-<? echo $scnd_great_child_comm_id; ?>" parent="<? echo $scnd_great_child_comm_id; ?>"></div><?
  247. if($scnd_great_child_comm_id){
  248. $thrd_great_child_args = array(
  249. 'order' => 'ASC',
  250. 'parent' => $scnd_great_child_comm_id,
  251. 'status' => 'approve',
  252. );
  253. $comm_thrd_great_children = get_comments($thrd_great_child_args);
  254. if($comm_thrd_great_children){
  255. foreach($comm_thrd_great_children as $thrd_great_child_comment){
  256. $thrd_great_child_comm_id = $thrd_great_child_comment->comment_ID;
  257. $thrd_great_child_commenter = $thrd_great_child_comment->user_id;
  258. $thrd_great_child_user_data = get_userdata($thrd_great_child_commenter);
  259. $thrd_great_child_current_likes = get_comment_meta($thrd_great_child_comm_id,'user_likes',true);
  260. $thrd_great_child_current_dislikes = get_comment_meta($thrd_great_child_comm_id,'user_dislikes',true); ?>
  261. <div class="literal twelve columns alpha omega great-child-comment" id="comment-<? echo $thrd_great_child_comm_id; ?>">
  262. <div class="literal one column alpha omega user-gravatar"><?
  263. echo get_avatar($thrd_great_child_commenter, 50); ?>
  264. </div>
  265. <div class="literal seven columns alpha omega comment-by">
  266. <p>3gPosted by <? echo $thrd_great_child_user_data->display_name; ?></p>
  267. </div>
  268. <div class="literal eleven columns alpha omega comment">
  269. <p class="comment-content"><? echo apply_filters('the_content', $thrd_great_child_comment->comment_content); ?></p>
  270. <div class="clear"></div>
  271. <div class="literal four columns alpha omega user-data"><?
  272. if(get_current_user_id() > 0){ ?>
  273. <a class="reply-link" com_id="<? echo $thrd_great_child_comm_id; ?>">Reply</a>
  274. <a class="upvote-link" com_id="<? echo $thrd_great_child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/greenarrow.png" /><span class="upvote"><? echo $thrd_great_child_current_likes; ?></span></a>
  275. <a class="downvote-link" com_id="<? echo $thrd_great_child_comm_id; ?>"><img src="<? echo get_template_directory_uri(); ?>/images/redarrow.png" /><span class="downvote"><? echo $thrd_great_child_current_dislikes; ?></span></a><?
  276. } else { ?>
  277. <p class="news add-news">You must <a href="<? echo bloginfo('url').'/wp-login.php'; ?>"><span class="comment-login">log in</span></a> or <a href="<? echo bloginfo('url').'/wp-login.php?action=register'; ?>"><span class="comment-login">register</span></a> to reply.</p><?
  278. } ?>
  279. </div>
  280. </div>
  281. </div>
  282. <div class="clear"></div><div class="literal twelve columns alpha omega" id="reply-form-<? echo $scnd_great_child_comm_id; ?>" parent="<? echo $thrd_great_child_comm_id; ?>"></div><?
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. }
  296. }
  297. } ?>
  298. </div><?
  299. }
  300. //var_viewer($comm_grand_children);
  301. ?>
  302. </div>
  303. <div id="form-template">
  304. <form action="http://gamelust.com/wp-comments-post.php" method="post" id="reply-form" class="comment-form">
  305. <p class="comment-form-comment">
  306. <textarea id="reply" class="reply-box" name="comment" cols="45" rows="8" aria-required="true"></textarea>
  307. </p>
  308. <p class="form-submit">
  309. <input name="submit" type="submit" id="submit_reply" class="submit" value="Add Reply" />
  310. <input type='hidden' name='comment_post_ID' value='<? echo get_the_id(); ?>' id='reply_post_ID' />
  311. <input name="close" type="submit" id="close_reply" class="close-reply" value="Cancel" com_id="" />
  312. </p>
  313. <input type="hidden" id="_wp_unfiltered_html_comment_disabled" name="_wp_unfiltered_html_comment_disabled" value="e9a412a3bc" />
  314. <script>
  315. (function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();
  316. </script>
  317. </form>
  318. </div>
  319. <!--<div id="comment-template"><li><div cols="7"><img t="av" /></div><div cols="1"><p type="d_name"></p></div><div cols="11"><p type="cont"></p><div class="clear"></div><div cols="4"><a type="reply">Reply</a><a type="uv"><img type="uv" /><span count="uv"></span></a><a type="dv"><img type="dv" /><span count="dv"></span></a></div></div></div><div type="clear"></div></div>-->
  320. <?
  321.  
  322. /*
  323.  
  324. $commentdata = array(
  325. 'comment_post_ID' => $post->ID, // to which post the comment will show up
  326. 'comment_author' => 'Another Someone', //fixed value - can be dynamic
  327. 'comment_author_email' => '[email protected]', //fixed value - can be dynamic
  328. 'comment_author_url' => 'http://example.com', //fixed value - can be dynamic
  329. 'comment_content' => 'Comment messsage...', //fixed value - can be dynamic
  330. 'comment_type' => '', //empty for regular comments, 'pingback' for pingbacks, 'trackback' for trackbacks
  331. 'comment_parent' => 0, //0 if it's not a reply to another comment; if it's a reply, mention the parent comment ID here
  332. 'user_id' => $current_user->ID, //passing current user ID or any predefined as per the demand
  333. );
  334.  
  335. //Insert new comment and get the comment ID
  336. $comment_id = wp_new_comment( $commentdata );
  337.  
  338. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement