author | Anthony Ly <anthonyly.com@gmail.com> |
Mon, 19 Nov 2012 18:26:13 +0100 | |
changeset 194 | 32102edaa81b |
parent 136 | bde1974c263b |
permissions | -rw-r--r-- |
136 | 1 |
<?php |
2 |
/** |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
3 |
* Comment Management Screen |
136 | 4 |
* |
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** Load WordPress Bootstrap */ |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
10 |
require_once('./admin.php'); |
136 | 11 |
|
12 |
$parent_file = 'edit-comments.php'; |
|
13 |
$submenu_file = 'edit-comments.php'; |
|
14 |
||
15 |
wp_reset_vars( array('action') ); |
|
16 |
||
17 |
if ( isset( $_POST['deletecomment'] ) ) |
|
18 |
$action = 'deletecomment'; |
|
19 |
||
20 |
if ( 'cdc' == $action ) |
|
21 |
$action = 'delete'; |
|
22 |
elseif ( 'mac' == $action ) |
|
23 |
$action = 'approve'; |
|
24 |
||
25 |
if ( isset( $_GET['dt'] ) ) { |
|
26 |
if ( 'spam' == $_GET['dt'] ) |
|
27 |
$action = 'spam'; |
|
28 |
elseif ( 'trash' == $_GET['dt'] ) |
|
29 |
$action = 'trash'; |
|
30 |
} |
|
31 |
||
32 |
/** |
|
33 |
* Display error message at bottom of comments. |
|
34 |
* |
|
35 |
* @param string $msg Error Message. Assumed to contain HTML and be sanitized. |
|
36 |
*/ |
|
37 |
function comment_footer_die( $msg ) { |
|
38 |
echo "<div class='wrap'><p>$msg</p></div>"; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
39 |
include('./admin-footer.php'); |
136 | 40 |
die; |
41 |
} |
|
42 |
||
43 |
switch( $action ) { |
|
44 |
||
45 |
case 'editcomment' : |
|
46 |
$title = __('Edit Comment'); |
|
47 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
48 |
get_current_screen()->add_help_tab( array( |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
49 |
'id' => 'overview', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
50 |
'title' => __('Overview'), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
51 |
'content' => |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
52 |
'<p>' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '</p>' . |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
53 |
'<p>' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '</p>' |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
54 |
) ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
55 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
56 |
get_current_screen()->set_help_sidebar( |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
57 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
58 |
'<p>' . __( '<a href="http://codex.wordpress.org/Administration_Screens#Comments" target="_blank">Documentation on Comments</a>' ) . '</p>' . |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
59 |
'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
60 |
); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
61 |
|
136 | 62 |
wp_enqueue_script('comment'); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
63 |
require_once('./admin-header.php'); |
136 | 64 |
|
65 |
$comment_id = absint( $_GET['c'] ); |
|
66 |
||
67 |
if ( !$comment = get_comment( $comment_id ) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
68 |
comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'javascript:history.go(-1)') ); |
136 | 69 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
70 |
if ( !current_user_can( 'edit_comment', $comment_id ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
71 |
comment_footer_die( __('You are not allowed to edit this comment.') ); |
136 | 72 |
|
73 |
if ( 'trash' == $comment->comment_approved ) |
|
74 |
comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') ); |
|
75 |
||
76 |
$comment = get_comment_to_edit( $comment_id ); |
|
77 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
78 |
include('./edit-form-comment.php'); |
136 | 79 |
|
80 |
break; |
|
81 |
||
82 |
case 'delete' : |
|
83 |
case 'approve' : |
|
84 |
case 'trash' : |
|
85 |
case 'spam' : |
|
86 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
87 |
$title = __('Moderate Comment'); |
136 | 88 |
|
89 |
$comment_id = absint( $_GET['c'] ); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
90 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
91 |
if ( !$comment = get_comment_to_edit( $comment_id ) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
92 |
wp_redirect( admin_url('edit-comments.php?error=1') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
93 |
die(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
94 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
95 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
96 |
if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
97 |
wp_redirect( admin_url('edit-comments.php?error=2') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
98 |
die(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
99 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
100 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
101 |
// No need to re-approve/re-trash/re-spam a comment. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
102 |
if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
103 |
wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
104 |
die(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
105 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
106 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
107 |
require_once('./admin-header.php'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
108 |
|
136 | 109 |
$formaction = $action . 'comment'; |
110 |
$nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_'; |
|
111 |
$nonce_action .= $comment_id; |
|
112 |
||
113 |
?> |
|
114 |
<div class='wrap'> |
|
115 |
||
116 |
<div class="narrow"> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
117 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
118 |
<?php screen_icon(); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
119 |
<h2><?php echo esc_html( $title ); ?></h2> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
120 |
|
136 | 121 |
<?php |
122 |
switch ( $action ) { |
|
123 |
case 'spam' : |
|
124 |
$caution_msg = __('You are about to mark the following comment as spam:'); |
|
125 |
$button = __('Spam Comment'); |
|
126 |
break; |
|
127 |
case 'trash' : |
|
128 |
$caution_msg = __('You are about to move the following comment to the Trash:'); |
|
129 |
$button = __('Trash Comment'); |
|
130 |
break; |
|
131 |
case 'delete' : |
|
132 |
$caution_msg = __('You are about to delete the following comment:'); |
|
133 |
$button = __('Permanently Delete Comment'); |
|
134 |
break; |
|
135 |
default : |
|
136 |
$caution_msg = __('You are about to approve the following comment:'); |
|
137 |
$button = __('Approve Comment'); |
|
138 |
break; |
|
139 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
140 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
141 |
if ( $comment->comment_approved != '0' ) { // if not unapproved |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
142 |
$message = ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
143 |
switch ( $comment->comment_approved ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
144 |
case '1' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
145 |
$message = __('This comment is currently approved.'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
146 |
break; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
147 |
case 'spam' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
148 |
$message = __('This comment is currently marked as spam.'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
149 |
break; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
150 |
case 'trash' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
151 |
$message = __('This comment is currently in the Trash.'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
152 |
break; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
153 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
154 |
if ( $message ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
155 |
echo '<div class="updated"><p>' . $message . '</p></div>'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
156 |
} |
136 | 157 |
?> |
158 |
<p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p> |
|
159 |
||
160 |
<table class="form-table comment-ays"> |
|
161 |
<tr class="alt"> |
|
162 |
<th scope="row"><?php _e('Author'); ?></th> |
|
163 |
<td><?php echo $comment->comment_author; ?></td> |
|
164 |
</tr> |
|
165 |
<?php if ( $comment->comment_author_email ) { ?> |
|
166 |
<tr> |
|
167 |
<th scope="row"><?php _e('E-mail'); ?></th> |
|
168 |
<td><?php echo $comment->comment_author_email; ?></td> |
|
169 |
</tr> |
|
170 |
<?php } ?> |
|
171 |
<?php if ( $comment->comment_author_url ) { ?> |
|
172 |
<tr> |
|
173 |
<th scope="row"><?php _e('URL'); ?></th> |
|
174 |
<td><a href="<?php echo $comment->comment_author_url; ?>"><?php echo $comment->comment_author_url; ?></a></td> |
|
175 |
</tr> |
|
176 |
<?php } ?> |
|
177 |
<tr> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
178 |
<th scope="row" valign="top"><?php /* translators: field name in comment form */ _ex('Comment', 'noun'); ?></th> |
136 | 179 |
<td><?php echo $comment->comment_content; ?></td> |
180 |
</tr> |
|
181 |
</table> |
|
182 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
183 |
<p><?php _e('Are you sure you want to do this?'); ?></p> |
136 | 184 |
|
185 |
<form action='comment.php' method='get'> |
|
186 |
||
187 |
<table width="100%"> |
|
188 |
<tr> |
|
189 |
<td><a class="button" href="<?php echo admin_url('edit-comments.php'); ?>"><?php esc_attr_e('No'); ?></a></td> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
190 |
<td class="textright"><?php submit_button( $button, 'button' ); ?></td> |
136 | 191 |
</tr> |
192 |
</table> |
|
193 |
||
194 |
<?php wp_nonce_field( $nonce_action ); ?> |
|
195 |
<input type='hidden' name='action' value='<?php echo esc_attr($formaction); ?>' /> |
|
196 |
<input type='hidden' name='c' value='<?php echo esc_attr($comment->comment_ID); ?>' /> |
|
197 |
<input type='hidden' name='noredir' value='1' /> |
|
198 |
</form> |
|
199 |
||
200 |
</div> |
|
201 |
</div> |
|
202 |
<?php |
|
203 |
break; |
|
204 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
205 |
case 'deletecomment' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
206 |
case 'trashcomment' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
207 |
case 'untrashcomment' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
208 |
case 'spamcomment' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
209 |
case 'unspamcomment' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
210 |
case 'approvecomment' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
211 |
case 'unapprovecomment' : |
136 | 212 |
$comment_id = absint( $_REQUEST['c'] ); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
213 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
214 |
if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
215 |
check_admin_referer( 'approve-comment_' . $comment_id ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
216 |
else |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
217 |
check_admin_referer( 'delete-comment_' . $comment_id ); |
136 | 218 |
|
219 |
$noredir = isset($_REQUEST['noredir']); |
|
220 |
||
221 |
if ( !$comment = get_comment($comment_id) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
222 |
comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'edit-comments.php') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
223 |
if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) |
136 | 224 |
comment_footer_die( __('You are not allowed to edit comments on this post.') ); |
225 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
226 |
if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') ) |
136 | 227 |
$redir = wp_get_referer(); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
228 |
elseif ( '' != wp_get_original_referer() && ! $noredir ) |
136 | 229 |
$redir = wp_get_original_referer(); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
230 |
elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
231 |
$redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); |
136 | 232 |
else |
233 |
$redir = admin_url('edit-comments.php'); |
|
234 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
235 |
$redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir ); |
136 | 236 |
|
237 |
switch ( $action ) { |
|
238 |
case 'deletecomment' : |
|
239 |
wp_delete_comment( $comment_id ); |
|
240 |
$redir = add_query_arg( array('deleted' => '1'), $redir ); |
|
241 |
break; |
|
242 |
case 'trashcomment' : |
|
243 |
wp_trash_comment($comment_id); |
|
244 |
$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir ); |
|
245 |
break; |
|
246 |
case 'untrashcomment' : |
|
247 |
wp_untrash_comment($comment_id); |
|
248 |
$redir = add_query_arg( array('untrashed' => '1'), $redir ); |
|
249 |
break; |
|
250 |
case 'spamcomment' : |
|
251 |
wp_spam_comment($comment_id); |
|
252 |
$redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir ); |
|
253 |
break; |
|
254 |
case 'unspamcomment' : |
|
255 |
wp_unspam_comment($comment_id); |
|
256 |
$redir = add_query_arg( array('unspammed' => '1'), $redir ); |
|
257 |
break; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
258 |
case 'approvecomment' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
259 |
wp_set_comment_status( $comment_id, 'approve' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
260 |
$redir = add_query_arg( array( 'approved' => 1 ), $redir ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
261 |
break; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
262 |
case 'unapprovecomment' : |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
263 |
wp_set_comment_status( $comment_id, 'hold' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
264 |
$redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
265 |
break; |
136 | 266 |
} |
267 |
||
268 |
wp_redirect( $redir ); |
|
269 |
die; |
|
270 |
break; |
|
271 |
||
272 |
case 'editedcomment' : |
|
273 |
||
274 |
$comment_id = absint( $_POST['comment_ID'] ); |
|
275 |
$comment_post_id = absint( $_POST['comment_post_ID'] ); |
|
276 |
||
277 |
check_admin_referer( 'update-comment_' . $comment_id ); |
|
278 |
||
279 |
edit_comment(); |
|
280 |
||
281 |
$location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id; |
|
282 |
$location = apply_filters( 'comment_edit_redirect', $location, $comment_id ); |
|
283 |
wp_redirect( $location ); |
|
284 |
||
285 |
exit(); |
|
286 |
break; |
|
287 |
||
288 |
default: |
|
289 |
wp_die( __('Unknown action.') ); |
|
290 |
break; |
|
291 |
||
292 |
} // end switch |
|
293 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
294 |
include('./admin-footer.php'); |