function comments_rows($rows, $type = "") { global $wpdb; if (!$rows) { ?> <tr class="empty"> <td colspan="5"><p>No Comments Found</p></td> </tr> <?php return; } else { ?> <?php $comment = new WT_Comment(); foreach ($rows as $row) { echo get_comment_row_html($comment->db_out($row), $type); } } }
break; // POST // POST case "add_post": $post = new WT_Post(); $post->update($_POST); $post->db_response("json"); break; //COMMENTS //COMMENTS case "get_comment": $comment = new WT_Comment($_POST["comment_id"]); if (!empty($_POST["comment_id"])) { $comment->retrieve(); } echo json_encode($comment->db_out(null, 0)); break; case "get_event_comments": if (!empty($_POST["event_id"])) { $comment = new WT_Comment(); echo "<table id='the-comment-list' class='widefat'>"; comments_rows($comment->query("comment_event_id=" . $_POST["event_id"])); echo "</table>"; } break; case "insert_comment": $comment = new WT_Comment(); $insert = $comment->insert($_POST); if ($insert) { $comment->db_response("html"); }