PageRenderTime 51ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/akismet/akismet.php

https://bitbucket.org/aqge/deptandashboard
PHP | 555 lines | 392 code | 89 blank | 74 comment | 108 complexity | 52edc596478b96edf3cb9b4eca2d5796 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @package Akismet
  4. */
  5. /*
  6. Plugin Name: Akismet
  7. Plugin URI: http://akismet.com/?return=true
  8. Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/?return=true">Sign up for an Akismet API key</a>, and 3) Go to your <a href="admin.php?page=akismet-key-config">Akismet configuration</a> page, and save your API key.
  9. Version: 2.5.5
  10. Author: Automattic
  11. Author URI: http://automattic.com/wordpress-plugins/
  12. License: GPLv2 or later
  13. */
  14. /*
  15. This program is free software; you can redistribute it and/or
  16. modify it under the terms of the GNU General Public License
  17. as published by the Free Software Foundation; either version 2
  18. of the License, or (at your option) any later version.
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. GNU General Public License for more details.
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software
  25. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  26. */
  27. define('AKISMET_VERSION', '2.5.5');
  28. define('AKISMET_PLUGIN_URL', plugin_dir_url( __FILE__ ));
  29. /** If you hardcode a WP.com API key here, all key config screens will be hidden */
  30. if ( defined('WPCOM_API_KEY') )
  31. $wpcom_api_key = constant('WPCOM_API_KEY');
  32. else
  33. $wpcom_api_key = '';
  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. if ( isset($wp_db_version) && $wp_db_version <= 9872 )
  40. include_once dirname( __FILE__ ) . '/legacy.php';
  41. include_once dirname( __FILE__ ) . '/widget.php';
  42. if ( is_admin() )
  43. require_once dirname( __FILE__ ) . '/admin.php';
  44. function akismet_init() {
  45. global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
  46. if ( $wpcom_api_key )
  47. $akismet_api_host = $wpcom_api_key . '.rest.akismet.com';
  48. else
  49. $akismet_api_host = get_option('wordpress_api_key') . '.rest.akismet.com';
  50. $akismet_api_port = 80;
  51. }
  52. add_action('init', 'akismet_init');
  53. function akismet_get_key() {
  54. global $wpcom_api_key;
  55. if ( !empty($wpcom_api_key) )
  56. return $wpcom_api_key;
  57. return get_option('wordpress_api_key');
  58. }
  59. function akismet_verify_key( $key, $ip = null ) {
  60. global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
  61. $blog = urlencode( get_option('home') );
  62. if ( $wpcom_api_key )
  63. $key = $wpcom_api_key;
  64. $response = akismet_http_post("key=$key&blog=$blog", 'rest.akismet.com', '/1.1/verify-key', $akismet_api_port, $ip);
  65. if ( !is_array($response) || !isset($response[1]) || $response[1] != 'valid' && $response[1] != 'invalid' )
  66. return 'failed';
  67. return $response[1];
  68. }
  69. // if we're in debug or test modes, use a reduced service level so as not to polute training or stats data
  70. function akismet_test_mode() {
  71. if ( defined('AKISMET_TEST_MODE') && AKISMET_TEST_MODE )
  72. return true;
  73. return false;
  74. }
  75. // return a comma-separated list of role names for the given user
  76. function akismet_get_user_roles($user_id ) {
  77. $roles = false;
  78. if ( !class_exists('WP_User') )
  79. return false;
  80. if ( $user_id > 0 ) {
  81. $comment_user = new WP_User($user_id);
  82. if ( isset($comment_user->roles) )
  83. $roles = join(',', $comment_user->roles);
  84. }
  85. if ( is_multisite() && is_super_admin( $user_id ) ) {
  86. if ( empty( $roles ) ) {
  87. $roles = 'super_admin';
  88. } else {
  89. $comment_user->roles[] = 'super_admin';
  90. $roles = join( ',', $comment_user->roles );
  91. }
  92. }
  93. return $roles;
  94. }
  95. // Returns array with headers in $response[0] and body in $response[1]
  96. function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
  97. global $wp_version;
  98. $akismet_ua = "WordPress/{$wp_version} | ";
  99. $akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' );
  100. $akismet_ua = apply_filters( 'akismet_ua', $akismet_ua );
  101. $content_length = strlen( $request );
  102. $http_host = $host;
  103. // use a specific IP if provided
  104. // needed by akismet_check_server_connectivity()
  105. if ( $ip && long2ip( ip2long( $ip ) ) ) {
  106. $http_host = $ip;
  107. } else {
  108. $http_host = $host;
  109. }
  110. // use the WP HTTP class if it is available
  111. if ( function_exists( 'wp_remote_post' ) ) {
  112. $http_args = array(
  113. 'body' => $request,
  114. 'headers' => array(
  115. 'Content-Type' => 'application/x-www-form-urlencoded; ' .
  116. 'charset=' . get_option( 'blog_charset' ),
  117. 'Host' => $host,
  118. 'User-Agent' => $akismet_ua
  119. ),
  120. 'httpversion' => '1.0',
  121. 'timeout' => 15
  122. );
  123. $akismet_url = "http://{$http_host}{$path}";
  124. $response = wp_remote_post( $akismet_url, $http_args );
  125. if ( is_wp_error( $response ) )
  126. return '';
  127. return array( $response['headers'], $response['body'] );
  128. } else {
  129. $http_request = "POST $path HTTP/1.0\r\n";
  130. $http_request .= "Host: $host\r\n";
  131. $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
  132. $http_request .= "Content-Length: {$content_length}\r\n";
  133. $http_request .= "User-Agent: {$akismet_ua}\r\n";
  134. $http_request .= "\r\n";
  135. $http_request .= $request;
  136. $response = '';
  137. if( false != ( $fs = @fsockopen( $http_host, $port, $errno, $errstr, 10 ) ) ) {
  138. fwrite( $fs, $http_request );
  139. while ( !feof( $fs ) )
  140. $response .= fgets( $fs, 1160 ); // One TCP-IP packet
  141. fclose( $fs );
  142. $response = explode( "\r\n\r\n", $response, 2 );
  143. }
  144. return $response;
  145. }
  146. }
  147. // filter handler used to return a spam result to pre_comment_approved
  148. function akismet_result_spam( $approved ) {
  149. // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
  150. if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
  151. update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
  152. // this is a one-shot deal
  153. remove_filter( 'pre_comment_approved', 'akismet_result_spam' );
  154. return 'spam';
  155. }
  156. function akismet_result_hold( $approved ) {
  157. // once only
  158. remove_filter( 'pre_comment_approved', 'akismet_result_hold' );
  159. return '0';
  160. }
  161. // how many approved comments does this author have?
  162. function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
  163. global $wpdb;
  164. if ( !empty($user_id) )
  165. return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE user_id = %d AND comment_approved = 1", $user_id ) );
  166. if ( !empty($comment_author_email) )
  167. return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1", $comment_author_email, $comment_author, $comment_author_url ) );
  168. return 0;
  169. }
  170. function akismet_microtime() {
  171. $mtime = explode( ' ', microtime() );
  172. return $mtime[1] + $mtime[0];
  173. }
  174. // log an event for a given comment, storing it in comment_meta
  175. function akismet_update_comment_history( $comment_id, $message, $event=null ) {
  176. global $current_user;
  177. // failsafe for old WP versions
  178. if ( !function_exists('add_comment_meta') )
  179. return false;
  180. $user = '';
  181. if ( is_object($current_user) && isset($current_user->user_login) )
  182. $user = $current_user->user_login;
  183. $event = array(
  184. 'time' => akismet_microtime(),
  185. 'message' => $message,
  186. 'event' => $event,
  187. 'user' => $user,
  188. );
  189. // $unique = false so as to allow multiple values per comment
  190. $r = add_comment_meta( $comment_id, 'akismet_history', $event, false );
  191. }
  192. // get the full comment history for a given comment, as an array in reverse chronological order
  193. function akismet_get_comment_history( $comment_id ) {
  194. // failsafe for old WP versions
  195. if ( !function_exists('add_comment_meta') )
  196. return false;
  197. $history = get_comment_meta( $comment_id, 'akismet_history', false );
  198. usort( $history, 'akismet_cmp_time' );
  199. return $history;
  200. }
  201. function akismet_cmp_time( $a, $b ) {
  202. return $a['time'] > $b['time'] ? -1 : 1;
  203. }
  204. // this fires on wp_insert_comment. we can't update comment_meta when akismet_auto_check_comment() runs
  205. // because we don't know the comment ID at that point.
  206. function akismet_auto_check_update_meta( $id, $comment ) {
  207. global $akismet_last_comment;
  208. // failsafe for old WP versions
  209. if ( !function_exists('add_comment_meta') )
  210. return false;
  211. // wp_insert_comment() might be called in other contexts, so make sure this is the same comment
  212. // as was checked by akismet_auto_check_comment
  213. if ( is_object($comment) && !empty($akismet_last_comment) && is_array($akismet_last_comment) ) {
  214. if ( intval($akismet_last_comment['comment_post_ID']) == intval($comment->comment_post_ID)
  215. && $akismet_last_comment['comment_author'] == $comment->comment_author
  216. && $akismet_last_comment['comment_author_email'] == $comment->comment_author_email ) {
  217. // normal result: true or false
  218. if ( $akismet_last_comment['akismet_result'] == 'true' ) {
  219. update_comment_meta( $comment->comment_ID, 'akismet_result', 'true' );
  220. akismet_update_comment_history( $comment->comment_ID, __('Akismet caught this comment as spam'), 'check-spam' );
  221. if ( $comment->comment_approved != 'spam' )
  222. akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed'.$comment->comment_approved );
  223. } elseif ( $akismet_last_comment['akismet_result'] == 'false' ) {
  224. update_comment_meta( $comment->comment_ID, 'akismet_result', 'false' );
  225. akismet_update_comment_history( $comment->comment_ID, __('Akismet cleared this comment'), 'check-ham' );
  226. if ( $comment->comment_approved == 'spam' ) {
  227. if ( wp_blacklist_check($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent) )
  228. akismet_update_comment_history( $comment->comment_ID, __('Comment was caught by wp_blacklist_check'), 'wp-blacklisted' );
  229. else
  230. akismet_update_comment_history( $comment->comment_ID, sprintf( __('Comment status was changed to %s'), $comment->comment_approved), 'status-changed-'.$comment->comment_approved );
  231. }
  232. // abnormal result: error
  233. } else {
  234. update_comment_meta( $comment->comment_ID, 'akismet_error', time() );
  235. akismet_update_comment_history( $comment->comment_ID, sprintf( __('Akismet was unable to check this comment (response: %s), will automatically retry again later.'), $akismet_last_comment['akismet_result']), 'check-error' );
  236. }
  237. // record the complete original data as submitted for checking
  238. if ( isset($akismet_last_comment['comment_as_submitted']) )
  239. update_comment_meta( $comment->comment_ID, 'akismet_as_submitted', $akismet_last_comment['comment_as_submitted'] );
  240. }
  241. }
  242. }
  243. add_action( 'wp_insert_comment', 'akismet_auto_check_update_meta', 10, 2 );
  244. function akismet_auto_check_comment( $commentdata ) {
  245. global $akismet_api_host, $akismet_api_port, $akismet_last_comment;
  246. $comment = $commentdata;
  247. $comment['user_ip'] = $_SERVER['REMOTE_ADDR'];
  248. $comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
  249. $comment['referrer'] = $_SERVER['HTTP_REFERER'];
  250. $comment['blog'] = get_option('home');
  251. $comment['blog_lang'] = get_locale();
  252. $comment['blog_charset'] = get_option('blog_charset');
  253. $comment['permalink'] = get_permalink($comment['comment_post_ID']);
  254. if ( !empty( $comment['user_ID'] ) ) {
  255. $comment['user_role'] = akismet_get_user_roles($comment['user_ID']);
  256. }
  257. $akismet_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
  258. $comment['akismet_comment_nonce'] = 'inactive';
  259. if ( $akismet_nonce_option == 'true' || $akismet_nonce_option == '' ) {
  260. $comment['akismet_comment_nonce'] = 'failed';
  261. if ( isset( $_POST['akismet_comment_nonce'] ) && wp_verify_nonce( $_POST['akismet_comment_nonce'], 'akismet_comment_nonce_' . $comment['comment_post_ID'] ) )
  262. $comment['akismet_comment_nonce'] = 'passed';
  263. // comment reply in wp-admin
  264. if ( isset( $_POST['_ajax_nonce-replyto-comment'] ) && check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' ) )
  265. $comment['akismet_comment_nonce'] = 'passed';
  266. }
  267. if ( akismet_test_mode() )
  268. $comment['is_test'] = 'true';
  269. foreach ($_POST as $key => $value ) {
  270. if ( is_string($value) )
  271. $comment["POST_{$key}"] = $value;
  272. }
  273. $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
  274. foreach ( $_SERVER as $key => $value ) {
  275. if ( !in_array( $key, $ignore ) && is_string($value) )
  276. $comment["$key"] = $value;
  277. else
  278. $comment["$key"] = '';
  279. }
  280. $post = get_post( $comment['comment_post_ID'] );
  281. $comment[ 'comment_post_modified_gmt' ] = $post->post_modified_gmt;
  282. $query_string = '';
  283. foreach ( $comment as $key => $data )
  284. $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
  285. $commentdata['comment_as_submitted'] = $comment;
  286. $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
  287. $commentdata['akismet_result'] = $response[1];
  288. if ( 'true' == $response[1] ) {
  289. // akismet_spam_count will be incremented later by akismet_result_spam()
  290. add_filter('pre_comment_approved', 'akismet_result_spam');
  291. do_action( 'akismet_spam_caught' );
  292. $last_updated = strtotime( $post->post_modified_gmt );
  293. $diff = time() - $last_updated;
  294. $diff = $diff / 86400;
  295. if ( $post->post_type == 'post' && $diff > 30 && get_option( 'akismet_discard_month' ) == 'true' && empty($comment['user_ID']) ) {
  296. // akismet_result_spam() won't be called so bump the counter here
  297. if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
  298. update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
  299. wp_safe_redirect( $_SERVER['HTTP_REFERER'] );
  300. die();
  301. }
  302. }
  303. // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
  304. if ( 'true' != $response[1] && 'false' != $response[1] ) {
  305. if ( !wp_get_current_user() ) {
  306. add_filter('pre_comment_approved', 'akismet_result_hold');
  307. }
  308. wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
  309. }
  310. if ( function_exists('wp_next_scheduled') && function_exists('wp_schedule_event') ) {
  311. // WP 2.1+: delete old comments daily
  312. if ( !wp_next_scheduled('akismet_scheduled_delete') )
  313. wp_schedule_event(time(), 'daily', 'akismet_scheduled_delete');
  314. } elseif ( (mt_rand(1, 10) == 3) ) {
  315. // WP 2.0: run this one time in ten
  316. akismet_delete_old();
  317. }
  318. $akismet_last_comment = $commentdata;
  319. return $commentdata;
  320. }
  321. add_action('preprocess_comment', 'akismet_auto_check_comment', 1);
  322. function akismet_delete_old() {
  323. global $wpdb;
  324. $now_gmt = current_time('mysql', 1);
  325. $comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = 'spam'");
  326. if ( empty( $comment_ids ) )
  327. return;
  328. $comma_comment_ids = implode( ', ', array_map('intval', $comment_ids) );
  329. do_action( 'delete_comment', $comment_ids );
  330. $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_id IN ( $comma_comment_ids )");
  331. $wpdb->query("DELETE FROM $wpdb->commentmeta WHERE comment_id IN ( $comma_comment_ids )");
  332. clean_comment_cache( $comment_ids );
  333. $n = mt_rand(1, 5000);
  334. if ( apply_filters('akismet_optimize_table', ($n == 11)) ) // lucky number
  335. $wpdb->query("OPTIMIZE TABLE $wpdb->comments");
  336. }
  337. function akismet_delete_old_metadata() {
  338. global $wpdb;
  339. $now_gmt = current_time( 'mysql', 1 );
  340. $interval = apply_filters( 'akismet_delete_commentmeta_interval', 15 );
  341. # enfore a minimum of 1 day
  342. $interval = absint( $interval );
  343. if ( $interval < 1 ) {
  344. return;
  345. }
  346. // akismet_as_submitted meta values are large, so expire them
  347. // after $interval days regardless of the comment status
  348. while ( TRUE ) {
  349. $comment_ids = $wpdb->get_col( "SELECT $wpdb->comments.comment_id FROM $wpdb->commentmeta INNER JOIN $wpdb->comments USING(comment_id) WHERE meta_key = 'akismet_as_submitted' AND DATE_SUB('$now_gmt', INTERVAL {$interval} DAY) > comment_date_gmt LIMIT 10000" );
  350. if ( empty( $comment_ids ) ) {
  351. return;
  352. }
  353. foreach ( $comment_ids as $comment_id ) {
  354. delete_comment_meta( $comment_id, 'akismet_as_submitted' );
  355. }
  356. }
  357. /*
  358. $n = mt_rand( 1, 5000 );
  359. if ( apply_filters( 'akismet_optimize_table', ( $n == 11 ), 'commentmeta' ) ) { // lucky number
  360. $wpdb->query( "OPTIMIZE TABLE $wpdb->commentmeta" );
  361. }
  362. */
  363. }
  364. add_action('akismet_scheduled_delete', 'akismet_delete_old');
  365. add_action('akismet_scheduled_delete', 'akismet_delete_old_metadata');
  366. function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
  367. global $wpdb, $akismet_api_host, $akismet_api_port;
  368. $id = (int) $id;
  369. $c = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID = '$id'", ARRAY_A );
  370. if ( !$c )
  371. return;
  372. $c['user_ip'] = $c['comment_author_IP'];
  373. $c['user_agent'] = $c['comment_agent'];
  374. $c['referrer'] = '';
  375. $c['blog'] = get_option('home');
  376. $c['blog_lang'] = get_locale();
  377. $c['blog_charset'] = get_option('blog_charset');
  378. $c['permalink'] = get_permalink($c['comment_post_ID']);
  379. $id = $c['comment_ID'];
  380. if ( akismet_test_mode() )
  381. $c['is_test'] = 'true';
  382. $c['recheck_reason'] = $recheck_reason;
  383. $query_string = '';
  384. foreach ( $c as $key => $data )
  385. $query_string .= $key . '=' . urlencode( stripslashes($data) ) . '&';
  386. $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port);
  387. return $response[1];
  388. }
  389. function akismet_cron_recheck() {
  390. global $wpdb;
  391. delete_option('akismet_available_servers');
  392. $comment_errors = $wpdb->get_col( "
  393. SELECT comment_id
  394. FROM {$wpdb->prefix}commentmeta
  395. WHERE meta_key = 'akismet_error'
  396. LIMIT 100
  397. " );
  398. foreach ( (array) $comment_errors as $comment_id ) {
  399. // if the comment no longer exists, remove the meta entry from the queue to avoid getting stuck
  400. if ( !get_comment( $comment_id ) ) {
  401. delete_comment_meta( $comment_id, 'akismet_error' );
  402. continue;
  403. }
  404. add_comment_meta( $comment_id, 'akismet_rechecking', true );
  405. $status = akismet_check_db_comment( $comment_id, 'retry' );
  406. $msg = '';
  407. if ( $status == 'true' ) {
  408. $msg = __( 'Akismet caught this comment as spam during an automatic retry.' );
  409. } elseif ( $status == 'false' ) {
  410. $msg = __( 'Akismet cleared this comment during an automatic retry.' );
  411. }
  412. // If we got back a legit response then update the comment history
  413. // other wise just bail now and try again later. No point in
  414. // re-trying all the comments once we hit one failure.
  415. if ( !empty( $msg ) ) {
  416. delete_comment_meta( $comment_id, 'akismet_error' );
  417. akismet_update_comment_history( $comment_id, $msg, 'cron-retry' );
  418. update_comment_meta( $comment_id, 'akismet_result', $status );
  419. // make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
  420. $comment = get_comment( $comment_id );
  421. if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
  422. if ( $status == 'true' ) {
  423. wp_spam_comment( $comment_id );
  424. } elseif ( $status == 'false' ) {
  425. // comment is good, but it's still in the pending queue. depending on the moderation settings
  426. // we may need to change it to approved.
  427. if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) )
  428. wp_set_comment_status( $comment_id, 1 );
  429. }
  430. }
  431. } else {
  432. delete_comment_meta( $comment_id, 'akismet_rechecking' );
  433. wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
  434. return;
  435. }
  436. }
  437. $remaining = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
  438. if ( $remaining && !wp_next_scheduled('akismet_schedule_cron_recheck') ) {
  439. wp_schedule_single_event( time() + 1200, 'akismet_schedule_cron_recheck' );
  440. }
  441. }
  442. add_action( 'akismet_schedule_cron_recheck', 'akismet_cron_recheck' );
  443. function akismet_add_comment_nonce( $post_id ) {
  444. echo '<p style="display: none;">';
  445. wp_nonce_field( 'akismet_comment_nonce_' . $post_id, 'akismet_comment_nonce', FALSE );
  446. echo '</p>';
  447. }
  448. $akismet_comment_nonce_option = apply_filters( 'akismet_comment_nonce', get_option( 'akismet_comment_nonce' ) );
  449. if ( $akismet_comment_nonce_option == 'true' || $akismet_comment_nonce_option == '' )
  450. add_action( 'comment_form', 'akismet_add_comment_nonce' );
  451. if ( '3.0.5' == $wp_version ) {
  452. remove_filter( 'comment_text', 'wp_kses_data' );
  453. if ( is_admin() )
  454. add_filter( 'comment_text', 'wp_kses_post' );
  455. }