From 05952b31eb58ff8cd2da3923cc86d78aca6aec06 Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Fri, 1 Sep 2017 20:12:26 -0400 Subject: Update akismet 3.3.4 Signed-off-by: Anthony G. Basile --- plugins/akismet/_inc/akismet.js | 54 ++++++++++-- plugins/akismet/akismet.php | 4 +- plugins/akismet/class.akismet-admin.php | 40 +++++---- plugins/akismet/class.akismet-widget.php | 2 +- plugins/akismet/class.akismet.php | 28 ++++-- plugins/akismet/readme.txt | 20 ++++- plugins/akismet/views/config.php | 110 +++++++++++------------ plugins/akismet/views/notice.php | 4 +- plugins/akismet/views/start.php | 147 ++++++++++++++++--------------- 9 files changed, 249 insertions(+), 160 deletions(-) (limited to 'plugins') diff --git a/plugins/akismet/_inc/akismet.js b/plugins/akismet/_inc/akismet.js index b7ff7194..c1ddc8b0 100644 --- a/plugins/akismet/_inc/akismet.js +++ b/plugins/akismet/_inc/akismet.js @@ -3,6 +3,8 @@ jQuery( function ( $ ) { var mshotSecondTryTimer = null var mshotThirdTryTimer = null + var mshotEnabledLinkSelector = 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a'; + $('.akismet-status').each(function () { var thisId = $(this).attr('commentid'); $(this).prependTo('#comment-' + thisId + ' .column-comment'); @@ -82,7 +84,7 @@ jQuery( function ( $ ) { }); // Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments. - $( '#the-comment-list' ).on( 'mouseover', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () { + $( '#the-comment-list' ).on( 'mouseover', mshotEnabledLinkSelector, function () { clearTimeout( mshotRemovalTimer ); if ( $( '.akismet-mshot' ).length > 0 ) { @@ -99,9 +101,9 @@ jQuery( function ( $ ) { clearTimeout( mshotSecondTryTimer ); clearTimeout( mshotThirdTryTimer ); - var thisHref = encodeURIComponent( $( this ).attr( 'href' ) ); + var thisHref = $( this ).attr( 'href' ); - var mShot = $( '
' ); + var mShot = $( '
' ); mShot.data( 'link', this ); var offset = $( this ).offset(); @@ -111,12 +113,15 @@ jQuery( function ( $ ) { top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness } ); + // These retries appear to be superfluous if .mshot-image has already loaded, but it's because mShots + // can return a "Generating thumbnail..." image if it doesn't have a thumbnail ready, so we need + // to retry to see if we can get the newly generated thumbnail. mshotSecondTryTimer = setTimeout( function () { - mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=2' ); + mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 2 ) ); }, 6000 ); mshotThirdTryTimer = setTimeout( function () { - mShot.find( '.mshot-image' ).attr( 'src', '//s0.wordpress.com/mshots/v1/'+thisHref+'?w=450&r=3' ); + mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 3 ) ); }, 12000 ); $( 'body' ).append( mShot ); @@ -127,6 +132,18 @@ jQuery( function ( $ ) { $( '.akismet-mshot' ).remove(); }, 200 ); + } ).on( 'mouseover', 'tr', function () { + // When the mouse hovers over a comment row, begin preloading mshots for any links in the comment or the comment author. + var linksToPreloadMshotsFor = $( this ).find( mshotEnabledLinkSelector ); + + linksToPreloadMshotsFor.each( function () { + // Don't attempt to preload an mshot for a single link twice. Browser caching should cover this, but in case of + // race conditions, save a flag locally when we've begun trying to preload one. + if ( ! $( this ).data( 'akismet-mshot-preloaded' ) ) { + akismet_preload_mshot( $( this ).attr( 'href' ) ); + $( this ).data( 'akismet-mshot-preloaded', true ); + } + } ); } ); $('.checkforspam:not(.button-disabled)').click( function(e) { @@ -223,4 +240,31 @@ jQuery( function ( $ ) { } }); } + + /** + * Generate an mShot URL if given a link URL. + * + * @param string linkUrl + * @param int retry If retrying a request, the number of the retry. + * @return string The mShot URL; + */ + function akismet_mshot_url( linkUrl, retry ) { + var mshotUrl = '//s0.wordpress.com/mshots/v1/' + encodeURIComponent( linkUrl ) + '?w=900'; + + if ( retry ) { + mshotUrl += '&r=' + encodeURIComponent( retry ); + } + + return mshotUrl; + } + + /** + * Begin loading an mShot preview of a link. + * + * @param string linkUrl + */ + function akismet_preload_mshot( linkUrl ) { + var img = new Image(); + img.src = akismet_mshot_url( linkUrl ); + } }); \ No newline at end of file diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php index ca21d8b7..9894295b 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 protect your blog from spam. 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.2 +Version: 3.3.4 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.2' ); +define( 'AKISMET_VERSION', '3.3.4' ); 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-admin.php b/plugins/akismet/class.akismet-admin.php index fe29233d..aed5e3d5 100644 --- a/plugins/akismet/class.akismet-admin.php +++ b/plugins/akismet/class.akismet-admin.php @@ -208,7 +208,7 @@ class Akismet_Admin { 'content' => '

' . esc_html__( 'Akismet Configuration' , 'akismet') . '

' . '

' . esc_html__( 'Akismet filters out spam, so you can focus on more important things.' , 'akismet') . '

' . - '

' . esc_html__( 'On this page, you are able to enter/remove an API key, view account information and view spam stats.' , 'akismet') . '

', + '

' . esc_html__( 'On this page, you are able to update your Akismet settings and view spam stats.' , 'akismet') . '

', ) ); @@ -218,22 +218,24 @@ class Akismet_Admin { 'title' => __( 'Settings' , 'akismet'), 'content' => '

' . esc_html__( 'Akismet Configuration' , 'akismet') . '

' . - '

' . esc_html__( 'API Key' , 'akismet') . ' - ' . esc_html__( 'Enter/remove an API key.' , 'akismet') . '

' . + ( Akismet::predefined_api_key() ? '' : '

' . esc_html__( 'API Key' , 'akismet') . ' - ' . esc_html__( 'Enter/remove an API key.' , 'akismet') . '

' ) . '

' . esc_html__( 'Comments' , 'akismet') . ' - ' . esc_html__( 'Show the number of approved comments beside each comment author in the comments list page.' , 'akismet') . '

' . '

' . esc_html__( 'Strictness' , 'akismet') . ' - ' . esc_html__( 'Choose to either discard the worst spam automatically or to always put all spam in spam folder.' , 'akismet') . '

', ) ); - $current_screen->add_help_tab( - array( - 'id' => 'account', - 'title' => __( 'Account' , 'akismet'), - 'content' => - '

' . esc_html__( 'Akismet Configuration' , 'akismet') . '

' . - '

' . esc_html__( 'Subscription Type' , 'akismet') . ' - ' . esc_html__( 'The Akismet subscription plan' , 'akismet') . '

' . - '

' . esc_html__( 'Status' , 'akismet') . ' - ' . esc_html__( 'The subscription status - active, cancelled or suspended' , 'akismet') . '

', - ) - ); + if ( ! Akismet::predefined_api_key() ) { + $current_screen->add_help_tab( + array( + 'id' => 'account', + 'title' => __( 'Account' , 'akismet'), + 'content' => + '

' . esc_html__( 'Akismet Configuration' , 'akismet') . '

' . + '

' . esc_html__( 'Subscription Type' , 'akismet') . ' - ' . esc_html__( 'The Akismet subscription plan' , 'akismet') . '

' . + '

' . esc_html__( 'Status' , 'akismet') . ' - ' . esc_html__( 'The subscription status - active, cancelled or suspended' , 'akismet') . '

', + ) + ); + } } } @@ -255,10 +257,11 @@ class Akismet_Admin { foreach( array( 'akismet_strictness', 'akismet_show_user_comments_approved' ) as $option ) { update_option( $option, isset( $_POST[$option] ) && (int) $_POST[$option] == 1 ? '1' : '0' ); } - - if ( defined( 'WPCOM_API_KEY' ) ) + + if ( Akismet::predefined_api_key() ) { return false; //shouldn't have option to save key if already defined - + } + $new_key = preg_replace( '/[^a-f0-9]/i', '', $_POST['key'] ); $old_key = Akismet::get_api_key(); @@ -907,6 +910,11 @@ class Akismet_Admin { if ( get_option( 'akismet_strictness' ) === false ) { add_option( 'akismet_strictness', ( get_option( 'akismet_discard_month' ) === 'false' ? '0' : '1' ) ); } + + // Sync the local "Total spam blocked" count with the authoritative count from the server. + if ( isset( $stat_totals['all'], $stat_totals['all']->spam ) ) { + update_option( 'akismet_spam_count', $stat_totals['all']->spam ); + } $notices = array(); @@ -1011,7 +1019,7 @@ class Akismet_Admin { public static function display_status() { if ( ! self::get_server_connectivity() ) { - Akismet::view( 'notice', compact( 'servers-be-down' ) ); + Akismet::view( 'notice', array( 'type' => 'servers-be-down' ) ); } else if ( ! empty( self::$notices ) ) { foreach ( self::$notices as $index => $type ) { diff --git a/plugins/akismet/class.akismet-widget.php b/plugins/akismet/class.akismet-widget.php index 474f7592..55b0f35c 100644 --- a/plugins/akismet/class.akismet-widget.php +++ b/plugins/akismet/class.akismet-widget.php @@ -62,7 +62,7 @@ class Akismet_Widget extends WP_Widget { } function form( $instance ) { - if ( $instance ) { + if ( $instance && isset( $instance['title'] ) ) { $title = $instance['title']; } else { diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php index 95099136..f4172e03 100644 --- a/plugins/akismet/class.akismet.php +++ b/plugins/akismet/class.akismet.php @@ -914,6 +914,15 @@ class Akismet { return $approved; } + if ( 'trash' === $approved ) { + // If the last comment we checked has had its approval set to 'trash', + // then it failed the comment blacklist check. Let that blacklist override + // the spam check, since users have the (valid) expectation that when + // they fill out their blacklists, comments that match it will always + // end up in the trash. + return $approved; + } + // bump the counter here instead of when the filter is added to reduce the possibility of overcounting if ( $incr = apply_filters('akismet_spam_count_incr', 1) ) update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr ); @@ -1091,17 +1100,10 @@ class Akismet { } public static function load_form_js() { - // WP < 3.3 can't enqueue a script this late in the game and still have it appear in the footer. - // Once we drop support for everything pre-3.3, this can change back to a single enqueue call. wp_register_script( 'akismet-form', plugin_dir_url( __FILE__ ) . '_inc/form.js', array(), AKISMET_VERSION, true ); - add_action( 'wp_footer', array( 'Akismet', 'print_form_js' ) ); - add_action( 'admin_footer', array( 'Akismet', 'print_form_js' ) ); + wp_enqueue_script( 'akismet-form' ); } - public static function print_form_js() { - wp_print_scripts( 'akismet-form' ); - } - public static function inject_ak_js( $fields ) { echo '

'; echo ''; @@ -1205,7 +1207,7 @@ p { * @param mixed $akismet_debug The data to log. */ public static function log( $akismet_debug ) { - if ( apply_filters( 'akismet_debug_log', defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) ) { + if ( apply_filters( 'akismet_debug_log', defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG && defined( 'AKISMET_DEBUG' ) && AKISMET_DEBUG ) ) { error_log( print_r( compact( 'akismet_debug' ), true ) ); } } @@ -1292,4 +1294,12 @@ p { return $meta_value; } + + public static function predefined_api_key() { + if ( defined( 'WPCOM_API_KEY' ) ) { + return true; + } + + return apply_filters( 'akismet_predefined_api_key', false ); + } } diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt index dc087934..d56cc7a7 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.4 -Stable tag: 3.3.2 +Tested up to: 4.8.1 +Stable tag: 3.3.4 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,22 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co == Changelog == += 3.3.4 = + +* Disabled Akismet's debug log output by default unless AKISMET_DEBUG is defined. +* URL previews now begin preloading when the mouse moves near them in the comments section of wp-admin. +* When a comment is caught by the Comment Blacklist, Akismet will always allow it to stay in the trash even if it is spam as well. +* Fixed a bug that was preventing an error from being shown when a site can't reach Akismet's servers. + += 3.3.3 = +*Release Date - 13 July 2017* + +* Reduced amount of bandwidth used by the URL Preview feature. +* Improved the admin UI when the API key is manually pre-defined for the site. +* Removed a workaround for WordPress installations older than 3.3 that will improve Akismet's compatibility with other plugins. +* The number of spam blocked that is displayed on the WordPress dashboard will now be more accurate and updated more frequently. +* Fixed a bug in the Akismet widget that could cause PHP warnings. + = 3.3.2 = *Release Date - 10 May 2017* diff --git a/plugins/akismet/views/config.php b/plugins/akismet/views/config.php index f7b232ed..c12914a0 100644 --- a/plugins/akismet/views/config.php +++ b/plugins/akismet/views/config.php @@ -65,7 +65,7 @@

- + - + @@ -157,11 +157,11 @@
@@ -73,7 +73,7 @@
- +
- +
@@ -172,61 +172,63 @@
- -
-
-
- + + +
+
+
+ +
-
-
- - - - - - - - - - - next_billing_date ) : ?> - - - - - - -
- -

account_name ); ?>

