42 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') ); |
54 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') ); |
43 |
55 |
44 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) |
56 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) |
45 comment_footer_die( __('You are not allowed to edit comments on this post.') ); |
57 comment_footer_die( __('You are not allowed to edit comments on this post.') ); |
46 |
58 |
|
59 if ( 'trash' == $comment->comment_approved ) |
|
60 comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') ); |
|
61 |
47 $comment = get_comment_to_edit( $comment_id ); |
62 $comment = get_comment_to_edit( $comment_id ); |
48 |
63 |
49 include('edit-form-comment.php'); |
64 include('edit-form-comment.php'); |
50 |
65 |
51 break; |
66 break; |
52 |
67 |
53 case 'cdc' : |
68 case 'delete' : |
54 case 'mac' : |
69 case 'approve' : |
|
70 case 'trash' : |
|
71 case 'spam' : |
55 |
72 |
56 require_once('admin-header.php'); |
73 require_once('admin-header.php'); |
57 |
74 |
58 $comment_id = absint( $_GET['c'] ); |
75 $comment_id = absint( $_GET['c'] ); |
59 $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment'; |
76 $formaction = $action . 'comment'; |
60 $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_'; |
77 $nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_'; |
61 $nonce_action .= $comment_id; |
78 $nonce_action .= $comment_id; |
62 |
79 |
63 if ( !$comment = get_comment_to_edit( $comment_id ) ) |
80 if ( !$comment = get_comment_to_edit( $comment_id ) ) |
64 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); |
81 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); |
65 |
82 |
66 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) |
83 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) |
67 comment_footer_die( 'cdc' == $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.') ); |
84 comment_footer_die( 'approve' != $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.') ); |
68 ?> |
85 ?> |
69 <div class='wrap'> |
86 <div class='wrap'> |
70 |
87 |
71 <div class="narrow"> |
88 <div class="narrow"> |
72 <?php |
89 <?php |
73 if ( 'spam' == $_GET['dt'] ) { |
90 switch ( $action ) { |
74 $caution_msg = __('You are about to mark the following comment as spam:'); |
91 case 'spam' : |
75 $button = __('Spam Comment'); |
92 $caution_msg = __('You are about to mark the following comment as spam:'); |
76 } elseif ( 'cdc' == $action ) { |
93 $button = __('Spam Comment'); |
77 $caution_msg = __('You are about to delete the following comment:'); |
94 break; |
78 $button = __('Delete Comment'); |
95 case 'trash' : |
79 } else { |
96 $caution_msg = __('You are about to move the following comment to the Trash:'); |
80 $caution_msg = __('You are about to approve the following comment:'); |
97 $button = __('Trash Comment'); |
81 $button = __('Approve Comment'); |
98 break; |
|
99 case 'delete' : |
|
100 $caution_msg = __('You are about to delete the following comment:'); |
|
101 $button = __('Permanently Delete Comment'); |
|
102 break; |
|
103 default : |
|
104 $caution_msg = __('You are about to approve the following comment:'); |
|
105 $button = __('Approve Comment'); |
|
106 break; |
82 } |
107 } |
83 ?> |
108 ?> |
84 |
109 |
85 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p> |
110 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p> |
86 |
111 |
|
112 <table class="form-table comment-ays"> |
|
113 <tr class="alt"> |
|
114 <th scope="row"><?php _e('Author'); ?></th> |
|
115 <td><?php echo $comment->comment_author; ?></td> |
|
116 </tr> |
|
117 <?php if ( $comment->comment_author_email ) { ?> |
|
118 <tr> |
|
119 <th scope="row"><?php _e('E-mail'); ?></th> |
|
120 <td><?php echo $comment->comment_author_email; ?></td> |
|
121 </tr> |
|
122 <?php } ?> |
|
123 <?php if ( $comment->comment_author_url ) { ?> |
|
124 <tr> |
|
125 <th scope="row"><?php _e('URL'); ?></th> |
|
126 <td><a href="<?php echo $comment->comment_author_url; ?>"><?php echo $comment->comment_author_url; ?></a></td> |
|
127 </tr> |
|
128 <?php } ?> |
|
129 <tr> |
|
130 <th scope="row" valign="top"><?php /* translators: field name in comment form */ echo _x('Comment', 'noun'); ?></th> |
|
131 <td><?php echo $comment->comment_content; ?></td> |
|
132 </tr> |
|
133 </table> |
|
134 |
87 <p><?php _e('Are you sure you want to do that?'); ?></p> |
135 <p><?php _e('Are you sure you want to do that?'); ?></p> |
88 |
136 |
89 <form action='comment.php' method='get'> |
137 <form action='comment.php' method='get'> |
90 |
138 |
91 <table width="100%"> |
139 <table width="100%"> |
92 <tr> |
140 <tr> |
93 <td><input type='button' class="button" value='<?php esc_attr_e('No'); ?>' onclick="self.location='<?php echo admin_url('edit-comments.php'); ?>" /></td> |
141 <td><a class="button" href="<?php echo admin_url('edit-comments.php'); ?>"><?php esc_attr_e('No'); ?></a></td> |
94 <td class="textright"><input type='submit' class="button" value='<?php echo esc_attr($button); ?>' /></td> |
142 <td class="textright"><input type='submit' class="button" value='<?php echo esc_attr($button); ?>' /></td> |
95 </tr> |
143 </tr> |
96 </table> |
144 </table> |
97 |
145 |
98 <?php wp_nonce_field( $nonce_action ); ?> |
146 <?php wp_nonce_field( $nonce_action ); ?> |
99 <input type='hidden' name='action' value='<?php echo esc_attr($formaction); ?>' /> |
147 <input type='hidden' name='action' value='<?php echo esc_attr($formaction); ?>' /> |
100 <?php if ( 'spam' == $_GET['dt'] ) { ?> |
|
101 <input type='hidden' name='dt' value='spam' /> |
|
102 <?php } ?> |
|
103 <input type='hidden' name='p' value='<?php echo esc_attr($comment->comment_post_ID); ?>' /> |
148 <input type='hidden' name='p' value='<?php echo esc_attr($comment->comment_post_ID); ?>' /> |
104 <input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' /> |
149 <input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' /> |
105 <input type='hidden' name='noredir' value='1' /> |
150 <input type='hidden' name='noredir' value='1' /> |
106 </form> |
151 </form> |
107 |
152 |
108 <table class="form-table" cellpadding="5"> |
|
109 <tr class="alt"> |
|
110 <th scope="row"><?php _e('Author'); ?></th> |
|
111 <td><?php echo $comment->comment_author; ?></td> |
|
112 </tr> |
|
113 <?php if ( $comment->comment_author_email ) { ?> |
|
114 <tr> |
|
115 <th scope="row"><?php _e('E-mail'); ?></th> |
|
116 <td><?php echo $comment->comment_author_email; ?></td> |
|
117 </tr> |
|
118 <?php } ?> |
|
119 <?php if ( $comment->comment_author_url ) { ?> |
|
120 <tr> |
|
121 <th scope="row"><?php _e('URL'); ?></th> |
|
122 <td><a href="<?php echo $comment->comment_author_url; ?>"><?php echo $comment->comment_author_url; ?></a></td> |
|
123 </tr> |
|
124 <?php } ?> |
|
125 <tr> |
|
126 <th scope="row" valign="top"><?php /* translators: field name in comment form */ echo _x('Comment', 'noun'); ?></th> |
|
127 <td><?php echo $comment->comment_content; ?></td> |
|
128 </tr> |
|
129 </table> |
|
130 |
|
131 </div> |
153 </div> |
132 </div> |
154 </div> |
133 <?php |
155 <?php |
134 break; |
156 break; |
135 |
157 |
136 case 'deletecomment' : |
158 case 'deletecomment' : |
|
159 case 'trashcomment' : |
|
160 case 'untrashcomment' : |
|
161 case 'spamcomment' : |
|
162 case 'unspamcomment' : |
137 $comment_id = absint( $_REQUEST['c'] ); |
163 $comment_id = absint( $_REQUEST['c'] ); |
138 check_admin_referer( 'delete-comment_' . $comment_id ); |
164 check_admin_referer( 'delete-comment_' . $comment_id ); |
139 |
165 |
140 if ( isset( $_REQUEST['noredir'] ) ) |
166 $noredir = isset($_REQUEST['noredir']); |
141 $noredir = true; |
167 |
|
168 if ( !$comment = get_comment($comment_id) ) |
|
169 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') ); |
|
170 if ( !current_user_can('edit_post', $comment->comment_post_ID ) ) |
|
171 comment_footer_die( __('You are not allowed to edit comments on this post.') ); |
|
172 |
|
173 if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php') ) |
|
174 $redir = wp_get_referer(); |
|
175 elseif ( '' != wp_get_original_referer() && false == $noredir ) |
|
176 $redir = wp_get_original_referer(); |
142 else |
177 else |
143 $noredir = false; |
178 $redir = admin_url('edit-comments.php'); |
144 |
179 |
145 if ( !$comment = get_comment( $comment_id ) ) |
180 $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids'), $redir ); |
146 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') ); |
181 |
147 |
182 switch ( $action ) { |
148 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) |
183 case 'deletecomment' : |
149 comment_footer_die( __('You are not allowed to edit comments on this post.') ); |
184 wp_delete_comment( $comment_id ); |
150 |
185 $redir = add_query_arg( array('deleted' => '1'), $redir ); |
151 if ( 'spam' == $_REQUEST['dt'] ) |
186 break; |
152 wp_set_comment_status( $comment->comment_ID, 'spam' ); |
187 case 'trashcomment' : |
153 else |
188 wp_trash_comment($comment_id); |
154 wp_delete_comment( $comment->comment_ID ); |
189 $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir ); |
155 |
190 break; |
156 if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ) ) |
191 case 'untrashcomment' : |
157 wp_redirect( wp_get_referer() ); |
192 wp_untrash_comment($comment_id); |
158 else if ( '' != wp_get_original_referer() && false == $noredir ) |
193 $redir = add_query_arg( array('untrashed' => '1'), $redir ); |
159 wp_redirect( wp_get_original_referer() ); |
194 break; |
160 else |
195 case 'spamcomment' : |
161 wp_redirect( admin_url('edit-comments.php') ); |
196 wp_spam_comment($comment_id); |
|
197 $redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir ); |
|
198 break; |
|
199 case 'unspamcomment' : |
|
200 wp_unspam_comment($comment_id); |
|
201 $redir = add_query_arg( array('unspammed' => '1'), $redir ); |
|
202 break; |
|
203 } |
|
204 |
|
205 wp_redirect( $redir ); |
162 |
206 |
163 die; |
207 die; |
164 break; |
208 break; |
165 |
209 |
|
210 case 'approvecomment' : |
166 case 'unapprovecomment' : |
211 case 'unapprovecomment' : |
167 $comment_id = absint( $_GET['c'] ); |
212 $comment_id = absint( $_GET['c'] ); |
168 check_admin_referer( 'unapprove-comment_' . $comment_id ); |
213 check_admin_referer( 'approve-comment_' . $comment_id ); |
169 |
214 |
170 if ( isset( $_GET['noredir'] ) ) |
215 $noredir = isset( $_GET['noredir'] ); |
171 $noredir = true; |
|
172 else |
|
173 $noredir = false; |
|
174 |
216 |
175 if ( !$comment = get_comment( $comment_id ) ) |
217 if ( !$comment = get_comment( $comment_id ) ) |
176 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); |
218 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); |
177 |
219 |
178 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) |
220 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) { |
179 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') ); |
221 if ( 'approvecomment' == $action ) |
180 |
222 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); |
181 wp_set_comment_status( $comment->comment_ID, 'hold' ); |
223 else |
|
224 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') ); |
|
225 } |
182 |
226 |
183 if ( '' != wp_get_referer() && false == $noredir ) |
227 if ( '' != wp_get_referer() && false == $noredir ) |
184 wp_redirect( wp_get_referer() ); |
228 $redir = remove_query_arg( array('approved', 'unapproved'), wp_get_referer() ); |
185 else |
229 else |
186 wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') ); |
230 $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); |
187 |
231 |
188 exit(); |
232 if ( 'approvecomment' == $action ) { |
189 break; |
233 wp_set_comment_status( $comment_id, 'approve' ); |
190 |
234 $redir = add_query_arg( array( 'approved' => 1 ), $redir ); |
191 case 'approvecomment' : |
235 } else { |
192 $comment_id = absint( $_GET['c'] ); |
236 wp_set_comment_status( $comment_id, 'hold' ); |
193 check_admin_referer( 'approve-comment_' . $comment_id ); |
237 $redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); |
194 |
238 } |
195 if ( isset( $_GET['noredir'] ) ) |
239 |
196 $noredir = true; |
240 wp_redirect( $redir ); |
197 else |
|
198 $noredir = false; |
|
199 |
|
200 if ( !$comment = get_comment( $comment_id ) ) |
|
201 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') ); |
|
202 |
|
203 if ( !current_user_can('edit_post', $comment->comment_post_ID) ) |
|
204 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') ); |
|
205 |
|
206 wp_set_comment_status( $comment->comment_ID, 'approve' ); |
|
207 |
|
208 if ( '' != wp_get_referer() && false == $noredir ) |
|
209 wp_redirect( wp_get_referer() ); |
|
210 else |
|
211 wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') ); |
|
212 |
241 |
213 exit(); |
242 exit(); |
214 break; |
243 break; |
215 |
244 |
216 case 'editedcomment' : |
245 case 'editedcomment' : |