├── akismet ├── index.php ├── _inc │ ├── img │ │ ├── logo-a-2x.png │ │ └── logo-full-2x.png │ ├── akismet.js │ └── akismet.css ├── views │ ├── title.php │ ├── activate.php │ ├── setup.php │ ├── predefined.php │ ├── stats.php │ ├── get.php │ ├── enter.php │ ├── start.php │ ├── connect-jp.php │ ├── config.php │ └── notice.php ├── akismet.php ├── class.akismet-widget.php ├── readme.txt ├── class.akismet-cli.php ├── wrapper.php ├── class.akismet-rest-api.php ├── LICENSE.txt ├── changelog.txt └── class.akismet-admin.php ├── index.php └── hello.php /akismet/index.php: -------------------------------------------------------------------------------- 1 | 2 |

3 | -------------------------------------------------------------------------------- /akismet/views/activate.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 |
6 |
7 | 8 |
-------------------------------------------------------------------------------- /akismet/views/setup.php: -------------------------------------------------------------------------------- 1 |
2 |

3 | __( 'Set up your Akismet account' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?> 4 |
5 | -------------------------------------------------------------------------------- /akismet/views/predefined.php: -------------------------------------------------------------------------------- 1 |
2 |

3 |

4 | wp-config.php' ); 8 | 9 | ?> 10 |

11 |
-------------------------------------------------------------------------------- /akismet/views/stats.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 | 7 |
8 |
9 |
10 | 11 |
-------------------------------------------------------------------------------- /akismet/views/get.php: -------------------------------------------------------------------------------- 1 | 7 |
8 | 9 | 10 | 11 | 12 |
-------------------------------------------------------------------------------- /akismet/views/enter.php: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 | 6 | 7 |

8 | 9 | 10 |

11 |
12 |
13 |
-------------------------------------------------------------------------------- /akismet/views/start.php: -------------------------------------------------------------------------------- 1 | 7 |
8 |
9 |
10 |
11 | 12 |
13 |
14 |
15 |
16 | 17 |
18 | status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) { 23 | Akismet::view( 'connect-jp', compact( 'akismet_user' ) ); 24 | } else { 25 | Akismet::view( 'activate' ); 26 | } 27 | 28 | ?> 29 |
30 |
31 |
-------------------------------------------------------------------------------- /akismet/akismet.php: -------------------------------------------------------------------------------- 1 | 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. 9 | Version: 4.2.2 10 | Author: Automattic 11 | Author URI: https://automattic.com/wordpress-plugins/ 12 | License: GPLv2 or later 13 | Text Domain: akismet 14 | */ 15 | 16 | /* 17 | This program is free software; you can redistribute it and/or 18 | modify it under the terms of the GNU General Public License 19 | as published by the Free Software Foundation; either version 2 20 | of the License, or (at your option) any later version. 21 | 22 | This program is distributed in the hope that it will be useful, 23 | but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | GNU General Public License for more details. 26 | 27 | You should have received a copy of the GNU General Public License 28 | along with this program; if not, write to the Free Software 29 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30 | 31 | Copyright 2005-2015 Automattic, Inc. 32 | */ 33 | 34 | // Make sure we don't expose any info if called directly 35 | if ( !function_exists( 'add_action' ) ) { 36 | echo 'Hi there! I\'m just a plugin, not much I can do when called directly.'; 37 | exit; 38 | } 39 | 40 | define( 'AKISMET_VERSION', '4.2.2' ); 41 | define( 'AKISMET__MINIMUM_WP_VERSION', '5.0' ); 42 | define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 43 | define( 'AKISMET_DELETE_LIMIT', 10000 ); 44 | 45 | register_activation_hook( __FILE__, array( 'Akismet', 'plugin_activation' ) ); 46 | register_deactivation_hook( __FILE__, array( 'Akismet', 'plugin_deactivation' ) ); 47 | 48 | require_once( AKISMET__PLUGIN_DIR . 'class.akismet.php' ); 49 | require_once( AKISMET__PLUGIN_DIR . 'class.akismet-widget.php' ); 50 | require_once( AKISMET__PLUGIN_DIR . 'class.akismet-rest-api.php' ); 51 | 52 | add_action( 'init', array( 'Akismet', 'init' ) ); 53 | 54 | add_action( 'rest_api_init', array( 'Akismet_REST_API', 'init' ) ); 55 | 56 | if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { 57 | require_once( AKISMET__PLUGIN_DIR . 'class.akismet-admin.php' ); 58 | add_action( 'init', array( 'Akismet_Admin', 'init' ) ); 59 | } 60 | 61 | //add wrapper class around deprecated akismet functions that are referenced elsewhere 62 | require_once( AKISMET__PLUGIN_DIR . 'wrapper.php' ); 63 | 64 | if ( defined( 'WP_CLI' ) && WP_CLI ) { 65 | require_once( AKISMET__PLUGIN_DIR . 'class.akismet-cli.php' ); 66 | } 67 | -------------------------------------------------------------------------------- /hello.php: -------------------------------------------------------------------------------- 1 | Hello, Dolly in the upper right of your admin screen on every page. 10 | Author: Matt Mullenweg 11 | Version: 1.7.2 12 | Author URI: http://ma.tt/ 13 | */ 14 | 15 | function hello_dolly_get_lyric() { 16 | /** These are the lyrics to Hello Dolly */ 17 | $lyrics = "Hello, Dolly 18 | Well, hello, Dolly 19 | It's so nice to have you back where you belong 20 | You're lookin' swell, Dolly 21 | I can tell, Dolly 22 | You're still glowin', you're still crowin' 23 | You're still goin' strong 24 | I feel the room swayin' 25 | While the band's playin' 26 | One of our old favorite songs from way back when 27 | So, take her wrap, fellas 28 | Dolly, never go away again 29 | Hello, Dolly 30 | Well, hello, Dolly 31 | It's so nice to have you back where you belong 32 | You're lookin' swell, Dolly 33 | I can tell, Dolly 34 | You're still glowin', you're still crowin' 35 | You're still goin' strong 36 | I feel the room swayin' 37 | While the band's playin' 38 | One of our old favorite songs from way back when 39 | So, golly, gee, fellas 40 | Have a little faith in me, fellas 41 | Dolly, never go away 42 | Promise, you'll never go away 43 | Dolly'll never go away again"; 44 | 45 | // Here we split it into lines. 46 | $lyrics = explode( "\n", $lyrics ); 47 | 48 | // And then randomly choose a line. 49 | return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] ); 50 | } 51 | 52 | // This just echoes the chosen line, we'll position it later. 53 | function hello_dolly() { 54 | $chosen = hello_dolly_get_lyric(); 55 | $lang = ''; 56 | if ( 'en_' !== substr( get_user_locale(), 0, 3 ) ) { 57 | $lang = ' lang="en"'; 58 | } 59 | 60 | printf( 61 | '

%s %s

', 62 | __( 'Quote from Hello Dolly song, by Jerry Herman:' ), 63 | $lang, 64 | $chosen 65 | ); 66 | } 67 | 68 | // Now we set that function up to execute when the admin_notices action is called. 69 | add_action( 'admin_notices', 'hello_dolly' ); 70 | 71 | // We need some CSS to position the paragraph. 72 | function dolly_css() { 73 | echo " 74 | 97 | "; 98 | } 99 | 100 | add_action( 'admin_head', 'dolly_css' ); 101 | -------------------------------------------------------------------------------- /akismet/class.akismet-widget.php: -------------------------------------------------------------------------------- 1 | __( 'Display the number of spam comments Akismet has caught' , 'akismet') ) 14 | ); 15 | 16 | if ( is_active_widget( false, false, $this->id_base ) ) { 17 | add_action( 'wp_head', array( $this, 'css' ) ); 18 | } 19 | } 20 | 21 | function css() { 22 | ?> 23 | 24 | 60 | 61 | 72 | 73 |

74 | 75 | 76 |

77 | 78 | 100 | 101 |
102 | 103 | %1$s spam blocked by Akismet', 110 | '%1$s spam blocked by Akismet', 111 | $count, 112 | 'akismet' 113 | ), 114 | number_format_i18n( $count ) 115 | ), 116 | array( 117 | 'strong' => array( 118 | 'class' => true, 119 | ), 120 | ) 121 | ); 122 | 123 | ?> 124 | 125 |
126 | 127 | 7 |
8 | 9 |
10 |

status, array( 'no-sub', 'missing' ) ) ) {?> 12 |

13 |
14 | 15 | 16 | 17 | 18 | 19 |
20 | user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> 21 |

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

24 | status == 'cancelled' ) { ?> 25 |

26 |
27 | 28 | 29 | 30 | 31 | 32 |
33 | user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> 34 |

user_email ) ); ?>
user_email ); ?>

37 | status == 'suspended' ) { ?> 38 |
39 |

40 |
41 |

42 | user_email ) ); ?> 45 | 46 |

47 | 48 |

49 |
50 | 51 | 52 | 53 | 54 |
55 | user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?> 56 |

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

59 | 60 |
61 |
62 | 63 |
64 |
65 | 66 | 67 |
68 |
69 |
70 |
71 | 72 |
-------------------------------------------------------------------------------- /akismet/class.akismet-cli.php: -------------------------------------------------------------------------------- 1 | ... 14 | * : The ID(s) of the comment(s) to check. 15 | * 16 | * [--noaction] 17 | * : Don't change the status of the comment. Just report what Akismet thinks it is. 18 | * 19 | * ## EXAMPLES 20 | * 21 | * wp akismet check 12345 22 | * 23 | * @alias comment-check 24 | */ 25 | public function check( $args, $assoc_args ) { 26 | foreach ( $args as $comment_id ) { 27 | if ( isset( $assoc_args['noaction'] ) ) { 28 | // Check the comment, but don't reclassify it. 29 | $api_response = Akismet::check_db_comment( $comment_id, 'wp-cli' ); 30 | } 31 | else { 32 | $api_response = Akismet::recheck_comment( $comment_id, 'wp-cli' ); 33 | } 34 | 35 | if ( 'true' === $api_response ) { 36 | WP_CLI::line( sprintf( __( "Comment #%d is spam.", 'akismet' ), $comment_id ) ); 37 | } 38 | else if ( 'false' === $api_response ) { 39 | WP_CLI::line( sprintf( __( "Comment #%d is not spam.", 'akismet' ), $comment_id ) ); 40 | } 41 | else { 42 | if ( false === $api_response ) { 43 | WP_CLI::error( __( "Failed to connect to Akismet.", 'akismet' ) ); 44 | } 45 | else if ( is_wp_error( $api_response ) ) { 46 | WP_CLI::warning( sprintf( __( "Comment #%d could not be checked.", 'akismet' ), $comment_id ) ); 47 | } 48 | } 49 | } 50 | } 51 | 52 | /** 53 | * Recheck all comments in the Pending queue. 54 | * 55 | * ## EXAMPLES 56 | * 57 | * wp akismet recheck_queue 58 | * 59 | * @alias recheck-queue 60 | */ 61 | public function recheck_queue() { 62 | $batch_size = 100; 63 | $start = 0; 64 | 65 | $total_counts = array(); 66 | 67 | do { 68 | $result_counts = Akismet_Admin::recheck_queue_portion( $start, $batch_size ); 69 | 70 | if ( $result_counts['processed'] > 0 ) { 71 | foreach ( $result_counts as $key => $count ) { 72 | if ( ! isset( $total_counts[ $key ] ) ) { 73 | $total_counts[ $key ] = $count; 74 | } 75 | else { 76 | $total_counts[ $key ] += $count; 77 | } 78 | } 79 | $start += $batch_size; 80 | $start -= $result_counts['spam']; // These comments will have been removed from the queue. 81 | } 82 | } while ( $result_counts['processed'] > 0 ); 83 | 84 | WP_CLI::line( sprintf( _n( "Processed %d comment.", "Processed %d comments.", $total_counts['processed'], 'akismet' ), number_format( $total_counts['processed'] ) ) ); 85 | WP_CLI::line( sprintf( _n( "%d comment moved to Spam.", "%d comments moved to Spam.", $total_counts['spam'], 'akismet' ), number_format( $total_counts['spam'] ) ) ); 86 | 87 | if ( $total_counts['error'] ) { 88 | 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'] ) ) ); 89 | } 90 | } 91 | 92 | /** 93 | * Fetches stats from the Akismet API. 94 | * 95 | * ## OPTIONS 96 | * 97 | * [] 98 | * : The time period for which to retrieve stats. 99 | * --- 100 | * default: all 101 | * options: 102 | * - days 103 | * - months 104 | * - all 105 | * --- 106 | * 107 | * [--format=] 108 | * : Allows overriding the output of the command when listing connections. 109 | * --- 110 | * default: table 111 | * options: 112 | * - table 113 | * - json 114 | * - csv 115 | * - yaml 116 | * - count 117 | * --- 118 | * 119 | * [--summary] 120 | * : When set, will display a summary of the stats. 121 | * 122 | * ## EXAMPLES 123 | * 124 | * wp akismet stats 125 | * wp akismet stats all 126 | * wp akismet stats days 127 | * wp akismet stats months 128 | * wp akismet stats all --summary 129 | */ 130 | public function stats( $args, $assoc_args ) { 131 | $api_key = Akismet::get_api_key(); 132 | 133 | if ( empty( $api_key ) ) { 134 | WP_CLI::error( __( 'API key must be set to fetch stats.', 'akismet' ) ); 135 | } 136 | 137 | switch ( $args[0] ) { 138 | case 'days': 139 | $interval = '60-days'; 140 | break; 141 | case 'months': 142 | $interval = '6-months'; 143 | break; 144 | default: 145 | $interval = 'all'; 146 | break; 147 | } 148 | 149 | $response = Akismet::http_post( 150 | Akismet::build_query( array( 151 | 'blog' => get_option( 'home' ), 152 | 'key' => $api_key, 153 | 'from' => $interval, 154 | ) ), 155 | 'get-stats' 156 | ); 157 | 158 | if ( empty( $response[1] ) ) { 159 | WP_CLI::error( __( 'Currently unable to fetch stats. Please try again.', 'akismet' ) ); 160 | } 161 | 162 | $response_body = json_decode( $response[1], true ); 163 | 164 | if ( is_null( $response_body ) ) { 165 | WP_CLI::error( __( 'Stats response could not be decoded.', 'akismet' ) ); 166 | } 167 | 168 | if ( isset( $assoc_args['summary'] ) ) { 169 | $keys = array( 170 | 'spam', 171 | 'ham', 172 | 'missed_spam', 173 | 'false_positives', 174 | 'accuracy', 175 | 'time_saved', 176 | ); 177 | 178 | WP_CLI\Utils\format_items( $assoc_args['format'], array( $response_body ), $keys ); 179 | } 180 | else { 181 | $stats = $response_body['breakdown']; 182 | WP_CLI\Utils\format_items( $assoc_args['format'], $stats, array_keys( end( $stats ) ) ); 183 | } 184 | } 185 | } -------------------------------------------------------------------------------- /akismet/wrapper.php: -------------------------------------------------------------------------------- 1 | WP_REST_Server::READABLE, 16 | 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 17 | 'callback' => array( 'Akismet_REST_API', 'get_key' ), 18 | ), array( 19 | 'methods' => WP_REST_Server::EDITABLE, 20 | 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 21 | 'callback' => array( 'Akismet_REST_API', 'set_key' ), 22 | 'args' => array( 23 | 'key' => array( 24 | 'required' => true, 25 | 'type' => 'string', 26 | 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 27 | 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), 28 | ), 29 | ), 30 | ), array( 31 | 'methods' => WP_REST_Server::DELETABLE, 32 | 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 33 | 'callback' => array( 'Akismet_REST_API', 'delete_key' ), 34 | ) 35 | ) ); 36 | 37 | register_rest_route( 'akismet/v1', '/settings/', array( 38 | array( 39 | 'methods' => WP_REST_Server::READABLE, 40 | 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 41 | 'callback' => array( 'Akismet_REST_API', 'get_settings' ), 42 | ), 43 | array( 44 | 'methods' => WP_REST_Server::EDITABLE, 45 | 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 46 | 'callback' => array( 'Akismet_REST_API', 'set_boolean_settings' ), 47 | 'args' => array( 48 | 'akismet_strictness' => array( 49 | 'required' => false, 50 | 'type' => 'boolean', 51 | 'description' => __( 'If true, Akismet will automatically discard the worst spam automatically rather than putting it in the spam folder.', 'akismet' ), 52 | ), 53 | 'akismet_show_user_comments_approved' => array( 54 | 'required' => false, 55 | 'type' => 'boolean', 56 | 'description' => __( 'If true, show the number of approved comments beside each comment author in the comments list page.', 'akismet' ), 57 | ), 58 | ), 59 | ) 60 | ) ); 61 | 62 | register_rest_route( 'akismet/v1', '/stats', array( 63 | 'methods' => WP_REST_Server::READABLE, 64 | 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 65 | 'callback' => array( 'Akismet_REST_API', 'get_stats' ), 66 | 'args' => array( 67 | 'interval' => array( 68 | 'required' => false, 69 | 'type' => 'string', 70 | 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_interval' ), 71 | 'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ), 72 | 'default' => 'all', 73 | ), 74 | ), 75 | ) ); 76 | 77 | register_rest_route( 'akismet/v1', '/stats/(?P[\w+])', array( 78 | 'args' => array( 79 | 'interval' => array( 80 | 'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ), 81 | 'type' => 'string', 82 | ), 83 | ), 84 | array( 85 | 'methods' => WP_REST_Server::READABLE, 86 | 'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ), 87 | 'callback' => array( 'Akismet_REST_API', 'get_stats' ), 88 | ) 89 | ) ); 90 | 91 | register_rest_route( 'akismet/v1', '/alert', array( 92 | array( 93 | 'methods' => WP_REST_Server::READABLE, 94 | 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ), 95 | 'callback' => array( 'Akismet_REST_API', 'get_alert' ), 96 | 'args' => array( 97 | 'key' => array( 98 | 'required' => false, 99 | 'type' => 'string', 100 | 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 101 | 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), 102 | ), 103 | ), 104 | ), 105 | array( 106 | 'methods' => WP_REST_Server::EDITABLE, 107 | 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ), 108 | 'callback' => array( 'Akismet_REST_API', 'set_alert' ), 109 | 'args' => array( 110 | 'key' => array( 111 | 'required' => false, 112 | 'type' => 'string', 113 | 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 114 | 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), 115 | ), 116 | ), 117 | ), 118 | array( 119 | 'methods' => WP_REST_Server::DELETABLE, 120 | 'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ), 121 | 'callback' => array( 'Akismet_REST_API', 'delete_alert' ), 122 | 'args' => array( 123 | 'key' => array( 124 | 'required' => false, 125 | 'type' => 'string', 126 | 'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ), 127 | 'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ), 128 | ), 129 | ), 130 | ) 131 | ) ); 132 | } 133 | 134 | /** 135 | * Get the current Akismet API key. 136 | * 137 | * @param WP_REST_Request $request 138 | * @return WP_Error|WP_REST_Response 139 | */ 140 | public static function get_key( $request = null ) { 141 | return rest_ensure_response( Akismet::get_api_key() ); 142 | } 143 | 144 | /** 145 | * Set the API key, if possible. 146 | * 147 | * @param WP_REST_Request $request 148 | * @return WP_Error|WP_REST_Response 149 | */ 150 | public static function set_key( $request ) { 151 | if ( defined( 'WPCOM_API_KEY' ) ) { 152 | return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be changed via the API.', 'akismet' ), array( 'status'=> 409 ) ) ); 153 | } 154 | 155 | $new_api_key = $request->get_param( 'key' ); 156 | 157 | if ( ! self::key_is_valid( $new_api_key ) ) { 158 | return rest_ensure_response( new WP_Error( 'invalid_key', __( 'The value provided is not a valid and registered API key.', 'akismet' ), array( 'status' => 400 ) ) ); 159 | } 160 | 161 | update_option( 'wordpress_api_key', $new_api_key ); 162 | 163 | return self::get_key(); 164 | } 165 | 166 | /** 167 | * Unset the API key, if possible. 168 | * 169 | * @param WP_REST_Request $request 170 | * @return WP_Error|WP_REST_Response 171 | */ 172 | public static function delete_key( $request ) { 173 | if ( defined( 'WPCOM_API_KEY' ) ) { 174 | return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be deleted.', 'akismet' ), array( 'status'=> 409 ) ) ); 175 | } 176 | 177 | delete_option( 'wordpress_api_key' ); 178 | 179 | return rest_ensure_response( true ); 180 | } 181 | 182 | /** 183 | * Get the Akismet settings. 184 | * 185 | * @param WP_REST_Request $request 186 | * @return WP_Error|WP_REST_Response 187 | */ 188 | public static function get_settings( $request = null ) { 189 | return rest_ensure_response( array( 190 | 'akismet_strictness' => ( get_option( 'akismet_strictness', '1' ) === '1' ), 191 | 'akismet_show_user_comments_approved' => ( get_option( 'akismet_show_user_comments_approved', '1' ) === '1' ), 192 | ) ); 193 | } 194 | 195 | /** 196 | * Update the Akismet settings. 197 | * 198 | * @param WP_REST_Request $request 199 | * @return WP_Error|WP_REST_Response 200 | */ 201 | public static function set_boolean_settings( $request ) { 202 | foreach ( array( 203 | 'akismet_strictness', 204 | 'akismet_show_user_comments_approved', 205 | ) as $setting_key ) { 206 | 207 | $setting_value = $request->get_param( $setting_key ); 208 | if ( is_null( $setting_value ) ) { 209 | // This setting was not specified. 210 | continue; 211 | } 212 | 213 | // From 4.7+, WP core will ensure that these are always boolean 214 | // values because they are registered with 'type' => 'boolean', 215 | // but we need to do this ourselves for prior versions. 216 | $setting_value = Akismet_REST_API::parse_boolean( $setting_value ); 217 | 218 | update_option( $setting_key, $setting_value ? '1' : '0' ); 219 | } 220 | 221 | return self::get_settings(); 222 | } 223 | 224 | /** 225 | * Parse a numeric or string boolean value into a boolean. 226 | * 227 | * @param mixed $value The value to convert into a boolean. 228 | * @return bool The converted value. 229 | */ 230 | public static function parse_boolean( $value ) { 231 | switch ( $value ) { 232 | case true: 233 | case 'true': 234 | case '1': 235 | case 1: 236 | return true; 237 | 238 | case false: 239 | case 'false': 240 | case '0': 241 | case 0: 242 | return false; 243 | 244 | default: 245 | return (bool) $value; 246 | } 247 | } 248 | 249 | /** 250 | * Get the Akismet stats for a given time period. 251 | * 252 | * Possible `interval` values: 253 | * - all 254 | * - 60-days 255 | * - 6-months 256 | * 257 | * @param WP_REST_Request $request 258 | * @return WP_Error|WP_REST_Response 259 | */ 260 | public static function get_stats( $request ) { 261 | $api_key = Akismet::get_api_key(); 262 | 263 | $interval = $request->get_param( 'interval' ); 264 | 265 | $stat_totals = array(); 266 | 267 | $response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' ); 268 | 269 | if ( ! empty( $response[1] ) ) { 270 | $stat_totals[$interval] = json_decode( $response[1] ); 271 | } 272 | 273 | return rest_ensure_response( $stat_totals ); 274 | } 275 | 276 | /** 277 | * Get the current alert code and message. Alert codes are used to notify the site owner 278 | * if there's a problem, like a connection issue between their site and the Akismet API, 279 | * invalid requests being sent, etc. 280 | * 281 | * @param WP_REST_Request $request 282 | * @return WP_Error|WP_REST_Response 283 | */ 284 | public static function get_alert( $request ) { 285 | return rest_ensure_response( array( 286 | 'code' => get_option( 'akismet_alert_code' ), 287 | 'message' => get_option( 'akismet_alert_msg' ), 288 | ) ); 289 | } 290 | 291 | /** 292 | * Update the current alert code and message by triggering a call to the Akismet server. 293 | * 294 | * @param WP_REST_Request $request 295 | * @return WP_Error|WP_REST_Response 296 | */ 297 | public static function set_alert( $request ) { 298 | delete_option( 'akismet_alert_code' ); 299 | delete_option( 'akismet_alert_msg' ); 300 | 301 | // Make a request so the most recent alert code and message are retrieved. 302 | Akismet::verify_key( Akismet::get_api_key() ); 303 | 304 | return self::get_alert( $request ); 305 | } 306 | 307 | /** 308 | * Clear the current alert code and message. 309 | * 310 | * @param WP_REST_Request $request 311 | * @return WP_Error|WP_REST_Response 312 | */ 313 | public static function delete_alert( $request ) { 314 | delete_option( 'akismet_alert_code' ); 315 | delete_option( 'akismet_alert_msg' ); 316 | 317 | return self::get_alert( $request ); 318 | } 319 | 320 | private static function key_is_valid( $key ) { 321 | $response = Akismet::http_post( 322 | Akismet::build_query( 323 | array( 324 | 'key' => $key, 325 | 'blog' => get_option( 'home' ) 326 | ) 327 | ), 328 | 'verify-key' 329 | ); 330 | 331 | if ( $response[1] == 'valid' ) { 332 | return true; 333 | } 334 | 335 | return false; 336 | } 337 | 338 | public static function privileged_permission_callback() { 339 | return current_user_can( 'manage_options' ); 340 | } 341 | 342 | /** 343 | * For calls that Akismet.com makes to the site to clear outdated alert codes, use the API key for authorization. 344 | */ 345 | public static function remote_call_permission_callback( $request ) { 346 | $local_key = Akismet::get_api_key(); 347 | 348 | return $local_key && ( strtolower( $request->get_param( 'key' ) ) === strtolower( $local_key ) ); 349 | } 350 | 351 | public static function sanitize_interval( $interval, $request, $param ) { 352 | $interval = trim( $interval ); 353 | 354 | $valid_intervals = array( '60-days', '6-months', 'all', ); 355 | 356 | if ( ! in_array( $interval, $valid_intervals ) ) { 357 | $interval = 'all'; 358 | } 359 | 360 | return $interval; 361 | } 362 | 363 | public static function sanitize_key( $key, $request, $param ) { 364 | return trim( $key ); 365 | } 366 | } 367 | -------------------------------------------------------------------------------- /akismet/views/config.php: -------------------------------------------------------------------------------- 1 | 7 |
8 |
9 |
10 |
11 | 12 |
13 |
14 |
15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | spam > 0 ) : ?> 25 |
26 |
27 |
28 | 29 |
30 |
31 | 32 | 33 | 34 |
35 |
36 | 37 |
38 | 39 |
    40 |
  • 41 |

    42 | spam );?> 43 | spam, 'akismet' ) ); ?> 44 |
  • 45 |
  • 46 |

    47 | spam );?> 48 | spam, 'akismet' ) ); ?> 49 |
  • 50 |
  • 51 |

    52 | accuracy ); ?>% 53 | missed_spam, 'akismet' ), number_format( $stat_totals['all']->missed_spam ) ); ?> 54 | | 55 | false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ); ?> 56 |
  • 57 |
