summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/akismet')
-rw-r--r--plugins/akismet/_inc/akismet.css4
-rw-r--r--plugins/akismet/_inc/akismet.js92
-rw-r--r--plugins/akismet/_inc/img/logo-full-2x.pngbin7570 -> 5052 bytes
-rw-r--r--plugins/akismet/akismet.php4
-rw-r--r--plugins/akismet/class.akismet.php80
-rw-r--r--plugins/akismet/readme.txt12
6 files changed, 125 insertions, 67 deletions
diff --git a/plugins/akismet/_inc/akismet.css b/plugins/akismet/_inc/akismet.css
index 53495bb2..85f3c5ec 100644
--- a/plugins/akismet/_inc/akismet.css
+++ b/plugins/akismet/_inc/akismet.css
@@ -16,12 +16,12 @@
text-decoration: inherit;
color: inherit;
}
-#the-comment-list .remove_url {
+#the-comment-list .akismet_remove_url {
margin-left: 3px;
color: #999;
padding: 2px 3px 2px 0;
}
-#the-comment-list .remove_url:hover {
+#the-comment-list .akismet_remove_url:hover {
color: #A7301F;
font-weight: bold;
padding: 2px 2px 2px 0;
diff --git a/plugins/akismet/_inc/akismet.js b/plugins/akismet/_inc/akismet.js
index a72e3a9a..5d18aa39 100644
--- a/plugins/akismet/_inc/akismet.js
+++ b/plugins/akismet/_inc/akismet.js
@@ -11,31 +11,10 @@ jQuery( function ( $ ) {
var thisId = $(this).attr('commentid');
$(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
});
- $('#the-comment-list')
- .find('tr.comment, tr[id ^= "comment-"]')
- .find('.column-author a[href^="http"]:first') // Ignore mailto: links, which would be the comment author's email.
- .each(function () {
- var linkHref = $(this).attr( 'href' );
-
- // Ignore any links to the current domain, which are diagnostic tools, like the IP address link
- // or any other links another plugin might add.
- var currentHostParts = document.location.href.split( '/' );
- var currentHost = currentHostParts[0] + '//' + currentHostParts[2] + '/';
-
- if ( linkHref.indexOf( currentHost ) != 0 ) {
- var thisCommentId = $(this).parents('tr:first').attr('id').split("-");
-
- $(this)
- .attr("id", "author_comment_url_"+ thisCommentId[1])
- .after(
- $( '<a href="#" class="remove_url">x</a>' )
- .attr( 'commentid', thisCommentId[1] )
- .attr( 'title', WPAkismet.strings['Remove this URL'] )
- );
- }
- });
+
+ akismet_enable_comment_author_url_removal();
- $( '#the-comment-list' ).on( 'click', '.remove_url', function () {
+ $( '#the-comment-list' ).on( 'click', '.akismet_remove_url', function () {
var thisId = $(this).attr('commentid');
var data = {
action: 'comment_author_deurl',
@@ -103,7 +82,7 @@ jQuery( function ( $ ) {
});
// Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
- $( 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, table.comments td.comment p a' ).mouseover( function () {
+ $( '#the-comment-list' ).on( 'mouseover', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () {
clearTimeout( mshotRemovalTimer );
if ( $( '.akismet-mshot' ).length > 0 ) {
@@ -120,7 +99,7 @@ jQuery( function ( $ ) {
clearTimeout( mshotSecondTryTimer );
clearTimeout( mshotThirdTryTimer );
- var thisHref = $.URLEncode( $( this ).attr( 'href' ) );
+ var thisHref = encodeURIComponent( $( this ).attr( 'href' ) );
var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="//s0.wordpress.com/mshots/v1/' + thisHref + '?w=450" width="450" height="338" class="mshot-image" /></div>' );
mShot.data( 'link', this );
@@ -141,7 +120,7 @@ jQuery( function ( $ ) {
}, 12000 );
$( 'body' ).append( mShot );
- } ).mouseout( function () {
+ } ).on( 'mouseout', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () {
mshotRemovalTimer = setTimeout( function () {
clearTimeout( mshotSecondTryTimer );
clearTimeout( mshotThirdTryTimer );
@@ -194,11 +173,54 @@ jQuery( function ( $ ) {
if ( "start_recheck" in WPAkismet && WPAkismet.start_recheck ) {
$( '.checkforspam' ).click();
}
-});
-// 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;}
-});
+
+ if ( typeof 'MutationObserver' !== 'undefined' ) {
+ // Dynamically add the "X" next the the author URL links when a comment is quick-edited.
+ var comment_list_container = document.getElementById( 'the-comment-list' );
+
+ if ( comment_list_container ) {
+ var observer = new MutationObserver( function ( mutations ) {
+ for ( var i = 0, _len = mutations.length; i < _len; i++ ) {
+ if ( mutations[i].addedNodes.length > 0 ) {
+ akismet_enable_comment_author_url_removal();
+
+ // Once we know that we'll have to check for new author links, skip the rest of the mutations.
+ break;
+ }
+ }
+ } );
+
+ observer.observe( comment_list_container, { attributes: true, childList: true, characterData: true } );
+ }
+ }
+
+ function akismet_enable_comment_author_url_removal() {
+ $( '#the-comment-list' )
+ .find( 'tr.comment, tr[id ^= "comment-"]' )
+ .find( '.column-author a[href^="http"]:first' ) // Ignore mailto: links, which would be the comment author's email.
+ .each(function () {
+ if ( $( this ).parent().find( '.akismet_remove_url' ).length > 0 ) {
+ return;
+ }
+
+ var linkHref = $(this).attr( 'href' );
+
+ // Ignore any links to the current domain, which are diagnostic tools, like the IP address link
+ // or any other links another plugin might add.
+ var currentHostParts = document.location.href.split( '/' );
+ var currentHost = currentHostParts[0] + '//' + currentHostParts[2] + '/';
+
+ if ( linkHref.indexOf( currentHost ) != 0 ) {
+ var thisCommentId = $(this).parents('tr:first').attr('id').split("-");
+
+ $(this)
+ .attr("id", "author_comment_url_"+ thisCommentId[1])
+ .after(
+ $( '<a href="#" class="akismet_remove_url">x</a>' )
+ .attr( 'commentid', thisCommentId[1] )
+ .attr( 'title', WPAkismet.strings['Remove this URL'] )
+ );
+ }
+ });
+ }
+}); \ No newline at end of file
diff --git a/plugins/akismet/_inc/img/logo-full-2x.png b/plugins/akismet/_inc/img/logo-full-2x.png
index c555285a..79545854 100644
--- a/plugins/akismet/_inc/img/logo-full-2x.png
+++ b/plugins/akismet/_inc/img/logo-full-2x.png
Binary files differ
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php
index 42d33213..80e5bcb6 100644
--- a/plugins/akismet/akismet.php
+++ b/plugins/akismet/akismet.php
@@ -6,7 +6,7 @@
Plugin Name: Akismet Anti-Spam
Plugin URI: https://akismet.com/
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
-Version: 3.3
+Version: 3.3.1
Author: Automattic
Author URI: https://automattic.com/wordpress-plugins/
License: GPLv2 or later
@@ -37,7 +37,7 @@ if ( !function_exists( 'add_action' ) ) {
exit;
}
-define( 'AKISMET_VERSION', '3.3' );
+define( 'AKISMET_VERSION', '3.3.1' );
define( 'AKISMET__MINIMUM_WP_VERSION', '3.7' );
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'AKISMET_DELETE_LIMIT', 100000 );
diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php
index c8d5d75d..95099136 100644
--- a/plugins/akismet/class.akismet.php
+++ b/plugins/akismet/class.akismet.php
@@ -29,18 +29,7 @@ class Akismet {
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments_meta' ) );
add_action( 'akismet_schedule_cron_recheck', array( 'Akismet', 'cron_recheck' ) );
- /**
- * To disable the Akismet comment nonce, add a filter for the 'akismet_comment_nonce' tag
- * and return any string value that is not 'true' or '' (empty string).
- *
- * Don't return boolean false, because that implies that the 'akismet_comment_nonce' option
- * has not been set and that Akismet should just choose the default behavior for that
- * situation.
- */
- $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
-
- if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
- add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 );
+ add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 );
add_action( 'admin_head-edit-comments.php', array( 'Akismet', 'load_form_js' ) );
add_action( 'comment_form', array( 'Akismet', 'load_form_js' ) );
@@ -171,7 +160,11 @@ class Akismet {
}
$post = get_post( $comment['comment_post_ID'] );
- $comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
+
+ if ( ! is_null( $post ) ) {
+ // $post can technically be null, although in the past, it's always been an indicator of another plugin interfering.
+ $comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
+ }
$response = self::http_post( Akismet::build_query( $comment ), 'comment-check' );
@@ -200,7 +193,9 @@ class Akismet {
// 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 );
- $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : get_permalink( $post );
+ // The spam is obvious, so we're bailing out early. Redirect back to the previous page,
+ // or failing that, the post permalink, or failing that, the homepage of the blog.
+ $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : ( $post ? get_permalink( $post ) : home_url() );
wp_safe_redirect( esc_url_raw( $redirect_to ) );
die();
}
@@ -266,9 +261,6 @@ class Akismet {
if ( !function_exists('add_comment_meta') )
return false;
- if ( !isset( self::$last_comment['comment_author_email'] ) )
- self::$last_comment['comment_author_email'] = '';
-
// wp_insert_comment() might be called in other contexts, so make sure this is the same comment
// as was checked by auto_check_comment
if ( is_object( $comment ) && !empty( self::$last_comment ) && is_array( self::$last_comment ) ) {
@@ -355,6 +347,7 @@ class Akismet {
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->commentmeta} WHERE comment_id IN ( " . $format_string . " )", $comment_ids ) );
clean_comment_cache( $comment_ids );
+ do_action( 'akismet_delete_comment_batch', count( $comment_ids ) );
}
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->comments ) ) // lucky number
@@ -382,6 +375,8 @@ class Akismet {
foreach ( $comment_ids as $comment_id ) {
delete_comment_meta( $comment_id, 'akismet_as_submitted' );
}
+
+ do_action( 'akismet_delete_commentmeta_batch', count( $comment_ids ) );
}
if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->commentmeta ) ) // lucky number
@@ -606,7 +601,10 @@ class Akismet {
$comment->is_test = 'true';
$post = get_post( $comment->comment_post_ID );
- $comment->comment_post_modified_gmt = $post->post_modified_gmt;
+
+ if ( ! is_null( $post ) ) {
+ $comment->comment_post_modified_gmt = $post->post_modified_gmt;
+ }
$response = Akismet::http_post( Akismet::build_query( $comment ), 'submit-spam' );
if ( $comment->reporter ) {
@@ -653,7 +651,10 @@ class Akismet {
$comment->is_test = 'true';
$post = get_post( $comment->comment_post_ID );
- $comment->comment_post_modified_gmt = $post->post_modified_gmt;
+
+ if ( ! is_null( $post ) ) {
+ $comment->comment_post_modified_gmt = $post->post_modified_gmt;
+ }
$response = self::http_post( Akismet::build_query( $comment ), 'submit-ham' );
if ( $comment->reporter ) {
@@ -768,9 +769,21 @@ class Akismet {
}
public static function add_comment_nonce( $post_id ) {
- echo '<p style="display: none;">';
- wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
- echo '</p>';
+ /**
+ * To disable the Akismet comment nonce, add a filter for the 'akismet_comment_nonce' tag
+ * and return any string value that is not 'true' or '' (empty string).
+ *
+ * Don't return boolean false, because that implies that the 'akismet_comment_nonce' option
+ * has not been set and that Akismet should just choose the default behavior for that
+ * situation.
+ */
+ $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
+
+ if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' ) {
+ echo '<p style="display: none;">';
+ wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
+ echo '</p>';
+ }
}
public static function is_test_mode() {
@@ -800,7 +813,25 @@ class Akismet {
private static function comments_match( $comment1, $comment2 ) {
$comment1 = (array) $comment1;
$comment2 = (array) $comment2;
-
+
+ // Set default values for these strings that we check in order to simplify
+ // the checks and avoid PHP warnings.
+ if ( ! isset( $comment1['comment_author'] ) ) {
+ $comment1['comment_author'] = '';
+ }
+
+ if ( ! isset( $comment2['comment_author'] ) ) {
+ $comment2['comment_author'] = '';
+ }
+
+ if ( ! isset( $comment1['comment_author_email'] ) ) {
+ $comment1['comment_author_email'] = '';
+ }
+
+ if ( ! isset( $comment2['comment_author_email'] ) ) {
+ $comment2['comment_author_email'] = '';
+ }
+
$comments_match = (
isset( $comment1['comment_post_ID'], $comment2['comment_post_ID'] )
&& intval( $comment1['comment_post_ID'] ) == intval( $comment2['comment_post_ID'] )
@@ -834,9 +865,6 @@ class Akismet {
// Does the supplied comment match the details of the one most recently stored in self::$last_comment?
public static function matches_last_comment( $comment ) {
- if ( is_object( $comment ) )
- $comment = (array) $comment;
-
return self::comments_match( self::$last_comment, $comment );
}
diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt
index 3d7beb00..cb06293a 100644
--- a/plugins/akismet/readme.txt
+++ b/plugins/akismet/readme.txt
@@ -2,8 +2,8 @@
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs
Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
Requires at least: 3.7
-Tested up to: 4.7.2
-Stable tag: 3.3
+Tested up to: 4.7.4
+Stable tag: 3.3.1
License: GPLv2 or later
Akismet checks your comments and contact form submissions against our global database of spam to protect you and your site from malicious content.
@@ -30,6 +30,14 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
== Changelog ==
+= 3.3.1 =
+*Release Date - 2 May 2017*
+
+* Improve performance by only requesting the akismet_comment_nonce option when absolutely necessary.
+* Fixed two bugs that could cause PHP warnings.
+* Fixed a bug that was preventing the "Remove author URL" feature from working after a comment was edited using "Quick Edit."
+* Fixed a bug that was preventing the URL preview feature from working after a comment was edited using "Quick Edit."
+
= 3.3 =
*Release Date - 23 February 2017*