summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Chatzimichos <tampakrap@gentoo.org>2012-06-13 16:18:13 +0200
committerTheo Chatzimichos <tampakrap@gentoo.org>2012-06-13 16:18:13 +0200
commitab05ecf6ac2bdd10e542eff7764de0f02a17f0a8 (patch)
tree5134afa67836f0657151a40cfba49c9adf969a50 /plugins/akismet
parentUpdate limit-login-attempts, smart-youtube and wp-stats (diff)
downloadblogs-gentoo-ab05ecf6ac2bdd10e542eff7764de0f02a17f0a8.tar.gz
blogs-gentoo-ab05ecf6ac2bdd10e542eff7764de0f02a17f0a8.tar.bz2
blogs-gentoo-ab05ecf6ac2bdd10e542eff7764de0f02a17f0a8.zip
New module jetpack, replacement of wp-stats
Update akismet, limit-login-attempts, smart-youtube, wp-importer
Diffstat (limited to 'plugins/akismet')
-rw-r--r--plugins/akismet/admin.php188
-rw-r--r--plugins/akismet/akismet.css5
-rw-r--r--plugins/akismet/akismet.js102
-rw-r--r--plugins/akismet/akismet.php122
-rw-r--r--plugins/akismet/index.php2
-rw-r--r--plugins/akismet/legacy.php6
-rw-r--r--plugins/akismet/readme.txt27
-rw-r--r--plugins/akismet/widget.php156
8 files changed, 477 insertions, 131 deletions
diff --git a/plugins/akismet/admin.php b/plugins/akismet/admin.php
index 91cedb29..aa30cde7 100644
--- a/plugins/akismet/admin.php
+++ b/plugins/akismet/admin.php
@@ -1,6 +1,6 @@
<?php
-add_action( 'admin_menu', 'akismet_config_page' );
-add_action( 'admin_menu', 'akismet_stats_page' );
+add_action( 'admin_menu', 'akismet_admin_menu' );
+
akismet_admin_warnings();
function akismet_admin_init() {
@@ -25,24 +25,38 @@ function akismet_admin_init() {
$hook = 'dashboard_page_akismet-stats-display';
add_action('admin_head-'.$hook, 'akismet_stats_script');
add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
- wp_register_style('akismet.css', AKISMET_PLUGIN_URL . 'akismet.css');
- wp_enqueue_style('akismet.css');
- wp_register_script('akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'));
- wp_enqueue_script('akismet.js');
}
add_action('admin_init', 'akismet_admin_init');
+add_action( 'admin_enqueue_scripts', 'akismet_load_js_and_css' );
+function akismet_load_js_and_css() {
+ global $hook_suffix;
+
+ if (
+ $hook_suffix == 'index.php' # dashboard
+ || $hook_suffix == 'edit-comments.php'
+ || $hook_suffix == 'comment.php'
+ || $hook_suffix == 'post.php'
+ || $hook_suffix == 'plugins_page_akismet-key-config'
+ ) {
+ wp_register_style( 'akismet.css', AKISMET_PLUGIN_URL . 'akismet.css', array(), '2.5.4.4' );
+ wp_enqueue_style( 'akismet.css');
+
+ wp_register_script( 'akismet.js', AKISMET_PLUGIN_URL . 'akismet.js', array('jquery'), '2.5.4.6' );
+ wp_enqueue_script( 'akismet.js' );
+ wp_localize_script( 'akismet.js', 'WPAkismet', array(
+ 'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' )
+ ) );
+ }
+}
+
+
function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
$akismet_nonce = 'akismet-update-key';
-function akismet_config_page() {
- if ( function_exists('add_submenu_page') )
- add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
-}
-
function akismet_plugin_action_links( $links, $file ) {
if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
- $links[] = '<a href="plugins.php?page=akismet-key-config">'.__('Settings').'</a>';
+ $links[] = '<a href="admin.php?page=akismet-key-config">'.__('Settings').'</a>';
}
return $links;
@@ -111,8 +125,7 @@ function akismet_conf() {
if ( $key_status == 'valid' ) {
$ms[] = 'key_valid';
} else if ( $key_status == 'invalid' ) {
- delete_option('wordpress_api_key');
- $ms[] = 'key_empty';
+ $ms[] = 'key_invalid';
} else if ( !empty($key) && $key_status == 'failed' ) {
$ms[] = 'key_failed';
}
@@ -124,8 +137,9 @@ function akismet_conf() {
'new_key_invalid' => array('color' => '888', 'text' => __('The key you entered is invalid. Please double-check it.')),
'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.')),
'no_connection' => array('color' => '888', 'text' => __('There was a problem connecting to the Akismet server. Please check your server configuration.')),
- '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/')),
+ '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')),
'key_valid' => array('color' => '4AB915', 'text' => __('This key is valid.')),
+ 'key_invalid' => array('color' => '888', 'text' => __('This key is invalid.')),
'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.')),
'bad_home_url' => array('color' => '888', 'text' => sprintf( __('Your WordPress home URL %s is invalid. Please fix the <a href="%s">home option</a>.'), esc_html( get_bloginfo('url') ), admin_url('options.php#home') ) ),
);
@@ -141,13 +155,13 @@ function akismet_conf() {
<div class="narrow">
<form action="" method="post" id="akismet-conf" style="margin: auto; width: 400px; ">
<?php if ( !$wpcom_api_key ) { ?>
- <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>
+ <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>
<h3><label for="key"><?php _e('Akismet API Key'); ?></label></h3>
<?php foreach ( $ms as $m ) : ?>
<p style="padding: .5em; background-color: #<?php echo $messages[$m]['color']; ?>; color: #fff; font-weight: bold;"><?php echo $messages[$m]['text']; ?></p>
<?php endforeach; ?>
-<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>
+<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>
<?php if ( isset( $invalid_key) && $invalid_key ) { ?>
<h3><?php _e('Why might my key be invalid?'); ?></h3>
<p><?php _e('This can mean one of two things, either you copied the key wrong or that the plugin is unable to reach the Akismet servers, which is most often caused by an issue with your web host around firewalls or similar.'); ?></p>
@@ -226,12 +240,6 @@ function akismet_conf() {
<?php
}
-function akismet_stats_page() {
- if ( function_exists('add_submenu_page') )
- add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
-
-}
-
function akismet_stats_script() {
?>
<script type="text/javascript">
@@ -278,16 +286,41 @@ function akismet_stats() {
$link = 'edit-comments.php';
else
$link = 'edit.php';
- 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>';
+ 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>';
}
add_action('activity_box_end', 'akismet_stats');
function akismet_admin_warnings() {
- global $wpcom_api_key;
+ global $wpcom_api_key, $pagenow;
+
+ if (
+ $pagenow == 'edit-comments.php'
+ || ( !empty( $_GET['page'] ) && $_GET['page'] == 'akismet-key-config' )
+ || ( !empty( $_GET['page'] ) && $_GET['page'] == 'akismet-stats-display' )
+ ) {
+ if ( get_option( 'akismet_alert_code' ) ) {
+ function akismet_alert() {
+ $alert = array(
+ 'code' => (int) get_option( 'akismet_alert_code' ),
+ 'msg' => get_option( 'akismet_alert_msg' )
+ );
+ ?>
+ <div class='error'>
+ <p><strong>Akismet Error Code: <?php echo $alert['code']; ?></strong></p>
+ <p><?php esc_html_e( $alert['msg'] ); ?></p>
+ <p>More information is available at <a href="https://akismet.com/errors/<?php echo $alert['code']; ?>">https://akismet.com/errors/<?php echo $alert['code']; ?></a></p>
+ </div>
+ <?php
+ }
+
+ add_action( 'admin_notices', 'akismet_alert' );
+ }
+ }
+
if ( !get_option('wordpress_api_key') && !$wpcom_api_key && !isset($_POST['submit']) ) {
function akismet_warning() {
echo "
- <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet is almost ready.')."</strong> ".sprintf(__('You must <a href="%1$s">enter your Akismet API key</a> for it to work.'), "plugins.php?page=akismet-key-config")."</p></div>
+ <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet is almost ready.')."</strong> ".sprintf(__('You must <a href="%1$s">enter your Akismet API key</a> for it to work.'), "admin.php?page=akismet-key-config")."</p></div>
";
}
add_action('admin_notices', 'akismet_warning');
@@ -295,11 +328,12 @@ function akismet_admin_warnings() {
} elseif ( ( empty($_SERVER['SCRIPT_FILENAME']) || basename($_SERVER['SCRIPT_FILENAME']) == 'edit-comments.php' ) && wp_next_scheduled('akismet_schedule_cron_recheck') ) {
function akismet_warning() {
global $wpdb;
+ akismet_fix_scheduled_recheck();
$waiting = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
- $next_check = human_time_diff( wp_next_scheduled('akismet_schedule_cron_recheck') );
- if ( $waiting > 0 )
+ $next_check = wp_next_scheduled('akismet_schedule_cron_recheck');
+ if ( $waiting > 0 && $next_check > time() )
echo "
- <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(_n('A server or network problem prevented Akismet from checking %d comment. It has been temporarily held for moderation and will be automatically re-checked in %s.', 'A server or network problem prevented Akismet from checking %d comments. They have been temporarily held for moderation and will be automatically re-checked in %s.', $waiting), number_format_i18n( $waiting ), $next_check)."</p></div>
+ <div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(__('Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation. Please check your <a href="%s">Akismet configuration</a> and contact your web host if problems persist.'), 'admin.php?page=akismet-key-config')."</p></div>
";
}
add_action('admin_notices', 'akismet_warning');
@@ -316,10 +350,13 @@ function akismet_comment_row_action( $a, $comment ) {
return $a;
$akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true );
+ $akismet_error = get_comment_meta( $comment->comment_ID, 'akismet_error', true );
$user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true);
$comment_status = wp_get_comment_status( $comment->comment_ID );
$desc = null;
- if ( !$user_result || $user_result == $akismet_result ) {
+ if ( $akismet_error ) {
+ $desc = __( 'Awaiting spam check' );
+ } elseif ( !$user_result || $user_result == $akismet_result ) {
// Show the original Akismet result if the user hasn't overridden it, or if their decision was the same
if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' )
$desc = __( 'Flagged as spam by Akismet' );
@@ -338,8 +375,12 @@ function akismet_comment_row_action( $a, $comment ) {
$b = array();
foreach ( $a as $k => $item ) {
$b[ $k ] = $item;
- if ( $k == 'edit' )
+ if (
+ $k == 'edit'
+ || ( $k == 'unspam' && $GLOBALS['wp_version'] >= 3.4 )
+ ) {
$b['history'] = '<a href="comment.php?action=editcomment&amp;c='.$comment->comment_ID.'#akismet-status" title="'. esc_attr__( 'View comment history' ) . '"> '. __('History') . '</a>';
+ }
}
$a = $b;
@@ -428,11 +469,6 @@ add_filter('comment_text', 'akismet_text_add_link_class');
function akismet_rightnow() {
global $submenu, $wp_db_version;
- // clean_url was deprecated in WP 3.0
- $esc_url = 'clean_url';
- if ( function_exists( 'esc_url' ) )
- $esc_url = 'esc_url';
-
if ( 8645 < $wp_db_version ) // 2.7
$link = 'edit-comments.php?comment_status=spam';
elseif ( isset( $submenu['edit-comments.php'] ) )
@@ -445,19 +481,20 @@ function akismet_rightnow() {
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comment already. ',
'<a href="%1$s">Akismet</a> has protected your site from %2$s spam comments already. ',
$count
- ), 'http://akismet.com/', number_format_i18n( $count ) );
+ ), 'http://akismet.com/?return=true', number_format_i18n( $count ) );
} else {
- $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/' );
+ $intro = sprintf( __('<a href="%1$s">Akismet</a> blocks spam from getting to your blog. '), 'http://akismet.com/?return=true' );
}
+ $link = function_exists( 'esc_url' ) ? esc_url( $link ) : clean_url( $link );
if ( $queue_count = akismet_spam_count() ) {
$queue_text = sprintf( _n(
'There\'s <a href="%2$s">%1$s comment</a> in your spam queue right now.',
'There are <a href="%2$s">%1$s comments</a> in your spam queue right now.',
$queue_count
- ), number_format_i18n( $queue_count ), $esc_url($link) );
+ ), number_format_i18n( $queue_count ), $link );
} else {
- $queue_text = sprintf( __( "There's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $esc_url($link) );
+ $queue_text = sprintf( __( "There's nothing in your <a href='%1\$s'>spam queue</a> at the moment." ), $link );
}
$text = $intro . '<br />' . $queue_text;
@@ -512,6 +549,9 @@ function akismet_submit_nonspam_comment ( $comment_id ) {
if ( akismet_test_mode() )
$comment->is_test = 'true';
+ $post = get_post( $comment->comment_post_ID );
+ $comment->comment_post_modified_gmt = $post->post_modified_gmt;
+
$query_string = '';
foreach ( $comment as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
@@ -561,6 +601,9 @@ function akismet_submit_spam_comment ( $comment_id ) {
if ( akismet_test_mode() )
$comment->is_test = 'true';
+ $post = get_post( $comment->comment_post_ID );
+ $comment->comment_post_modified_gmt = $post->post_modified_gmt;
+
$query_string = '';
foreach ( $comment as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
@@ -591,6 +634,10 @@ function akismet_transition_comment_status( $new_status, $old_status, $comment )
if ( defined('WP_IMPORTING') && WP_IMPORTING == true )
return;
+
+ // if this is present, it means the status has been changed by a re-check, not an explicit user action
+ if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
+ return;
global $current_user;
$reporter = '';
@@ -611,8 +658,7 @@ function akismet_transition_comment_status( $new_status, $old_status, $comment )
}
}
- if ( !get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
- akismet_update_comment_history( $comment->comment_ID, sprintf( __('%s changed the comment status to %s'), $reporter, $new_status ), 'status-' . $new_status );
+ akismet_update_comment_history( $comment->comment_ID, sprintf( __('%s changed the comment status to %s'), $reporter, $new_status ), 'status-' . $new_status );
}
add_action( 'transition_comment_status', 'akismet_transition_comment_status', 10, 3 );
@@ -647,6 +693,8 @@ function akismet_spam_count( $type = false ) {
function akismet_recheck_queue() {
global $wpdb, $akismet_api_host, $akismet_api_port;
+ akismet_fix_scheduled_recheck();
+
if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) )
return;
@@ -673,28 +721,63 @@ function akismet_recheck_queue() {
foreach ( $c as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
+ add_comment_meta( $c['comment_ID'], 'akismet_rechecking', true );
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
if ( 'true' == $response[1] ) {
wp_set_comment_status($c['comment_ID'], 'spam');
update_comment_meta( $c['comment_ID'], 'akismet_result', 'true' );
+ delete_comment_meta( $c['comment_ID'], 'akismet_error' );
akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and caught this comment as spam'), 'check-spam' );
} elseif ( 'false' == $response[1] ) {
update_comment_meta( $c['comment_ID'], 'akismet_result', 'false' );
+ delete_comment_meta( $c['comment_ID'], 'akismet_error' );
akismet_update_comment_history( $c['comment_ID'], __('Akismet re-checked and cleared this comment'), 'check-ham' );
// abnormal result: error
} else {
update_comment_meta( $c['comment_ID'], 'akismet_result', 'error' );
- akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), $response[1]), 'check-error' );
+ akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), substr($response[1], 0, 50)), 'check-error' );
}
+ delete_comment_meta( $c['comment_ID'], 'akismet_rechecking' );
}
- wp_redirect( $_SERVER['HTTP_REFERER'] );
+ wp_safe_redirect( $_SERVER['HTTP_REFERER'] );
exit;
}
add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
+// Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link
+function akismet_remove_comment_author_url() {
+ if ( !empty($_POST['id'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
+ global $wpdb;
+ $comment = get_comment( intval($_POST['id']), ARRAY_A );
+ if (current_user_can('edit_comment', $comment['comment_ID'])) {
+ $comment['comment_author_url'] = '';
+ do_action( 'comment_remove_author_url' );
+ print(wp_update_comment( $comment ));
+ die();
+ }
+ }
+}
+
+add_action('wp_ajax_comment_author_deurl', 'akismet_remove_comment_author_url');
+
+function akismet_add_comment_author_url() {
+ if ( !empty( $_POST['id'] ) && !empty( $_POST['url'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) {
+ global $wpdb;
+ $comment = get_comment( intval($_POST['id']), ARRAY_A );
+ if (current_user_can('edit_comment', $comment['comment_ID'])) {
+ $comment['comment_author_url'] = esc_url($_POST['url']);
+ do_action( 'comment_add_author_url' );
+ print(wp_update_comment( $comment ));
+ die();
+ }
+ }
+}
+
+add_action('wp_ajax_comment_author_reurl', 'akismet_add_comment_author_url');
+
// Check connectivity between the WordPress blog and Akismet's servers.
// 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).
function akismet_check_server_connectivity() {
@@ -748,3 +831,20 @@ function akismet_server_connectivity_ok() {
return !( empty($servers) || !count($servers) || count( array_filter($servers) ) < count($servers) );
}
+function akismet_admin_menu() {
+ if ( class_exists( 'Jetpack' ) ) {
+ add_action( 'jetpack_admin_menu', 'akismet_load_menu' );
+ } else {
+ akismet_load_menu();
+ }
+}
+
+function akismet_load_menu() {
+ if ( class_exists( 'Jetpack' ) ) {
+ add_submenu_page( 'jetpack', __( 'Akismet Configuration' ), __( 'Akismet Configuration' ), 'manage_options', 'akismet-key-config', 'akismet_conf' );
+ add_submenu_page( 'jetpack', __( 'Akismet Stats' ), __( 'Akismet Stats' ), 'manage_options', 'akismet-stats-display', 'akismet_stats_display' );
+ } else {
+ add_submenu_page('plugins.php', __('Akismet Configuration'), __('Akismet Configuration'), 'manage_options', 'akismet-key-config', 'akismet_conf');
+ add_submenu_page('index.php', __('Akismet Stats'), __('Akismet Stats'), 'manage_options', 'akismet-stats-display', 'akismet_stats_display');
+ }
+}
diff --git a/plugins/akismet/akismet.css b/plugins/akismet/akismet.css
index 6bc84587..dccc9c49 100644
--- a/plugins/akismet/akismet.css
+++ b/plugins/akismet/akismet.css
@@ -1,7 +1,12 @@
#submitted-on { position: relative; }
#the-comment-list .author .akismet-user-comment-count { display: inline; }
+#the-comment-list .author a span { text-decoration: none; color: #999; }
+#the-comment-list .remove_url { margin-left: 3px; color: #999; padding: 2px 3px 2px 0; }
+#the-comment-list .remove_url:hover { color: #A7301F; font-weight: bold; padding: 2px 2px 2px 0; }
#dashboard_recent_comments .akismet-status { display: none; } /* never show the flagged by text on the dashboard */
.akismet-status { float: right; }
.akismet-status a { color: #AAA; font-style: italic; }
span.comment-link a { text-decoration: underline; }
span.comment-link:after { content: " " attr(title) " "; color: #aaa; text-decoration: none; }
+.mshot-arrow { width: 0; height: 0; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-right:10px solid #5C5C5C; position: absolute; left: -6px; top: 91px; }
+.mshot-container { background: #5C5C5C; position: absolute; top: -94px; padding: 7px; width: 450px; height: 338px; z-index: 20000; -moz-border-radius:6px; border-radius:6px; -webkit-border-radius:6px; } \ No newline at end of file
diff --git a/plugins/akismet/akismet.js b/plugins/akismet/akismet.js
index 39089351..839fe6bc 100644
--- a/plugins/akismet/akismet.js
+++ b/plugins/akismet/akismet.js
@@ -7,4 +7,106 @@ jQuery(document).ready(function () {
var thisId = jQuery(this).attr('commentid');
jQuery(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
});
+ jQuery('#the-comment-list tr.comment .column-author a[title ^= "http://"]').each(function () {
+ var thisTitle = jQuery(this).attr('title');
+ thisCommentId = jQuery(this).parents('tr:first').attr('id').split("-");
+
+ jQuery(this).attr("id", "author_comment_url_"+ thisCommentId[1]);
+
+ if (thisTitle) {
+ jQuery(this).after(' <a href="#" class="remove_url" commentid="'+ thisCommentId[1] +'" title="Remove this URL">x</a>');
+ }
+ });
+ jQuery('.remove_url').live('click', function () {
+ var thisId = jQuery(this).attr('commentid');
+ var data = {
+ action: 'comment_author_deurl',
+ _wpnonce: WPAkismet.comment_author_url_nonce,
+ id: thisId
+ };
+ jQuery.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ data: data,
+ beforeSend: function () {
+ // Removes "x" link
+ jQuery("a[commentid='"+ thisId +"']").hide();
+ // Show temp status
+ jQuery("#author_comment_url_"+ thisId).html('<span>Removing...</span>');
+ },
+ success: function (response) {
+ if (response) {
+ // Show status/undo link
+ jQuery("#author_comment_url_"+ thisId).attr('cid', thisId).addClass('akismet_undo_link_removal').html('<span>URL removed (</span>undo<span>)</span>');
+ }
+ }
+ });
+
+ return false;
+ });
+ jQuery('.akismet_undo_link_removal').live('click', function () {
+ var thisId = jQuery(this).attr('cid');
+ var thisUrl = jQuery(this).attr('href').replace("http://www.", "").replace("http://", "");
+ var data = {
+ action: 'comment_author_reurl',
+ _wpnonce: WPAkismet.comment_author_url_nonce,
+ id: thisId,
+ url: thisUrl
+ };
+ jQuery.ajax({
+ url: ajaxurl,
+ type: 'POST',
+ data: data,
+ beforeSend: function () {
+ // Show temp status
+ jQuery("#author_comment_url_"+ thisId).html('<span>Re-adding…</span>');
+ },
+ success: function (response) {
+ if (response) {
+ // Add "x" link
+ jQuery("a[commentid='"+ thisId +"']").show();
+ // Show link
+ jQuery("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').html(thisUrl);
+ }
+ }
+ });
+
+ return false;
+ });
+ jQuery('a[id^="author_comment_url"]').mouseover(function () {
+ // Need to determine size of author column
+ var thisParentWidth = jQuery(this).parent().width();
+ // It changes based on if there is a gravatar present
+ thisParentWidth = (jQuery(this).parent().find('.grav-hijack').length) ? thisParentWidth - 42 + 'px' : thisParentWidth + 'px';
+ if (jQuery(this).find('.mShot').length == 0 && !jQuery(this).hasClass('akismet_undo_link_removal')) {
+ var thisId = jQuery(this).attr('id').replace('author_comment_url_', '');
+ jQuery('.widefat td').css('overflow', 'visible');
+ jQuery(this).css('position', 'relative');
+ var thisHref = jQuery.URLEncode(jQuery(this).attr('href'));
+ jQuery(this).append('<div class="mShot mshot-container" style="left: '+thisParentWidth+'"><div class="mshot-arrow"></div><img src="http://s.wordpress.com/mshots/v1/'+thisHref+'?w=450" width="450" class="mshot-image_'+thisId+'" style="margin: 0;" /></div>');
+ setTimeout(function () {
+ jQuery('.mshot-image_'+thisId).attr('src', 'http://s.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2');
+ }, 6000);
+ setTimeout(function () {
+ jQuery('.mshot-image_'+thisId).attr('src', 'http://s.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3');
+ }, 12000);
+ } else {
+ jQuery(this).find('.mShot').css('left', thisParentWidth).show();
+ }
+ }).mouseout(function () {
+ jQuery(this).find('.mShot').hide();
+ });
+});
+// URL encode plugin
+jQuery.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
+ while(x<c.length){var m=r.exec(c.substr(x));
+ if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
+ }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
+ o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;}
});
+// Preload mshot images after everything else has loaded
+jQuery(window).load(function() {
+ jQuery('a[id^="author_comment_url"]').each(function () {
+ jQuery.get('http://s.wordpress.com/mshots/v1/'+jQuery.URLEncode(jQuery(this).attr('href'))+'?w=450');
+ });
+}); \ No newline at end of file
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php
index ad86624d..48fa3c3a 100644
--- a/plugins/akismet/akismet.php
+++ b/plugins/akismet/akismet.php
@@ -4,9 +4,9 @@
*/
/*
Plugin Name: Akismet
-Plugin URI: http://akismet.com/
-Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="plugins.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key.
-Version: 2.5.3
+Plugin URI: http://akismet.com/?return=true
+Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="admin.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key.
+Version: 2.5.6
Author: Automattic
Author URI: http://automattic.com/wordpress-plugins/
License: GPLv2 or later
@@ -28,7 +28,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-define('AKISMET_VERSION', '2.5.3');
+define('AKISMET_VERSION', '2.5.6');
define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ ));
/** If you hardcode a WP.com API key here, all key config screens will be hidden */
@@ -71,12 +71,33 @@ function akismet_get_key() {
return get_option('wordpress_api_key');
}
-function akismet_verify_key( $key, $ip = null ) {
+function akismet_check_key_status( $key, $ip = null ) {
global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
$blog = urlencode( get_option('home') );
if ( $wpcom_api_key )
$key = $wpcom_api_key;
$response = akismet_http_post("key=$key&blog=$blog", 'rest.akismet.com', '/1.1/verify-key', $akismet_api_port, $ip);
+ return $response;
+}
+
+// given a response from an API call like akismet_check_key_status(), update the alert code options if an alert is present.
+function akismet_update_alert( $response ) {
+ $code = $msg = null;
+ if ( isset($response[0]['x-akismet-alert-code']) ) {
+ $code = $response[0]['x-akismet-alert-code'];
+ $msg = $response[0]['x-akismet-alert-msg'];
+ }
+
+ // only call update_option() if the value has changed
+ if ( $code != get_option( 'akismet_alert_code' ) ) {
+ update_option( 'akismet_alert_code', $code );
+ update_option( 'akismet_alert_msg', $msg );
+ }
+}
+
+function akismet_verify_key( $key, $ip = null ) {
+ $response = akismet_check_key_status( $key, $ip );
+ akismet_update_alert( $response );
if ( !is_array($response) || !isset($response[1]) || $response[1] != 'valid' && $response[1] != 'invalid' )
return 'failed';
return $response[1];
@@ -121,6 +142,8 @@ function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
$akismet_ua = "WordPress/{$wp_version} | ";
$akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
+ $akismet_ua = apply_filters( 'akismet_ua', $akismet_ua );
+
$content_length = strlen( $request );
$http_host = $host;
@@ -279,7 +302,7 @@ function akismet_auto_check_update_meta( $id, $comment ) {
// abnormal result: error
} else {
update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
- akismet_update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), $akismet_last_comment['akismet_result']), 'check-error' );
+ akismet_update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), substr($akismet_last_comment['akismet_result'], 0, 50)), 'check-error' );
}
// record the complete original data as submitted for checking
@@ -304,7 +327,9 @@ function akismet_auto_check_comment( $commentdata ) {
$comment['blog_charset'] = get_option('blog_charset');
$comment['permalink'] = get_permalink($comment['comment_post_ID']);
- $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
+ if ( !empty( $comment['user_ID'] ) ) {
+ $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
+ }
$akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
$comment['akismet_comment_nonce'] = 'inactive';
@@ -336,6 +361,9 @@ function akismet_auto_check_comment( $commentdata ) {
$comment["$key"] = '';
}
+ $post = get_post( $comment['comment_post_ID'] );
+ $comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
+
$query_string = '';
foreach ( $comment as $key => $data )
$query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
@@ -343,6 +371,7 @@ function akismet_auto_check_comment( $commentdata ) {
$commentdata['comment_as_submitted'] = $comment;
$response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
+ akismet_update_alert( $response );
$commentdata['akismet_result'] = $response[1];
if ( 'true' == $response[1] ) {
// akismet_spam_count will be incremented later by akismet_result_spam()
@@ -350,7 +379,6 @@ function akismet_auto_check_comment( $commentdata ) {
do_action( 'akismet_spam_caught' );
- $post = get_post( $comment['comment_post_ID'] );
$last_updated = strtotime( $post->post_modified_gmt );
$diff = time() - $last_updated;
$diff = $diff / 86400;
@@ -359,15 +387,19 @@ function akismet_auto_check_comment( $commentdata ) {
// akismet_result_spam() won't be called so bump the counter here
if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
- wp_redirect( $_SERVER['HTTP_REFERER'] );
+ wp_safe_redirect( $_SERVER['HTTP_REFERER'] );
die();
}
}
// if the response is neither true nor false, hold the comment for moderation and schedule a recheck
if ( 'true' != $response[1] && 'false' != $response[1] ) {
- add_filter('pre_comment_approved', 'akismet_result_hold');
- wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
+ if ( !current_user_can('moderate_comments') ) {
+ add_filter('pre_comment_approved', 'akismet_result_hold');
+ }
+ if ( !wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) {
+ wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
+ }
}
if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
@@ -379,6 +411,8 @@ function akismet_auto_check_comment( $commentdata ) {
akismet_delete_old();
}
$akismet_last_comment = $commentdata;
+
+ akismet_fix_scheduled_recheck();
return $commentdata;
}
@@ -403,7 +437,42 @@ function akismet_delete_old() {
}
+function akismet_delete_old_metadata() {
+ global $wpdb;
+
+ $now_gmt = current_time( 'mysql', 1 );
+ $interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
+
+ # enfore a minimum of 1 day
+ $interval = absint( $interval );
+ if ( $interval < 1 ) {
+ return;
+ }
+
+ // akismet_as_submitted meta values are large, so expire them
+ // after $interval days regardless of the comment status
+ while ( TRUE ) {
+ $comment_ids = $wpdb->get_col( "SELECT $wpdb->comments.comment_id FROM $wpdb->commentmeta INNER JOIN $wpdb->comments USING(comment_id) WHERE meta_key = 'akismet_as_submitted' AND DATE_SUB('$now_gmt', INTERVAL {$interval} DAY) > comment_date_gmt LIMIT 10000" );
+
+ if ( empty( $comment_ids ) ) {
+ return;
+ }
+
+ foreach ( $comment_ids as $comment_id ) {
+ delete_comment_meta( $comment_id, 'akismet_as_submitted' );
+ }
+ }
+
+ /*
+ $n = mt_rand( 1, 5000 );
+ if ( apply_filters( 'akismet_optimize_table', ( $n == 11 ), 'commentmeta' ) ) { // lucky number
+ $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" );
+ }
+ */
+}
+
add_action('akismet_scheduled_delete', 'akismet_delete_old');
+add_action('akismet_scheduled_delete', 'akismet_delete_old_metadata');
function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
global $wpdb, $akismet_api_host, $akismet_api_port;
@@ -436,6 +505,13 @@ function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
function akismet_cron_recheck() {
global $wpdb;
+ $status = akismet_verify_key( akismet_get_key() );
+ if ( get_option( 'akismet_alert_code' ) || $status == 'invalid' ) {
+ // since there is currently a problem with the key, reschedule a check for 6 hours hence
+ wp_schedule_single_event( time() + 21600, 'akismet_schedule_cron_recheck' );
+ return false;
+ }
+
delete_option('akismet_available_servers');
$comment_errors = $wpdb->get_col( "
@@ -446,8 +522,9 @@ function akismet_cron_recheck() {
" );
foreach ( (array) $comment_errors as $comment_id ) {
- // if the comment no longer exists, remove the meta entry from the queue to avoid getting stuck
- if ( !get_comment( $comment_id ) ) {
+ // if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
+ $comment = get_comment( $comment_id );
+ if ( !$comment || strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) ) {
delete_comment_meta( $comment_id, 'akismet_error' );
continue;
}
@@ -486,6 +563,7 @@ function akismet_cron_recheck() {
wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
return;
}
+ delete_comment_meta( $comment_id, 'akismet_rechecking' );
}
$remaining = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
@@ -506,8 +584,26 @@ $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_opti
if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
add_action( 'comment_form', 'akismet_add_comment_nonce' );
+global $wp_version;
if ( '3.0.5' == $wp_version ) {
remove_filter( 'comment_text', 'wp_kses_data' );
if ( is_admin() )
add_filter( 'comment_text', 'wp_kses_post' );
}
+
+function akismet_fix_scheduled_recheck() {
+ $future_check = wp_next_scheduled( 'akismet_schedule_cron_recheck' );
+ if ( !$future_check ) {
+ return;
+ }
+
+ if ( get_option( 'akismet_alert_code' ) > 0 ) {
+ return;
+ }
+
+ $check_range = time() + 1200;
+ if ( $future_check > $check_range ) {
+ wp_clear_scheduled_hook( 'akismet_schedule_cron_recheck' );
+ wp_schedule_single_event( time() + 300, 'akismet_schedule_cron_recheck' );
+ }
+}
diff --git a/plugins/akismet/index.php b/plugins/akismet/index.php
new file mode 100644
index 00000000..a6ce9c89
--- /dev/null
+++ b/plugins/akismet/index.php
@@ -0,0 +1,2 @@
+<?php
+# Silence is golden.
diff --git a/plugins/akismet/legacy.php b/plugins/akismet/legacy.php
index d5d53b08..e6de8cb3 100644
--- a/plugins/akismet/legacy.php
+++ b/plugins/akismet/legacy.php
@@ -71,7 +71,7 @@ function akismet_caught() {
++$i;
endforeach;
$to = add_query_arg( 'recovered', $i, $_SERVER['HTTP_REFERER'] );
- wp_redirect( $to );
+ wp_safe_redirect( $to );
exit;
}
if ('delete' == $_POST['action']) {
@@ -87,7 +87,7 @@ function akismet_caught() {
wp_cache_delete( 'akismet_spam_count', 'widget' );
}
$to = add_query_arg( 'deleted', 'all', $_SERVER['HTTP_REFERER'] );
- wp_redirect( $to );
+ wp_safe_redirect( $to );
exit;
}
@@ -366,7 +366,7 @@ function redirect_old_akismet_urls( ) {
// 2.7 redirect for people who might have bookmarked the old page
if ( 8204 < $wp_db_version && ( 'edit-comments.php' == $script_name || 'edit.php' == $script_name ) && 'akismet-admin' == $page ) {
$new_url = esc_url( 'edit-comments.php?comment_status=spam' );
- wp_redirect( $new_url, 301 );
+ wp_safe_redirect( $new_url, 301 );
exit;
}
}
diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt
index fbd3513b..227fad95 100644
--- a/plugins/akismet/readme.txt
+++ b/plugins/akismet/readme.txt
@@ -2,8 +2,8 @@
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, automattic
Tags: akismet, comments, spam
Requires at least: 3.0
-Tested up to: 3.1
-Stable tag: 2.5.3
+Tested up to: 3.4
+Stable tag: 2.5.6
License: GPLv2 or later
Akismet checks your comments against the Akismet web service to see if they look like spam or not.
@@ -31,6 +31,29 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
== Changelog ==
+= 2.5.6 =
+* Prevent retry scheduling problems on sites where wp_cron is misbehaving
+* Preload mshot previews
+* Modernize the widget code
+* Fix a bug where comments were not held for moderation during an error condition
+* Improve the UX and display when comments are temporarily held due to an error
+* Make the Check For Spam button force a retry when comments are held due to an error
+* Handle errors caused by an invalid key
+* Don't retry comments that are too old
+* Improve error messages when verifying an API key
+
+= 2.5.5 =
+* Add nonce check for comment author URL remove action
+* Fix the settings link
+
+= 2.5.4 =
+* Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it
+* Added author URL quick removal functionality
+* Added mShot preview on Author URL hover
+* Added empty index.php to prevent directory listing
+* Move wp-admin menu items under Jetpack, if it is installed
+* Purge old Akismet comment meta data, default of 15 days
+
= 2.5.3 =
* Specify the license is GPL v2 or later
* Fix a bug that could result in orphaned commentmeta entries
diff --git a/plugins/akismet/widget.php b/plugins/akismet/widget.php
index e9a3f626..8c5a120f 100644
--- a/plugins/akismet/widget.php
+++ b/plugins/akismet/widget.php
@@ -2,89 +2,107 @@
/**
* @package Akismet
*/
-// Widget stuff
-function widget_akismet_register() {
- if ( function_exists('register_sidebar_widget') ) :
- function widget_akismet($args) {
- extract($args);
- $options = get_option('widget_akismet');
- $count = get_option('akismet_spam_count');
- ?>
- <?php echo $before_widget; ?>
- <?php echo $before_title . $options['title'] . $after_title; ?>
- <div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><?php printf( _n( '%1$s%2$s%3$s %4$sspam comment%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', '%1$s%2$s%3$s %4$sspam comments%5$s %6$sblocked by%7$s<br />%8$sAkismet%9$s', $count ), '<span id="akismet1"><span id="akismetcount">', number_format_i18n( $count ), '</span>', '<span id="akismetsc">', '</span></span>', '<span id="akismet2"><span id="akismetbb">', '</span>', '<span id="akismeta">', '</span></span>' ); ?></a></div></div>
- <?php echo $after_widget; ?>
- <?php
+class Akismet_Widget extends WP_Widget {
+
+ function __construct() {
+ parent::__construct(
+ 'akismet_widget',
+ __( 'Akismet Widget' ),
+ array( 'description' => __( 'Display the number of spam comments Akismet has caught' ) )
+ );
+
+ if ( is_active_widget( false, false, $this->id_base ) ) {
+ add_action( 'wp_head', array( $this, 'css' ) );
+ }
}
- function widget_akismet_style() {
- $plugin_dir = '/wp-content/plugins';
- if ( defined( 'PLUGINDIR' ) )
- $plugin_dir = '/' . PLUGINDIR;
+ function css() {
+?>
- ?>
<style type="text/css">
-#aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
-#aka:hover{border:none;text-decoration:none}
-#aka:hover #akismet1{display:none}
-#aka:hover #akismet2,#akismet1{display:block}
-#akismet2{display:none;padding-top:2px}
-#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
-#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
-#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
+.a-stats {
+ width: auto;
+}
+.a-stats a {
+ background: #7CA821;
+ background-image:-moz-linear-gradient(0% 100% 90deg,#5F8E14,#7CA821);
+ background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#7CA821),to(#5F8E14));
+ border: 1px solid #5F8E14;
+ border-radius:3px;
+ color: #CFEA93;
+ cursor: pointer;
+ display: block;
+ font-weight: normal;
+ height: 100%;
+ -moz-border-radius:3px;
+ padding: 7px 0 8px;
+ text-align: center;
+ text-decoration: none;
+ -webkit-border-radius:3px;
+ width: 100%;
+}
+.a-stats a:hover {
+ text-decoration: none;
+ background-image:-moz-linear-gradient(0% 100% 90deg,#6F9C1B,#659417);
+ background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#659417),to(#6F9C1B));
+}
+.a-stats .count {
+ color: #FFF;
+ display: block;
+ font-size: 15px;
+ line-height: 16px;
+ padding: 0 13px;
+ white-space: nowrap;
+}
</style>
- <?php
+
+<?php
}
- function widget_akismet_control() {
- $options = $newoptions = get_option('widget_akismet');
- if ( isset( $_POST['akismet-submit'] ) && $_POST["akismet-submit"] ) {
- $newoptions['title'] = strip_tags(stripslashes($_POST["akismet-title"]));
- if ( empty($newoptions['title']) ) $newoptions['title'] = __('Spam Blocked');
+ function form( $instance ) {
+ if ( $instance ) {
+ $title = esc_attr( $instance['title'] );
}
- if ( $options != $newoptions ) {
- $options = $newoptions;
- update_option('widget_akismet', $options);
+ else {
+ $title = __( 'Spam Blocked' );
}
- $title = htmlspecialchars($options['title'], ENT_QUOTES);
- ?>
- <p><label for="akismet-title"><?php _e('Title:'); ?> <input style="width: 250px;" id="akismet-title" name="akismet-title" type="text" value="<?php echo $title; ?>" /></label></p>
- <input type="hidden" id="akismet-submit" name="akismet-submit" value="1" />
- <?php
- }
+?>
- if ( function_exists( 'wp_register_sidebar_widget' ) ) {
- wp_register_sidebar_widget( 'akismet', 'Akismet', 'widget_akismet', null, 'akismet');
- wp_register_widget_control( 'akismet', 'Akismet', 'widget_akismet_control', null, 75, 'akismet');
- } else {
- register_sidebar_widget('Akismet', 'widget_akismet', null, 'akismet');
- register_widget_control('Akismet', 'widget_akismet_control', null, 75, 'akismet');
+ <p>
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" />
+ </p>
+
+<?php
}
- if ( is_active_widget('widget_akismet') )
- add_action('wp_head', 'widget_akismet_style');
- endif;
-}
-add_action('init', 'widget_akismet_register');
+ function update( $new_instance, $old_instance ) {
+ $instance['title'] = strip_tags( $new_instance['title'] );
+ return $instance;
+ }
-// Counter for non-widget users
-function akismet_counter() {
- $plugin_dir = '/wp-content/plugins';
- if ( defined( 'PLUGINDIR' ) )
- $plugin_dir = '/' . PLUGINDIR;
+ function widget( $args, $instance ) {
+ $count = get_option( 'akismet_spam_count' );
+ echo $args['before_widget'];
+ if ( ! empty( $instance['title'] ) ) {
+ echo $args['before_title'];
+ echo esc_html( $instance['title'] );
+ echo $args['after_title'];
+ }
?>
-<style type="text/css">
-#akismetwrap #aka,#aka:link,#aka:hover,#aka:visited,#aka:active{color:#fff;text-decoration:none}
-#aka:hover{border:none;text-decoration:none}
-#aka:hover #akismet1{display:none}
-#aka:hover #akismet2,#akismet1{display:block}
-#akismet2{display:none;padding-top:2px}
-#akismeta{font-size:16px;font-weight:bold;line-height:18px;text-decoration:none}
-#akismetcount{display:block;font:15px Verdana,Arial,Sans-Serif;font-weight:bold;text-decoration:none}
-#akismetwrap #akismetstats{background:url(<?php echo get_option('siteurl'), $plugin_dir; ?>/akismet/akismet.gif) no-repeat top left;border:none;color:#fff;font:11px 'Trebuchet MS','Myriad Pro',sans-serif;height:40px;line-height:100%;overflow:hidden;padding:8px 0 0;text-align:center;width:120px}
-</style>
+
+ <div class="a-stats">
+ <a href="http://akismet.com" target="_blank" title=""><?php printf( _n( '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', $count ), number_format_i18n( $count ) ); ?></a>
+ </div>
+
<?php
-$count = get_option('akismet_spam_count');
-printf( _n( '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comment</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', '<div id="akismetwrap"><div id="akismetstats"><a id="aka" href="http://akismet.com" title=""><div id="akismet1"><span id="akismetcount">%1$s</span> <span id="akismetsc">spam comments</span></div> <div id="akismet2"><span id="akismetbb">blocked by</span><br /><span id="akismeta">Akismet</span></div></a></div></div>', $count ), number_format_i18n( $count ) );
+ echo $args['after_widget'];
+ }
}
+
+function akismet_register_widgets() {
+ register_widget( 'Akismet_Widget' );
+}
+
+add_action( 'widgets_init', 'akismet_register_widgets' );