Plugin to allow visitor contributions to WordPress posts, wiki style.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.8KB

  1. <?php
  2. global $wpdb;
  3. $table_name = $wpdb->prefix . 'visitors_edits';
  4. if(isset($_GET["delete"])){
  5. $wpdb->delete($table_name, array( 'edit_id' => $_GET["delete"] ) );
  6. flashMessage("The review was deleted","danger");
  7. }
  8. if(!empty($_POST)){
  9. wp_update_post([
  10. "ID"=>$_POST["ID"],
  11. "post_content"=>$_POST["post_content"]
  12. ]);
  13. $wpdb->delete($table_name, array( 'edit_id' => $_POST["edit_id"] ) );
  14. flashMessage("The post was updated successfully","");
  15. //Notify visitor
  16. if(isset($_POST["notify_visitor"])){
  17. require 'mail.php';
  18. $post = get_post($_POST["ID"]);
  19. $mail = [
  20. "visitor_name"=>$_POST["visitor_name"],
  21. "post_title"=>$post->post_title,
  22. "post_url"=>get_permalink($_POST["ID"]),
  23. "blog_title" => get_bloginfo("name"),
  24. "admin_message"=>$_POST["admin_message"]
  25. ];
  26. $visitor_submitionMail=new visitors_edits_EMAIL($mail,"visitor_approval");
  27. $visitor_submitionMail->send($_POST["visitor_email"]);
  28. }
  29. }
  30. $edits = $wpdb->get_results("SELECT * FROM ".$table_name);
  31. for ($r=0; $r <count($edits); $r++) {
  32. $edits[$r]->post=get_post($edits[$r]->post_id);
  33. }
  34. ?>
  35. <h1 class="visitors_edits_no_data" <?php if(count($edits)==0){echo 'style="display:block"';}?>>
  36. Emty pending list
  37. </h1>
  38. <div class="visitors_edits_pending" <?php if(count($edits)==0){echo 'style="display:none"';}?>>
  39. <h1>Pending reviews (<?php echo count($edits);?>)</h1>
  40. <table class="widefat pending">
  41. <thead>
  42. <tr>
  43. <th>Post</th>
  44. <th>Author</th>
  45. <th>Author comment</th>
  46. <th>Date</th>
  47. <th>Options</th>
  48. </tr>
  49. </thead>
  50. <tbody>
  51. <?php
  52. for ($i=0; $i < count($edits); $i++) {
  53. $edit=$edits[$i];
  54. ?>
  55. <tr>
  56. <td><?php echo $edit->post->post_title; ?></td>
  57. <td><?php echo $edit->visitor_name?></td>
  58. <td>
  59. <?php echo stripslashes($edit->visitor_comment); ?>
  60. </td>
  61. <td><?php
  62. $creationDate=date_create($edit->edit_time);
  63. echo date_format($creationDate,"m/d/Y")." at ".date_format($creationDate,"h:i a")
  64. ?></td>
  65. <td>
  66. <a class="button-primary" href="<?php echo menu_page_url('visitors_edits_approve',false);?>&edit=<?php echo $edit->edit_id;?>">Review</a>
  67. <a class="button-secondary" href="<?php echo menu_page_url('visitors_edits_main',false);?>&delete=<?php echo $edit->edit_id;?>">Delete</a>
  68. </td>
  69. </tr>
  70. <?php
  71. }
  72. ?>
  73. </tbody>
  74. </table>
  75. </div>
  76. <?php
  77. function flashMessage($msg,$type){
  78. ?>
  79. <div class="visitors_flashMessage <?php echo $type ?>">
  80. <p>
  81. <?php echo $msg ;?>
  82. </p>
  83. </div>
  84. <?php
  85. }
  86. ?>