Make WordPress Core

Ticket #2509: akismet.php.diff

File akismet.php.diff, 11.4 KB (added by Sewar, 19 years ago)

Patch for Akismet plugin

  • akismet.php

     
    44Plugin URI: http://akismet.com/
    55Description: 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.
    66Author: Matt Mullenweg
     7Author URI: http://photomatt.net/
    78Version: 1.15
    8 Author URI: http://photomatt.net/
    99*/
    1010
     11load_plugin_textdomain('akismet', 'wp-content/plugins/akismet');
     12
    1113add_action('admin_menu', 'ksd_config_page');
    1214
    1315if ( ! function_exists('wp_nonce_field') ) {
     
    2527function ksd_config_page() {
    2628        global $wpdb;
    2729        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');
    2931}
    3032
    3133function akismet_conf() {
     
    4648?>
    4749
    4850<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>
    5153
    5254<form action="" method="post" id="akismet-conf" style="margin: auto; width: 25em; ">
    5355<?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>
    5557<?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>
    5759<?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 &raquo;'); ?>" /></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 &raquo;', 'akismet'); ?>" /></p>
    6062</form>
    6163</div>
    6264<?php
     
    7678        function akismet_warning() {
    7779        $path = plugin_basename(__FILE__);
    7880                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>
    8082                <style type='text/css'>
    8183                #adminmenu { margin-bottom: 5em; }
    8284                #akismet-warning { position: absolute; top: 7em; }
     
    200202
    201203function ksd_manage_page() {
    202204        global $wpdb;
    203         $count = sprintf(__('Akismet Spam (%s)'), ksd_spam_count());
     205        $count = sprintf(__('Akismet Spam (%s)', 'akismet'), ksd_spam_count());
    204206        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');
    206208}
    207209
    208210function ksd_caught() {
    209211        global $wpdb, $comment;
    210212        if (isset($_POST['submit']) && 'recover' == $_POST['action'] && ! empty($_POST['not_spam'])) {
    211213                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'));
    213215               
    214216                $i = 0;
    215217                foreach ($_POST['not_spam'] as $comment):
     
    221223                        ksd_submit_nonspam_comment($comment);
    222224                        ++$i;
    223225                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>";
    225227        }
    226228        if ('delete' == $_POST['action']) {
    227229                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'));
    229231
    230232                $delete_time = addslashes( $_POST['display_time'] );
    231233                $nuked = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
    232234                if (isset($nuked)) {
    233235                        echo '<div class="updated"><p>';
    234236                        if ($nuked) {
    235                                 _e('All spam deleted.');
     237                                _e('All spam deleted.', 'akismet');
    236238                        }
    237239                        echo "</p></div>";
    238240                }
    239241        }
    240242?>
    241243<div class="wrap">
    242 <h2><?php _e('Caught Spam') ?></h2>
     244<h2><?php _e('Caught Spam', 'akismet') ?></h2>
    243245<?php
    244246$count = get_option('akismet_spam_count');
    245247if ( $count ) {
    246248?>
    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>
    248250<?php
    249251}
    250252$spam_count = ksd_spam_count();
    251253if (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>';
    253255        echo '</div>';
    254256} 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&#8217;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&#8217;t sweat it.', 'akismet').'</p>';
    256258?>
    257259<form method="post" action="">
    258260<input type="hidden" name="action" value="delete" />
    259 <?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?>&nbsp; &nbsp; <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); ?>&nbsp; &nbsp; <input type="submit" name="Submit" value="<?php _e('Delete all', 'akismet'); ?>" />
    260262<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" />
    261263</form>
    262264</div>
    263265<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>'; ?>
    266268<?php
    267269$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = 'spam' ORDER BY comment_date DESC LIMIT 150");
    268270
     
    289291
    290292<p><label for="spam-<?php echo $comment->comment_ID; ?>">
    291293<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> &#8212; <?php comment_date('M j, g:i A');  ?> &#8212; [
     294<?php _e('Not Spam', 'akismet') ?></label> &#8212; <?php comment_date('M j, g:i A');  ?> &#8212; [
    293295<?php
    294296$post = get_post($comment->comment_post_ID);
    295297$post_title = wp_specialchars( $post->post_title, 'double' );
     
    304306?>
    305307</ul>
    306308<p class="submit">
    307 <input type="submit" name="submit" value="<?php _e('De-spam marked comments &raquo;'); ?>" />
     309<input type="submit" name="submit" value="<?php _e('De-spam marked comments &raquo;', 'akismet'); ?>" />
    308310</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>
    310312</form>
    311313<form method="post" action="">
    312314<p><input type="hidden" name="action" value="delete" />
    313 <?php printf(__('There are currently %1$s comments identified as spam.'), $spam_count); ?>&nbsp; &nbsp; <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); ?>&nbsp; &nbsp; <input type="submit" name="Submit" value="<?php _e('Delete all', 'akismet'); ?>" />
    314316<input type="hidden" name="display_time" value="<?php echo current_time('mysql', 1); ?>" /></p>
    315317</form>
    316318</div>
     
    325327        if ( !$count )
    326328                return;
    327329        $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>';
    330332}
    331333
    332334add_action('activity_box_end', 'akismet_stats');