58 |
59 |
60 | 61 | 62 | 63 |
64 |
65 |
66 | 67 |
68 |
69 | 70 |
71 |
72 | 73 | 74 | 75 | 76 | 77 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 108 | 109 | 110 | 111 | 112 | 113 | 132 | 133 | 134 | 135 | 136 | 159 | 160 | 161 | 162 | 163 | 170 | 171 | 172 |
78 | 79 | 80 |
88 |

89 | 106 |

107 |
114 |

115 | 130 |

131 |
137 |
138 |

139 |

140 |
141 | 142 | spam folder older than 1 day is deleted automatically.', 149 | 'Spam in the spam folder older than %2$d days is deleted automatically.', 150 | $delete_interval, 151 | 'akismet' 152 | ), 153 | admin_url( 'edit-comments.php?comment_status=spam' ), 154 | $delete_interval 155 | ); 156 | 157 | ?> 158 |
164 |
165 |

166 |

167 |
168 | 169 |
173 |
174 | 175 |
176 | 177 |
178 | 179 | 180 |
181 | 182 | 183 |
184 |
185 |
186 |
187 |
188 |
189 | 190 | 191 |
192 |
193 |
194 | 195 |
196 |
197 | 198 |
199 | 200 | 201 | 202 | 203 | 207 | 208 | 209 | 210 | 225 | 226 | next_billing_date ) : ?> 227 | 228 | 229 | 233 | 234 | 235 | 236 |
204 | 205 |

account_name ); ?>

206 |
211 | 212 |

status ) : 214 | esc_html_e( 'Cancelled', 'akismet' ); 215 | elseif ( 'suspended' == $akismet_user->status ) : 216 | esc_html_e( 'Suspended', 'akismet' ); 217 | elseif ( 'missing' == $akismet_user->status ) : 218 | esc_html_e( 'Missing', 'akismet' ); 219 | elseif ( 'no-sub' == $akismet_user->status ) : 220 | esc_html_e( 'No Subscription Found', 'akismet' ); 221 | else : 222 | esc_html_e( 'Active', 'akismet' ); 223 | endif; ?>

224 |
230 | 231 |

next_billing_date ); ?>

