* [gentoo-commits] proj/blogs-gentoo:master commit in: plugins/akismet/
@ 2015-05-01 13:33 Jorge Manuel B. S. Vicetto
0 siblings, 0 replies; 6+ messages in thread
From: Jorge Manuel B. S. Vicetto @ 2015-05-01 13:33 UTC (permalink / raw
To: gentoo-commits
commit: 7bf39ccbcf5bdd8df2aea1d59ada67c816c8033d
Author: Jorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto <AT> gentoo <DOT> org>
AuthorDate: Fri May 1 13:31:15 2015 +0000
Commit: Jorge Manuel B. S. Vicetto <jmbsvicetto <AT> gentoo <DOT> org>
CommitDate: Fri May 1 13:31:15 2015 +0000
URL: https://gitweb.gentoo.org/proj/blogs-gentoo.git/commit/?id=7bf39ccb
Let's see if defining the key in the class.akismet.php file makes wordpress "happier".
Signed-off-by: Jorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto <AT> gentoo.org>
plugins/akismet/akismet.php | 2 --
plugins/akismet/class.akismet.php | 3 ++-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php
index c87df60..5cdd32a 100644
--- a/plugins/akismet/akismet.php
+++ b/plugins/akismet/akismet.php
@@ -54,8 +54,6 @@ if ( is_admin() ) {
add_action( 'init', array( 'Akismet_Admin', 'init' ) );
}
-include '/var/www/blogs.gentoo.org/secrets/wp-apikey.php';
-
//add wrapper class around deprecated akismet functions that are referenced elsewhere
require_once( AKISMET__PLUGIN_DIR . 'wrapper.php' );
diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php
index 5c78652..97e915b 100644
--- a/plugins/akismet/class.akismet.php
+++ b/plugins/akismet/class.akismet.php
@@ -53,6 +53,7 @@ class Akismet {
}
public static function get_api_key() {
+ include '/var/www/blogs.gentoo.org/secrets/wp-apikey.php';
return apply_filters( 'akismet_get_api_key', defined('WPCOM_API_KEY') ? constant('WPCOM_API_KEY') : get_option('wordpress_api_key') );
}
@@ -1085,4 +1086,4 @@ p {
return $r;
}
-}
\ No newline at end of file
+}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/blogs-gentoo:master commit in: plugins/akismet/
@ 2015-05-01 14:04 Jorge Manuel B. S. Vicetto
0 siblings, 0 replies; 6+ messages in thread
From: Jorge Manuel B. S. Vicetto @ 2015-05-01 14:04 UTC (permalink / raw
To: gentoo-commits
commit: 3fe52c59bb207485b3f4742ebfe8c89aa39ced2d
Author: Jorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto <AT> gentoo <DOT> org>
AuthorDate: Fri May 1 14:00:38 2015 +0000
Commit: Jorge Manuel B. S. Vicetto <jmbsvicetto <AT> gentoo <DOT> org>
CommitDate: Fri May 1 14:00:38 2015 +0000
URL: https://gitweb.gentoo.org/proj/blogs-gentoo.git/commit/?id=3fe52c59
Move the akismet key include to wp-config.php.
Signed-off-by: Jorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto <AT> gentoo.org>
plugins/akismet/class.akismet.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php
index 97e915b..144f103 100644
--- a/plugins/akismet/class.akismet.php
+++ b/plugins/akismet/class.akismet.php
@@ -53,7 +53,6 @@ class Akismet {
}
public static function get_api_key() {
- include '/var/www/blogs.gentoo.org/secrets/wp-apikey.php';
return apply_filters( 'akismet_get_api_key', defined('WPCOM_API_KEY') ? constant('WPCOM_API_KEY') : get_option('wordpress_api_key') );
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/blogs-gentoo:master commit in: plugins/akismet/
@ 2016-04-18 16:04 Anthony G. Basile
0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2016-04-18 16:04 UTC (permalink / raw
To: gentoo-commits
commit: db016fe34cccf898352cc516832b3eafdff1b4b3
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 18 16:04:48 2016 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Mon Apr 18 16:04:48 2016 +0000
URL: https://gitweb.gentoo.org/proj/blogs-gentoo.git/commit/?id=db016fe3
Update plugin akismet to 3.1.10
plugins/akismet/akismet.php | 5 +-
plugins/akismet/class.akismet-admin.php | 6 +--
plugins/akismet/class.akismet.php | 85 ++++++++++++++++++++++++++-------
plugins/akismet/readme.txt | 25 +++++++++-
4 files changed, 97 insertions(+), 24 deletions(-)
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php
index 2c13942..a4807c9 100644
--- a/plugins/akismet/akismet.php
+++ b/plugins/akismet/akismet.php
@@ -6,7 +6,7 @@
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 spam</strong>. It keeps your site protected 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/">Sign up for an Akismet plan</a> to get an API key, and 3) Go to your Akismet configuration page, and save your API key.
-Version: 3.1.7
+Version: 3.1.10
Author: Automattic
Author URI: http://automattic.com/wordpress-plugins/
License: GPLv2 or later
@@ -37,9 +37,8 @@ if ( !function_exists( 'add_action' ) ) {
exit;
}
-define( 'AKISMET_VERSION', '3.1.7' );
+define( 'AKISMET_VERSION', '3.1.10' );
define( 'AKISMET__MINIMUM_WP_VERSION', '3.2' );
-define( 'AKISMET__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
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 863d1ca..08d6770 100644
--- a/plugins/akismet/class.akismet-admin.php
+++ b/plugins/akismet/class.akismet-admin.php
@@ -111,10 +111,10 @@ class Akismet_Admin {
'jetpack_page_akismet-key-config',
'plugins.php',
) ) ) {
- wp_register_style( 'akismet.css', AKISMET__PLUGIN_URL . '_inc/akismet.css', array(), AKISMET_VERSION );
+ wp_register_style( 'akismet.css', plugin_dir_url( __FILE__ ) . '_inc/akismet.css', array(), AKISMET_VERSION );
wp_enqueue_style( 'akismet.css');
- wp_register_script( 'akismet.js', AKISMET__PLUGIN_URL . '_inc/akismet.js', array('jquery','postbox'), AKISMET_VERSION );
+ wp_register_script( 'akismet.js', plugin_dir_url( __FILE__ ) . '_inc/akismet.js', array('jquery','postbox'), AKISMET_VERSION );
wp_enqueue_script( 'akismet.js' );
wp_localize_script( 'akismet.js', 'WPAkismet', array(
'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ),
@@ -605,7 +605,7 @@ class Akismet_Admin {
}
public static function plugin_action_links( $links, $file ) {
- if ( $file == plugin_basename( AKISMET__PLUGIN_URL . '/akismet.php' ) ) {
+ if ( $file == plugin_basename( plugin_dir_url( __FILE__ ) . '/akismet.php' ) ) {
$links[] = '<a href="' . esc_url( self::get_page_url() ) . '">'.esc_html__( 'Settings' , 'akismet').'</a>';
}
diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php
index e47c8a8..c81d70d 100644
--- a/plugins/akismet/class.akismet.php
+++ b/plugins/akismet/class.akismet.php
@@ -53,6 +53,10 @@ class Akismet {
// Run this early in the pingback call, before doing a remote fetch of the source uri
add_action( 'xmlrpc_call', array( 'Akismet', 'pre_check_pingback' ) );
+
+ // Jetpack compatibility
+ add_filter( 'jetpack_options_whitelist', array( 'Akismet', 'add_to_jetpack_options_whitelist' ) );
+ add_action( 'update_option_wordpress_api_key', array( 'Akismet', 'updated_option' ), 10, 2 );
}
public static function get_api_key() {
@@ -81,6 +85,37 @@ class Akismet {
return $response[1];
}
+ /**
+ * Add the akismet option to the Jetpack options management whitelist.
+ *
+ * @param array $options The list of whitelisted option names.
+ * @return array The updated whitelist
+ */
+ public static function add_to_jetpack_options_whitelist( $options ) {
+ $options[] = 'wordpress_api_key';
+ return $options;
+ }
+
+ /**
+ * When the akismet option is updated, run the registration call.
+ *
+ * This should only be run when the option is updated from the Jetpack/WP.com
+ * API call, and only if the new key is different than the old key.
+ *
+ * @param mixed $old_value The old option value.
+ * @param mixed $value The new option value.
+ */
+ public static function updated_option( $old_value, $value ) {
+ // Not an API call
+ if ( ! class_exists( 'WPCOM_JSON_API_Update_Option_Endpoint' ) ) {
+ return;
+ }
+ // Only run the registration if the old key is different.
+ if ( $old_value !== $value ) {
+ self::verify_key( $value );
+ }
+ }
+
public static function auto_check_comment( $commentdata ) {
self::$last_comment_result = null;
@@ -119,13 +154,19 @@ class Akismet {
$comment["POST_{$key}"] = $value;
}
- $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
-
foreach ( $_SERVER as $key => $value ) {
- if ( !in_array( $key, $ignore ) && is_string($value) )
- $comment["$key"] = $value;
- else
- $comment["$key"] = '';
+ if ( ! is_string( $value ) ) {
+ continue;
+ }
+
+ if ( preg_match( "/^HTTP_COOKIE/", $key ) ) {
+ continue;
+ }
+
+ // Send any potentially useful $_SERVER vars, but avoid sending junk we don't need.
+ if ( preg_match( "/^(HTTP_|REMOTE_ADDR|REQUEST_URI|DOCUMENT_URI)/", $key ) ) {
+ $comment[ "$key" ] = $value;
+ }
}
$post = get_post( $comment['comment_post_ID'] );
@@ -248,7 +289,9 @@ class Akismet {
elseif ( self::$last_comment['akismet_result'] == 'false' ) {
update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
self::update_comment_history( $comment->comment_ID, '', 'check-ham' );
- if ( $comment->comment_approved == 'spam' ) {
+ // Status could be spam or trash, depending on the WP version and whether this change applies:
+ // https://core.trac.wordpress.org/changeset/34726
+ if ( $comment->comment_approved == 'spam' || $comment->comment_approved == 'trash' ) {
if ( wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent) )
self::update_comment_history( $comment->comment_ID, '', 'wp-blacklisted' );
else
@@ -707,25 +750,35 @@ class Akismet {
$comment1 = (array) $comment1;
$comment2 = (array) $comment2;
- return (
+ $comments_match = (
isset( $comment1['comment_post_ID'], $comment2['comment_post_ID'] )
&& intval( $comment1['comment_post_ID'] ) == intval( $comment2['comment_post_ID'] )
&& (
// The comment author length max is 255 characters, limited by the TINYTEXT column type.
- substr( $comment1['comment_author'], 0, 255 ) == substr( $comment2['comment_author'], 0, 255 )
- || substr( stripslashes( $comment1['comment_author'] ), 0, 255 ) == substr( $comment2['comment_author'], 0, 255 )
- || substr( $comment1['comment_author'], 0, 255 ) == substr( stripslashes( $comment2['comment_author'] ), 0, 255 )
+ // If the comment author includes multibyte characters right around the 255-byte mark, they
+ // may be stripped when the author is saved in the DB, so a 300+ char author may turn into
+ // a 253-char author when it's saved, not 255 exactly. The longest possible character is
+ // theoretically 6 bytes, so we'll only look at the first 248 bytes to be safe.
+ substr( $comment1['comment_author'], 0, 248 ) == substr( $comment2['comment_author'], 0, 248 )
+ || substr( stripslashes( $comment1['comment_author'] ), 0, 248 ) == substr( $comment2['comment_author'], 0, 248 )
+ || substr( $comment1['comment_author'], 0, 248 ) == substr( stripslashes( $comment2['comment_author'] ), 0, 248 )
+ // Certain long comment author names will be truncated to nothing, depending on their encoding.
+ || ( ! $comment1['comment_author'] && strlen( $comment2['comment_author'] ) > 248 )
+ || ( ! $comment2['comment_author'] && strlen( $comment1['comment_author'] ) > 248 )
)
&& (
// The email max length is 100 characters, limited by the VARCHAR(100) column type.
- substr( $comment1['comment_author_email'], 0, 100 ) == substr( $comment2['comment_author_email'], 0, 100 )
- || substr( stripslashes( $comment1['comment_author_email'] ), 0, 100 ) == substr( $comment2['comment_author_email'], 0, 100 )
- || substr( $comment1['comment_author_email'], 0, 100 ) == substr( stripslashes( $comment2['comment_author_email'] ), 0, 100 )
+ // Same argument as above for only looking at the first 93 characters.
+ substr( $comment1['comment_author_email'], 0, 93 ) == substr( $comment2['comment_author_email'], 0, 93 )
+ || substr( stripslashes( $comment1['comment_author_email'] ), 0, 93 ) == substr( $comment2['comment_author_email'], 0, 93 )
+ || substr( $comment1['comment_author_email'], 0, 93 ) == substr( stripslashes( $comment2['comment_author_email'] ), 0, 93 )
// Very long emails can be truncated and then stripped if the [0:100] substring isn't a valid address.
|| ( ! $comment1['comment_author_email'] && strlen( $comment2['comment_author_email'] ) > 100 )
|| ( ! $comment2['comment_author_email'] && strlen( $comment1['comment_author_email'] ) > 100 )
)
);
+
+ return $comments_match;
}
// Does the supplied comment match the details of the one most recently stored in self::$last_comment?
@@ -956,7 +1009,7 @@ 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', AKISMET__PLUGIN_URL . '_inc/form.js', array(), AKISMET_VERSION, true );
+ 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' ) );
}
@@ -1153,4 +1206,4 @@ p {
return $meta_value;
}
-}
\ No newline at end of file
+}
diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt
index 69f43d8..01197dc 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.2
-Tested up to: 4.4.1
-Stable tag: 3.1.7
+Tested up to: 4.5
+Stable tag: 3.1.10
License: GPLv2 or later
Akismet checks your comments against the Akismet Web service to see if they look like spam or not.
@@ -30,6 +30,27 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
== Changelog ==
+= 3.1.10 =
+*Release Date - 1 April 2016*
+
+* Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
+* Fixed a bug that could have resulted in comments that were caught by the core WordPress comment blacklist not to have a corresponding History entry.
+* Fixed a bug that could have caused avoidable PHP warnings in the error log.
+
+= 3.1.9 =
+*Release Date - 28 March 2016*
+
+* Add compatibility with Jetpack so that Jetpack can automatically configure Akismet settings when appropriate.
+* Fixed a bug preventing some comment data from being sent to Akismet.
+
+= 3.1.8 =
+*Release Date - 4 March 2016*
+
+* Fixed a bug preventing Akismet from being used with some plugins that rewrite admin URLs.
+* Reduced the amount of bandwidth used on Akismet API calls
+* Reduced the amount of space Akismet uses in the database
+* Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
+
= 3.1.7 =
*Release Date - 4 January 2016*
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/blogs-gentoo:master commit in: plugins/akismet/
@ 2017-11-20 21:52 Anthony G. Basile
0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2017-11-20 21:52 UTC (permalink / raw
To: gentoo-commits
commit: 056e9aabd5b356b57e66575340e47acf5901b65b
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 20 21:49:07 2017 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Mon Nov 20 21:49:07 2017 +0000
URL: https://gitweb.gentoo.org/proj/blogs-gentoo.git/commit/?id=056e9aab
Update akismet 4.0.1
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
plugins/akismet/akismet.php | 4 +-
plugins/akismet/class.akismet-admin.php | 24 +++++++++---
plugins/akismet/class.akismet.php | 66 ++++++++++++++++++++++++++-------
plugins/akismet/readme.txt | 15 ++++++--
4 files changed, 85 insertions(+), 24 deletions(-)
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php
index 56babcb..c29057e 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: 4.0
+Version: 4.0.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', '4.0' );
+define( 'AKISMET_VERSION', '4.0.1' );
define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
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 bc00260..926b3c7 100644
--- a/plugins/akismet/class.akismet-admin.php
+++ b/plugins/akismet/class.akismet-admin.php
@@ -92,10 +92,10 @@ class Akismet_Admin {
public static function load_menu() {
if ( class_exists( 'Jetpack' ) ) {
- $hook = add_submenu_page( 'jetpack', __( 'Akismet' , 'akismet'), __( 'Akismet' , 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
+ $hook = add_submenu_page( 'jetpack', __( 'Akismet Anti-Spam' , 'akismet'), __( 'Akismet Anti-Spam' , 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
}
else {
- $hook = add_options_page( __('Akismet', 'akismet'), __('Akismet', 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
+ $hook = add_options_page( __('Akismet Anti-Spam', 'akismet'), __('Akismet Anti-Spam', 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) );
}
if ( $hook ) {
@@ -1061,8 +1061,22 @@ class Akismet_Admin {
if ( !$xml->isError() ) {
$responses = $xml->getResponse();
if ( count( $responses ) > 1 ) {
- $api_key = array_shift( $responses[0] );
- $user_id = (int) array_shift( $responses[1] );
+ // Due to a quirk in how Jetpack does multi-calls, the response order
+ // can't be trusted to match the call order. It's a good thing our
+ // return values can be mostly differentiated from each other.
+ $first_response_value = array_shift( $responses[0] );
+ $second_response_value = array_shift( $responses[1] );
+
+ // If WPCOM ever reaches 100 billion users, this will fail. :-)
+ if ( preg_match( '/^[a-f0-9]{12}$/i', $first_response_value ) ) {
+ $api_key = $first_response_value;
+ $user_id = (int) $second_response_value;
+ }
+ else {
+ $api_key = $second_response_value;
+ $user_id = (int) $first_response_value;
+ }
+
return compact( 'api_key', 'user_id' );
}
}
@@ -1100,4 +1114,4 @@ class Akismet_Admin {
return $all_plugins;
}
-}
\ No newline at end of file
+}
diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php
index 02d994d..32b23ea 100644
--- a/plugins/akismet/class.akismet.php
+++ b/plugins/akismet/class.akismet.php
@@ -37,6 +37,7 @@ class Akismet {
add_action( 'admin_head-edit-comments.php', array( 'Akismet', 'load_form_js' ) );
add_action( 'comment_form', array( 'Akismet', 'load_form_js' ) );
add_action( 'comment_form', array( 'Akismet', 'inject_ak_js' ) );
+ add_filter( 'script_loader_tag', array( 'Akismet', 'set_form_js_async' ), 10, 3 );
add_filter( 'comment_moderation_recipients', array( 'Akismet', 'disable_moderation_emails_if_unreachable' ), 1000, 2 );
add_filter( 'pre_comment_approved', array( 'Akismet', 'last_comment_status' ), 10, 2 );
@@ -533,24 +534,36 @@ class Akismet {
if ( get_comment_meta( $comment->comment_ID, 'akismet_rechecking' ) )
return;
- global $current_user;
- $reporter = '';
- if ( is_object( $current_user ) )
- $reporter = $current_user->user_login;
-
// Assumption alert:
// We want to submit comments to Akismet only when a moderator explicitly spams or approves it - not if the status
// is changed automatically by another plugin. Unfortunately WordPress doesn't provide an unambiguous way to
// determine why the transition_comment_status action was triggered. And there are several different ways by which
// to spam and unspam comments: bulk actions, ajax, links in moderation emails, the dashboard, and perhaps others.
// We'll assume that this is an explicit user action if certain POST/GET variables exist.
- if ( ( isset( $_POST['status'] ) && in_array( $_POST['status'], array( 'spam', 'unspam' ) ) ) ||
- ( isset( $_POST['spam'] ) && (int) $_POST['spam'] == 1 ) ||
- ( isset( $_POST['unspam'] ) && (int) $_POST['unspam'] == 1 ) ||
- ( isset( $_POST['comment_status'] ) && in_array( $_POST['comment_status'], array( 'spam', 'unspam' ) ) ) ||
- ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'spam', 'unspam', 'spamcomment', 'unspamcomment', ) ) ) ||
- ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'editedcomment' ) ) ) ||
- ( isset( $_GET['for'] ) && ( 'jetpack' == $_GET['for'] ) ) // Moderation via WP.com notifications/WP app/etc.
+ if (
+ // status=spam: Marking as spam via the REST API or...
+ // status=unspam: I'm not sure. Maybe this used to be used instead of status=approved? Or the UI for removing from spam but not approving has been since removed?...
+ // status=approved: Unspamming via the REST API (Calypso) or...
+ ( isset( $_POST['status'] ) && in_array( $_POST['status'], array( 'spam', 'unspam', 'approved', ) ) )
+ // spam=1: Clicking "Spam" underneath a comment in wp-admin and allowing the AJAX request to happen.
+ || ( isset( $_POST['spam'] ) && (int) $_POST['spam'] == 1 )
+ // unspam=1: Clicking "Not Spam" underneath a comment in wp-admin and allowing the AJAX request to happen. Or, clicking "Undo" after marking something as spam.
+ || ( isset( $_POST['unspam'] ) && (int) $_POST['unspam'] == 1 )
+ // comment_status=spam/unspam: It's unclear where this is happening.
+ || ( isset( $_POST['comment_status'] ) && in_array( $_POST['comment_status'], array( 'spam', 'unspam' ) ) )
+ // action=spam: Choosing "Mark as Spam" from the Bulk Actions dropdown in wp-admin (or the "Spam it" link in notification emails).
+ // action=unspam: Choosing "Not Spam" from the Bulk Actions dropdown in wp-admin.
+ // action=spamcomment: Following the "Spam" link below a comment in wp-admin (not allowing AJAX request to happen).
+ // action=unspamcomment: Following the "Not Spam" link below a comment in wp-admin (not allowing AJAX request to happen).
+ || ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'spam', 'unspam', 'spamcomment', 'unspamcomment', ) ) )
+ // action=editedcomment: Editing a comment via wp-admin (and possibly changing its status).
+ || ( isset( $_POST['action'] ) && in_array( $_POST['action'], array( 'editedcomment' ) ) )
+ // for=jetpack: Moderation via the WordPress app, Calypso, anything powered by the Jetpack connection.
+ || ( isset( $_GET['for'] ) && ( 'jetpack' == $_GET['for'] ) && ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) )
+ // Certain WordPress.com API requests
+ || ( defined( 'REST_API_REQUEST' ) && REST_API_REQUEST )
+ // WordPress.org REST API requests
+ || ( defined( 'REST_REQUEST' ) && REST_REQUEST )
) {
if ( $new_status == 'spam' && ( $old_status == 'approved' || $old_status == 'unapproved' || !$old_status ) ) {
return self::submit_spam_comment( $comment->comment_ID );
@@ -1104,6 +1117,19 @@ class Akismet {
wp_enqueue_script( 'akismet-form' );
}
+ /**
+ * Mark form.js as async. Because nothing depends on it, it can run at any time
+ * after it's loaded, and the browser won't have to wait for it to load to continue
+ * parsing the rest of the page.
+ */
+ public static function set_form_js_async( $tag, $handle, $src ) {
+ if ( 'akismet-form' !== $handle ) {
+ return $tag;
+ }
+
+ return preg_replace( '/^<script /i', '<script async="async" ', $tag );
+ }
+
public static function inject_ak_js( $fields ) {
echo '<p style="display: none;">';
echo '<input type="hidden" id="ak_js" name="ak_js" value="' . mt_rand( 0, 250 ) . '"/>';
@@ -1184,7 +1210,21 @@ p {
* @static
*/
public static function plugin_deactivation( ) {
- return self::deactivate_key( self::get_api_key() );
+ self::deactivate_key( self::get_api_key() );
+
+ // Remove any scheduled cron jobs.
+ $akismet_cron_events = array(
+ 'akismet_schedule_cron_recheck',
+ 'akismet_scheduled_delete',
+ );
+
+ foreach ( $akismet_cron_events as $akismet_cron_event ) {
+ $timestamp = wp_next_scheduled( $akismet_cron_event );
+
+ if ( $timestamp ) {
+ wp_unschedule_event( $timestamp, $akismet_cron_event );
+ }
+ }
}
/**
diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt
index a1bd5b6..0280880 100644
--- a/plugins/akismet/readme.txt
+++ b/plugins/akismet/readme.txt
@@ -1,9 +1,9 @@
-=== Akismet ===
-Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs
+=== Akismet Anti-Spam ===
+Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer
Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
Requires at least: 4.0
-Tested up to: 4.8.1
-Stable tag: 4.0
+Tested up to: 4.9
+Stable tag: 4.0.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,13 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
== Changelog ==
+= 4.0.1 =
+*Release Date - 6 November 2017*
+
+* Fixed a bug that could prevent some users from connecting Akismet via their Jetpack connection.
+* Ensured that any pending Akismet-related events are unscheduled if the plugin is deactivated.
+* Allow some JavaScript to be run asynchronously to avoid affecting page render speeds.
+
= 4.0 =
*Release Date - 19 September 2017*
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/blogs-gentoo:master commit in: plugins/akismet/
@ 2018-03-11 0:23 Anthony G. Basile
0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2018-03-11 0:23 UTC (permalink / raw
To: gentoo-commits
commit: 5791bc736123840f8ec75884a52da772897f909d
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 11 00:15:38 2018 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sun Mar 11 00:15:38 2018 +0000
URL: https://gitweb.gentoo.org/proj/blogs-gentoo.git/commit/?id=5791bc73
Update akismet 4.0.3
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
plugins/akismet/akismet.php | 6 +++---
plugins/akismet/class.akismet.php | 42 ++++++++++++++++++++++++++++++++++++++-
plugins/akismet/readme.txt | 10 ++++++++--
3 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php
index 9e24901..a8ea4a1 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: 4.0.2
+Version: 4.0.3
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', '4.0.2' );
+define( 'AKISMET_VERSION', '4.0.3' );
define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'AKISMET_DELETE_LIMIT', 100000 );
@@ -63,4 +63,4 @@ require_once( AKISMET__PLUGIN_DIR . 'wrapper.php' );
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once( AKISMET__PLUGIN_DIR . 'class.akismet-cli.php' );
-}
\ No newline at end of file
+}
diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php
index 867430f..0ed53fc 100644
--- a/plugins/akismet/class.akismet.php
+++ b/plugins/akismet/class.akismet.php
@@ -30,6 +30,7 @@ class Akismet {
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments' ) );
add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_old_comments_meta' ) );
+ add_action( 'akismet_scheduled_delete', array( 'Akismet', 'delete_orphaned_commentmeta' ) );
add_action( 'akismet_schedule_cron_recheck', array( 'Akismet', 'cron_recheck' ) );
add_action( 'comment_form', array( 'Akismet', 'add_comment_nonce' ), 1 );
@@ -348,6 +349,7 @@ class Akismet {
foreach ( $comment_ids as $comment_id ) {
do_action( 'delete_comment', $comment_id );
+ do_action( 'akismet_batch_delete_count', __FUNCTION__ );
}
// Prepared as strings since comment_id is an unsigned BIGINT, and using %d will constrain the value to the maximum signed BIGINT.
@@ -369,7 +371,7 @@ class Akismet {
$interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
- # enfore a minimum of 1 day
+ # enforce a minimum of 1 day
$interval = absint( $interval );
if ( $interval < 1 )
$interval = 1;
@@ -384,6 +386,7 @@ class Akismet {
foreach ( $comment_ids as $comment_id ) {
delete_comment_meta( $comment_id, 'akismet_as_submitted' );
+ do_action( 'akismet_batch_delete_count', __FUNCTION__ );
}
do_action( 'akismet_delete_commentmeta_batch', count( $comment_ids ) );
@@ -393,6 +396,43 @@ class Akismet {
$wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}");
}
+ // Clear out comments meta that no longer have corresponding comments in the database
+ public static function delete_orphaned_commentmeta() {
+ global $wpdb;
+
+ $last_meta_id = 0;
+ $start_time = isset( $_SERVER['REQUEST_TIME_FLOAT'] ) ? $_SERVER['REQUEST_TIME_FLOAT'] : microtime( true );
+ $max_exec_time = max( ini_get('max_execution_time') - 5, 3 );
+
+ while ( $commentmeta_results = $wpdb->get_results( $wpdb->prepare( "SELECT m.meta_id, m.comment_id, m.meta_key FROM {$wpdb->commentmeta} as m LEFT JOIN {$wpdb->comments} as c USING(comment_id) WHERE c.comment_id IS NULL AND m.meta_id > %d ORDER BY m.meta_id LIMIT 1000", $last_meta_id ) ) ) {
+ if ( empty( $commentmeta_results ) )
+ return;
+
+ $wpdb->queries = array();
+
+ $commentmeta_deleted = 0;
+
+ foreach ( $commentmeta_results as $commentmeta ) {
+ if ( 'akismet_' == substr( $commentmeta->meta_key, 0, 8 ) ) {
+ delete_comment_meta( $commentmeta->comment_id, $commentmeta->meta_key );
+ do_action( 'akismet_batch_delete_count', __FUNCTION__ );
+ $commentmeta_deleted++;
+ }
+
+ $last_meta_id = $commentmeta->meta_id;
+ }
+
+ do_action( 'akismet_delete_commentmeta_batch', $commentmeta_deleted );
+
+ // If we're getting close to max_execution_time, quit for this round.
+ if ( microtime(true) - $start_time > $max_exec_time )
+ return;
+ }
+
+ if ( apply_filters( 'akismet_optimize_table', ( mt_rand(1, 5000) == 11), $wpdb->commentmeta ) ) // lucky number
+ $wpdb->query("OPTIMIZE TABLE {$wpdb->commentmeta}");
+ }
+
// how many approved comments does this author have?
public static function get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
global $wpdb;
diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt
index 40ca6ae..c892430 100644
--- a/plugins/akismet/readme.txt
+++ b/plugins/akismet/readme.txt
@@ -1,9 +1,9 @@
=== Akismet Anti-Spam ===
-Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer
+Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau
Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
Requires at least: 4.0
Tested up to: 4.9.1
-Stable tag: 4.0.2
+Stable tag: 4.0.3
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,12 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
== Changelog ==
+= 4.0.3 =
+*Release Date - 19 February 2018*
+
+* Added a scheduled task to remove entries in wp_commentmeta that no longer have corresponding comments in wp_comments.
+* Added a new `akismet_batch_delete_count` action to the batch delete methods for people who'd like to keep track of the numbers of records being processed by those methods.
+
= 4.0.2 =
*Release Date - 18 December 2017*
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/blogs-gentoo:master commit in: plugins/akismet/
@ 2019-01-02 3:27 Anthony G. Basile
0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2019-01-02 3:27 UTC (permalink / raw
To: gentoo-commits
commit: d6d1dfaa04642908ab488292ffd21fac36460c56
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 2 03:26:55 2019 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Wed Jan 2 03:26:55 2019 +0000
URL: https://gitweb.gentoo.org/proj/blogs-gentoo.git/commit/?id=d6d1dfaa
Update akismet 4.1
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
plugins/akismet/akismet.php | 4 +-
plugins/akismet/class.akismet-admin.php | 63 +++++++++++++++++++-
plugins/akismet/class.akismet-cli.php | 94 +++++++++++++++++++++++++++++
plugins/akismet/class.akismet-rest-api.php | 95 ++++++++++++++++++++++++++++++
plugins/akismet/class.akismet.php | 1 -
plugins/akismet/readme.txt | 11 +++-
6 files changed, 262 insertions(+), 6 deletions(-)
diff --git a/plugins/akismet/akismet.php b/plugins/akismet/akismet.php
index d4f2135..800dd72 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: 4.0.8
+Version: 4.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', '4.0.8' );
+define( 'AKISMET_VERSION', '4.1' );
define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
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 1e80617..07a4d19 100644
--- a/plugins/akismet/class.akismet-admin.php
+++ b/plugins/akismet/class.akismet-admin.php
@@ -74,6 +74,9 @@ class Akismet_Admin {
add_filter( 'akismet_comment_form_privacy_notice_url_display', array( 'Akismet_Admin', 'jetpack_comment_form_privacy_notice_url' ) );
add_filter( 'akismet_comment_form_privacy_notice_url_hide', array( 'Akismet_Admin', 'jetpack_comment_form_privacy_notice_url' ) );
}
+
+ // priority=1 because we need ours to run before core's comment anonymizer runs, and that's registered at priority=10
+ add_filter( 'wp_privacy_personal_data_erasers', array( 'Akismet_Admin', 'register_personal_data_eraser' ), 1 );
}
public static function admin_init() {
@@ -1049,7 +1052,7 @@ class Akismet_Admin {
$message .= ' ';
if ( $spam_count === 0 ) {
- $message .= __( 'No comments were caught as spam.' );
+ $message .= __( 'No comments were caught as spam.', 'akismet' );
}
else {
$message .= sprintf( _n( '%s comment was caught as spam.', '%s comments were caught as spam.', $spam_count, 'akismet' ), number_format( $spam_count ) );
@@ -1180,4 +1183,62 @@ class Akismet_Admin {
public static function jetpack_comment_form_privacy_notice_url( $url ) {
return str_replace( 'options-general.php', 'admin.php', $url );
}
+
+ public static function register_personal_data_eraser( $erasers ) {
+ $erasers['akismet'] = array(
+ 'eraser_friendly_name' => __( 'Akismet', 'akismet' ),
+ 'callback' => array( 'Akismet_Admin', 'erase_personal_data' ),
+ );
+
+ return $erasers;
+ }
+
+ /**
+ * When a user requests that their personal data be removed, Akismet has a duty to discard
+ * any personal data we store outside of the comment itself. Right now, that is limited
+ * to the copy of the comment we store in the akismet_as_submitted commentmeta.
+ *
+ * FWIW, this information would be automatically deleted after 15 days.
+ *
+ * @param $email_address string The email address of the user who has requested erasure.
+ * @param $page int This function can (and will) be called multiple times to prevent timeouts,
+ * so this argument is used for pagination.
+ * @return array
+ * @see https://developer.wordpress.org/plugins/privacy/adding-the-personal-data-eraser-to-your-plugin/
+ */
+ public static function erase_personal_data( $email_address, $page = 1 ) {
+ $items_removed = false;
+
+ $number = 50;
+ $page = (int) $page;
+
+ $comments = get_comments(
+ array(
+ 'author_email' => $email_address,
+ 'number' => $number,
+ 'paged' => $page,
+ 'order_by' => 'comment_ID',
+ 'order' => 'ASC',
+ )
+ );
+
+ foreach ( (array) $comments as $comment ) {
+ $comment_as_submitted = get_comment_meta( $comment->comment_ID, 'akismet_as_submitted', true );
+
+ if ( $comment_as_submitted ) {
+ delete_comment_meta( $comment->comment_ID, 'akismet_as_submitted' );
+ $items_removed = true;
+ }
+ }
+
+ // Tell core if we have more comments to work on still
+ $done = count( $comments ) < $number;
+
+ return array(
+ 'items_removed' => $items_removed,
+ 'items_retained' => false, // always false in this example
+ 'messages' => array(), // no messages in this example
+ 'done' => $done,
+ );
+ }
}
diff --git a/plugins/akismet/class.akismet-cli.php b/plugins/akismet/class.akismet-cli.php
index b0b4836..9cbe7a9 100644
--- a/plugins/akismet/class.akismet-cli.php
+++ b/plugins/akismet/class.akismet-cli.php
@@ -88,4 +88,98 @@ class Akismet_CLI extends WP_CLI_Command {
WP_CLI::line( sprintf( _n( "%d comment could not be checked.", "%d comments could not be checked.", $total_counts['error'], 'akismet' ), number_format( $total_counts['error'] ) ) );
}
}
+
+ /**
+ * Fetches stats from the Akismet API.
+ *
+ * ## OPTIONS
+ *
+ * [<interval>]
+ * : The time period for which to retrieve stats.
+ * ---
+ * default: all
+ * options:
+ * - days
+ * - months
+ * - all
+ * ---
+ *
+ * [--format=<format>]
+ * : Allows overriding the output of the command when listing connections.
+ * ---
+ * default: table
+ * options:
+ * - table
+ * - json
+ * - csv
+ * - yaml
+ * - count
+ * ---
+ *
+ * [--summary]
+ * : When set, will display a summary of the stats.
+ *
+ * ## EXAMPLES
+ *
+ * wp akismet stats
+ * wp akismet stats all
+ * wp akismet stats days
+ * wp akismet stats months
+ * wp akismet stats all --summary
+ */
+ public function stats( $args, $assoc_args ) {
+ $api_key = Akismet::get_api_key();
+
+ if ( empty( $api_key ) ) {
+ WP_CLI::error( __( 'API key must be set to fetch stats.', 'akismet' ) );
+ }
+
+ switch ( $args[0] ) {
+ case 'days':
+ $interval = '60-days';
+ break;
+ case 'months':
+ $interval = '6-months';
+ break;
+ default:
+ $interval = 'all';
+ break;
+ }
+
+ $response = Akismet::http_post(
+ Akismet::build_query( array(
+ 'blog' => get_option( 'home' ),
+ 'key' => $api_key,
+ 'from' => $interval,
+ ) ),
+ 'get-stats'
+ );
+
+ if ( empty( $response[1] ) ) {
+ WP_CLI::error( __( 'Currently unable to fetch stats. Please try again.', 'akismet' ) );
+ }
+
+ $response_body = json_decode( $response[1], true );
+
+ if ( is_null( $response_body ) ) {
+ WP_CLI::error( __( 'Stats response could not be decoded.', 'akismet' ) );
+ }
+
+ if ( isset( $assoc_args['summary'] ) ) {
+ $keys = array(
+ 'spam',
+ 'ham',
+ 'missed_spam',
+ 'false_positives',
+ 'accuracy',
+ 'time_saved',
+ );
+
+ WP_CLI\Utils\format_items( $assoc_args['format'], array( $response_body ), $keys );
+ }
+ else {
+ $stats = $response_body['breakdown'];
+ WP_CLI\Utils\format_items( $assoc_args['format'], $stats, array_keys( end( $stats ) ) );
+ }
+ }
}
\ No newline at end of file
diff --git a/plugins/akismet/class.akismet-rest-api.php b/plugins/akismet/class.akismet-rest-api.php
index f97b710..bf71998 100644
--- a/plugins/akismet/class.akismet-rest-api.php
+++ b/plugins/akismet/class.akismet-rest-api.php
@@ -87,6 +87,48 @@ class Akismet_REST_API {
'callback' => array( 'Akismet_REST_API', 'get_stats' ),
)
) );
+
+ register_rest_route( 'akismet/v1', '/alert', array(
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
+ 'callback' => array( 'Akismet_REST_API', 'get_alert' ),
+ 'args' => array(
+ 'key' => array(
+ 'required' => false,
+ 'type' => 'string',
+ 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
+ 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ),
+ ),
+ ),
+ ),
+ array(
+ 'methods' => WP_REST_Server::EDITABLE,
+ 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
+ 'callback' => array( 'Akismet_REST_API', 'set_alert' ),
+ 'args' => array(
+ 'key' => array(
+ 'required' => false,
+ 'type' => 'string',
+ 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
+ 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ),
+ ),
+ ),
+ ),
+ array(
+ 'methods' => WP_REST_Server::DELETABLE,
+ 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
+ 'callback' => array( 'Akismet_REST_API', 'delete_alert' ),
+ 'args' => array(
+ 'key' => array(
+ 'required' => false,
+ 'type' => 'string',
+ 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
+ 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ),
+ ),
+ ),
+ )
+ ) );
}
/**
@@ -231,6 +273,50 @@ class Akismet_REST_API {
return rest_ensure_response( $stat_totals );
}
+ /**
+ * Get the current alert code and message. Alert codes are used to notify the site owner
+ * if there's a problem, like a connection issue between their site and the Akismet API,
+ * invalid requests being sent, etc.
+ *
+ * @param WP_REST_Request $request
+ * @return WP_Error|WP_REST_Response
+ */
+ public static function get_alert( $request ) {
+ return rest_ensure_response( array(
+ 'code' => get_option( 'akismet_alert_code' ),
+ 'message' => get_option( 'akismet_alert_msg' ),
+ ) );
+ }
+
+ /**
+ * Update the current alert code and message by triggering a call to the Akismet server.
+ *
+ * @param WP_REST_Request $request
+ * @return WP_Error|WP_REST_Response
+ */
+ public static function set_alert( $request ) {
+ delete_option( 'akismet_alert_code' );
+ delete_option( 'akismet_alert_msg' );
+
+ // Make a request so the most recent alert code and message are retrieved.
+ Akismet::verify_key( Akismet::get_api_key() );
+
+ return self::get_alert( $request );
+ }
+
+ /**
+ * Clear the current alert code and message.
+ *
+ * @param WP_REST_Request $request
+ * @return WP_Error|WP_REST_Response
+ */
+ public static function delete_alert( $request ) {
+ delete_option( 'akismet_alert_code' );
+ delete_option( 'akismet_alert_msg' );
+
+ return self::get_alert( $request );
+ }
+
private static function key_is_valid( $key ) {
$response = Akismet::http_post(
Akismet::build_query(
@@ -253,6 +339,15 @@ class Akismet_REST_API {
return current_user_can( 'manage_options' );
}
+ /**
+ * For calls that Akismet.com makes to the site to clear outdated alert codes, use the API key for authorization.
+ */
+ public static function remote_call_permission_callback( $request ) {
+ $local_key = Akismet::get_api_key();
+
+ return $local_key && ( strtolower( $request->get_param( 'key' ) ) === strtolower( $local_key ) );
+ }
+
public static function sanitize_interval( $interval, $request, $param ) {
$interval = trim( $interval );
diff --git a/plugins/akismet/class.akismet.php b/plugins/akismet/class.akismet.php
index 3a1307f..9b70d9e 100644
--- a/plugins/akismet/class.akismet.php
+++ b/plugins/akismet/class.akismet.php
@@ -762,7 +762,6 @@ class Akismet {
|| strtotime( $comment->comment_date_gmt ) < strtotime( "-15 days" ) // Comment is too old.
|| $comment->comment_approved !== "0" // Comment is no longer in the Pending queue
) {
- echo "Deleting";
delete_comment_meta( $comment_id, 'akismet_error' );
delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
continue;
diff --git a/plugins/akismet/readme.txt b/plugins/akismet/readme.txt
index 4853f6f..9473fb9 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, procifer, stephdau
Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
Requires at least: 4.0
-Tested up to: 4.9.6
-Stable tag: 4.0.8
+Tested up to: 5.0
+Stable tag: 4.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,13 @@ Upload the Akismet plugin to your blog, Activate it, then enter your [Akismet.co
== Changelog ==
+= 4.1 =
+*Release Date - 12 November 2018*
+
+* Added a WP-CLI method for retrieving stats.
+* Hooked into the new "Personal Data Eraser" functionality from WordPress 4.9.6.
+* Added functionality to clear outdated alerts from Akismet.com.
+
= 4.0.8 =
*Release Date - 19 June 2018*
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-01-02 3:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-01 13:33 [gentoo-commits] proj/blogs-gentoo:master commit in: plugins/akismet/ Jorge Manuel B. S. Vicetto
-- strict thread matches above, loose matches on Subject: below --
2015-05-01 14:04 Jorge Manuel B. S. Vicetto
2016-04-18 16:04 Anthony G. Basile
2017-11-20 21:52 Anthony G. Basile
2018-03-11 0:23 Anthony G. Basile
2019-01-02 3:27 Anthony G. Basile
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox