WordPress.org

Plugin Directory

Changeset 418862


Ignore:
Timestamp:
08/03/11 17:09:31 (3 years ago)
Author:
lessbloat
Message:

Must have started with an older version of trunk. Fixed my changes.

Location:
akismet/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • akismet/trunk/admin.php

    r418849 r418862  
    2626    add_action('admin_head-'.$hook, 'akismet_stats_script'); 
    2727    add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal'); 
    28     wp_register_style('akismet.css', AKISMET_PLUGIN_URL . 'akismet.css'); 
    29     wp_enqueue_style('akismet.css'); 
    30     wp_register_script('akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery')); 
    31     wp_enqueue_script('akismet.js'); 
    3228} 
    3329add_action('admin_init', 'akismet_admin_init'); 
     30 
     31add_action( 'admin_enqueue_scripts', 'akismet_load_js_and_css' ); 
     32function akismet_load_js_and_css() { 
     33    global $hook_suffix; 
     34 
     35    if ( 
     36        $hook_suffix == 'index.php' # dashboard 
     37        || $hook_suffix == 'edit-comments.php'  
     38        || $hook_suffix == 'comment.php'  
     39        || $hook_suffix == 'post.php'  
     40        || $hook_suffix == 'plugins_page_akismet-key-config' 
     41    ) { 
     42        wp_register_style( 'akismet.css', AKISMET_PLUGIN_URL . 'akismet.css' ); 
     43        wp_enqueue_style( 'akismet.css'); 
     44     
     45        wp_register_script( 'akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery') ); 
     46        wp_enqueue_script( 'akismet.js' ); 
     47    } 
     48} 
     49 
    3450 
    3551function akismet_nonce_field($action = -1) { return wp_nonce_field($action); } 
     
    125141        'new_key_failed' => array('color' => '888', 'text' => __('The key you entered could not be verified because a connection to akismet.com could not be established. Please check your server configuration.')), 
    126142        'no_connection' => array('color' => '888', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')), 
    127         'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (<a href="%s" style="color:#fff">Get your key.</a>)'), 'http://akismet.com/get/')), 
     143        'key_empty' => array('color' => 'aa0', 'text' => sprintf(__('Please enter an API key. (<a href="%s" style="color:#fff">Get your key.</a>)'), 'http://akismet.com/get/?return=true')), 
    128144        'key_valid' => array('color' => '4AB915', 'text' => __('This key is valid.')), 
    129145        'key_failed' => array('color' => 'aa0', 'text' => __('The key below was previously validated but a connection to akismet.com can not be established at this time. Please check your server configuration.')), 
     
    142158<form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; "> 
    143159<?php if ( !$wpcom_api_key ) { ?> 
    144     <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 an API key yet, you can get one at <a href="%2$s">Akismet.com</a>.'), 'http://akismet.com/', 'http://akismet.com/get/'); ?></p> 
     160    <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 an API key yet, you can get one at <a href="%2$s">Akismet.com</a>.'), 'http://akismet.com/?return=true', 'http://akismet.com/get/?return=true'); ?></p> 
    145161 
    146162<h3><label for="key"><?php _e('Akismet API Key'); ?></label></h3> 
     
    148164    <p style="padding: .5em; background-color: #<?php echo $messages[$m]['color']; ?>; color: #fff; font-weight: bold;"><?php echo $messages[$m]['text']; ?></p> 
    149165<?php endforeach; ?> 
    150 <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://akismet.com/get/">What is this?</a>'); ?>)</p> 
     166<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://akismet.com/get/?return=true">What is this?</a>'); ?>)</p> 
    151167<?php if ( isset( $invalid_key) && $invalid_key ) { ?> 
    152168<h3><?php _e('Why might my key be invalid?'); ?></h3> 
     
    279295    else 
    280296        $link = 'edit.php'; 
    281     echo '<p>'.sprintf( _n( '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', $count ), 'http://akismet.com/', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>'; 
     297    echo '<p>'.sprintf( _n( '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', '<a href="%1$s">Akismet</a> has protected your site from <a href="%2$s">%3$s spam comments</a>.', $count ), 'http://akismet.com/?return=true', clean_url("$link?page=akismet-admin"), number_format_i18n($count) ).'</p>'; 
    282298} 
    283299add_action('activity_box_end', 'akismet_stats'); 
     
    446462            '<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ', 
    447463            $count 
    448         ), 'http://akismet.com/', number_format_i18n( $count ) ); 
     464        ), 'http://akismet.com/?return=true', number_format_i18n( $count ) ); 
    449465    } else { 
    450         $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/' ); 
     466        $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/?return=true' ); 
    451467    } 
    452468 
     
    644660} 
    645661 
     662 
     663function akismet_recheck_queue() { 
     664    global $wpdb, $akismet_api_host, $akismet_api_port; 
     665 
     666    if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) ) 
     667        return; 
     668         
     669    $moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A ); 
     670    foreach ( (array) $moderation as $c ) { 
     671        $c['user_ip']    = $c['comment_author_IP']; 
     672        $c['user_agent'] = $c['comment_agent']; 
     673        $c['referrer']   = ''; 
     674        $c['blog']       = get_bloginfo('url'); 
     675        $c['blog_lang']  = get_locale(); 
     676        $c['blog_charset'] = get_option('blog_charset'); 
     677        $c['permalink']  = get_permalink($c['comment_post_ID']); 
     678 
     679        $c['user_role'] = ''; 
     680        if ( isset( $c['user_ID'] ) ) 
     681            $c['user_role']  = akismet_get_user_roles($c['user_ID']); 
     682 
     683        if ( akismet_test_mode() ) 
     684            $c['is_test'] = 'true'; 
     685 
     686        $id = (int) $c['comment_ID']; 
     687 
     688        $query_string = ''; 
     689        foreach ( $c as $key => $data ) 
     690        $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; 
     691 
     692        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); 
     693        if ( 'true' == $response[1] ) { 
     694            wp_set_comment_status($c['comment_ID'], 'spam'); 
     695            update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' ); 
     696            akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' ); 
     697         
     698        } elseif ( 'false' == $response[1] ) { 
     699            update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' ); 
     700            akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' ); 
     701        // abnormal result: error 
     702        } else { 
     703            update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' ); 
     704            akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error' ); 
     705        } 
     706 
     707    } 
     708    wp_redirect( $_SERVER['HTTP_REFERER'] ); 
     709    exit; 
     710} 
     711 
     712add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue'); 
     713 
     714// Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link 
    646715function akismet_remove_comment_author_url() { 
    647716    if (!empty($_POST['id'])) { 
     
    672741add_action('wp_ajax_comment_author_reurl', 'akismet_add_comment_author_url'); 
    673742 
    674 function akismet_recheck_queue() { 
    675     global $wpdb, $akismet_api_host, $akismet_api_port; 
    676  
    677     if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) ) 
    678         return; 
    679          
    680     $moderation = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'", ARRAY_A ); 
    681     foreach ( (array) $moderation as $c ) { 
    682         $c['user_ip']    = $c['comment_author_IP']; 
    683         $c['user_agent'] = $c['comment_agent']; 
    684         $c['referrer']   = ''; 
    685         $c['blog']       = get_bloginfo('url'); 
    686         $c['blog_lang']  = get_locale(); 
    687         $c['blog_charset'] = get_option('blog_charset'); 
    688         $c['permalink']  = get_permalink($c['comment_post_ID']); 
    689  
    690         $c['user_role'] = ''; 
    691         if ( isset( $c['user_ID'] ) ) 
    692             $c['user_role']  = akismet_get_user_roles($c['user_ID']); 
    693  
    694         if ( akismet_test_mode() ) 
    695             $c['is_test'] = 'true'; 
    696  
    697         $id = (int) $c['comment_ID']; 
    698  
    699         $query_string = ''; 
    700         foreach ( $c as $key => $data ) 
    701         $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&'; 
    702  
    703         $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); 
    704         if ( 'true' == $response[1] ) { 
    705             wp_set_comment_status($c['comment_ID'], 'spam'); 
    706             update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' ); 
    707             akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' ); 
    708          
    709         } elseif ( 'false' == $response[1] ) { 
    710             update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' ); 
    711             akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' ); 
    712         // abnormal result: error 
    713         } else { 
    714             update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' ); 
    715             akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error' ); 
    716         } 
    717  
    718     } 
    719     wp_redirect( $_SERVER['HTTP_REFERER'] ); 
    720     exit; 
    721 } 
    722  
    723 add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue'); 
    724  
    725743// Check connectivity between the WordPress blog and Akismet's servers. 
    726744// Returns an associative array of server IP addresses, where the key is the IP address, and value is true (available) or false (unable to connect). 
     
    775793    return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) ); 
    776794} 
    777  
  • akismet/trunk/akismet.css

    r418849 r418862  
    11#submitted-on { position: relative; } 
    22#the-comment-list .author .akismet-user-comment-count { display: inline; } 
    3 #the-comment-list .author a span { text-decoration: none; color: #999; } 
    43#the-comment-list .remove_url { margin-left: 5px; color: #999; padding: 2px 3px 2px 0; } 
    54#the-comment-list .remove_url:hover { color: #A7301F; font-weight: bold; } 
  • akismet/trunk/akismet.js

    r418849 r418862  
    5353        return false; 
    5454    }); 
     55 
    5556}); 
  • akismet/trunk/readme.txt

    r418849 r418862  
    3232== Changelog == 
    3333 
     34= 2.5.4 = 
     35* Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it 
     36* Added author URL quick removal functionality 
     37 
    3438= 2.5.3 =  
    3539* Specify the license is GPL v2 or later 
    3640* Fix a bug that could result in orphaned commentmeta entries 
    3741* Include hotfix for WordPress 3.0.5 filter issue 
    38 * Added author URL quick removal functionality 
    3942 
    4043= 2.5.2 = 
Note: See TracChangeset for help on using the changeset viewer.