-
- -

status ) : - esc_html_e( 'Cancelled', 'akismet' ); - elseif ( 'suspended' == $akismet_user->status ) : - esc_html_e( 'Suspended', 'akismet' ); - elseif ( 'missing' == $akismet_user->status ) : - esc_html_e( 'Missing', 'akismet' ); - elseif ( 'no-sub' == $akismet_user->status ) : - esc_html_e( 'No Subscription Found', 'akismet' ); - else : - esc_html_e( 'Active', 'akismet' ); - endif; ?>

-
- -

next_billing_date ); ?>

-
-
-
- ( $akismet_user->account_type == 'free-api-key' && $akismet_user->status == 'active' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?> +
+ + + + + + + + + + + next_billing_date ) : ?> + + + + + + +
+ +

account_name ); ?>

+
+ +

status ) : + esc_html_e( 'Cancelled', 'akismet' ); + elseif ( 'suspended' == $akismet_user->status ) : + esc_html_e( 'Suspended', 'akismet' ); + elseif ( 'missing' == $akismet_user->status ) : + esc_html_e( 'Missing', 'akismet' ); + elseif ( 'no-sub' == $akismet_user->status ) : + esc_html_e( 'No Subscription Found', 'akismet' ); + else : + esc_html_e( 'Active', 'akismet' ); + endif; ?>

+
+ +

next_billing_date ); ?>

+
+
+
+ ( $akismet_user->account_type == 'free-api-key' && $akismet_user->status == 'active' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?> +
+
-
-
+
\ No newline at end of file diff --git a/plugins/akismet/views/notice.php b/plugins/akismet/views/notice.php index e82f1685..3b6236da 100644 --- a/plugins/akismet/views/notice.php +++ b/plugins/akismet/views/notice.php @@ -46,8 +46,8 @@
-

-

our guide about firewalls.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?>

+

+

our guide about firewalls.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?>

diff --git a/plugins/akismet/views/start.php b/plugins/akismet/views/start.php index d17b53dc..0ec35fdb 100644 --- a/plugins/akismet/views/start.php +++ b/plugins/akismet/views/start.php @@ -8,86 +8,95 @@
+

- status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) { ?> - status, array( 'no-sub', 'missing' ) ) ) { ?> + + status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) { ?> + status, array( 'no-sub', 'missing' ) ) ) { ?> +
+

+

+
+ + + + + +
+ user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> +

' . esc_html( $akismet_user->user_login ) . '' ); ?>
user_email ); ?>

+
+ status == 'cancelled' ) { ?> +
+

+
+ + + + + +
+

user_email ) ); ?>

+
+ status == 'suspended' ) { ?> +
+

+

user_email ) ); ?>

