Ticket #2509: akismet.php.diff
File akismet.php.diff, 11.4 KB (added by , 19 years ago) |
---|
-
akismet.php
4 4 Plugin URI: http://akismet.com/ 5 5 Description: Akismet checks your comments against the Akismet web serivce to see if they look like spam or not. You need a <a href="http://wordpress.com/api-keys/">WordPress.com API key</a> to use this service. You can review the spam it catches under "Manage" and it automatically deletes old spam after 15 days. Hat tip: <a href="http://ioerror.us/">Michael Hampton</a> and <a href="http://chrisjdavis.org/">Chris J. Davis</a> for help with the plugin. 6 6 Author: Matt Mullenweg 7 Author URI: http://photomatt.net/ 7 8 Version: 1.15 8 Author URI: http://photomatt.net/9 9 */ 10 10 11 load_plugin_textdomain('akismet', 'wp-content/plugins/akismet'); 12 11 13 add_action('admin_menu', 'ksd_config_page'); 12 14 13 15 if ( ! function_exists('wp_nonce_field') ) { … … 25 27 function ksd_config_page() { 26 28 global $wpdb; 27 29 if ( function_exists('add_submenu_page') ) 28 add_submenu_page('plugins.php', __('Akismet Configuration' ), __('Akismet Configuration'), 'manage_options', __FILE__, 'akismet_conf');30 add_submenu_page('plugins.php', __('Akismet Configuration', 'akismet'), __('Akismet Configuration', 'akismet'), 'manage_options', __FILE__, 'akismet_conf'); 29 31 } 30 32 31 33 function akismet_conf() { … … 46 48 ?> 47 49 48 50 <div class="wrap"> 49 <h2><?php _e('Akismet Configuration' ); ?></h2>50 <p><?php printf(__('For many people, <a href="%1$s">Akismet</a> will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Akismet will learn from the mistakes. If you don\'t have a WordPress.com account yet, you can get one at <a href="%2$s">WordPress.com</a>.' ), 'http://akismet.com/', 'http://wordpress.com/api-keys/'); ?></p>51 <h2><?php _e('Akismet Configuration', 'akismet'); ?></h2> 52 <p><?php printf(__('For many people, <a href="%1$s">Akismet</a> will greatly reduce or even completely eliminate the comment and trackback spam you get on your site. If one does happen to get through, simply mark it as "spam" on the moderation screen and Akismet will learn from the mistakes. If you don\'t have a WordPress.com account yet, you can get one at <a href="%2$s">WordPress.com</a>.', 'akismet'), 'http://akismet.com/', 'http://wordpress.com/api-keys/'); ?></p> 51 53 52 54 <form action="" method="post" id="akismet-conf" style="margin: auto; width: 25em; "> 53 55 <?php akismet_nonce_field($akismet_nonce) ?> 54 <h3><label for="key"><?php _e('WordPress.com API Key' ); ?></label></h3>56 <h3><label for="key"><?php _e('WordPress.com API Key', 'akismet'); ?></label></h3> 55 57 <?php if ( $invalid_key ) { ?> 56 <p style="padding: .5em; background-color: #f33; color: #fff; font-weight: bold;"><?php _e('Your key appears invalid. Double-check it.' ); ?></p>58 <p style="padding: .5em; background-color: #f33; color: #fff; font-weight: bold;"><?php _e('Your key appears invalid. Double-check it.', 'akismet'); ?></p> 57 59 <?php } ?> 58 <p><input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo get_option('wordpress_api_key'); ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php _e('<a href="http://faq.wordpress.com/2005/10/19/api-key/">What is this?</a>' ); ?>)</p>59 <p class="submit"><input type="submit" name="submit" value="<?php _e('Update API Key »' ); ?>" /></p>60 <p><input id="key" name="key" type="text" size="15" maxlength="12" value="<?php echo get_option('wordpress_api_key'); ?>" style="font-family: 'Courier New', Courier, mono; font-size: 1.5em;" /> (<?php _e('<a href="http://faq.wordpress.com/2005/10/19/api-key/">What is this?</a>', 'akismet'); ?>)</p> 61 <p class="submit"><input type="submit" name="submit" value="<?php _e('Update API Key »', 'akismet'); ?>" /></p> 60 62 </form> 61 63 </div> 62 64 <?php … … 76 78 function akismet_warning() { 77 79 $path = plugin_basename(__FILE__); 78 80 echo " 79 <div id='akismet-warning' class='updated fade-ff0000'><p><strong>".__('Akismet is not active.' )."</strong> ".sprintf(__('You must <a href="%1$s">enter your WordPress.com API key</a> for it to work.'), "plugins.php?page=$path")."</p></div>81 <div id='akismet-warning' class='updated fade-ff0000'><p><strong>".__('Akismet is not active.', 'akismet')."</strong> ".sprintf(__('You must <a href="%1$s">enter your WordPress.com API key</a> for it to work.', 'akismet'), "plugins.php?page=$path")."</p></div> 80 82 <style type='text/css'> 81 83 #adminmenu { margin-bottom: 5em; } 82 84 #akismet-warning { position: absolute; top: 7em; } … … 200 202 201 203 function ksd_manage_page() { 202 204 global $wpdb; 203 $count = sprintf(__('Akismet Spam (%s)' ), ksd_spam_count());205 $count = sprintf(__('Akismet Spam (%s)', 'akismet'), ksd_spam_count()); 204 206 if ( function_exists('add_management_page') ) 205 add_management_page(__('Akismet Spam' ), $count, 'moderate_comments', __FILE__, 'ksd_caught');207 add_management_page(__('Akismet Spam', 'akismet'), $count, 'moderate_comments', __FILE__, 'ksd_caught'); 206 208 } 207 209 208 210 function ksd_caught() { 209 211 global $wpdb, $comment; 210 212 if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) { 211 213 if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) 212 die(__('You do not have sufficient permission to moderate comments.' ));214 die(__('You do not have sufficient permission to moderate comments.', 'akismet')); 213 215 214 216 $i = 0; 215 217 foreach ($_POST['not_spam'] as $comment): … … 221 223 ksd_submit_nonspam_comment($comment); 222 224 ++$i; 223 225 endforeach; 224 echo '<div class="updated"><p>' . sprintf(__('%1$s comments recovered.' ), $i) . "</p></div>";226 echo '<div class="updated"><p>' . sprintf(__('%1$s comments recovered.', 'akismet'), $i) . "</p></div>"; 225 227 } 226 228 if ('delete' == $_POST['action']) { 227 229 if ( function_exists('current_user_can') && !current_user_can('moderate_comments') ) 228 die(__('You do not have sufficient permission to moderate comments.' ));230 die(__('You do not have sufficient permission to moderate comments.', 'akismet')); 229 231 230 232 $delete_time = addslashes( $_POST['display_time'] ); 231 233 $nuked = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" ); 232 234 if (isset($nuked)) { 233 235 echo '<div class="updated"><p>'; 234 236 if ($nuked) { 235 _e('All spam deleted.' );237 _e('All spam deleted.', 'akismet'); 236 238 } 237 239 echo "</p></div>"; 238 240 } 239 241 } 240 242 ?> 241 243 <div class="wrap"> 242 <h2><?php _e('Caught Spam' ) ?></h2>244 <h2><?php _e('Caught Spam', 'akismet') ?></h2> 243 245 <?php 244 246 $count = get_option('akismet_spam_count'); 245 247 if ( $count ) { 246 248 ?> 247 <p><?php printf(__('Akismet has caught <strong>%1$s spam</strong> for you since you first installed it.' ), number_format($count) ); ?></p>249 <p><?php printf(__('Akismet has caught <strong>%1$s spam</strong> for you since you first installed it.', 'akismet'), number_format($count) ); ?></p> 248 250 <?php 249 251 } 250 252 $spam_count = ksd_spam_count(); 251 253 if (0 == $spam_count) { 252 echo '<p>'.__('You have no spam currently in the queue. Must be your lucky day. :)' ).'</p>';254 echo '<p>'.__('You have no spam currently in the queue. Must be your lucky day. :)', 'akismet').'</p>'; 253 255 echo '</div>'; 254 256 } else { 255 echo '<p>'.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don’t sweat it.' ).'</p>';257 echo '<p>'.__('You can delete all of the spam from your database with a single click. This operation cannot be undone, so you may wish to check to ensure that no legitimate comments got through first. Spam is automatically deleted after 15 days, so don’t sweat it.', 'akismet').'</p>'; 256 258 ?> 257 259 <form method="post" action=""> 258 260 <input type="hidden" name="action" value="delete" /> 259 <?php printf(__('There are currently %1$s comments identified as spam.' ), $spam_count); ?> <input type="submit" name="Submit" value="<?php _e('Delete all'); ?>" />261 <?php printf(__('There are currently %1$s comments identified as spam.', 'akismet'), $spam_count); ?> <input type="submit" name="Submit" value="<?php _e('Delete all', 'akismet'); ?>" /> 260 262 <input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /> 261 263 </form> 262 264 </div> 263 265 <div class="wrap"> 264 <h2><?php _e('Latest Spam' ); ?></h2>265 <?php echo '<p>'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.' ).'</p>'; ?>266 <h2><?php _e('Latest Spam', 'akismet'); ?></h2> 267 <?php echo '<p>'.__('These are the latest comments identified as spam by Akismet. If you see any mistakes, simply mark the comment as "not spam" and Akismet will learn from the submission. If you wish to recover a comment from spam, simply select the comment, and click Not Spam. After 15 days we clean out the junk for you.', 'akismet').'</p>'; ?> 266 268 <?php 267 269 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT 150"); 268 270 … … 289 291 290 292 <p><label for="spam-<?php echo $comment->comment_ID; ?>"> 291 293 <input type="checkbox" id="spam-<?php echo $comment->comment_ID; ?>" name="not_spam[]" value="<?php echo $comment->comment_ID; ?>" /> 292 <?php _e('Not Spam' ) ?></label> — <?php comment_date('M j, g:i A'); ?> — [294 <?php _e('Not Spam', 'akismet') ?></label> — <?php comment_date('M j, g:i A'); ?> — [ 293 295 <?php 294 296 $post = get_post($comment->comment_post_ID); 295 297 $post_title = wp_specialchars( $post->post_title, 'double' ); … … 304 306 ?> 305 307 </ul> 306 308 <p class="submit"> 307 <input type="submit" name="submit" value="<?php _e('De-spam marked comments »' ); ?>" />309 <input type="submit" name="submit" value="<?php _e('De-spam marked comments »', 'akismet'); ?>" /> 308 310 </p> 309 <p><?php _e('Comments you de-spam will be submitted to Akismet as mistakes so it can learn and get better.' ); ?></p>311 <p><?php _e('Comments you de-spam will be submitted to Akismet as mistakes so it can learn and get better.', 'akismet'); ?></p> 310 312 </form> 311 313 <form method="post" action=""> 312 314 <p><input type="hidden" name="action" value="delete" /> 313 <?php printf(__('There are currently %1$s comments identified as spam.' ), $spam_count); ?> <input type="submit" name="Submit" value="<?php _e('Delete all'); ?>" />315 <?php printf(__('There are currently %1$s comments identified as spam.', 'akismet'), $spam_count); ?> <input type="submit" name="Submit" value="<?php _e('Delete all', 'akismet'); ?>" /> 314 316 <input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /></p> 315 317 </form> 316 318 </div> … … 325 327 if ( !$count ) 326 328 return; 327 329 $path = plugin_basename(__FILE__); 328 echo '<h3>'.__('Spam' ).'</h3>';329 echo '<p>'.sprintf(__('<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.' ), 'http://akismet.com/', "edit.php?page=$path", number_format($count) ).'</p>';330 echo '<h3>'.__('Spam', 'akismet').'</h3>'; 331 echo '<p>'.sprintf(__('<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', 'akismet'), 'http://akismet.com/', "edit.php?page=$path", number_format($count) ).'</p>'; 330 332 } 331 333 332 334 add_action('activity_box_end', 'akismet_stats');