| [ Index ] |
WordPress Source Cross Reference |
[Summary view] [Print] [Text view]
1 <?php 2 require_once ('admin.php'); 3 4 $parent_file = 'edit.php'; 5 $submenu_file = 'edit-comments.php'; 6 7 wp_reset_vars(array('action')); 8 9 if ( isset( $_POST['deletecomment'] ) ) 10 $action = 'deletecomment'; 11 12 switch($action) { 13 case 'editcomment': 14 $title = __('Edit Comment'); 15 if ( user_can_richedit() ) 16 wp_enqueue_script( 'wp_tiny_mce' ); 17 require_once ('admin-header.php'); 18 19 $comment = (int) $_GET['comment']; 20 21 if ( ! $comment = get_comment($comment) ) 22 wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)')); 23 24 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) 25 wp_die( __('You are not allowed to edit comments on this post.') ); 26 27 $comment = get_comment_to_edit($comment); 28 29 include ('edit-form-comment.php'); 30 31 break; 32 33 case 'confirmdeletecomment': 34 case 'mailapprovecomment': 35 36 require_once ('./admin-header.php'); 37 38 $comment = (int) $_GET['comment']; 39 $p = (int) $_GET['p']; 40 $formaction = 'confirmdeletecomment' == $action ? 'deletecomment' : 'approvecomment'; 41 $nonce_action = 'confirmdeletecomment' == $action ? 'delete-comment_' : 'approve-comment_'; 42 $nonce_action .= $comment; 43 44 if ( ! $comment = get_comment($comment) ) 45 wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php')); 46 47 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) 48 wp_die( 'confirmdeletecomment' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); 49 50 echo "<div class='wrap'>\n"; 51 if ( 'spam' == $_GET['delete_type'] ) 52 echo "<p>" . __('<strong>Caution:</strong> You are about to mark the following comment as spam:') . "</p>\n"; 53 elseif ( 'confirmdeletecomment' == $action ) 54 echo "<p>" . __('<strong>Caution:</strong> You are about to delete the following comment:') . "</p>\n"; 55 else 56 echo "<p>" . __('<strong>Caution:</strong> You are about to approve the following comment:') . "</p>\n"; 57 echo "<table border='0'>\n"; 58 echo "<tr><td>" . __('Author:') . "</td><td>$comment->comment_author</td></tr>\n"; 59 echo "<tr><td>" . __('E-mail:') . "</td><td>$comment->comment_author_email</td></tr>\n"; 60 echo "<tr><td>". __('URL:') . "</td><td>$comment->comment_author_url</td></tr>\n"; 61 echo "<tr><td>". __('Comment:') . "</td><td>$comment->comment_content</td></tr>\n"; 62 echo "</table>\n"; 63 echo "<p>" . __('Are you sure you want to do that?') . "</p>\n"; 64 65 echo "<form action='".get_settings('siteurl')."/wp-admin/comment.php' method='get'>\n"; 66 wp_nonce_field($nonce_action); 67 echo "<input type='hidden' name='action' value='$formaction' />\n"; 68 if ( 'spam' == $_GET['delete_type'] ) 69 echo "<input type='hidden' name='delete_type' value='spam' />\n"; 70 echo "<input type='hidden' name='p' value='$p' />\n"; 71 echo "<input type='hidden' name='comment' value='{$comment->comment_ID}' />\n"; 72 echo "<input type='hidden' name='noredir' value='1' />\n"; 73 echo "<input type='submit' value='" . __('Yes') . "' />"; 74 echo " "; 75 echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit-comments.php';\" />\n"; 76 echo "</form>\n"; 77 echo "</div>\n"; 78 79 break; 80 81 case 'deletecomment': 82 $comment = (int) $_REQUEST['comment']; 83 check_admin_referer('delete-comment_' . $comment); 84 85 $p = (int) $_REQUEST['p']; 86 if ( isset($_REQUEST['noredir']) ) { 87 $noredir = true; 88 } else { 89 $noredir = false; 90 } 91 92 $postdata = get_post($p) or 93 wp_die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php')); 94 95 if ( ! $comment = get_comment($comment) ) 96 wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php')); 97 98 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) 99 wp_die( __('You are not allowed to edit comments on this post.') ); 100 101 if ( 'spam' == $_REQUEST['delete_type'] ) 102 wp_set_comment_status($comment->comment_ID, 'spam'); 103 else 104 wp_delete_comment($comment->comment_ID); 105 106 if ((wp_get_referer() != '') && (false == $noredir)) { 107 wp_redirect(wp_get_referer()); 108 } else { 109 wp_redirect(get_settings('siteurl') .'/wp-admin/edit-comments.php'); 110 } 111 exit(); 112 break; 113 114 case 'unapprovecomment': 115 $comment = (int) $_GET['comment']; 116 check_admin_referer('unapprove-comment_' . $comment); 117 118 $p = (int) $_GET['p']; 119 if (isset($_GET['noredir'])) { 120 $noredir = true; 121 } else { 122 $noredir = false; 123 } 124 125 if ( ! $comment = get_comment($comment) ) 126 wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php')); 127 128 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) 129 wp_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') ); 130 131 wp_set_comment_status($comment->comment_ID, "hold"); 132 133 if ((wp_get_referer() != "") && (false == $noredir)) { 134 wp_redirect(wp_get_referer()); 135 } else { 136 wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments'); 137 } 138 exit(); 139 break; 140 141 case 'approvecomment': 142 $comment = (int) $_GET['comment']; 143 check_admin_referer('approve-comment_' . $comment); 144 145 $p = (int) $_GET['p']; 146 if (isset($_GET['noredir'])) { 147 $noredir = true; 148 } else { 149 $noredir = false; 150 } 151 152 if ( ! $comment = get_comment($comment) ) 153 wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php')); 154 155 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) 156 wp_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); 157 158 wp_set_comment_status($comment->comment_ID, "approve"); 159 if (get_settings("comments_notify") == true) { 160 wp_notify_postauthor($comment->comment_ID); 161 } 162 163 164 if ((wp_get_referer() != "") && (false == $noredir)) { 165 wp_redirect(wp_get_referer()); 166 } else { 167 wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments'); 168 } 169 exit(); 170 break; 171 172 case 'editedcomment': 173 174 $comment_ID = (int) $_POST['comment_ID']; 175 $comment_post_ID = (int) $_POST['comment_post_id']; 176 177 check_admin_referer('update-comment_' . $comment_ID); 178 179 edit_comment(); 180 181 $referredby = $_POST['referredby']; 182 if (!empty($referredby)) { 183 wp_redirect($referredby); 184 } else { 185 wp_redirect("edit.php?p=$comment_post_ID&c=1#comments"); 186 } 187 188 break; 189 default: 190 break; 191 } // end switch 192 193 include ('admin-footer.php'); 194 195 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Jul 15 11:57:04 2006 | Courtesy of Taragana |