-
+ 95CD3ACDF8D8F8A91CE0AB861B2C93D2381569A13662BD482800FF53744488185F2D1C7371D10BA8E0D7A109447F41A094826099D0E4F6486915FFC158F812FAmp-wp/wp-admin/comment.php(0 . 0)(1 . 240)
1999 <?php
2000 /**
2001 * Comment Management Panel
2002 *
2003 * @package WordPress
2004 * @subpackage Administration
2005 */
2006
2007 /** Load WordPress Bootstrap */
2008 require_once('admin.php');
2009
2010 $parent_file = 'edit-comments.php';
2011 $submenu_file = 'edit-comments.php';
2012
2013 wp_reset_vars( array('action') );
2014
2015 if ( isset( $_POST['deletecomment'] ) )
2016 $action = 'deletecomment';
2017
2018 /**
2019 * Display error message at bottom of comments.
2020 *
2021 * @param string $msg Error Message. Assumed to contain HTML and be sanitized.
2022 */
2023 function comment_footer_die( $msg ) { //
2024 echo "<div class='wrap'><p>$msg</p></div>";
2025 include('admin-footer.php');
2026 die;
2027 }
2028
2029 switch( $action ) {
2030
2031 case 'editcomment' :
2032 $title = __('Edit Comment');
2033
2034 wp_enqueue_script('comment');
2035 require_once('admin-header.php');
2036
2037 $comment_id = absint( $_GET['c'] );
2038
2039 if ( !$comment = get_comment( $comment_id ) )
2040 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') );
2041
2042 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
2043 comment_footer_die( __('You are not allowed to edit comments on this post.') );
2044
2045 $comment = get_comment_to_edit( $comment_id );
2046
2047 include('edit-form-comment.php');
2048
2049 break;
2050
2051 case 'cdc' :
2052 case 'mac' :
2053
2054 require_once('admin-header.php');
2055
2056 $comment_id = absint( $_GET['c'] );
2057 $formaction = 'cdc' == $action ? 'deletecomment' : 'approvecomment';
2058 $nonce_action = 'cdc' == $action ? 'delete-comment_' : 'approve-comment_';
2059 $nonce_action .= $comment_id;
2060
2061 if ( !$comment = get_comment_to_edit( $comment_id ) )
2062 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
2063
2064 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
2065 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.') );
2066 ?>
2067 <div class='wrap'>
2068
2069 <div class="narrow">
2070 <?php
2071 if ( 'spam' == $_GET['dt'] ) {
2072 $caution_msg = __('You are about to mark the following comment as spam:');
2073 $button = __('Spam Comment');
2074 } elseif ( 'cdc' == $action ) {
2075 $caution_msg = __('You are about to delete the following comment:');
2076 $button = __('Delete Comment');
2077 } else {
2078 $caution_msg = __('You are about to approve the following comment:');
2079 $button = __('Approve Comment');
2080 }
2081 ?>
2082
2083 <p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p>
2084
2085 <p><?php _e('Are you sure you want to do that?'); ?></p>
2086
2087 <form action='comment.php' method='get'>
2088
2089 <table width="100%">
2090 <tr>
2091 <td><input type='button' class="button" value='<?php _e('No'); ?>' onclick="self.location='<?php echo admin_url('edit-comments.php'); ?>" /></td>
2092 <td class="textright"><input type='submit' class="button" value='<?php echo $button; ?>' /></td>
2093 </tr>
2094 </table>
2095
2096 <?php wp_nonce_field( $nonce_action ); ?>
2097 <input type='hidden' name='action' value='<?php echo $formaction; ?>' />
2098 <?php if ( 'spam' == $_GET['dt'] ) { ?>
2099 <input type='hidden' name='dt' value='spam' />
2100 <?php } ?>
2101 <input type='hidden' name='p' value='<?php echo $comment->comment_post_ID; ?>' />
2102 <input type='hidden' name='c' value='<?php echo $comment->comment_ID; ?>' />
2103 <input type='hidden' name='noredir' value='1' />
2104 </form>
2105
2106 <table class="form-table" cellpadding="5">
2107 <tr class="alt">
2108 <th scope="row"><?php _e('Author'); ?></th>
2109 <td><?php echo $comment->comment_author; ?></td>
2110 </tr>
2111 <?php if ( $comment->comment_author_email ) { ?>
2112 <tr>
2113 <th scope="row"><?php _e('E-mail'); ?></th>
2114 <td><?php echo $comment->comment_author_email; ?></td>
2115 </tr>
2116 <?php } ?>
2117 <?php if ( $comment->comment_author_url ) { ?>
2118 <tr>
2119 <th scope="row"><?php _e('URL'); ?></th>
2120 <td><a href='<?php echo $comment->comment_author_url; ?>'><?php echo $comment->comment_author_url; ?></a></td>
2121 </tr>
2122 <?php } ?>
2123 <tr>
2124 <th scope="row" valign="top"><?php echo _c('Comment|noun'); ?></th>
2125 <td><?php echo $comment->comment_content; ?></td>
2126 </tr>
2127 </table>
2128
2129 </div>
2130 </div>
2131 <?php
2132 break;
2133
2134 case 'deletecomment' :
2135 $comment_id = absint( $_REQUEST['c'] );
2136 check_admin_referer( 'delete-comment_' . $comment_id );
2137
2138 if ( isset( $_REQUEST['noredir'] ) )
2139 $noredir = true;
2140 else
2141 $noredir = false;
2142
2143 if ( !$comment = get_comment( $comment_id ) )
2144 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') );
2145
2146 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
2147 comment_footer_die( __('You are not allowed to edit comments on this post.') );
2148
2149 if ( 'spam' == $_REQUEST['dt'] )
2150 wp_set_comment_status( $comment->comment_ID, 'spam' );
2151 else
2152 wp_delete_comment( $comment->comment_ID );
2153
2154 if ( '' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ) )
2155 wp_redirect( wp_get_referer() );
2156 else if ( '' != wp_get_original_referer() && false == $noredir )
2157 wp_redirect( wp_get_original_referer() );
2158 else
2159 wp_redirect( admin_url('edit-comments.php') );
2160
2161 die;
2162 break;
2163
2164 case 'unapprovecomment' :
2165 $comment_id = absint( $_GET['c'] );
2166 check_admin_referer( 'unapprove-comment_' . $comment_id );
2167
2168 if ( isset( $_GET['noredir'] ) )
2169 $noredir = true;
2170 else
2171 $noredir = false;
2172
2173 if ( !$comment = get_comment( $comment_id ) )
2174 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
2175
2176 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
2177 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
2178
2179 wp_set_comment_status( $comment->comment_ID, 'hold' );
2180
2181 if ( '' != wp_get_referer() && false == $noredir )
2182 wp_redirect( wp_get_referer() );
2183 else
2184 wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
2185
2186 exit();
2187 break;
2188
2189 case 'approvecomment' :
2190 $comment_id = absint( $_GET['c'] );
2191 check_admin_referer( 'approve-comment_' . $comment_id );
2192
2193 if ( isset( $_GET['noredir'] ) )
2194 $noredir = true;
2195 else
2196 $noredir = false;
2197
2198 if ( !$comment = get_comment( $comment_id ) )
2199 comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit.php') );
2200
2201 if ( !current_user_can('edit_post', $comment->comment_post_ID) )
2202 comment_footer_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
2203
2204 wp_set_comment_status( $comment->comment_ID, 'approve' );
2205
2206 if ( '' != wp_get_referer() && false == $noredir )
2207 wp_redirect( wp_get_referer() );
2208 else
2209 wp_redirect( admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
2210
2211 exit();
2212 break;
2213
2214 case 'editedcomment' :
2215
2216 $comment_id = absint( $_POST['comment_ID'] );
2217 $comment_post_id = absint( $_POST['comment_post_id'] );
2218
2219 check_admin_referer( 'update-comment_' . $comment_id );
2220
2221 edit_comment();
2222
2223 $location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
2224 $location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
2225 wp_redirect( $location );
2226
2227 exit();
2228 break;
2229
2230 default:
2231 wp_die( __('Unknown action.') );
2232 break;
2233
2234 } // end switch
2235
2236 include('admin-footer.php');
2237
2238 ?>