232 |
237 |
238 |
239 | ( $akismet_user->account_type == 'free-api-key' && $akismet_user->status == 'active' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?> 240 |
241 |
242 |
243 |
244 |
245 | 246 | 247 |
248 |
249 | -------------------------------------------------------------------------------- /akismet/views/notice.php: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 |
10 |
11 |
A
12 |
13 |
14 | 15 |
16 |
17 |
Almost done - configure Akismet and say goodbye to spam', 'akismet');?>
18 |
19 |
20 |
21 | 22 |
23 |

24 |

25 | 26 |

27 | 28 |
29 | 30 |
31 |

32 |

33 |

https://akismet.com/errors/' . $code . '' ); 37 | 38 | ?> 39 |

40 |
41 | 42 |
43 |

44 |

45 | 46 |

47 |
48 | 49 |
50 |

51 |

gethostbynamel function. Akismet cannot work correctly until this is fixed. Please contact your web host or firewall administrator and give them this information about Akismet’s system requirements.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?>

52 |
53 | 54 |
55 |

56 |

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

57 |
58 | 59 |
60 |

61 |

update your payment details.', 'akismet'), 'https://akismet.com/account/'); ?>

62 |
63 | 64 |
65 |

66 |

Akismet account page to reactivate your subscription.', 'akismet'), 'https://akismet.com/account/'); ?>

67 |
68 | 69 |
70 |

71 |

Akismet support for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?>

72 |
73 | 74 |
75 |

76 |

contributing a token amount.', 'akismet'), 'https://akismet.com/account/upgrade/'); ?>

77 |
78 | 79 |
80 |

81 |

Akismet support for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?>

82 |
83 | 84 |
85 |

86 |

87 | sign into your account and choose one.', 'akismet'), 'https://akismet.com/account/upgrade/' ); ?> 88 |

89 | contact our support team with any questions.', 'akismet' ), 'https://akismet.com/contact/' ); ?> 90 |

91 |
92 | get_var( "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_approved = '0' LIMIT 1" ); 98 | 99 | if ( $at_least_one_comment_in_moderation) { 100 | $check_pending_link = 'edit-comments.php?akismet_recheck=' . wp_create_nonce( 'akismet_recheck' ); 101 | } 102 | 103 | ?> 104 |
105 |

106 | 107 |

check pending comments?', 'akismet' ), esc_url( $check_pending_link ) ); ?>

108 | 109 |
110 | 111 |
112 |

113 |
114 | 115 |
116 |

117 |

118 | contact Akismet support.', 'akismet' ), 124 | 'https://akismet.com/contact/' 125 | ), 126 | array( 127 | 'a' => array( 128 | 'href' => true, 129 | 'target' => true, 130 | ), 131 | ) 132 | ); 133 | 134 | ?> 135 |

136 |
137 | 138 |
139 |

140 |

141 | our guide about firewalls and check your server configuration.', 'akismet' ), 147 | 'https://blog.akismet.com/akismet-hosting-faq/' 148 | ), 149 | array( 150 | 'a' => array( 151 | 'href' => true, 152 | 'target' => true, 153 | ), 154 | ) 155 | ); 156 | 157 | ?> 158 |

159 |
160 | 161 |
162 | 163 |

164 |

165 | purchase additional Plus subscriptions or upgrade to an Enterprise subscription that allows the use of Akismet on unlimited sites.', 'akismet' ), 171 | 'https://docs.akismet.com/billing/add-more-sites/' 172 | ), 173 | array( 174 | 'a' => array( 175 | 'href' => true, 176 | 'target' => true, 177 | ), 178 | ) 179 | ); 180 | 181 | ?> 182 |

183 | contact our support team with any questions.', 'akismet' ), 'https://akismet.com/contact/'); ?> 184 |

185 | 186 |

187 |

188 | upgrade to an Enterprise subscription, which covers an unlimited number of sites.', 'akismet'), 'https://akismet.com/account/upgrade/' ); ?> 189 |

190 | contact our support team with any questions.', 'akismet' ), 'https://akismet.com/contact/'); ?> 191 |

192 | 193 |
194 | 195 |
196 | 199 |
200 |

201 | 217 |

218 |

219 | '; 233 | echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) ); 234 | echo ''; 235 | 236 | break; 237 | case 'SECOND_MONTH_OVER_LIMIT': 238 | echo esc_html( __( 'Your Akismet usage has been over your plan’s limit for two consecutive months. Next month, we will restrict your account after you reach the limit. Please consider upgrading your plan.', 'akismet' ) ); 239 | 240 | echo ''; 241 | echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) ); 242 | echo ''; 243 | 244 | break; 245 | case 'THIRD_MONTH_APPROACHING_LIMIT': 246 | echo esc_html( __( 'Your Akismet usage is nearing your plan’s limit for the third consecutive month. We will restrict your account after you reach the limit. Upgrade your plan so Akismet can continue blocking spam.', 'akismet' ) ); 247 | 248 | echo ''; 249 | echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) ); 250 | echo ''; 251 | 252 | break; 253 | case 'THIRD_MONTH_OVER_LIMIT': 254 | case 'FOUR_PLUS_MONTHS_OVER_LIMIT': 255 | echo esc_html( __( 'Your Akismet usage has been over your plan’s limit for three consecutive months. We have restricted your account for the rest of the month. Upgrade your plan so Akismet can continue blocking spam.', 'akismet' ) ); 256 | 257 | echo ''; 258 | echo esc_html( __( 'Learn more about usage limits.', 'akismet' ) ); 259 | echo ''; 260 | 261 | break; 262 | default: 263 | } 264 | ?> 265 |

266 |
267 |
268 | 269 | 283 | 284 |
285 |
286 | 287 | -------------------------------------------------------------------------------- /akismet/_inc/akismet.js: -------------------------------------------------------------------------------- 1 | jQuery( function ( $ ) { 2 | var mshotRemovalTimer = null; 3 | var mshotRetryTimer = null; 4 | var mshotTries = 0; 5 | var mshotRetryInterval = 1000; 6 | var mshotEnabledLinkSelector = 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a'; 7 | 8 | var preloadedMshotURLs = []; 9 | 10 | $('.akismet-status').each(function () { 11 | var thisId = $(this).attr('commentid'); 12 | $(this).prependTo('#comment-' + thisId + ' .column-comment'); 13 | }); 14 | $('.akismet-user-comment-count').each(function () { 15 | var thisId = $(this).attr('commentid'); 16 | $(this).insertAfter('#comment-' + thisId + ' .author strong:first').show(); 17 | }); 18 | 19 | akismet_enable_comment_author_url_removal(); 20 | 21 | $( '#the-comment-list' ).on( 'click', '.akismet_remove_url', function () { 22 | var thisId = $(this).attr('commentid'); 23 | var data = { 24 | action: 'comment_author_deurl', 25 | _wpnonce: WPAkismet.comment_author_url_nonce, 26 | id: thisId 27 | }; 28 | $.ajax({ 29 | url: ajaxurl, 30 | type: 'POST', 31 | data: data, 32 | beforeSend: function () { 33 | // Removes "x" link 34 | $("a[commentid='"+ thisId +"']").hide(); 35 | // Show temp status 36 | $("#author_comment_url_"+ thisId).html( $( '' ).text( WPAkismet.strings['Removing...'] ) ); 37 | }, 38 | success: function (response) { 39 | if (response) { 40 | // Show status/undo link 41 | $("#author_comment_url_"+ thisId) 42 | .attr('cid', thisId) 43 | .addClass('akismet_undo_link_removal') 44 | .html( 45 | $( '' ).text( WPAkismet.strings['URL removed'] ) 46 | ) 47 | .append( ' ' ) 48 | .append( 49 | $( '' ) 50 | .text( WPAkismet.strings['(undo)'] ) 51 | .addClass( 'akismet-span-link' ) 52 | ); 53 | } 54 | } 55 | }); 56 | 57 | return false; 58 | }).on( 'click', '.akismet_undo_link_removal', function () { 59 | var thisId = $(this).attr('cid'); 60 | var thisUrl = $(this).attr('href'); 61 | var data = { 62 | action: 'comment_author_reurl', 63 | _wpnonce: WPAkismet.comment_author_url_nonce, 64 | id: thisId, 65 | url: thisUrl 66 | }; 67 | $.ajax({ 68 | url: ajaxurl, 69 | type: 'POST', 70 | data: data, 71 | beforeSend: function () { 72 | // Show temp status 73 | $("#author_comment_url_"+ thisId).html( $( '' ).text( WPAkismet.strings['Re-adding...'] ) ); 74 | }, 75 | success: function (response) { 76 | if (response) { 77 | // Add "x" link 78 | $("a[commentid='"+ thisId +"']").show(); 79 | // Show link. Core strips leading http://, so let's do that too. 80 | $("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) ); 81 | } 82 | } 83 | }); 84 | 85 | return false; 86 | }); 87 | 88 | // Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments. 89 | if ( "enable_mshots" in WPAkismet && WPAkismet.enable_mshots ) { 90 | $( '#the-comment-list' ).on( 'mouseover', mshotEnabledLinkSelector, function () { 91 | clearTimeout( mshotRemovalTimer ); 92 | 93 | if ( $( '.akismet-mshot' ).length > 0 ) { 94 | if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) { 95 | // The preview is already showing for this link. 96 | return; 97 | } 98 | else { 99 | // A new link is being hovered, so remove the old preview. 100 | $( '.akismet-mshot' ).remove(); 101 | } 102 | } 103 | 104 | clearTimeout( mshotRetryTimer ); 105 | 106 | var linkUrl = $( this ).attr( 'href' ); 107 | 108 | if ( preloadedMshotURLs.indexOf( linkUrl ) !== -1 ) { 109 | // This preview image was already preloaded, so begin with a retry URL so the user doesn't see the placeholder image for the first second. 110 | mshotTries = 2; 111 | } 112 | else { 113 | mshotTries = 1; 114 | } 115 | 116 | var mShot = $( '
' ); 117 | mShot.data( 'link', this ); 118 | mShot.data( 'url', linkUrl ); 119 | 120 | mShot.find( 'img' ).on( 'load', function () { 121 | $( '.akismet-mshot' ).data( 'pending-request', false ); 122 | } ); 123 | 124 | var offset = $( this ).offset(); 125 | 126 | mShot.offset( { 127 | left : Math.min( $( window ).width() - 475, offset.left + $( this ).width() + 10 ), // Keep it on the screen if the link is near the edge of the window. 128 | top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness 129 | } ); 130 | 131 | $( 'body' ).append( mShot ); 132 | 133 | mshotRetryTimer = setTimeout( retryMshotUntilLoaded, mshotRetryInterval ); 134 | } ).on( 'mouseout', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () { 135 | mshotRemovalTimer = setTimeout( function () { 136 | clearTimeout( mshotRetryTimer ); 137 | 138 | $( '.akismet-mshot' ).remove(); 139 | }, 200 ); 140 | } ); 141 | 142 | var preloadDelayTimer = null; 143 | 144 | $( window ).on( 'scroll resize', function () { 145 | clearTimeout( preloadDelayTimer ); 146 | 147 | preloadDelayTimer = setTimeout( preloadMshotsInViewport, 500 ); 148 | } ); 149 | 150 | preloadMshotsInViewport(); 151 | } 152 | 153 | /** 154 | * The way mShots works is if there was no screenshot already recently generated for the URL, 155 | * it returns a "loading..." image for the first request. Then, some subsequent request will 156 | * receive the actual screenshot, but it's unknown how long it will take. So, what we do here 157 | * is continually re-request the mShot, waiting a second after every response until we get the 158 | * actual screenshot. 159 | */ 160 | function retryMshotUntilLoaded() { 161 | clearTimeout( mshotRetryTimer ); 162 | 163 | var imageWidth = $( '.akismet-mshot img' ).get(0).naturalWidth; 164 | 165 | if ( imageWidth == 0 ) { 166 | // It hasn't finished loading yet the first time. Check again shortly. 167 | setTimeout( retryMshotUntilLoaded, mshotRetryInterval ); 168 | } 169 | else if ( imageWidth == 400 ) { 170 | // It loaded the preview image. 171 | 172 | if ( mshotTries == 20 ) { 173 | // Give up if we've requested the mShot 20 times already. 174 | return; 175 | } 176 | 177 | if ( ! $( '.akismet-mshot' ).data( 'pending-request' ) ) { 178 | $( '.akismet-mshot' ).data( 'pending-request', true ); 179 | 180 | mshotTries++; 181 | 182 | $( '.akismet-mshot .mshot-image' ).attr( 'src', akismet_mshot_url( $( '.akismet-mshot' ).data( 'url' ), mshotTries ) ); 183 | } 184 | 185 | mshotRetryTimer = setTimeout( retryMshotUntilLoaded, mshotRetryInterval ); 186 | } 187 | else { 188 | // All done. 189 | } 190 | } 191 | 192 | function preloadMshotsInViewport() { 193 | var windowWidth = $( window ).width(); 194 | var windowHeight = $( window ).height(); 195 | 196 | $( '#the-comment-list' ).find( mshotEnabledLinkSelector ).each( function ( index, element ) { 197 | var linkUrl = $( this ).attr( 'href' ); 198 | 199 | // Don't attempt to preload an mshot for a single link twice. 200 | if ( preloadedMshotURLs.indexOf( linkUrl ) !== -1 ) { 201 | // The URL is already preloaded. 202 | return true; 203 | } 204 | 205 | if ( typeof element.getBoundingClientRect !== 'function' ) { 206 | // The browser is too old. Return false to stop this preloading entirely. 207 | return false; 208 | } 209 | 210 | var rect = element.getBoundingClientRect(); 211 | 212 | if ( rect.top >= 0 && rect.left >= 0 && rect.bottom <= windowHeight && rect.right <= windowWidth ) { 213 | akismet_preload_mshot( linkUrl ); 214 | $( this ).data( 'akismet-mshot-preloaded', true ); 215 | } 216 | } ); 217 | } 218 | 219 | $( '.checkforspam.enable-on-load' ).on( 'click', function( e ) { 220 | if ( $( this ).hasClass( 'ajax-disabled' ) ) { 221 | // Akismet hasn't been configured yet. Allow the user to proceed to the button's link. 222 | return; 223 | } 224 | 225 | e.preventDefault(); 226 | 227 | if ( $( this ).hasClass( 'button-disabled' ) ) { 228 | window.location.href = $( this ).data( 'success-url' ).replace( '__recheck_count__', 0 ).replace( '__spam_count__', 0 ); 229 | return; 230 | } 231 | 232 | $('.checkforspam').addClass('button-disabled').addClass( 'checking' ); 233 | $('.checkforspam-spinner').addClass( 'spinner' ).addClass( 'is-active' ); 234 | 235 | akismet_check_for_spam(0, 100); 236 | }).removeClass( 'button-disabled' ); 237 | 238 | var spam_count = 0; 239 | var recheck_count = 0; 240 | 241 | function akismet_check_for_spam(offset, limit) { 242 | var check_for_spam_buttons = $( '.checkforspam' ); 243 | 244 | var nonce = check_for_spam_buttons.data( 'nonce' ); 245 | 246 | // We show the percentage complete down to one decimal point so even queues with 100k 247 | // pending comments will show some progress pretty quickly. 248 | var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10; 249 | 250 | // Update the progress counter on the "Check for Spam" button. 251 | $( '.checkforspam' ).text( check_for_spam_buttons.data( 'progress-label' ).replace( '%1$s', percentage_complete ) ); 252 | 253 | $.post( 254 | ajaxurl, 255 | { 256 | 'action': 'akismet_recheck_queue', 257 | 'offset': offset, 258 | 'limit': limit, 259 | 'nonce': nonce 260 | }, 261 | function(result) { 262 | if ( 'error' in result ) { 263 | // An error is only returned in the case of a missing nonce, so we don't need the actual error message. 264 | window.location.href = check_for_spam_buttons.data( 'failure-url' ); 265 | return; 266 | } 267 | 268 | recheck_count += result.counts.processed; 269 | spam_count += result.counts.spam; 270 | 271 | if (result.counts.processed < limit) { 272 | window.location.href = check_for_spam_buttons.data( 'success-url' ).replace( '__recheck_count__', recheck_count ).replace( '__spam_count__', spam_count ); 273 | } 274 | else { 275 | // Account for comments that were caught as spam and moved out of the queue. 276 | akismet_check_for_spam(offset + limit - result.counts.spam, limit); 277 | } 278 | } 279 | ); 280 | } 281 | 282 | if ( "start_recheck" in WPAkismet && WPAkismet.start_recheck ) { 283 | $( '.checkforspam' ).click(); 284 | } 285 | 286 | if ( typeof MutationObserver !== 'undefined' ) { 287 | // Dynamically add the "X" next the the author URL links when a comment is quick-edited. 288 | var comment_list_container = document.getElementById( 'the-comment-list' ); 289 | 290 | if ( comment_list_container ) { 291 | var observer = new MutationObserver( function ( mutations ) { 292 | for ( var i = 0, _len = mutations.length; i < _len; i++ ) { 293 | if ( mutations[i].addedNodes.length > 0 ) { 294 | akismet_enable_comment_author_url_removal(); 295 | 296 | // Once we know that we'll have to check for new author links, skip the rest of the mutations. 297 | break; 298 | } 299 | } 300 | } ); 301 | 302 | observer.observe( comment_list_container, { attributes: true, childList: true, characterData: true } ); 303 | } 304 | } 305 | 306 | function akismet_enable_comment_author_url_removal() { 307 | $( '#the-comment-list' ) 308 | .find( 'tr.comment, tr[id ^= "comment-"]' ) 309 | .find( '.column-author a[href^="http"]:first' ) // Ignore mailto: links, which would be the comment author's email. 310 | .each(function () { 311 | if ( $( this ).parent().find( '.akismet_remove_url' ).length > 0 ) { 312 | return; 313 | } 314 | 315 | var linkHref = $(this).attr( 'href' ); 316 | 317 | // Ignore any links to the current domain, which are diagnostic tools, like the IP address link 318 | // or any other links another plugin might add. 319 | var currentHostParts = document.location.href.split( '/' ); 320 | var currentHost = currentHostParts[0] + '//' + currentHostParts[2] + '/'; 321 | 322 | if ( linkHref.indexOf( currentHost ) != 0 ) { 323 | var thisCommentId = $(this).parents('tr:first').attr('id').split("-"); 324 | 325 | $(this) 326 | .attr("id", "author_comment_url_"+ thisCommentId[1]) 327 | .after( 328 | $( 'x' ) 329 | .attr( 'commentid', thisCommentId[1] ) 330 | .attr( 'title', WPAkismet.strings['Remove this URL'] ) 331 | ); 332 | } 333 | }); 334 | } 335 | 336 | /** 337 | * Generate an mShot URL if given a link URL. 338 | * 339 | * @param string linkUrl 340 | * @param int retry If retrying a request, the number of the retry. 341 | * @return string The mShot URL; 342 | */ 343 | function akismet_mshot_url( linkUrl, retry ) { 344 | var mshotUrl = '//s0.wp.com/mshots/v1/' + encodeURIComponent( linkUrl ) + '?w=900'; 345 | 346 | if ( retry > 1 ) { 347 | mshotUrl += '&r=' + encodeURIComponent( retry ); 348 | } 349 | 350 | mshotUrl += '&source=akismet'; 351 | 352 | return mshotUrl; 353 | } 354 | 355 | /** 356 | * Begin loading an mShot preview of a link. 357 | * 358 | * @param string linkUrl 359 | */ 360 | function akismet_preload_mshot( linkUrl ) { 361 | var img = new Image(); 362 | img.src = akismet_mshot_url( linkUrl ); 363 | 364 | preloadedMshotURLs.push( linkUrl ); 365 | } 366 | 367 | $( '.akismet-could-be-primary' ).each( function () { 368 | var form = $( this ).closest( 'form' ); 369 | 370 | form.data( 'initial-state', form.serialize() ); 371 | 372 | form.on( 'change keyup', function () { 373 | var self = $( this ); 374 | var submit_button = self.find( '.akismet-could-be-primary' ); 375 | 376 | if ( self.serialize() != self.data( 'initial-state' ) ) { 377 | submit_button.addClass( 'akismet-is-primary' ); 378 | } 379 | else { 380 | submit_button.removeClass( 'akismet-is-primary' ); 381 | } 382 | } ); 383 | } ); 384 | 385 | /** 386 | * Shows the Enter API key form 387 | */ 388 | $( '.akismet-enter-api-key-box a' ).on( 'click', function ( e ) { 389 | e.preventDefault(); 390 | 391 | var div = $( '.enter-api-key' ); 392 | div.show( 500 ); 393 | div.find( 'input[name=key]' ).focus(); 394 | 395 | $( this ).hide(); 396 | } ); 397 | 398 | /** 399 | * Hides the Connect with Jetpack form | Shows the Activate Akismet Account form 400 | */ 401 | $( 'a.toggle-ak-connect' ).on( 'click', function ( e ) { 402 | e.preventDefault(); 403 | 404 | $( '.akismet-ak-connect' ).slideToggle('slow'); 405 | $( 'a.toggle-ak-connect' ).hide(); 406 | $( '.akismet-jp-connect' ).hide(); 407 | $( 'a.toggle-jp-connect' ).show(); 408 | } ); 409 | 410 | /** 411 | * Shows the Connect with Jetpack form | Hides the Activate Akismet Account form 412 | */ 413 | $( 'a.toggle-jp-connect' ).on( 'click', function ( e ) { 414 | e.preventDefault(); 415 | 416 | $( '.akismet-jp-connect' ).slideToggle('slow'); 417 | $( 'a.toggle-jp-connect' ).hide(); 418 | $( '.akismet-ak-connect' ).hide(); 419 | $( 'a.toggle-ak-connect' ).show(); 420 | } ); 421 | }); 422 | -------------------------------------------------------------------------------- /akismet/_inc/akismet.css: -------------------------------------------------------------------------------- 1 | .wp-admin.jetpack_page_akismet-key-config, .wp-admin.settings_page_akismet-key-config { 2 | background-color:#f3f6f8; 3 | } 4 | 5 | #submitted-on { 6 | position: relative; 7 | } 8 | #the-comment-list .author .akismet-user-comment-count { 9 | display: inline; 10 | } 11 | #the-comment-list .author a span { 12 | text-decoration: none; 13 | color: #999; 14 | } 15 | #the-comment-list .author a span.akismet-span-link { 16 | text-decoration: inherit; 17 | color: inherit; 18 | } 19 | #the-comment-list .akismet_remove_url { 20 | margin-left: 3px; 21 | color: #999; 22 | padding: 2px 3px 2px 0; 23 | } 24 | #the-comment-list .akismet_remove_url:hover { 25 | color: #A7301F; 26 | font-weight: bold; 27 | padding: 2px 2px 2px 0; 28 | } 29 | #dashboard_recent_comments .akismet-status { 30 | display: none; 31 | } 32 | .akismet-status { 33 | float: right; 34 | } 35 | .akismet-status a { 36 | color: #AAA; 37 | font-style: italic; 38 | } 39 | table.comments td.comment p a { 40 | text-decoration: underline; 41 | } 42 | table.comments td.comment p a:after { 43 | content: attr(href); 44 | color: #aaa; 45 | display: inline-block; /* Show the URL without the link's underline extending under it. */ 46 | padding: 0 1ex; /* Because it's inline block, we can't just use spaces in the content: attribute to separate it from the link text. */ 47 | } 48 | .mshot-arrow { 49 | width: 0; 50 | height: 0; 51 | border-top: 10px solid transparent; 52 | border-bottom: 10px solid transparent; 53 | border-right: 10px solid #5C5C5C; 54 | position: absolute; 55 | left: -6px; 56 | top: 91px; 57 | } 58 | .mshot-container { 59 | background: #5C5C5C; 60 | position: absolute; 61 | top: -94px; 62 | padding: 7px; 63 | width: 450px; 64 | height: 338px; 65 | z-index: 20000; 66 | -moz-border-radius: 6px; 67 | border-radius: 6px; 68 | -webkit-border-radius: 6px; 69 | } 70 | .akismet-mshot { 71 | position: absolute; 72 | z-index: 100; 73 | } 74 | .akismet-mshot .mshot-image { 75 | margin: 0; 76 | height: 338px; 77 | width: 450px; 78 | } 79 | .checkforspam { 80 | display: inline-block !important; 81 | } 82 | 83 | .checkforspam-spinner { 84 | display: inline-block; 85 | margin-top: 7px; 86 | } 87 | 88 | .akismet-right { 89 | float: right; 90 | } 91 | 92 | .akismet-card .akismet-right { 93 | margin: 1em 0; 94 | } 95 | 96 | .akismet-alert-text { 97 | color: #dd3d36; 98 | font-weight: bold; 99 | font-size: 120%; 100 | margin-top: .5rem; 101 | } 102 | .akismet-alert { 103 | padding: 0.4em 1em 1.4em 1em; 104 | box-sizing: border-box; 105 | box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3; 106 | } 107 | 108 | .akismet-alert h3.akismet-key-status { 109 | color: #fff; 110 | margin: 1em 0 0.5em 0; 111 | } 112 | 113 | .akismet-alert.akismet-critical { 114 | background-color: #993300; 115 | } 116 | 117 | .akismet-alert.akismet-active { 118 | background-color: #649316; 119 | } 120 | 121 | .akismet-alert p.akismet-key-status { 122 | font-size: 24px; 123 | } 124 | 125 | .akismet-alert p.akismet-description { 126 | color:#fff; 127 | font-size: 14px; 128 | margin: 0 0; 129 | font-style: normal; 130 | } 131 | 132 | .akismet-alert p.akismet-description a, 133 | .akismet-alert p.akismet-description a, 134 | .akismet-alert p.akismet-description a, 135 | .akismet-alert p.akismet-description a { 136 | color: #fff; 137 | } 138 | 139 | .akismet-new-snapshot { 140 | margin-top: 1em; 141 | padding: 1em; 142 | text-align: center; 143 | background: #fff; 144 | } 145 | 146 | .akismet-new-snapshot h3 { 147 | background: #f5f5f5; 148 | color: #888; 149 | font-size: 11px; 150 | margin: 0; 151 | padding: 3px; 152 | } 153 | 154 | .new-snapspot ul { 155 | font-size: 12px; 156 | width: 100%; 157 | } 158 | 159 | .akismet-new-snapshot ul li { 160 | color: #999; 161 | float: left; 162 | font-size: 11px; 163 | padding: 0 20px; 164 | text-transform: uppercase; 165 | width: 33%; 166 | box-sizing: border-box; 167 | -moz-box-sizing: border-box; 168 | -webkit-box-sizing: border-box; 169 | -ms-box-sizing: border-box; 170 | } 171 | 172 | .akismet-new-snapshot ul li:first-child, 173 | .akismet-new-snapshot ul li:nth-child(2) { 174 | border-right:1px dotted #ccc; 175 | } 176 | 177 | .akismet-new-snapshot ul li span { 178 | color: #52accc; 179 | display: block; 180 | font-size: 32px; 181 | font-weight: lighter; 182 | line-height: 1.5em; 183 | } 184 | 185 | .akismet-settings th:first-child { 186 | vertical-align: top; 187 | padding-top: 15px; 188 | } 189 | 190 | .akismet-settings th.akismet-api-key { 191 | vertical-align: middle; 192 | padding-top: 0; 193 | } 194 | 195 | .akismet-settings input[type=text] { 196 | width: 75%; 197 | } 198 | 199 | .akismet-settings span.akismet-note{ 200 | float: left; 201 | padding-left: 23px; 202 | font-size: 75%; 203 | margin-top: -10px; 204 | } 205 | 206 | /** 207 | * For the activation notice on the plugins page. 208 | */ 209 | 210 | #akismet_setup_prompt { 211 | background: none; 212 | border: none; 213 | margin: 0; 214 | padding: 0; 215 | width: 100%; 216 | } 217 | 218 | .akismet_activate { 219 | border: 1px solid #4F800D; 220 | padding: 5px; 221 | margin: 15px 0; 222 | background: #83AF24; 223 | background-image: -webkit-gradient(linear, 0% 0, 80% 100%, from(#83AF24), to(#4F800D)); 224 | background-image: -moz-linear-gradient(80% 100% 120deg, #4F800D, #83AF24); 225 | -moz-border-radius: 3px; 226 | border-radius: 3px; 227 | -webkit-border-radius: 3px; 228 | position: relative; 229 | overflow: hidden; 230 | } 231 | 232 | .akismet_activate .aa_a { 233 | position: absolute; 234 | top: -5px; 235 | right: 10px; 236 | font-size: 140px; 237 | color: #769F33; 238 | font-family: Georgia, "Times New Roman", Times, serif; 239 | } 240 | 241 | .akismet_activate .aa_button { 242 | font-weight: bold; 243 | border: 1px solid #029DD6; 244 | border-top: 1px solid #06B9FD; 245 | font-size: 15px; 246 | text-align: center; 247 | padding: 9px 0 8px 0; 248 | color: #FFF; 249 | background: #029DD6; 250 | background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1)); 251 | background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6); 252 | -moz-border-radius: 2px; 253 | border-radius: 2px; 254 | -webkit-border-radius: 2px; 255 | width: 100%; 256 | cursor: pointer; 257 | margin: 0; 258 | } 259 | 260 | .akismet_activate .aa_button:hover { 261 | text-decoration: none !important; 262 | border: 1px solid #029DD6; 263 | border-bottom: 1px solid #00A8EF; 264 | font-size: 15px; 265 | text-align: center; 266 | padding: 9px 0 8px 0; 267 | color: #F0F8FB; 268 | background: #0079B1; 269 | background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#0079B1), to(#0092BF)); 270 | background-image: -moz-linear-gradient(0% 100% 90deg, #0092BF, #0079B1); 271 | -moz-border-radius: 2px; 272 | border-radius: 2px; 273 | -webkit-border-radius: 2px; 274 | } 275 | 276 | .akismet_activate .aa_button_border { 277 | border: 1px solid #006699; 278 | -moz-border-radius: 2px; 279 | border-radius: 2px; 280 | -webkit-border-radius: 2px; 281 | background: #029DD6; 282 | background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1)); 283 | background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6); 284 | } 285 | 286 | .akismet_activate .aa_button_container { 287 | box-sizing: border-box; 288 | display: inline-block; 289 | background: #DEF1B8; 290 | padding: 5px; 291 | -moz-border-radius: 2px; 292 | border-radius: 2px; 293 | -webkit-border-radius: 2px; 294 | width: 266px; 295 | } 296 | 297 | .akismet_activate .aa_description { 298 | position: absolute; 299 | top: 22px; 300 | left: 285px; 301 | margin-left: 25px; 302 | color: #E5F2B1; 303 | font-size: 15px; 304 | } 305 | 306 | .akismet_activate .aa_description strong { 307 | color: #FFF; 308 | font-weight: normal; 309 | } 310 | 311 | @media (max-width: 550px) { 312 | .akismet_activate .aa_a { 313 | display: none; 314 | } 315 | 316 | .akismet_activate .aa_button_container { 317 | width: 100%; 318 | } 319 | } 320 | 321 | @media (max-width: 782px) { 322 | .akismet_activate { 323 | min-width: 0; 324 | } 325 | } 326 | 327 | @media (max-width: 850px) { 328 | #akismet_setup_prompt .aa_description { 329 | display: none; 330 | } 331 | 332 | .akismet_activate { 333 | min-width: 0; 334 | } 335 | } 336 | 337 | .jetpack_page_akismet-key-config #wpcontent, .settings_page_akismet-key-config #wpcontent { 338 | padding-left: 0; 339 | } 340 | 341 | .akismet-masthead { 342 | background-color:#fff; 343 | text-align:center; 344 | box-shadow:0 1px 0 rgba(200,215,225,0.5),0 1px 2px #e9eff3 345 | } 346 | @media (max-width: 45rem) { 347 | .akismet-masthead { 348 | padding:0 1.25rem 349 | } 350 | } 351 | 352 | .akismet-masthead__inside-container { 353 | padding:.375rem 0; 354 | margin:0 auto; 355 | width:100%; 356 | max-width:45rem; 357 | text-align: left; 358 | } 359 | .akismet-masthead__logo-container { 360 | padding:.3125rem 0 0 361 | } 362 | .akismet-masthead__logo { 363 | width:10.375rem; 364 | height:1.8125rem; 365 | } 366 | .akismet-masthead__logo-link { 367 | display:inline-block; 368 | outline:none; 369 | vertical-align:middle 370 | } 371 | .akismet-masthead__logo-link:focus { 372 | line-height:0; 373 | box-shadow:0 0 0 2px #78dcfa 374 | } 375 | .akismet-masthead__logo-link+code { 376 | margin:0 10px; 377 | padding:5px 9px; 378 | border-radius:2px; 379 | background:#e6ecf1; 380 | color:#647a88 381 | } 382 | .akismet-masthead__links { 383 | display:-ms-flexbox; 384 | display:flex; 385 | -ms-flex-flow:row wrap; 386 | flex-flow:row wrap; 387 | -ms-flex:2 50%; 388 | flex:2 50%; 389 | -ms-flex-pack:end; 390 | justify-content:flex-end; 391 | margin:0 392 | } 393 | @media (max-width: 480px) { 394 | .akismet-masthead__links { 395 | padding-right:.625rem 396 | } 397 | } 398 | .akismet-masthead__link-li { 399 | margin:0; 400 | padding:0 401 | } 402 | .akismet-masthead__link { 403 | font-style:normal; 404 | color:#0087be; 405 | padding:.625rem; 406 | display:inline-block 407 | } 408 | .akismet-masthead__link:visited { 409 | color:#0087be 410 | } 411 | .akismet-masthead__link:active,.akismet-masthead__link:hover { 412 | color:#00aadc 413 | } 414 | .akismet-masthead__link:hover { 415 | text-decoration:underline 416 | } 417 | .akismet-masthead__link .dashicons { 418 | display:none 419 | } 420 | @media (max-width: 480px) { 421 | .akismet-masthead__link:hover,.akismet-masthead__link:active { 422 | text-decoration:none 423 | } 424 | .akismet-masthead__link .dashicons { 425 | display:block; 426 | font-size:1.75rem 427 | } 428 | .akismet-masthead__link span+span { 429 | display:none 430 | } 431 | } 432 | .akismet-masthead__link-li:last-of-type .akismet-masthead__link { 433 | padding-right:0 434 | } 435 | 436 | .akismet-lower { 437 | margin: 0 auto; 438 | text-align: left; 439 | max-width: 45rem; 440 | padding: 1.5rem; 441 | } 442 | 443 | .akismet-lower .notice { 444 | margin-bottom: 2rem; 445 | } 446 | 447 | .akismet-card { 448 | margin-top: 1rem; 449 | margin-bottom: 0; 450 | position: relative; 451 | margin: 0 auto 0.625rem auto; 452 | box-sizing: border-box; 453 | background: white; 454 | box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3; 455 | } 456 | 457 | .akismet-card:after, .akismet-card .inside:after, .akismet-masthead__logo-container:after { 458 | content: "."; 459 | display: block; 460 | height: 0; 461 | clear: both; 462 | visibility: hidden; 463 | } 464 | 465 | .akismet-card .inside { 466 | padding: 1.5rem; 467 | padding-top: 1rem; 468 | } 469 | 470 | .akismet-card .akismet-card-actions { 471 | margin-top: 1rem; 472 | } 473 | 474 | .jetpack_page_akismet-key-config .update-nag, .settings_page_akismet-key-config .update-nag { 475 | display: none; 476 | } 477 | 478 | .akismet-masthead .akismet-right { 479 | line-height: 2.125rem; 480 | font-size: 0.9rem; 481 | } 482 | 483 | .akismet-box { 484 | box-sizing: border-box; 485 | background: white; 486 | border: 1px solid rgba(200, 215, 225, 0.5); 487 | } 488 | 489 | .akismet-box h2, .akismet-box h3 { 490 | padding: 1.5rem 1.5rem .5rem 1.5rem; 491 | margin: 0; 492 | } 493 | 494 | .akismet-box p { 495 | padding: 0 1.5rem 1.5rem 1.5rem; 496 | margin: 0; 497 | } 498 | 499 | .akismet-jetpack-email { 500 | font-style: oblique; 501 | } 502 | 503 | .akismet-jetpack-gravatar { 504 | padding: 0 0 0 1.5rem; 505 | float: left; 506 | margin-right: 1rem; 507 | width: 54px; 508 | height: 54px; 509 | } 510 | 511 | .akismet-box p:after { 512 | content: "."; 513 | display: block; 514 | height: 0; 515 | clear: both; 516 | visibility: hidden; 517 | } 518 | 519 | .akismet-box .akismet-right { 520 | padding-right: 1.5rem; 521 | } 522 | 523 | .akismet-boxes .akismet-box { 524 | margin-bottom: 0; 525 | padding: 0; 526 | margin-top: -1px; 527 | } 528 | 529 | .akismet-boxes .akismet-box:last-child { 530 | margin-bottom: 1.5rem; 531 | } 532 | 533 | .akismet-boxes .akismet-box:first-child { 534 | margin-top: 1.5rem; 535 | } 536 | 537 | .akismet-box-header { 538 | max-width: 700px; 539 | margin: 0 auto 40px auto; 540 | line-height: 1.5; 541 | } 542 | 543 | .akismet-box-header h2 { 544 | margin: 1.5rem 10% 0; 545 | font-size: 1.375rem; 546 | font-weight: 700; 547 | color: #000; 548 | } 549 | 550 | .akismet-box .centered { 551 | text-align: center; 552 | } 553 | 554 | .akismet-enter-api-key-box { 555 | margin: 1.5rem 0; 556 | } 557 | 558 | .akismet-box .enter-api-key { 559 | display: none; 560 | margin-top: 1.5rem; 561 | } 562 | 563 | .akismet-box .akismet-toggles { 564 | margin: 3rem 0; 565 | } 566 | 567 | .akismet-box .akismet-ak-connect, .akismet-box .toggle-jp-connect { 568 | display: none; 569 | } 570 | 571 | .akismet-box .enter-api-key p { 572 | padding: 0 1.5rem; 573 | } 574 | 575 | .akismet-button, .akismet-button:hover, .akismet-button:visited { 576 | background: white; 577 | border-color: #c8d7e1; 578 | border-style: solid; 579 | border-width: 1px 1px 2px; 580 | color: #2e4453; 581 | cursor: pointer; 582 | display: inline-block; 583 | margin: 0; 584 | outline: 0; 585 | overflow: hidden; 586 | font-size: 14px; 587 | font-weight: 500; 588 | text-overflow: ellipsis; 589 | text-decoration: none; 590 | vertical-align: top; 591 | box-sizing: border-box; 592 | font-size: 14px; 593 | line-height: 21px; 594 | border-radius: 4px; 595 | padding: 7px 14px 9px; 596 | -webkit-appearance: none; 597 | -moz-appearance: none; 598 | appearance: none; 599 | } 600 | 601 | .akismet-button:hover { 602 | border-color: #a8bece; 603 | } 604 | 605 | .akismet-button:active { 606 | border-width: 2px 1px 1px; 607 | } 608 | 609 | .akismet-is-primary, .akismet-is-primary:hover, .akismet-is-primary:visited { 610 | background: #00aadc; 611 | border-color: #0087be; 612 | color: white; 613 | } 614 | 615 | .akismet-is-primary:hover, .akismet-is-primary:focus { 616 | border-color: #005082; 617 | } 618 | 619 | .akismet-is-primary:hover { 620 | border-color: #005082; 621 | } 622 | 623 | .akismet-section-header { 624 | position: relative; 625 | margin: 0 auto 0.625rem auto; 626 | padding: 1rem; 627 | box-sizing: border-box; 628 | box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3; 629 | background: #ffffff; 630 | width: 100%; 631 | padding-top: 0.6875rem; 632 | padding-bottom: 0.6875rem; 633 | display: flex; 634 | } 635 | 636 | .akismet-section-header__label { 637 | display: -ms-flexbox; 638 | display: flex; 639 | -ms-flex-align: center; 640 | align-items: center; 641 | -ms-flex-positive: 1; 642 | flex-grow: 1; 643 | line-height: 1.75rem; 644 | position: relative; 645 | font-size: 0.875rem; 646 | color: #4f748e; 647 | } 648 | 649 | .akismet-section-header__actions { 650 | line-height: 1.75rem; 651 | } 652 | 653 | .akismet-setup-instructions { 654 | text-align: center; 655 | } 656 | 657 | .akismet-setup-instructions form { 658 | padding-bottom: 1.5rem; 659 | } 660 | 661 | div.error.akismet-usage-limit-alert { 662 | padding: 25px 45px 25px 15px; 663 | display: flex; 664 | align-items: center; 665 | } 666 | 667 | #akismet-plugin-container .akismet-usage-limit-alert { 668 | margin: 0 auto 0.625rem auto; 669 | box-sizing: border-box; 670 | box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3; 671 | border: none; 672 | border-left: 4px solid #d63638; 673 | } 674 | 675 | .akismet-usage-limit-alert .akismet-usage-limit-logo { 676 | width: 38px; 677 | min-width: 38px; 678 | height: 38px; 679 | border-radius: 20px; 680 | margin-right: 18px; 681 | background: black; 682 | position: relative; 683 | } 684 | 685 | .akismet-usage-limit-alert .akismet-usage-limit-logo img { 686 | position: absolute; 687 | width: 22px; 688 | left: 8px; 689 | top: 10px; 690 | } 691 | 692 | .akismet-usage-limit-alert .akismet-usage-limit-text { 693 | flex-grow: 1; 694 | margin-right: 18px; 695 | } 696 | 697 | .akismet-usage-limit-alert h3 { 698 | margin: 0; 699 | } 700 | 701 | .akismet-usage-limit-alert .akismet-usage-limit-cta { 702 | text-align: right; 703 | } 704 | 705 | @media (max-width: 550px) { 706 | div.error.akismet-usage-limit-alert { 707 | display: block; 708 | } 709 | 710 | .akismet-usage-limit-alert .akismet-usage-limit-logo, 711 | .akismet-usage-limit-alert .akismet-usage-limit-text { 712 | margin-bottom: 15px; 713 | } 714 | 715 | .akismet-usage-limit-alert .akismet-usage-limit-cta { 716 | text-align: left; 717 | } 718 | } -------------------------------------------------------------------------------- /akismet/LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /akismet/changelog.txt: -------------------------------------------------------------------------------- 1 | === Akismet Anti-Spam === 2 | 3 | == Archived Changelog Entries == 4 | 5 | This file contains older changelog entries, so we can keep the size of the standard WordPress readme.txt file reasonable. 6 | For the latest changes, please see the "Changelog" section of the [readme.txt file](https://plugins.svn.wordpress.org/akismet/trunk/readme.txt). 7 | 8 | = 4.1.5 = 9 | *Release Date - 29 April 2020* 10 | 11 | * Based on user feedback, we have dropped the in-admin notice explaining the availability of the "privacy notice" option in the AKismet settings screen. The option itself is available, but after displaying the notice for the last 2 years, it is now considered a known fact. 12 | * Updated the "Requires at least" to WP 4.6, based on recommendations from https://wp-info.org/tools/checkplugini18n.php?slug=akismet 13 | * Moved older changelog entries to a separate file to keep the size of this readme reasonable, also based on recommendations from https://wp-info.org/tools/checkplugini18n.php?slug=akismet 14 | 15 | = 4.1.4 = 16 | *Release Date - 17 March 2020* 17 | 18 | * Only redirect to the Akismet setup screen upon plugin activation if the plugin was activated manually from within the plugin-related screens, to help users with non-standard install workflows, like WP-CLI. 19 | * Update the layout of the initial setup screen to be more readable on small screens. 20 | * If no API key has been entered, don't run code that expects an API key. 21 | * Improve the readability of the comment history entries. 22 | * Don't modify the comment form HTML if no API key has been set. 23 | 24 | = 4.1.3 = 25 | *Release Date - 31 October 2019* 26 | 27 | * Prevented an attacker from being able to cause a user to unknowingly recheck their Pending comments for spam. 28 | * Improved compatibility with Jetpack 7.7+. 29 | * Updated the plugin activation page to use consistent language and markup. 30 | * Redirecting users to the Akismet connnection/settings screen upon plugin activation, in an effort to make it easier for people to get setup. 31 | 32 | = 4.1.2 = 33 | *Release Date - 14 May 2019* 34 | 35 | * Fixed a conflict between the Akismet setup banner and other plugin notices. 36 | * Reduced the number of API requests made by the plugin when attempting to verify the API key. 37 | * Include additional data in the pingback pre-check API request to help make the stats more accurate. 38 | * Fixed a bug that was enabling the "Check for Spam" button when no comments were eligible to be checked. 39 | * Improved Akismet's AMP compatibility. 40 | 41 | = 4.1.1 = 42 | *Release Date - 31 January 2019* 43 | 44 | * Fixed the "Setup Akismet" notice so it resizes responsively. 45 | * Only highlight the "Save Changes" button in the Akismet config when changes have been made. 46 | * The count of comments in your spam queue shown on the dashboard show now always be up-to-date. 47 | 48 | = 4.1 = 49 | *Release Date - 12 November 2018* 50 | 51 | * Added a WP-CLI method for retrieving stats. 52 | * Hooked into the new "Personal Data Eraser" functionality from WordPress 4.9.6. 53 | * Added functionality to clear outdated alerts from Akismet.com. 54 | 55 | = 4.0.8 = 56 | *Release Date - 19 June 2018* 57 | 58 | * Improved the grammar and consistency of the in-admin privacy related notes (notice and config). 59 | * Revised in-admin explanation of the comment form privacy notice to make its usage clearer. 60 | * Added `rel="nofollow noopener"` to the comment form privacy notice to improve SEO and security. 61 | 62 | = 4.0.7 = 63 | *Release Date - 28 May 2018* 64 | 65 | * Based on user feedback, the link on "Learn how your comment data is processed." in the optional privacy notice now has a `target` of `_blank` and opens in a new tab/window. 66 | * Updated the in-admin privacy notice to use the term "comment" instead of "contact" in "Akismet can display a notice to your users under your comment forms." 67 | * Only show in-admin privacy notice if Akismet has an API Key configured 68 | 69 | = 4.0.6 = 70 | *Release Date - 26 May 2018* 71 | 72 | * Moved away from using `empty( get_option() )` to instantiating a variable to be compatible with older versions of PHP (5.3, 5.4, etc). 73 | 74 | = 4.0.5 = 75 | *Release Date - 26 May 2018* 76 | 77 | * Corrected version number after tagging. Sorry... 78 | 79 | = 4.0.4 = 80 | *Release Date - 26 May 2018* 81 | 82 | * Added a hook to provide Akismet-specific privacy information for a site's privacy policy. 83 | * Added tools to control the display of a privacy related notice under comment forms. 84 | * Fixed HTML in activation failure message to close META and HEAD tag properly. 85 | * Fixed a bug that would sometimes prevent Akismet from being correctly auto-configured. 86 | 87 | = 4.0.3 = 88 | *Release Date - 19 February 2018* 89 | 90 | * Added a scheduled task to remove entries in wp_commentmeta that no longer have corresponding comments in wp_comments. 91 | * 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. 92 | 93 | = 4.0.2 = 94 | *Release Date - 18 December 2017* 95 | 96 | * Fixed a bug that could cause Akismet to recheck a comment that has already been manually approved or marked as spam. 97 | * Fixed a bug that could cause Akismet to claim that some comments are still waiting to be checked when no comments are waiting to be checked. 98 | 99 | = 4.0.1 = 100 | *Release Date - 6 November 2017* 101 | 102 | * Fixed a bug that could prevent some users from connecting Akismet via their Jetpack connection. 103 | * Ensured that any pending Akismet-related events are unscheduled if the plugin is deactivated. 104 | * Allow some JavaScript to be run asynchronously to avoid affecting page render speeds. 105 | 106 | = 4.0 = 107 | *Release Date - 19 September 2017* 108 | 109 | * Added REST API endpoints for configuring Akismet and retrieving stats. 110 | * Increased the minimum supported WordPress version to 4.0. 111 | * Added compatibility with comments submitted via the REST API. 112 | * Improved the progress indicator on the "Check for Spam" button. 113 | 114 | = 3.3.4 = 115 | *Release Date - 3 August 2017* 116 | 117 | * Disabled Akismet's debug log output by default unless AKISMET_DEBUG is defined. 118 | * URL previews now begin preloading when the mouse moves near them in the comments section of wp-admin. 119 | * 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. 120 | * Fixed a bug that was preventing an error from being shown when a site can't reach Akismet's servers. 121 | 122 | = 3.3.3 = 123 | *Release Date - 13 July 2017* 124 | 125 | * Reduced amount of bandwidth used by the URL Preview feature. 126 | * Improved the admin UI when the API key is manually pre-defined for the site. 127 | * Removed a workaround for WordPress installations older than 3.3 that will improve Akismet's compatibility with other plugins. 128 | * The number of spam blocked that is displayed on the WordPress dashboard will now be more accurate and updated more frequently. 129 | * Fixed a bug in the Akismet widget that could cause PHP warnings. 130 | 131 | = 3.3.2 = 132 | *Release Date - 10 May 2017* 133 | 134 | * Fixed a bug causing JavaScript errors in some browsers. 135 | 136 | = 3.3.1 = 137 | *Release Date - 2 May 2017* 138 | 139 | * Improve performance by only requesting the akismet_comment_nonce option when absolutely necessary. 140 | * Fixed two bugs that could cause PHP warnings. 141 | * Fixed a bug that was preventing the "Remove author URL" feature from working after a comment was edited using "Quick Edit." 142 | * Fixed a bug that was preventing the URL preview feature from working after a comment was edited using "Quick Edit." 143 | 144 | = 3.3 = 145 | *Release Date - 23 February 2017* 146 | 147 | * Updated the Akismet admin pages with a new clean design. 148 | * Fixed bugs preventing the `akismet_add_comment_nonce` and `akismet_update_alert` wrapper functions from working properly. 149 | * Fixed bug preventing the loading indicator from appearing when re-checking all comments for spam. 150 | * Added a progress indicator to the "Check for Spam" button. 151 | * Added a success message after manually rechecking the Pending queue for spam. 152 | 153 | = 3.2 = 154 | *Release Date - 6 September 2016* 155 | 156 | * Added a WP-CLI module. You can now check comments and recheck the moderation queue from the command line. 157 | * Stopped using the deprecated jQuery function `.live()`. 158 | * Fixed a bug in `remove_comment_author_url()` and `add_comment_author_url()` that could generate PHP notices. 159 | * Fixed a bug that could cause an infinite loop for sites with very very very large comment IDs. 160 | * Fixed a bug that could cause the Akismet widget title to be blank. 161 | 162 | = 3.1.11 = 163 | *Release Date - 12 May 2016* 164 | 165 | * Fixed a bug that could cause the "Check for Spam" button to skip some comments. 166 | * Fixed a bug that could prevent some spam submissions from being sent to Akismet. 167 | * Updated all links to use https:// when possible. 168 | * Disabled Akismet debug logging unless WP_DEBUG and WP_DEBUG_LOG are both enabled. 169 | 170 | = 3.1.10 = 171 | *Release Date - 1 April 2016* 172 | 173 | * Fixed a bug that could cause comments caught as spam to be placed in the Pending queue. 174 | * 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. 175 | * Fixed a bug that could have caused avoidable PHP warnings in the error log. 176 | 177 | = 3.1.9 = 178 | *Release Date - 28 March 2016* 179 | 180 | * Add compatibility with Jetpack so that Jetpack can automatically configure Akismet settings when appropriate. 181 | * Fixed a bug preventing some comment data from being sent to Akismet. 182 | 183 | = 3.1.8 = 184 | *Release Date - 4 March 2016* 185 | 186 | * Fixed a bug preventing Akismet from being used with some plugins that rewrite admin URLs. 187 | * Reduced the amount of bandwidth used on Akismet API calls 188 | * Reduced the amount of space Akismet uses in the database 189 | * Fixed a bug that could cause comments caught as spam to be placed in the Pending queue. 190 | 191 | = 3.1.7 = 192 | *Release Date - 4 January 2016* 193 | 194 | * Added documentation for the 'akismet_comment_nonce' filter. 195 | * The post-install activation button is now accessible to screen readers and keyboard-only users. 196 | * Fixed a bug that was preventing the "Remove author URL" feature from working in WordPress 4.4 197 | 198 | = 3.1.6 = 199 | *Release Date - 14 December 2015* 200 | 201 | * Improve the notices shown after activating Akismet. 202 | * Update some strings to allow for the proper plural forms in all languages. 203 | 204 | = 3.1.5 = 205 | *Release Date - 13 October 2015* 206 | 207 | * Closes a potential XSS vulnerability. 208 | 209 | = 3.1.4 = 210 | *Release Date - 24 September 2015* 211 | 212 | * Fixed a bug that was preventing some users from automatically connecting using Jetpack if they didn't have a current Akismet subscription. 213 | * Fixed a bug that could cause comments caught as spam to be placed in the Pending queue. 214 | * Error messages and instructions have been simplified to be more understandable. 215 | * Link previews are enabled for all links inside comments, not just the author's website link. 216 | 217 | = 3.1.3 = 218 | *Release Date - 6 July 2015* 219 | 220 | * Notify users when their account status changes after previously being successfully set up. This should help any users who are seeing blank Akismet settings screens. 221 | 222 | = 3.1.2 = 223 | *Release Date - 7 June 2015* 224 | 225 | * Reduced the amount of space Akismet uses in the commentmeta table. 226 | * Fixed a bug where some comments with quotes in the author name weren't getting history entries 227 | * Pre-emptive security improvements to ensure that the Akismet plugin can't be used by attackers to compromise a WordPress installation. 228 | * Better UI for the key entry field: allow whitespace to be included at the beginning or end of the key and strip it out automatically when the form is submitted. 229 | * When deactivating the plugin, notify the Akismet API so the site can be marked as inactive. 230 | * Clearer error messages. 231 | 232 | = 3.1.1 = 233 | *Release Date - 17th March, 2015* 234 | 235 | * Improvements to the "Remove comment author URL" JavaScript 236 | * Include the pingback pre-check from the 2.6 branch. 237 | 238 | = 3.1 = 239 | *Release Date - 11th March, 2015* 240 | 241 | * Use HTTPS by default for all requests to Akismet. 242 | * Fix for a situation where Akismet might strip HTML from a comment. 243 | 244 | = 3.0.4 = 245 | *Release Date - 11th December, 2014* 246 | 247 | * Fix to make .htaccess compatible with Apache 2.4. 248 | * Fix to allow removal of https author URLs. 249 | * Fix to avoid stripping part of the author URL when removing and re-adding. 250 | * Removed the "Check for Spam" button from the "Trash" and "Approved" queues, where it would have no effect. 251 | * Allow automatic API key configuration when Jetpack is installed and connected to a WordPress.com account 252 | 253 | = 3.0.3 = 254 | *Release Date - 3rd November, 2014* 255 | 256 | * Fix for sending the wrong data to delete_comment action that could have prevented old spam comments from being deleted. 257 | * Added a filter to disable logging of Akismet debugging information. 258 | * Added a filter for the maximum comment age when deleting old spam comments. 259 | * Added a filter for the number per batch when deleting old spam comments. 260 | * Removed the "Check for Spam" button from the Spam folder. 261 | 262 | = 3.0.2 = 263 | *Release Date - 18th August, 2014* 264 | 265 | * Performance improvements. 266 | * Fixed a bug that could truncate the comment data being sent to Akismet for checking. 267 | 268 | = 3.0.1 = 269 | *Release Date - 9th July, 2014* 270 | 271 | * Removed dependency on PHP's fsockopen function 272 | * Fix spam/ham reports to work when reported outside of the WP dashboard, e.g., from Notifications or the WP app 273 | * Remove jQuery dependency for comment form JavaScript 274 | * Remove unnecessary data from some Akismet comment meta 275 | * Suspended keys will now result in all comments being put in moderation, not spam. 276 | 277 | = 3.0.0 = 278 | *Release Date - 15th April, 2014* 279 | 280 | * Move Akismet to Settings menu 281 | * Drop Akismet Stats menu 282 | * Add stats snapshot to Akismet settings 283 | * Add Akismet subscription details and status to Akismet settings 284 | * Add contextual help for each page 285 | * Improve Akismet setup to use Jetpack to automate plugin setup 286 | * Fix "Check for Spam" to use AJAX to avoid page timing out 287 | * Fix Akismet settings page to be responsive 288 | * Drop legacy code 289 | * Tidy up CSS and Javascript 290 | * Replace the old discard setting with a new "discard pervasive spam" feature. 291 | 292 | = 2.6.0 = 293 | *Release Date - 18th March, 2014* 294 | 295 | * Add ajax paging to the check for spam button to handle large volumes of comments 296 | * Optimize javascript and add localization support 297 | * Fix bug in link to spam comments from right now dashboard widget 298 | * Fix bug with deleting old comments to avoid timeouts dealing with large volumes of comments 299 | * Include X-Pingback-Forwarded-For header in outbound WordPress pingback verifications 300 | * Add pre-check for pingbacks, to stop spam before an outbound verification request is made 301 | 302 | = 2.5.9 = 303 | *Release Date - 1st August, 2013* 304 | 305 | * Update 'Already have a key' link to redirect page rather than depend on javascript 306 | * Fix some non-translatable strings to be translatable 307 | * Update Activation banner in plugins page to redirect user to Akismet config page 308 | 309 | = 2.5.8 = 310 | *Release Date - 20th January, 2013* 311 | 312 | * Simplify the activation process for new users 313 | * Remove the reporter_ip parameter 314 | * Minor preventative security improvements 315 | 316 | = 2.5.7 = 317 | *Release Date - 13th December, 2012* 318 | 319 | * FireFox Stats iframe preview bug 320 | * Fix mshots preview when using https 321 | * Add .htaccess to block direct access to files 322 | * Prevent some PHP notices 323 | * Fix Check For Spam return location when referrer is empty 324 | * Fix Settings links for network admins 325 | * Fix prepare() warnings in WP 3.5 326 | 327 | = 2.5.6 = 328 | *Release Date - 26th April, 2012* 329 | 330 | * Prevent retry scheduling problems on sites where wp_cron is misbehaving 331 | * Preload mshot previews 332 | * Modernize the widget code 333 | * Fix a bug where comments were not held for moderation during an error condition 334 | * Improve the UX and display when comments are temporarily held due to an error 335 | * Make the Check For Spam button force a retry when comments are held due to an error 336 | * Handle errors caused by an invalid key 337 | * Don't retry comments that are too old 338 | * Improve error messages when verifying an API key 339 | 340 | = 2.5.5 = 341 | *Release Date - 11th January, 2012* 342 | 343 | * Add nonce check for comment author URL remove action 344 | * Fix the settings link 345 | 346 | = 2.5.4 = 347 | *Release Date - 5th January, 2012* 348 | 349 | * Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it 350 | * Added author URL quick removal functionality 351 | * Added mShot preview on Author URL hover 352 | * Added empty index.php to prevent directory listing 353 | * Move wp-admin menu items under Jetpack, if it is installed 354 | * Purge old Akismet comment meta data, default of 15 days 355 | 356 | = 2.5.3 = 357 | *Release Date - 8th Febuary, 2011* 358 | 359 | * Specify the license is GPL v2 or later 360 | * Fix a bug that could result in orphaned commentmeta entries 361 | * Include hotfix for WordPress 3.0.5 filter issue 362 | 363 | = 2.5.2 = 364 | *Release Date - 14th January, 2011* 365 | 366 | * Properly format the comment count for author counts 367 | * Look for super admins on multisite installs when looking up user roles 368 | * Increase the HTTP request timeout 369 | * Removed padding for author approved count 370 | * Fix typo in function name 371 | * Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side. 372 | 373 | = 2.5.1 = 374 | *Release Date - 17th December, 2010* 375 | 376 | * Fix a bug that caused the "Auto delete" option to fail to discard comments correctly 377 | * Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce 378 | * Fixed padding bug in "author" column of posts screen 379 | * Added margin-top to "cleared by ..." badges on dashboard 380 | * Fix possible error when calling akismet_cron_recheck() 381 | * Fix more PHP warnings 382 | * Clean up XHTML warnings for comment nonce 383 | * Fix for possible condition where scheduled comment re-checks could get stuck 384 | * Clean up the comment meta details after deleting a comment 385 | * Only show the status badge if the comment status has been changed by someone/something other than Akismet 386 | * Show a 'History' link in the row-actions 387 | * Translation fixes 388 | * Reduced font-size on author name 389 | * Moved "flagged by..." notification to top right corner of comment container and removed heavy styling 390 | * Hid "flagged by..." notification while on dashboard 391 | 392 | = 2.5.0 = 393 | *Release Date - 7th December, 2010* 394 | 395 | * Track comment actions under 'Akismet Status' on the edit comment screen 396 | * Fix a few remaining deprecated function calls ( props Mike Glendinning ) 397 | * Use HTTPS for the stats IFRAME when wp-admin is using HTTPS 398 | * Use the WordPress HTTP class if available 399 | * Move the admin UI code to a separate file, only loaded when needed 400 | * Add cron retry feature, to replace the old connectivity check 401 | * Display Akismet status badge beside each comment 402 | * Record history for each comment, and display it on the edit page 403 | * Record the complete comment as originally submitted in comment_meta, to use when reporting spam and ham 404 | * Highlight links in comment content 405 | * New option, "Show the number of comments you've approved beside each comment author." 406 | * New option, "Use a nonce on the comment form." 407 | 408 | = 2.4.0 = 409 | *Release Date - 23rd August, 2010* 410 | 411 | * Spell out that the license is GPLv2 412 | * Fix PHP warnings 413 | * Fix WordPress deprecated function calls 414 | * Fire the delete_comment action when deleting comments 415 | * Move code specific for older WP versions to legacy.php 416 | * General code clean up 417 | 418 | = 2.3.0 = 419 | *Release Date - 5th June, 2010* 420 | 421 | * Fix "Are you sure" nonce message on config screen in WPMU 422 | * Fix XHTML compliance issue in sidebar widget 423 | * Change author link; remove some old references to WordPress.com accounts 424 | * Localize the widget title (core ticket #13879) 425 | 426 | = 2.2.9 = 427 | *Release Date - 2nd June, 2010* 428 | 429 | * Eliminate a potential conflict with some plugins that may cause spurious reports 430 | 431 | = 2.2.8 = 432 | *Release Date - 27th May, 2010* 433 | 434 | * Fix bug in initial comment check for ipv6 addresses 435 | * Report comments as ham when they are moved from spam to moderation 436 | * Report comments as ham when clicking undo after spam 437 | * Use transition_comment_status action when available instead of older actions for spam/ham submissions 438 | * Better diagnostic messages when PHP network functions are unavailable 439 | * Better handling of comments by logged-in users 440 | 441 | = 2.2.7 = 442 | *Release Date - 17th December, 2009* 443 | 444 | * Add a new AKISMET_VERSION constant 445 | * Reduce the possibility of over-counting spam when another spam filter plugin is in use 446 | * Disable the connectivity check when the API key is hard-coded for WPMU 447 | 448 | = 2.2.6 = 449 | *Release Date - 20th July, 2009* 450 | 451 | * Fix a global warning introduced in 2.2.5 452 | * Add changelog and additional readme.txt tags 453 | * Fix an array conversion warning in some versions of PHP 454 | * Support a new WPCOM_API_KEY constant for easier use with WordPress MU 455 | 456 | = 2.2.5 = 457 | *Release Date - 13th July, 2009* 458 | 459 | * Include a new Server Connectivity diagnostic check, to detect problems caused by firewalls 460 | 461 | = 2.2.4 = 462 | *Release Date - 3rd June, 2009* 463 | 464 | * Fixed a key problem affecting the stats feature in WordPress MU 465 | * Provide additional blog information in Akismet API calls 466 | -------------------------------------------------------------------------------- /akismet/class.akismet-admin.php: -------------------------------------------------------------------------------- 1 | array( 10 | 'href' => true, 11 | 'title' => true, 12 | ), 13 | 'b' => array(), 14 | 'code' => array(), 15 | 'del' => array( 16 | 'datetime' => true, 17 | ), 18 | 'em' => array(), 19 | 'i' => array(), 20 | 'q' => array( 21 | 'cite' => true, 22 | ), 23 | 'strike' => array(), 24 | 'strong' => array(), 25 | ); 26 | 27 | public static function init() { 28 | if ( ! self::$initiated ) { 29 | self::init_hooks(); 30 | } 31 | 32 | if ( isset( $_POST['action'] ) && $_POST['action'] == 'enter-key' ) { 33 | self::enter_api_key(); 34 | } 35 | } 36 | 37 | public static function init_hooks() { 38 | // The standalone stats page was removed in 3.0 for an all-in-one config and stats page. 39 | // Redirect any links that might have been bookmarked or in browser history. 40 | if ( isset( $_GET['page'] ) && 'akismet-stats-display' == $_GET['page'] ) { 41 | wp_safe_redirect( esc_url_raw( self::get_page_url( 'stats' ) ), 301 ); 42 | die; 43 | } 44 | 45 | self::$initiated = true; 46 | 47 | add_action( 'admin_init', array( 'Akismet_Admin', 'admin_init' ) ); 48 | add_action( 'admin_menu', array( 'Akismet_Admin', 'admin_menu' ), 5 ); # Priority 5, so it's called before Jetpack's admin_menu. 49 | add_action( 'admin_notices', array( 'Akismet_Admin', 'display_notice' ) ); 50 | add_action( 'admin_enqueue_scripts', array( 'Akismet_Admin', 'load_resources' ) ); 51 | add_action( 'activity_box_end', array( 'Akismet_Admin', 'dashboard_stats' ) ); 52 | add_action( 'rightnow_end', array( 'Akismet_Admin', 'rightnow_stats' ) ); 53 | add_action( 'manage_comments_nav', array( 'Akismet_Admin', 'check_for_spam_button' ) ); 54 | add_action( 'admin_action_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) ); 55 | add_action( 'wp_ajax_akismet_recheck_queue', array( 'Akismet_Admin', 'recheck_queue' ) ); 56 | add_action( 'wp_ajax_comment_author_deurl', array( 'Akismet_Admin', 'remove_comment_author_url' ) ); 57 | add_action( 'wp_ajax_comment_author_reurl', array( 'Akismet_Admin', 'add_comment_author_url' ) ); 58 | add_action( 'jetpack_auto_activate_akismet', array( 'Akismet_Admin', 'connect_jetpack_user' ) ); 59 | 60 | add_filter( 'plugin_action_links', array( 'Akismet_Admin', 'plugin_action_links' ), 10, 2 ); 61 | add_filter( 'comment_row_actions', array( 'Akismet_Admin', 'comment_row_action' ), 10, 2 ); 62 | 63 | add_filter( 'plugin_action_links_'.plugin_basename( plugin_dir_path( __FILE__ ) . 'akismet.php'), array( 'Akismet_Admin', 'admin_plugin_settings_link' ) ); 64 | 65 | add_filter( 'wxr_export_skip_commentmeta', array( 'Akismet_Admin', 'exclude_commentmeta_from_export' ), 10, 3 ); 66 | 67 | add_filter( 'all_plugins', array( 'Akismet_Admin', 'modify_plugin_description' ) ); 68 | 69 | // priority=1 because we need ours to run before core's comment anonymizer runs, and that's registered at priority=10 70 | add_filter( 'wp_privacy_personal_data_erasers', array( 'Akismet_Admin', 'register_personal_data_eraser' ), 1 ); 71 | } 72 | 73 | public static function admin_init() { 74 | if ( get_option( 'Activated_Akismet' ) ) { 75 | delete_option( 'Activated_Akismet' ); 76 | if ( ! headers_sent() ) { 77 | wp_redirect( add_query_arg( array( 'page' => 'akismet-key-config', 'view' => 'start' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) ) ); 78 | } 79 | } 80 | 81 | load_plugin_textdomain( 'akismet' ); 82 | add_meta_box( 'akismet-status', __('Comment History', 'akismet'), array( 'Akismet_Admin', 'comment_status_meta_box' ), 'comment', 'normal' ); 83 | 84 | if ( function_exists( 'wp_add_privacy_policy_content' ) ) { 85 | wp_add_privacy_policy_content( 86 | __( 'Akismet', 'akismet' ), 87 | __( 'We collect information about visitors who comment on Sites that use our Akismet anti-spam service. The information we collect depends on how the User sets up Akismet for the Site, but typically includes the commenter\'s IP address, user agent, referrer, and Site URL (along with other information directly provided by the commenter such as their name, username, email address, and the comment itself).', 'akismet' ) 88 | ); 89 | } 90 | } 91 | 92 | public static function admin_menu() { 93 | if ( class_exists( 'Jetpack' ) ) 94 | add_action( 'jetpack_admin_menu', array( 'Akismet_Admin', 'load_menu' ) ); 95 | else 96 | self::load_menu(); 97 | } 98 | 99 | public static function admin_head() { 100 | if ( !current_user_can( 'manage_options' ) ) 101 | return; 102 | } 103 | 104 | public static function admin_plugin_settings_link( $links ) { 105 | $settings_link = ''.__('Settings', 'akismet').''; 106 | array_unshift( $links, $settings_link ); 107 | return $links; 108 | } 109 | 110 | public static function load_menu() { 111 | if ( class_exists( 'Jetpack' ) ) { 112 | $hook = add_submenu_page( 'jetpack', __( 'Akismet Anti-Spam' , 'akismet'), __( 'Akismet Anti-Spam' , 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) ); 113 | } 114 | else { 115 | $hook = add_options_page( __('Akismet Anti-Spam', 'akismet'), __('Akismet Anti-Spam', 'akismet'), 'manage_options', 'akismet-key-config', array( 'Akismet_Admin', 'display_page' ) ); 116 | } 117 | 118 | if ( $hook ) { 119 | add_action( "load-$hook", array( 'Akismet_Admin', 'admin_help' ) ); 120 | } 121 | } 122 | 123 | public static function load_resources() { 124 | global $hook_suffix; 125 | 126 | if ( in_array( $hook_suffix, apply_filters( 'akismet_admin_page_hook_suffixes', array( 127 | 'index.php', # dashboard 128 | 'edit-comments.php', 129 | 'comment.php', 130 | 'post.php', 131 | 'settings_page_akismet-key-config', 132 | 'jetpack_page_akismet-key-config', 133 | 'plugins.php', 134 | ) ) ) ) { 135 | wp_register_style( 'akismet.css', plugin_dir_url( __FILE__ ) . '_inc/akismet.css', array(), AKISMET_VERSION ); 136 | wp_enqueue_style( 'akismet.css'); 137 | 138 | wp_register_script( 'akismet.js', plugin_dir_url( __FILE__ ) . '_inc/akismet.js', array('jquery'), AKISMET_VERSION ); 139 | wp_enqueue_script( 'akismet.js' ); 140 | 141 | $inline_js = array( 142 | 'comment_author_url_nonce' => wp_create_nonce( 'comment_author_url_nonce' ), 143 | 'strings' => array( 144 | 'Remove this URL' => __( 'Remove this URL' , 'akismet'), 145 | 'Removing...' => __( 'Removing...' , 'akismet'), 146 | 'URL removed' => __( 'URL removed' , 'akismet'), 147 | '(undo)' => __( '(undo)' , 'akismet'), 148 | 'Re-adding...' => __( 'Re-adding...' , 'akismet'), 149 | ) 150 | ); 151 | 152 | if ( isset( $_GET['akismet_recheck'] ) && wp_verify_nonce( $_GET['akismet_recheck'], 'akismet_recheck' ) ) { 153 | $inline_js['start_recheck'] = true; 154 | } 155 | 156 | if ( apply_filters( 'akismet_enable_mshots', true ) ) { 157 | $inline_js['enable_mshots'] = true; 158 | } 159 | 160 | wp_localize_script( 'akismet.js', 'WPAkismet', $inline_js ); 161 | } 162 | } 163 | 164 | /** 165 | * Add help to the Akismet page 166 | * 167 | * @return false if not the Akismet page 168 | */ 169 | public static function admin_help() { 170 | $current_screen = get_current_screen(); 171 | 172 | // Screen Content 173 | if ( current_user_can( 'manage_options' ) ) { 174 | if ( !Akismet::get_api_key() || ( isset( $_GET['view'] ) && $_GET['view'] == 'start' ) ) { 175 | //setup page 176 | $current_screen->add_help_tab( 177 | array( 178 | 'id' => 'overview', 179 | 'title' => __( 'Overview' , 'akismet'), 180 | 'content' => 181 | '

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

' . 182 | '

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

' . 183 | '

' . esc_html__( 'On this page, you are able to set up the Akismet plugin.' , 'akismet') . '

', 184 | ) 185 | ); 186 | 187 | $current_screen->add_help_tab( 188 | array( 189 | 'id' => 'setup-signup', 190 | 'title' => __( 'New to Akismet' , 'akismet'), 191 | 'content' => 192 | '

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

' . 193 | '

' . esc_html__( 'You need to enter an API key to activate the Akismet service on your site.' , 'akismet') . '

' . 194 | '

' . sprintf( __( 'Sign up for an account on %s to get an API Key.' , 'akismet'), 'Akismet.com' ) . '

', 195 | ) 196 | ); 197 | 198 | $current_screen->add_help_tab( 199 | array( 200 | 'id' => 'setup-manual', 201 | 'title' => __( 'Enter an API Key' , 'akismet'), 202 | 'content' => 203 | '

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

' . 204 | '

' . esc_html__( 'If you already have an API key' , 'akismet') . '

' . 205 | '
    ' . 206 | '
  1. ' . esc_html__( 'Copy and paste the API key into the text field.' , 'akismet') . '
  2. ' . 207 | '
  3. ' . esc_html__( 'Click the Use this Key button.' , 'akismet') . '
  4. ' . 208 | '
', 209 | ) 210 | ); 211 | } 212 | elseif ( isset( $_GET['view'] ) && $_GET['view'] == 'stats' ) { 213 | //stats page 214 | $current_screen->add_help_tab( 215 | array( 216 | 'id' => 'overview', 217 | 'title' => __( 'Overview' , 'akismet'), 218 | 'content' => 219 | '

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

' . 220 | '

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

' . 221 | '

' . esc_html__( 'On this page, you are able to view stats on spam filtered on your site.' , 'akismet') . '

', 222 | ) 223 | ); 224 | } 225 | else { 226 | //configuration page 227 | $current_screen->add_help_tab( 228 | array( 229 | 'id' => 'overview', 230 | 'title' => __( 'Overview' , 'akismet'), 231 | 'content' => 232 | '

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

' . 233 | '

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

' . 234 | '

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

', 235 | ) 236 | ); 237 | 238 | $current_screen->add_help_tab( 239 | array( 240 | 'id' => 'settings', 241 | 'title' => __( 'Settings' , 'akismet'), 242 | 'content' => 243 | '

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

' . 244 | ( Akismet::predefined_api_key() ? '' : '

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

' ) . 245 | '

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

' . 246 | '

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

', 247 | ) 248 | ); 249 | 250 | if ( ! Akismet::predefined_api_key() ) { 251 | $current_screen->add_help_tab( 252 | array( 253 | 'id' => 'account', 254 | 'title' => __( 'Account' , 'akismet'), 255 | 'content' => 256 | '

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

' . 257 | '

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

' . 258 | '

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

', 259 | ) 260 | ); 261 | } 262 | } 263 | } 264 | 265 | // Help Sidebar 266 | $current_screen->set_help_sidebar( 267 | '

' . esc_html__( 'For more information:' , 'akismet') . '

' . 268 | '

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

' . 269 | '

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

' 270 | ); 271 | } 272 | 273 | public static function enter_api_key() { 274 | if ( ! current_user_can( 'manage_options' ) ) { 275 | die( __( 'Cheatin’ uh?', 'akismet' ) ); 276 | } 277 | 278 | if ( !wp_verify_nonce( $_POST['_wpnonce'], self::NONCE ) ) 279 | return false; 280 | 281 | foreach( array( 'akismet_strictness', 'akismet_show_user_comments_approved' ) as $option ) { 282 | update_option( $option, isset( $_POST[$option] ) && (int) $_POST[$option] == 1 ? '1' : '0' ); 283 | } 284 | 285 | if ( ! empty( $_POST['akismet_comment_form_privacy_notice'] ) ) { 286 | self::set_form_privacy_notice_option( $_POST['akismet_comment_form_privacy_notice'] ); 287 | } else { 288 | self::set_form_privacy_notice_option( 'hide' ); 289 | } 290 | 291 | if ( Akismet::predefined_api_key() ) { 292 | return false; //shouldn't have option to save key if already defined 293 | } 294 | 295 | $new_key = preg_replace( '/[^a-f0-9]/i', '', $_POST['key'] ); 296 | $old_key = Akismet::get_api_key(); 297 | 298 | if ( empty( $new_key ) ) { 299 | if ( !empty( $old_key ) ) { 300 | delete_option( 'wordpress_api_key' ); 301 | self::$notices[] = 'new-key-empty'; 302 | } 303 | } 304 | elseif ( $new_key != $old_key ) { 305 | self::save_key( $new_key ); 306 | } 307 | 308 | return true; 309 | } 310 | 311 | public static function save_key( $api_key ) { 312 | $key_status = Akismet::verify_key( $api_key ); 313 | 314 | if ( $key_status == 'valid' ) { 315 | $akismet_user = self::get_akismet_user( $api_key ); 316 | 317 | if ( $akismet_user ) { 318 | if ( in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub' ) ) ) 319 | update_option( 'wordpress_api_key', $api_key ); 320 | 321 | if ( $akismet_user->status == 'active' ) 322 | self::$notices['status'] = 'new-key-valid'; 323 | elseif ( $akismet_user->status == 'notice' ) 324 | self::$notices['status'] = $akismet_user; 325 | else 326 | self::$notices['status'] = $akismet_user->status; 327 | } 328 | else 329 | self::$notices['status'] = 'new-key-invalid'; 330 | } 331 | elseif ( in_array( $key_status, array( 'invalid', 'failed' ) ) ) 332 | self::$notices['status'] = 'new-key-'.$key_status; 333 | } 334 | 335 | public static function dashboard_stats() { 336 | if ( did_action( 'rightnow_end' ) ) { 337 | return; // We already displayed this info in the "Right Now" section 338 | } 339 | 340 | if ( !$count = get_option('akismet_spam_count') ) 341 | return; 342 | 343 | global $submenu; 344 | 345 | echo '

' . esc_html( _x( 'Spam', 'comments' , 'akismet') ) . '

'; 346 | 347 | echo '

'.sprintf( _n( 348 | 'Akismet has protected your site from %3$s spam comment.', 349 | 'Akismet has protected your site from %3$s spam comments.', 350 | $count 351 | , 'akismet'), 'https://akismet.com/wordpress/', esc_url( add_query_arg( array( 'page' => 'akismet-admin' ), admin_url( isset( $submenu['edit-comments.php'] ) ? 'edit-comments.php' : 'edit.php' ) ) ), number_format_i18n($count) ).'

'; 352 | } 353 | 354 | // WP 2.5+ 355 | public static function rightnow_stats() { 356 | if ( $count = get_option('akismet_spam_count') ) { 357 | $intro = sprintf( _n( 358 | 'Akismet has protected your site from %2$s spam comment already. ', 359 | 'Akismet has protected your site from %2$s spam comments already. ', 360 | $count 361 | , 'akismet'), 'https://akismet.com/wordpress/', number_format_i18n( $count ) ); 362 | } else { 363 | $intro = sprintf( __('Akismet blocks spam from getting to your blog. ', 'akismet'), 'https://akismet.com/wordpress/' ); 364 | } 365 | 366 | $link = add_query_arg( array( 'comment_status' => 'spam' ), admin_url( 'edit-comments.php' ) ); 367 | 368 | if ( $queue_count = self::get_spam_count() ) { 369 | $queue_text = sprintf( _n( 370 | 'There’s %1$s comment in your spam queue right now.', 371 | 'There are %1$s comments in your spam queue right now.', 372 | $queue_count 373 | , 'akismet'), number_format_i18n( $queue_count ), esc_url( $link ) ); 374 | } else { 375 | $queue_text = sprintf( __( "There’s nothing in your spam queue at the moment." , 'akismet'), esc_url( $link ) ); 376 | } 377 | 378 | $text = $intro . '
' . $queue_text; 379 | echo "

$text

\n"; 380 | } 381 | 382 | public static function check_for_spam_button( $comment_status ) { 383 | // The "Check for Spam" button should only appear when the page might be showing 384 | // a comment with comment_approved=0, which means an un-trashed, un-spammed, 385 | // not-yet-moderated comment. 386 | if ( 'all' != $comment_status && 'moderated' != $comment_status ) { 387 | return; 388 | } 389 | 390 | $link = ''; 391 | 392 | $comments_count = wp_count_comments(); 393 | 394 | echo ''; 395 | echo '
'; 396 | 397 | $classes = array( 398 | 'button-secondary', 399 | 'checkforspam', 400 | 'button-disabled' // Disable button until the page is loaded 401 | ); 402 | 403 | if ( $comments_count->moderated > 0 ) { 404 | $classes[] = 'enable-on-load'; 405 | 406 | if ( ! Akismet::get_api_key() ) { 407 | $link = add_query_arg( array( 'page' => 'akismet-key-config' ), class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) ); 408 | $classes[] = 'ajax-disabled'; 409 | } 410 | } 411 | 412 | echo '' . esc_html__('Check for Spam', 'akismet') . ''; 423 | echo ''; 424 | } 425 | 426 | public static function recheck_queue() { 427 | global $wpdb; 428 | 429 | Akismet::fix_scheduled_recheck(); 430 | 431 | if ( ! ( isset( $_GET['recheckqueue'] ) || ( isset( $_REQUEST['action'] ) && 'akismet_recheck_queue' == $_REQUEST['action'] ) ) ) { 432 | return; 433 | } 434 | 435 | if ( ! wp_verify_nonce( $_POST['nonce'], 'akismet_check_for_spam' ) ) { 436 | wp_send_json( array( 437 | 'error' => __( "You don't have permission to do that."), 438 | )); 439 | return; 440 | } 441 | 442 | $result_counts = self::recheck_queue_portion( empty( $_POST['offset'] ) ? 0 : $_POST['offset'], empty( $_POST['limit'] ) ? 100 : $_POST['limit'] ); 443 | 444 | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { 445 | wp_send_json( array( 446 | 'counts' => $result_counts, 447 | )); 448 | } 449 | else { 450 | $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url( 'edit-comments.php' ); 451 | wp_safe_redirect( $redirect_to ); 452 | exit; 453 | } 454 | } 455 | 456 | public static function recheck_queue_portion( $start = 0, $limit = 100 ) { 457 | global $wpdb; 458 | 459 | $paginate = ''; 460 | 461 | if ( $limit <= 0 ) { 462 | $limit = 100; 463 | } 464 | 465 | if ( $start < 0 ) { 466 | $start = 0; 467 | } 468 | 469 | $moderation = $wpdb->get_col( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0' LIMIT %d OFFSET %d", $limit, $start ) ); 470 | 471 | $result_counts = array( 472 | 'processed' => count( $moderation ), 473 | 'spam' => 0, 474 | 'ham' => 0, 475 | 'error' => 0, 476 | ); 477 | 478 | foreach ( $moderation as $comment_id ) { 479 | $api_response = Akismet::recheck_comment( $comment_id, 'recheck_queue' ); 480 | 481 | if ( 'true' === $api_response ) { 482 | ++$result_counts['spam']; 483 | } 484 | elseif ( 'false' === $api_response ) { 485 | ++$result_counts['ham']; 486 | } 487 | else { 488 | ++$result_counts['error']; 489 | } 490 | } 491 | 492 | return $result_counts; 493 | } 494 | 495 | // Adds an 'x' link next to author URLs, clicking will remove the author URL and show an undo link 496 | public static function remove_comment_author_url() { 497 | if ( !empty( $_POST['id'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) { 498 | $comment_id = intval( $_POST['id'] ); 499 | $comment = get_comment( $comment_id, ARRAY_A ); 500 | if ( $comment && current_user_can( 'edit_comment', $comment['comment_ID'] ) ) { 501 | $comment['comment_author_url'] = ''; 502 | do_action( 'comment_remove_author_url' ); 503 | print( wp_update_comment( $comment ) ); 504 | die(); 505 | } 506 | } 507 | } 508 | 509 | public static function add_comment_author_url() { 510 | if ( !empty( $_POST['id'] ) && !empty( $_POST['url'] ) && check_admin_referer( 'comment_author_url_nonce' ) ) { 511 | $comment_id = intval( $_POST['id'] ); 512 | $comment = get_comment( $comment_id, ARRAY_A ); 513 | if ( $comment && current_user_can( 'edit_comment', $comment['comment_ID'] ) ) { 514 | $comment['comment_author_url'] = esc_url( $_POST['url'] ); 515 | do_action( 'comment_add_author_url' ); 516 | print( wp_update_comment( $comment ) ); 517 | die(); 518 | } 519 | } 520 | } 521 | 522 | public static function comment_row_action( $a, $comment ) { 523 | $akismet_result = get_comment_meta( $comment->comment_ID, 'akismet_result', true ); 524 | $akismet_error = get_comment_meta( $comment->comment_ID, 'akismet_error', true ); 525 | $user_result = get_comment_meta( $comment->comment_ID, 'akismet_user_result', true); 526 | $comment_status = wp_get_comment_status( $comment->comment_ID ); 527 | $desc = null; 528 | if ( $akismet_error ) { 529 | $desc = __( 'Awaiting spam check' , 'akismet'); 530 | } elseif ( !$user_result || $user_result == $akismet_result ) { 531 | // Show the original Akismet result if the user hasn't overridden it, or if their decision was the same 532 | if ( $akismet_result == 'true' && $comment_status != 'spam' && $comment_status != 'trash' ) 533 | $desc = __( 'Flagged as spam by Akismet' , 'akismet'); 534 | elseif ( $akismet_result == 'false' && $comment_status == 'spam' ) 535 | $desc = __( 'Cleared by Akismet' , 'akismet'); 536 | } else { 537 | $who = get_comment_meta( $comment->comment_ID, 'akismet_user', true ); 538 | if ( $user_result == 'true' ) 539 | $desc = sprintf( __('Flagged as spam by %s', 'akismet'), $who ); 540 | else 541 | $desc = sprintf( __('Un-spammed by %s', 'akismet'), $who ); 542 | } 543 | 544 | // add a History item to the hover links, just after Edit 545 | if ( $akismet_result ) { 546 | $b = array(); 547 | foreach ( $a as $k => $item ) { 548 | $b[ $k ] = $item; 549 | if ( 550 | $k == 'edit' 551 | || $k == 'unspam' 552 | ) { 553 | $b['history'] = ' '. esc_html__('History', 'akismet') . ''; 554 | } 555 | } 556 | 557 | $a = $b; 558 | } 559 | 560 | if ( $desc ) 561 | echo ''.esc_html( $desc ).''; 562 | 563 | $show_user_comments_option = get_option( 'akismet_show_user_comments_approved' ); 564 | 565 | if ( $show_user_comments_option === false ) { 566 | // Default to active if the user hasn't made a decision. 567 | $show_user_comments_option = '1'; 568 | } 569 | 570 | $show_user_comments = apply_filters( 'akismet_show_user_comments_approved', $show_user_comments_option ); 571 | $show_user_comments = $show_user_comments === 'false' ? false : $show_user_comments; //option used to be saved as 'false' / 'true' 572 | 573 | if ( $show_user_comments ) { 574 | $comment_count = Akismet::get_user_comments_approved( $comment->user_id, $comment->comment_author_email, $comment->comment_author, $comment->comment_author_url ); 575 | $comment_count = intval( $comment_count ); 576 | echo ''; 577 | } 578 | 579 | return $a; 580 | } 581 | 582 | public static function comment_status_meta_box( $comment ) { 583 | $history = Akismet::get_comment_history( $comment->comment_ID ); 584 | 585 | if ( $history ) { 586 | foreach ( $history as $row ) { 587 | $time = date( 'D d M Y @ h:i:s a', $row['time'] ) . ' GMT'; 588 | 589 | $message = ''; 590 | 591 | if ( ! empty( $row['message'] ) ) { 592 | // Old versions of Akismet stored the message as a literal string in the commentmeta. 593 | // New versions don't do that for two reasons: 594 | // 1) Save space. 595 | // 2) The message can be translated into the current language of the blog, not stuck 596 | // in the language of the blog when the comment was made. 597 | $message = esc_html( $row['message'] ); 598 | } 599 | 600 | // If possible, use a current translation. 601 | switch ( $row['event'] ) { 602 | case 'recheck-spam'; 603 | $message = esc_html( __( 'Akismet re-checked and caught this comment as spam.', 'akismet' ) ); 604 | break; 605 | case 'check-spam': 606 | $message = esc_html( __( 'Akismet caught this comment as spam.', 'akismet' ) ); 607 | break; 608 | case 'recheck-ham': 609 | $message = esc_html( __( 'Akismet re-checked and cleared this comment.', 'akismet' ) ); 610 | break; 611 | case 'check-ham': 612 | $message = esc_html( __( 'Akismet cleared this comment.', 'akismet' ) ); 613 | break; 614 | case 'wp-blacklisted': 615 | case 'wp-disallowed': 616 | $message = sprintf( 617 | /* translators: The placeholder is a WordPress PHP function name. */ 618 | esc_html( __( 'Comment was caught by %s.', 'akismet' ) ), 619 | function_exists( 'wp_check_comment_disallowed_list' ) ? 'wp_check_comment_disallowed_list' : 'wp_blacklist_check' 620 | ); 621 | break; 622 | case 'report-spam': 623 | if ( isset( $row['user'] ) ) { 624 | $message = esc_html( sprintf( __( '%s reported this comment as spam.', 'akismet' ), $row['user'] ) ); 625 | } 626 | else if ( ! $message ) { 627 | $message = esc_html( __( 'This comment was reported as spam.', 'akismet' ) ); 628 | } 629 | break; 630 | case 'report-ham': 631 | if ( isset( $row['user'] ) ) { 632 | $message = esc_html( sprintf( __( '%s reported this comment as not spam.', 'akismet' ), $row['user'] ) ); 633 | } 634 | else if ( ! $message ) { 635 | $message = esc_html( __( 'This comment was reported as not spam.', 'akismet' ) ); 636 | } 637 | break; 638 | case 'cron-retry-spam': 639 | $message = esc_html( __( 'Akismet caught this comment as spam during an automatic retry.' , 'akismet') ); 640 | break; 641 | case 'cron-retry-ham': 642 | $message = esc_html( __( 'Akismet cleared this comment during an automatic retry.', 'akismet') ); 643 | break; 644 | case 'check-error': 645 | if ( isset( $row['meta'], $row['meta']['response'] ) ) { 646 | $message = sprintf( esc_html( __( 'Akismet was unable to check this comment (response: %s) but will automatically retry later.', 'akismet') ), '' . esc_html( $row['meta']['response'] ) . '' ); 647 | } 648 | else { 649 | $message = esc_html( __( 'Akismet was unable to check this comment but will automatically retry later.', 'akismet' ) ); 650 | } 651 | break; 652 | case 'recheck-error': 653 | if ( isset( $row['meta'], $row['meta']['response'] ) ) { 654 | $message = sprintf( esc_html( __( 'Akismet was unable to recheck this comment (response: %s).', 'akismet') ), '' . esc_html( $row['meta']['response'] ) . '' ); 655 | } 656 | else { 657 | $message = esc_html( __( 'Akismet was unable to recheck this comment.', 'akismet' ) ); 658 | } 659 | break; 660 | default: 661 | if ( preg_match( '/^status-changed/', $row['event'] ) ) { 662 | // Half of these used to be saved without the dash after 'status-changed'. 663 | // See https://plugins.trac.wordpress.org/changeset/1150658/akismet/trunk 664 | $new_status = preg_replace( '/^status-changed-?/', '', $row['event'] ); 665 | $message = sprintf( esc_html( __( 'Comment status was changed to %s', 'akismet' ) ), '' . esc_html( $new_status ) . '' ); 666 | } 667 | else if ( preg_match( '/^status-/', $row['event'] ) ) { 668 | $new_status = preg_replace( '/^status-/', '', $row['event'] ); 669 | 670 | if ( isset( $row['user'] ) ) { 671 | $message = sprintf( esc_html( __( '%1$s changed the comment status to %2$s.', 'akismet' ) ), $row['user'], '' . esc_html( $new_status ) . '' ); 672 | } 673 | } 674 | break; 675 | 676 | } 677 | 678 | if ( ! empty( $message ) ) { 679 | echo '

'; 680 | echo '' . sprintf( esc_html__('%s ago', 'akismet'), human_time_diff( $row['time'] ) ) . ''; 681 | echo ' - '; 682 | echo $message; // esc_html() is done above so that we can use HTML in some messages. 683 | echo '

'; 684 | } 685 | } 686 | } 687 | else { 688 | echo '

'; 689 | echo esc_html( __( 'No comment history.', 'akismet' ) ); 690 | echo '

'; 691 | } 692 | } 693 | 694 | public static function plugin_action_links( $links, $file ) { 695 | if ( $file == plugin_basename( plugin_dir_url( __FILE__ ) . '/akismet.php' ) ) { 696 | $links[] = ''.esc_html__( 'Settings' , 'akismet').''; 697 | } 698 | 699 | return $links; 700 | } 701 | 702 | // Total spam in queue 703 | // get_option( 'akismet_spam_count' ) is the total caught ever 704 | public static function get_spam_count( $type = false ) { 705 | global $wpdb; 706 | 707 | if ( !$type ) { // total 708 | $count = wp_cache_get( 'akismet_spam_count', 'widget' ); 709 | if ( false === $count ) { 710 | $count = wp_count_comments(); 711 | $count = $count->spam; 712 | wp_cache_set( 'akismet_spam_count', $count, 'widget', 3600 ); 713 | } 714 | return $count; 715 | } elseif ( 'comments' == $type || 'comment' == $type ) { // comments 716 | $type = ''; 717 | } 718 | 719 | return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_approved = 'spam' AND comment_type = %s", $type ) ); 720 | } 721 | 722 | // Check connectivity between the WordPress blog and Akismet's servers. 723 | // 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). 724 | public static function check_server_ip_connectivity() { 725 | 726 | $servers = $ips = array(); 727 | 728 | // Some web hosts may disable this function 729 | if ( function_exists('gethostbynamel') ) { 730 | 731 | $ips = gethostbynamel( 'rest.akismet.com' ); 732 | if ( $ips && is_array($ips) && count($ips) ) { 733 | $api_key = Akismet::get_api_key(); 734 | 735 | foreach ( $ips as $ip ) { 736 | $response = Akismet::verify_key( $api_key, $ip ); 737 | // even if the key is invalid, at least we know we have connectivity 738 | if ( $response == 'valid' || $response == 'invalid' ) 739 | $servers[$ip] = 'connected'; 740 | else 741 | $servers[$ip] = $response ? $response : 'unable to connect'; 742 | } 743 | } 744 | } 745 | 746 | return $servers; 747 | } 748 | 749 | // Simpler connectivity check 750 | public static function check_server_connectivity($cache_timeout = 86400) { 751 | 752 | $debug = array(); 753 | $debug[ 'PHP_VERSION' ] = PHP_VERSION; 754 | $debug[ 'WORDPRESS_VERSION' ] = $GLOBALS['wp_version']; 755 | $debug[ 'AKISMET_VERSION' ] = AKISMET_VERSION; 756 | $debug[ 'AKISMET__PLUGIN_DIR' ] = AKISMET__PLUGIN_DIR; 757 | $debug[ 'SITE_URL' ] = site_url(); 758 | $debug[ 'HOME_URL' ] = home_url(); 759 | 760 | $servers = get_option('akismet_available_servers'); 761 | if ( (time() - get_option('akismet_connectivity_time') < $cache_timeout) && $servers !== false ) { 762 | $servers = self::check_server_ip_connectivity(); 763 | update_option('akismet_available_servers', $servers); 764 | update_option('akismet_connectivity_time', time()); 765 | } 766 | 767 | if ( wp_http_supports( array( 'ssl' ) ) ) { 768 | $response = wp_remote_get( 'https://rest.akismet.com/1.1/test' ); 769 | } 770 | else { 771 | $response = wp_remote_get( 'http://rest.akismet.com/1.1/test' ); 772 | } 773 | 774 | $debug[ 'gethostbynamel' ] = function_exists('gethostbynamel') ? 'exists' : 'not here'; 775 | $debug[ 'Servers' ] = $servers; 776 | $debug[ 'Test Connection' ] = $response; 777 | 778 | Akismet::log( $debug ); 779 | 780 | if ( $response && 'connected' == wp_remote_retrieve_body( $response ) ) 781 | return true; 782 | 783 | return false; 784 | } 785 | 786 | // Check the server connectivity and store the available servers in an option. 787 | public static function get_server_connectivity($cache_timeout = 86400) { 788 | return self::check_server_connectivity( $cache_timeout ); 789 | } 790 | 791 | /** 792 | * Find out whether any comments in the Pending queue have not yet been checked by Akismet. 793 | * 794 | * @return bool 795 | */ 796 | public static function are_any_comments_waiting_to_be_checked() { 797 | return !! get_comments( array( 798 | // Exclude comments that are not pending. This would happen if someone manually approved or spammed a comment 799 | // that was waiting to be checked. The akismet_error meta entry will eventually be removed by the cron recheck job. 800 | 'status' => 'hold', 801 | 802 | // This is the commentmeta that is saved when a comment couldn't be checked. 803 | 'meta_key' => 'akismet_error', 804 | 805 | // We only need to know whether at least one comment is waiting for a check. 806 | 'number' => 1, 807 | ) ); 808 | } 809 | 810 | public static function get_page_url( $page = 'config' ) { 811 | 812 | $args = array( 'page' => 'akismet-key-config' ); 813 | 814 | if ( $page == 'stats' ) 815 | $args = array( 'page' => 'akismet-key-config', 'view' => 'stats' ); 816 | elseif ( $page == 'delete_key' ) 817 | $args = array( 'page' => 'akismet-key-config', 'view' => 'start', 'action' => 'delete-key', '_wpnonce' => wp_create_nonce( self::NONCE ) ); 818 | 819 | $url = add_query_arg( $args, class_exists( 'Jetpack' ) ? admin_url( 'admin.php' ) : admin_url( 'options-general.php' ) ); 820 | 821 | return $url; 822 | } 823 | 824 | public static function get_akismet_user( $api_key ) { 825 | $akismet_user = false; 826 | 827 | $subscription_verification = Akismet::http_post( Akismet::build_query( array( 'key' => $api_key, 'blog' => get_option( 'home' ) ) ), 'get-subscription' ); 828 | 829 | if ( ! empty( $subscription_verification[1] ) ) { 830 | if ( 'invalid' !== $subscription_verification[1] ) { 831 | $akismet_user = json_decode( $subscription_verification[1] ); 832 | } 833 | } 834 | 835 | return $akismet_user; 836 | } 837 | 838 | public static function get_stats( $api_key ) { 839 | $stat_totals = array(); 840 | 841 | foreach( array( '6-months', 'all' ) as $interval ) { 842 | $response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' ); 843 | 844 | if ( ! empty( $response[1] ) ) { 845 | $stat_totals[$interval] = json_decode( $response[1] ); 846 | } 847 | } 848 | 849 | return $stat_totals; 850 | } 851 | 852 | public static function verify_wpcom_key( $api_key, $user_id, $extra = array() ) { 853 | $akismet_account = Akismet::http_post( Akismet::build_query( array_merge( array( 854 | 'user_id' => $user_id, 855 | 'api_key' => $api_key, 856 | 'get_account_type' => 'true' 857 | ), $extra ) ), 'verify-wpcom-key' ); 858 | 859 | if ( ! empty( $akismet_account[1] ) ) 860 | $akismet_account = json_decode( $akismet_account[1] ); 861 | 862 | Akismet::log( compact( 'akismet_account' ) ); 863 | 864 | return $akismet_account; 865 | } 866 | 867 | public static function connect_jetpack_user() { 868 | 869 | if ( $jetpack_user = self::get_jetpack_user() ) { 870 | if ( isset( $jetpack_user['user_id'] ) && isset( $jetpack_user['api_key'] ) ) { 871 | $akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'], array( 'action' => 'connect_jetpack_user' ) ); 872 | 873 | if ( is_object( $akismet_user ) ) { 874 | self::save_key( $akismet_user->api_key ); 875 | return in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub' ) ); 876 | } 877 | } 878 | } 879 | 880 | return false; 881 | } 882 | 883 | public static function display_alert() { 884 | Akismet::view( 'notice', array( 885 | 'type' => 'alert', 886 | 'code' => (int) get_option( 'akismet_alert_code' ), 887 | 'msg' => get_option( 'akismet_alert_msg' ) 888 | ) ); 889 | } 890 | 891 | public static function get_usage_limit_alert_data() { 892 | return array( 893 | 'type' => 'usage-limit', 894 | 'code' => (int) get_option( 'akismet_alert_code' ), 895 | 'msg' => get_option( 'akismet_alert_msg' ), 896 | 'api_calls' => get_option( 'akismet_alert_api_calls' ), 897 | 'usage_limit' => get_option( 'akismet_alert_usage_limit' ), 898 | 'upgrade_plan' => get_option( 'akismet_alert_upgrade_plan' ), 899 | 'upgrade_url' => get_option( 'akismet_alert_upgrade_url' ), 900 | 'upgrade_type' => get_option( 'akismet_alert_upgrade_type' ), 901 | ); 902 | } 903 | 904 | public static function display_usage_limit_alert() { 905 | Akismet::view( 'notice', self::get_usage_limit_alert_data() ); 906 | } 907 | 908 | public static function display_spam_check_warning() { 909 | Akismet::fix_scheduled_recheck(); 910 | 911 | if ( wp_next_scheduled('akismet_schedule_cron_recheck') > time() && self::are_any_comments_waiting_to_be_checked() ) { 912 | $link_text = apply_filters( 'akismet_spam_check_warning_link_text', sprintf( __( 'Please check your Akismet configuration and contact your web host if problems persist.', 'akismet'), esc_url( self::get_page_url() ) ) ); 913 | Akismet::view( 'notice', array( 'type' => 'spam-check', 'link_text' => $link_text ) ); 914 | } 915 | } 916 | 917 | public static function display_api_key_warning() { 918 | Akismet::view( 'notice', array( 'type' => 'plugin' ) ); 919 | } 920 | 921 | public static function display_page() { 922 | if ( !Akismet::get_api_key() || ( isset( $_GET['view'] ) && $_GET['view'] == 'start' ) ) 923 | self::display_start_page(); 924 | elseif ( isset( $_GET['view'] ) && $_GET['view'] == 'stats' ) 925 | self::display_stats_page(); 926 | else 927 | self::display_configuration_page(); 928 | } 929 | 930 | public static function display_start_page() { 931 | if ( isset( $_GET['action'] ) ) { 932 | if ( $_GET['action'] == 'delete-key' ) { 933 | if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], self::NONCE ) ) 934 | delete_option( 'wordpress_api_key' ); 935 | } 936 | } 937 | 938 | if ( $api_key = Akismet::get_api_key() && ( empty( self::$notices['status'] ) || 'existing-key-invalid' != self::$notices['status'] ) ) { 939 | self::display_configuration_page(); 940 | return; 941 | } 942 | 943 | //the user can choose to auto connect their API key by clicking a button on the akismet done page 944 | //if jetpack, get verified api key by using connected wpcom user id 945 | //if no jetpack, get verified api key by using an akismet token 946 | 947 | $akismet_user = false; 948 | 949 | if ( isset( $_GET['token'] ) && preg_match('/^(\d+)-[0-9a-f]{20}$/', $_GET['token'] ) ) 950 | $akismet_user = self::verify_wpcom_key( '', '', array( 'token' => $_GET['token'] ) ); 951 | elseif ( $jetpack_user = self::get_jetpack_user() ) 952 | $akismet_user = self::verify_wpcom_key( $jetpack_user['api_key'], $jetpack_user['user_id'] ); 953 | 954 | if ( isset( $_GET['action'] ) ) { 955 | if ( $_GET['action'] == 'save-key' ) { 956 | if ( is_object( $akismet_user ) ) { 957 | self::save_key( $akismet_user->api_key ); 958 | self::display_configuration_page(); 959 | return; 960 | } 961 | } 962 | } 963 | 964 | Akismet::view( 'start', compact( 'akismet_user' ) ); 965 | 966 | /* 967 | // To see all variants when testing. 968 | $akismet_user->status = 'no-sub'; 969 | Akismet::view( 'start', compact( 'akismet_user' ) ); 970 | $akismet_user->status = 'cancelled'; 971 | Akismet::view( 'start', compact( 'akismet_user' ) ); 972 | $akismet_user->status = 'suspended'; 973 | Akismet::view( 'start', compact( 'akismet_user' ) ); 974 | $akismet_user->status = 'other'; 975 | Akismet::view( 'start', compact( 'akismet_user' ) ); 976 | $akismet_user = false; 977 | */ 978 | } 979 | 980 | public static function display_stats_page() { 981 | Akismet::view( 'stats' ); 982 | } 983 | 984 | public static function display_configuration_page() { 985 | $api_key = Akismet::get_api_key(); 986 | $akismet_user = self::get_akismet_user( $api_key ); 987 | 988 | if ( ! $akismet_user ) { 989 | // This could happen if the user's key became invalid after it was previously valid and successfully set up. 990 | self::$notices['status'] = 'existing-key-invalid'; 991 | self::display_start_page(); 992 | return; 993 | } 994 | 995 | $stat_totals = self::get_stats( $api_key ); 996 | 997 | // If unset, create the new strictness option using the old discard option to determine its default. 998 | // If the old option wasn't set, default to discarding the blatant spam. 999 | if ( get_option( 'akismet_strictness' ) === false ) { 1000 | add_option( 'akismet_strictness', ( get_option( 'akismet_discard_month' ) === 'false' ? '0' : '1' ) ); 1001 | } 1002 | 1003 | // Sync the local "Total spam blocked" count with the authoritative count from the server. 1004 | if ( isset( $stat_totals['all'], $stat_totals['all']->spam ) ) { 1005 | update_option( 'akismet_spam_count', $stat_totals['all']->spam ); 1006 | } 1007 | 1008 | $notices = array(); 1009 | 1010 | if ( empty( self::$notices ) ) { 1011 | if ( ! empty( $stat_totals['all'] ) && isset( $stat_totals['all']->time_saved ) && $akismet_user->status == 'active' && $akismet_user->account_type == 'free-api-key' ) { 1012 | 1013 | $time_saved = false; 1014 | 1015 | if ( $stat_totals['all']->time_saved > 1800 ) { 1016 | $total_in_minutes = round( $stat_totals['all']->time_saved / 60 ); 1017 | $total_in_hours = round( $total_in_minutes / 60 ); 1018 | $total_in_days = round( $total_in_hours / 8 ); 1019 | $cleaning_up = __( 'Cleaning up spam takes time.' , 'akismet'); 1020 | 1021 | if ( $total_in_days > 1 ) 1022 | $time_saved = $cleaning_up . ' ' . sprintf( _n( 'Akismet has saved you %s day!', 'Akismet has saved you %s days!', $total_in_days, 'akismet' ), number_format_i18n( $total_in_days ) ); 1023 | elseif ( $total_in_hours > 1 ) 1024 | $time_saved = $cleaning_up . ' ' . sprintf( _n( 'Akismet has saved you %d hour!', 'Akismet has saved you %d hours!', $total_in_hours, 'akismet' ), $total_in_hours ); 1025 | elseif ( $total_in_minutes >= 30 ) 1026 | $time_saved = $cleaning_up . ' ' . sprintf( _n( 'Akismet has saved you %d minute!', 'Akismet has saved you %d minutes!', $total_in_minutes, 'akismet' ), $total_in_minutes ); 1027 | } 1028 | 1029 | $notices[] = array( 'type' => 'active-notice', 'time_saved' => $time_saved ); 1030 | } 1031 | 1032 | if ( !empty( $akismet_user->limit_reached ) && in_array( $akismet_user->limit_reached, array( 'yellow', 'red' ) ) ) { 1033 | $notices[] = array( 'type' => 'limit-reached', 'level' => $akismet_user->limit_reached ); 1034 | } 1035 | } 1036 | 1037 | if ( !isset( self::$notices['status'] ) && in_array( $akismet_user->status, array( 'cancelled', 'suspended', 'missing', 'no-sub' ) ) ) { 1038 | $notices[] = array( 'type' => $akismet_user->status ); 1039 | } 1040 | 1041 | $alert_code = get_option( 'akismet_alert_code' ); 1042 | if ( isset( Akismet::$limit_notices[ $alert_code ] ) ) { 1043 | $notices[] = self::get_usage_limit_alert_data(); 1044 | } 1045 | 1046 | /* 1047 | // To see all variants when testing. 1048 | $notices[] = array( 'type' => 'active-notice', 'time_saved' => 'Cleaning up spam takes time. Akismet has saved you 1 minute!' ); 1049 | $notices[] = array( 'type' => 'plugin' ); 1050 | $notices[] = array( 'type' => 'spam-check', 'link_text' => 'Link text.' ); 1051 | $notices[] = array( 'type' => 'notice', 'notice_header' => 'This is the notice header.', 'notice_text' => 'This is the notice text.' ); 1052 | $notices[] = array( 'type' => 'missing-functions' ); 1053 | $notices[] = array( 'type' => 'servers-be-down' ); 1054 | $notices[] = array( 'type' => 'active-dunning' ); 1055 | $notices[] = array( 'type' => 'cancelled' ); 1056 | $notices[] = array( 'type' => 'suspended' ); 1057 | $notices[] = array( 'type' => 'missing' ); 1058 | $notices[] = array( 'type' => 'no-sub' ); 1059 | $notices[] = array( 'type' => 'new-key-valid' ); 1060 | $notices[] = array( 'type' => 'new-key-invalid' ); 1061 | $notices[] = array( 'type' => 'existing-key-invalid' ); 1062 | $notices[] = array( 'type' => 'new-key-failed' ); 1063 | $notices[] = array( 'type' => 'limit-reached', 'level' => 'yellow' ); 1064 | $notices[] = array( 'type' => 'limit-reached', 'level' => 'red' ); 1065 | $notices[] = array( 'type' => 'usage-limit', 'api_calls' => '15000', 'usage_limit' => '10000', 'upgrade_plan' => 'Enterprise', 'upgrade_url' => 'https://akismet.com/account/' ); 1066 | */ 1067 | 1068 | Akismet::log( compact( 'stat_totals', 'akismet_user' ) ); 1069 | Akismet::view( 'config', compact( 'api_key', 'akismet_user', 'stat_totals', 'notices' ) ); 1070 | } 1071 | 1072 | public static function display_notice() { 1073 | global $hook_suffix; 1074 | 1075 | if ( in_array( $hook_suffix, array( 'jetpack_page_akismet-key-config', 'settings_page_akismet-key-config' ) ) ) { 1076 | // This page manages the notices and puts them inline where they make sense. 1077 | return; 1078 | } 1079 | 1080 | if ( in_array( $hook_suffix, array( 'edit-comments.php' ) ) && (int) get_option( 'akismet_alert_code' ) > 0 ) { 1081 | Akismet::verify_key( Akismet::get_api_key() ); //verify that the key is still in alert state 1082 | 1083 | $alert_code = get_option( 'akismet_alert_code' ); 1084 | if ( isset( Akismet::$limit_notices[ $alert_code ] ) ) { 1085 | self::display_usage_limit_alert(); 1086 | } elseif ( $alert_code > 0 ) { 1087 | self::display_alert(); 1088 | } 1089 | } 1090 | elseif ( ( 'plugins.php' === $hook_suffix || 'edit-comments.php' === $hook_suffix ) && ! Akismet::get_api_key() ) { 1091 | // Show the "Set Up Akismet" banner on the comments and plugin pages if no API key has been set. 1092 | self::display_api_key_warning(); 1093 | } 1094 | elseif ( $hook_suffix == 'edit-comments.php' && wp_next_scheduled( 'akismet_schedule_cron_recheck' ) ) { 1095 | self::display_spam_check_warning(); 1096 | } 1097 | 1098 | if ( isset( $_GET['akismet_recheck_complete'] ) ) { 1099 | $recheck_count = (int) $_GET['recheck_count']; 1100 | $spam_count = (int) $_GET['spam_count']; 1101 | 1102 | if ( $recheck_count === 0 ) { 1103 | $message = __( 'There were no comments to check. Akismet will only check comments awaiting moderation.', 'akismet' ); 1104 | } 1105 | else { 1106 | $message = sprintf( _n( 'Akismet checked %s comment.', 'Akismet checked %s comments.', $recheck_count, 'akismet' ), number_format( $recheck_count ) ); 1107 | $message .= ' '; 1108 | 1109 | if ( $spam_count === 0 ) { 1110 | $message .= __( 'No comments were caught as spam.', 'akismet' ); 1111 | } 1112 | else { 1113 | $message .= sprintf( _n( '%s comment was caught as spam.', '%s comments were caught as spam.', $spam_count, 'akismet' ), number_format( $spam_count ) ); 1114 | } 1115 | } 1116 | 1117 | echo '

' . esc_html( $message ) . '

'; 1118 | } 1119 | else if ( isset( $_GET['akismet_recheck_error'] ) ) { 1120 | echo '

' . esc_html( __( 'Akismet could not recheck your comments for spam.', 'akismet' ) ) . '

'; 1121 | } 1122 | } 1123 | 1124 | public static function display_status() { 1125 | if ( ! self::get_server_connectivity() ) { 1126 | Akismet::view( 'notice', array( 'type' => 'servers-be-down' ) ); 1127 | } 1128 | else if ( ! empty( self::$notices ) ) { 1129 | foreach ( self::$notices as $index => $type ) { 1130 | if ( is_object( $type ) ) { 1131 | $notice_header = $notice_text = ''; 1132 | 1133 | if ( property_exists( $type, 'notice_header' ) ) { 1134 | $notice_header = wp_kses( $type->notice_header, self::$allowed ); 1135 | } 1136 | 1137 | if ( property_exists( $type, 'notice_text' ) ) { 1138 | $notice_text = wp_kses( $type->notice_text, self::$allowed ); 1139 | } 1140 | 1141 | if ( property_exists( $type, 'status' ) ) { 1142 | $type = wp_kses( $type->status, self::$allowed ); 1143 | Akismet::view( 'notice', compact( 'type', 'notice_header', 'notice_text' ) ); 1144 | 1145 | unset( self::$notices[ $index ] ); 1146 | } 1147 | } 1148 | else { 1149 | Akismet::view( 'notice', compact( 'type' ) ); 1150 | 1151 | unset( self::$notices[ $index ] ); 1152 | } 1153 | } 1154 | } 1155 | } 1156 | 1157 | private static function get_jetpack_user() { 1158 | if ( !class_exists('Jetpack') ) 1159 | return false; 1160 | 1161 | if ( defined( 'JETPACK__VERSION' ) && version_compare( JETPACK__VERSION, '7.7', '<' ) ) { 1162 | // For version of Jetpack prior to 7.7. 1163 | Jetpack::load_xml_rpc_client(); 1164 | } 1165 | 1166 | $xml = new Jetpack_IXR_ClientMulticall( array( 'user_id' => get_current_user_id() ) ); 1167 | 1168 | $xml->addCall( 'wpcom.getUserID' ); 1169 | $xml->addCall( 'akismet.getAPIKey' ); 1170 | $xml->query(); 1171 | 1172 | Akismet::log( compact( 'xml' ) ); 1173 | 1174 | if ( !$xml->isError() ) { 1175 | $responses = $xml->getResponse(); 1176 | if ( count( $responses ) > 1 ) { 1177 | // Due to a quirk in how Jetpack does multi-calls, the response order 1178 | // can't be trusted to match the call order. It's a good thing our 1179 | // return values can be mostly differentiated from each other. 1180 | $first_response_value = array_shift( $responses[0] ); 1181 | $second_response_value = array_shift( $responses[1] ); 1182 | 1183 | // If WPCOM ever reaches 100 billion users, this will fail. :-) 1184 | if ( preg_match( '/^[a-f0-9]{12}$/i', $first_response_value ) ) { 1185 | $api_key = $first_response_value; 1186 | $user_id = (int) $second_response_value; 1187 | } 1188 | else { 1189 | $api_key = $second_response_value; 1190 | $user_id = (int) $first_response_value; 1191 | } 1192 | 1193 | return compact( 'api_key', 'user_id' ); 1194 | } 1195 | } 1196 | return false; 1197 | } 1198 | 1199 | /** 1200 | * Some commentmeta isn't useful in an export file. Suppress it (when supported). 1201 | * 1202 | * @param bool $exclude 1203 | * @param string $key The meta key 1204 | * @param object $meta The meta object 1205 | * @return bool Whether to exclude this meta entry from the export. 1206 | */ 1207 | public static function exclude_commentmeta_from_export( $exclude, $key, $meta ) { 1208 | if ( in_array( $key, array( 'akismet_as_submitted', 'akismet_rechecking', 'akismet_delayed_moderation_email' ) ) ) { 1209 | return true; 1210 | } 1211 | 1212 | return $exclude; 1213 | } 1214 | 1215 | /** 1216 | * When Akismet is active, remove the "Activate Akismet" step from the plugin description. 1217 | */ 1218 | public static function modify_plugin_description( $all_plugins ) { 1219 | if ( isset( $all_plugins['akismet/akismet.php'] ) ) { 1220 | if ( Akismet::get_api_key() ) { 1221 | $all_plugins['akismet/akismet.php']['Description'] = __( 'Used by millions, Akismet is quite possibly the best way in the world to protect your blog from spam. Your site is fully configured and being protected, even while you sleep.', 'akismet' ); 1222 | } 1223 | else { 1224 | $all_plugins['akismet/akismet.php']['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, just go to your Akismet Settings page to set up your API key.', 'akismet' ); 1225 | } 1226 | } 1227 | 1228 | return $all_plugins; 1229 | } 1230 | 1231 | private static function set_form_privacy_notice_option( $state ) { 1232 | if ( in_array( $state, array( 'display', 'hide' ) ) ) { 1233 | update_option( 'akismet_comment_form_privacy_notice', $state ); 1234 | } 1235 | } 1236 | 1237 | public static function register_personal_data_eraser( $erasers ) { 1238 | $erasers['akismet'] = array( 1239 | 'eraser_friendly_name' => __( 'Akismet', 'akismet' ), 1240 | 'callback' => array( 'Akismet_Admin', 'erase_personal_data' ), 1241 | ); 1242 | 1243 | return $erasers; 1244 | } 1245 | 1246 | /** 1247 | * When a user requests that their personal data be removed, Akismet has a duty to discard 1248 | * any personal data we store outside of the comment itself. Right now, that is limited 1249 | * to the copy of the comment we store in the akismet_as_submitted commentmeta. 1250 | * 1251 | * FWIW, this information would be automatically deleted after 15 days. 1252 | * 1253 | * @param $email_address string The email address of the user who has requested erasure. 1254 | * @param $page int This function can (and will) be called multiple times to prevent timeouts, 1255 | * so this argument is used for pagination. 1256 | * @return array 1257 | * @see https://developer.wordpress.org/plugins/privacy/adding-the-personal-data-eraser-to-your-plugin/ 1258 | */ 1259 | public static function erase_personal_data( $email_address, $page = 1 ) { 1260 | $items_removed = false; 1261 | 1262 | $number = 50; 1263 | $page = (int) $page; 1264 | 1265 | $comments = get_comments( 1266 | array( 1267 | 'author_email' => $email_address, 1268 | 'number' => $number, 1269 | 'paged' => $page, 1270 | 'order_by' => 'comment_ID', 1271 | 'order' => 'ASC', 1272 | ) 1273 | ); 1274 | 1275 | foreach ( (array) $comments as $comment ) { 1276 | $comment_as_submitted = get_comment_meta( $comment->comment_ID, 'akismet_as_submitted', true ); 1277 | 1278 | if ( $comment_as_submitted ) { 1279 | delete_comment_meta( $comment->comment_ID, 'akismet_as_submitted' ); 1280 | $items_removed = true; 1281 | } 1282 | } 1283 | 1284 | // Tell core if we have more comments to work on still 1285 | $done = count( $comments ) < $number; 1286 | 1287 | return array( 1288 | 'items_removed' => $items_removed, 1289 | 'items_retained' => false, // always false in this example 1290 | 'messages' => array(), // no messages in this example 1291 | 'done' => $done, 1292 | ); 1293 | } 1294 | } 1295 | --------------------------------------------------------------------------------