+

+

+
+ +
+

+

+
+ + + + +
+ user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> +

' . esc_html( $akismet_user->user_login ) . '' ); ?>
user_email ); ?>

+
+ +
+

+
+ __( 'Sign up with a different email address' , 'akismet' ), 'classes' => array( 'akismet-button' ) ) ); ?> +
+

+
+ +
+

+
+ __( 'Get your API key' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?> +
+

+
+
-

-

-
- - - - - -
- user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> -

' . esc_html( $akismet_user->user_login ) . '' ); ?>
user_email ); ?>

-
- status == 'cancelled' ) { ?> -
-

-
- - - - - +

+

+ + + +

+ + +

-

user_email ) ); ?>

-
- status == 'suspended' ) { ?> -
-

-

user_email ) ); ?>

-

-

- +
-

-

-
- - - - -
- user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> -

' . esc_html( $akismet_user->user_login ) . '' ); ?>
user_email ); ?>

+

+

wp-config.php' ); ?>

-
-

-
- __( 'Sign up with a different email address' , 'akismet' ), 'classes' => array( 'akismet-button' ) ) ); ?> -
-

-
- -
-

-
- __( 'Get your API key' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?> -
-

-
- -
-

-

-
- - -

- - -

-
\ No newline at end of file -- cgit v1.2.3-65-gdbad