Spam protection, AntiSpam, FireWall by CleanTalk - Version 2.4.17

Version Description

Download this release

Release Info

Developer shagimuratov
Plugin Icon 128x128 Spam protection, AntiSpam, FireWall by CleanTalk
Version 2.4.17
Comparing to
See all releases

Code changes from version 2.4.15 to 2.4.17

Files changed (2) hide show
  1. cleantalk.php +232 -17
  2. i18n/cleantalk-ru_RU.mo +0 -0
cleantalk.php CHANGED
@@ -2,19 +2,22 @@
2
  /*
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org/wordpress
5
- Description: It's cloud, invisible, smart antispam for your blog. The plugin doesn't use CAPTCHA, Q&A, math to stop spam bots.
6
- Version: 2.4.15
7
- Author: СleanTalk team <welcome@cleantalk.ru>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
- $ct_agent_version = 'wordpress-2415';
 
12
 
13
  add_action('init', 'ct_init_locale');
14
  add_action('comment_form', 'ct_add_hidden_fields');
15
  add_action('parse_request', 'ct_set_session');
16
  add_action('admin_notices', 'admin_notice_message');
17
  add_filter('preprocess_comment', 'ct_check'); // param - comment data array
 
 
18
 
19
  if (is_admin()) {
20
  add_action('admin_init', 'ct_admin_init');
@@ -48,7 +51,11 @@ function ct_def_options() {
48
  return array(
49
  'server' => 'http://moderate.cleantalk.ru',
50
  'apikey' => __('enter key', 'cleantalk'),
51
- 'autoPubRevelantMess' => '1'
 
 
 
 
52
  );
53
  }
54
 
@@ -166,10 +173,12 @@ function ct_init_locale() {
166
  function ct_add_hidden_fields($post_id = 0) {
167
  $ct_checkjs_def = 0;
168
  $ct_checkjs_key = ct_get_checkjs_value();
169
-
170
- if (ct_is_user_enable() === false) {
 
171
  return false;
172
  }
 
173
  ?>
174
  <input type="hidden" id="ct_checkjs" name="ct_checkjs" value="0">
175
  <script type="text/javascript">
@@ -185,7 +194,8 @@ function ct_add_hidden_fields($post_id = 0) {
185
  */
186
  function ct_set_session() {
187
 
188
- if (ct_is_user_enable() === false) {
 
189
  return false;
190
  }
191
  // this action is called any time WP process GET request (shows any page)
@@ -214,6 +224,118 @@ function ct_is_user_enable() {
214
 
215
  return true;
216
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  /**
218
  * Public filter 'preprocess_comment' - Checks comment by cleantalk server
219
  * @param mixed[] $comment Comment data array
@@ -225,7 +347,8 @@ function ct_check($comment) {
225
  // after processing WP makes redirect to post page with comment's form by GET request (see above)
226
  global $wpdb, $current_user, $comment_post_id, $ct_agent_version;
227
 
228
- if (ct_is_user_enable() === false) {
 
229
  return $comment;
230
  }
231
 
@@ -242,8 +365,6 @@ function ct_check($comment) {
242
  return $comment;
243
  }
244
 
245
- $options = ct_get_options();
246
-
247
  $comment_post_id = $comment['comment_post_ID'];
248
 
249
  $post = get_post($comment_post_id);
@@ -289,7 +410,7 @@ function ct_check($comment) {
289
  $example['body'] = $post->post_content;
290
  $example['comments'] = null;
291
 
292
- $last_comments = get_comments(array('status' => 'approve', 'number' >= 10, 'post_id' => $comment_post_id));
293
  foreach ($last_comments as $post_comment){
294
  $example['comments'] .= "\n\n" . $post_comment->comment_content;
295
  }
@@ -472,6 +593,9 @@ function ct_comment_approved($comment_object) {
472
  $comment['comment_content'] = ct_feedback($hash, $comment['comment_content'], 1);
473
  $comment['comment_approved'] = 1;
474
  wp_update_comment($comment);
 
 
 
475
  return true;
476
  }
477
 
@@ -486,6 +610,9 @@ function ct_comment_unapproved($comment_object) {
486
  ct_feedback($hash, $comment['comment_content'], 0);
487
  $comment['comment_approved'] = 0;
488
  wp_update_comment($comment);
 
 
 
489
  return true;
490
  }
491
 
@@ -500,6 +627,9 @@ function ct_comment_spam($comment_object) {
500
  ct_feedback($hash, $comment['comment_content'], 0);
501
  $comment['comment_approved'] = 'spam';
502
  wp_update_comment($comment);
 
 
 
503
  return true;
504
  }
505
 
@@ -514,6 +644,9 @@ function ct_unspam_comment($comment_id) {
514
  $hash = get_comment_meta($comment_id, 'ct_hash', true);
515
  $comment['comment_content'] = ct_unmark_red($comment['comment_content']);
516
  $comment['comment_content'] = ct_feedback($hash, $comment['comment_content'], 1);
 
 
 
517
  wp_update_comment($comment);
518
  }
519
 
@@ -556,8 +689,12 @@ function ct_admin_add_page() {
556
  function ct_admin_init() {
557
  register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
558
  add_settings_section('cleantalk_settings_main', __('Main settings', 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
559
- add_settings_field('cleantalk_autoPubRevelantMess', __('Publish relevant comments', 'cleantalk'), 'ct_input_autoPubRevelantMess', 'cleantalk', 'cleantalk_settings_main');
560
  add_settings_field('cleantalk_apikey', __('Access key', 'cleantalk'), 'ct_input_apikey', 'cleantalk', 'cleantalk_settings_main');
 
 
 
 
561
  }
562
 
563
  /**
@@ -567,6 +704,13 @@ function ct_section_settings_main() {
567
  return true;
568
  }
569
 
 
 
 
 
 
 
 
570
  /**
571
  * @author Artem Leontiev
572
  * Admin callback function - Displays inputs of 'Publicate relevant comments' plugin parameter
@@ -576,11 +720,25 @@ function ct_section_settings_main() {
576
  function ct_input_autoPubRevelantMess () {
577
  $options = ct_get_options();
578
  $value = $options['autoPubRevelantMess'];
579
- echo "<input type='radio' id='cleantalk_autoPubRevelantMess0' name='cleantalk_settings[autoPubRevelantMess]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_autoPubRevelantMess0'> " . __('No') . "</label>";
580
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
581
  echo "<input type='radio' id='cleantalk_autoPubRevelantMess1' name='cleantalk_settings[autoPubRevelantMess]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_autoPubRevelantMess1'> " . __('Yes') . "</label>";
 
 
582
  admin_addDescriptionsFields(__('Relevant (not spam) comments will be automatic published at the blog', 'cleantalk'));
583
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
584
 
585
  /**
586
  * Admin callback function - Displays inputs of 'apikey' plugin parameter
@@ -594,6 +752,31 @@ function ct_input_apikey() {
594
  echo "<a target='__blank' style='margin-left: 10px' href='http://cleantalk.org/install/wordpress?step=2'>".__('Click here to get access key', 'cleantalk')."</a>";
595
  }
596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  /**
598
  * Admin callback function - Plugin parameters validator
599
  */
@@ -666,7 +849,7 @@ function admin_notice_message(){
666
  echo '<div class="updated"><p>' . __("Please enter the Access Key in <a href=\"options-general.php?page=cleantalk\">CleanTalk plugin</a> settings to enable protection from spam in comments!", 'cleantalk') . '</p></div>';
667
 
668
  ct_send_feedback();
669
-
670
  return true;
671
  }
672
 
@@ -683,7 +866,6 @@ function admin_addDescriptionsFields($descr = '') {
683
  * Tests plugin activation status
684
  * @return bool
685
  */
686
-
687
  function ct_active(){
688
  $ct_active = false;
689
  foreach (get_option('active_plugins') as $k => $v) {
@@ -693,6 +875,18 @@ function ct_active(){
693
 
694
  return $ct_active;
695
  }
 
 
 
 
 
 
 
 
 
 
 
 
696
 
697
  /**
698
  * Get ct_get_checkjs_value
@@ -704,6 +898,27 @@ function ct_get_checkjs_value() {
704
  return md5($options['apikey'] . '+' . get_settings('admin_email'));
705
  }
706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
707
 
708
 
709
  ?>
2
  /*
3
  Plugin Name: Anti-spam by CleanTalk
4
  Plugin URI: http://cleantalk.org/wordpress
5
+ Description: Invisible antispam for comments and feedback forms. The plugin doesn't use CAPTCHA, Q&A, math or quiz to stop spam bots.
6
+ Version: 2.4.17
7
+ Author: СleanTalk <welcome@cleantalk.ru>
8
  Author URI: http://cleantalk.org
9
  */
10
 
11
+ $ct_agent_version = 'wordpress-2417';
12
+ $ct_checkjs_frm = 'ct_checkjs_frm';
13
 
14
  add_action('init', 'ct_init_locale');
15
  add_action('comment_form', 'ct_add_hidden_fields');
16
  add_action('parse_request', 'ct_set_session');
17
  add_action('admin_notices', 'admin_notice_message');
18
  add_filter('preprocess_comment', 'ct_check'); // param - comment data array
19
+ add_action('frm_validate_entry', 'ct_frm_validate_entry', 20, 2);
20
+ add_action('frm_entries_footer_scripts', 'ct_frm_entries_footer_scripts', 20, 2);
21
 
22
  if (is_admin()) {
23
  add_action('admin_init', 'ct_admin_init');
51
  return array(
52
  'server' => 'http://moderate.cleantalk.ru',
53
  'apikey' => __('enter key', 'cleantalk'),
54
+ 'autoPubRevelantMess' => '1',
55
+ 'comments_test' => '1',
56
+ 'formidable_test' => '1',
57
+ 'remove_old_spam' => '1',
58
+ 'spam_store_days' => '1' // Days before delete comments from folder Spam
59
  );
60
  }
61
 
173
  function ct_add_hidden_fields($post_id = 0) {
174
  $ct_checkjs_def = 0;
175
  $ct_checkjs_key = ct_get_checkjs_value();
176
+
177
+ $options = ct_get_options();
178
+ if (ct_is_user_enable() === false || $options['comments_test'] == 0) {
179
  return false;
180
  }
181
+
182
  ?>
183
  <input type="hidden" id="ct_checkjs" name="ct_checkjs" value="0">
184
  <script type="text/javascript">
194
  */
195
  function ct_set_session() {
196
 
197
+ $options = ct_get_options();
198
+ if (ct_is_user_enable() === false || $options['comments_test'] == 0) {
199
  return false;
200
  }
201
  // this action is called any time WP process GET request (shows any page)
224
 
225
  return true;
226
  }
227
+
228
+ /**
229
+ * Public function - Insert JS code for spam tests
230
+ * return null;
231
+ */
232
+ function ct_frm_entries_footer_scripts($fields, $form) {
233
+ global $current_user, $ct_checkjs_frm;
234
+
235
+ $options = ct_get_options();
236
+ if (ct_is_user_enable() === false || $options['formidable_test'] == 0) {
237
+ return false;
238
+ }
239
+
240
+ $ct_checkjs_key = ct_get_checkjs_value();
241
+ $ct_frm_name = 'form_' . $form->form_key;
242
+
243
+ ?>
244
+
245
+ var input = document.createElement("input");
246
+ input.setAttribute("type", "hidden");
247
+ input.setAttribute("name", "<?php echo $ct_checkjs_frm; ?>");
248
+ input.setAttribute("value", "<?php echo $ct_checkjs_key; ?>");
249
+ document.getElementById("<?php echo $ct_frm_name; ?>").appendChild(input);
250
+
251
+ <?php
252
+ }
253
+
254
+ /**
255
+ * Public function - Test Formidable data for spam activity
256
+ * return @array with errors if spam has found
257
+ */
258
+ function ct_frm_validate_entry ($errors, $values) {
259
+ global $wpdb, $current_user, $ct_agent_version, $ct_checkjs_frm;
260
+
261
+ $options = ct_get_options();
262
+ if (ct_is_user_enable() === false || $options['formidable_test'] == 0) {
263
+ return false;
264
+ }
265
+
266
+ $checkjs = 0;
267
+ if (isset($_POST[$ct_checkjs_frm])) {
268
+ if($_POST[$ct_checkjs_frm] == ct_get_checkjs_value()) {
269
+ $checkjs = 1;
270
+ }
271
+ }
272
+
273
+ require_once('cleantalk.class.php');
274
+
275
+ $example = null;
276
+ $blog_lang = substr(get_locale(), 0, 2);
277
+ $user_info = array(
278
+ 'cms_lang' => $blog_lang,
279
+ 'REFFERRER' => @$_SERVER['HTTP_REFERER'],
280
+ 'USER_AGENT' => @$_SERVER['HTTP_USER_AGENT'],
281
+ );
282
+ $user_info = json_encode($user_info);
283
+ if ($user_info === false)
284
+ $user_info = '';
285
+
286
+ $post_info['comment_type'] = 'feedback';
287
+ $post_info = json_encode($post_info);
288
+ if ($post_info === false)
289
+ $post_info = '';
290
+
291
+ $sender_email = null;
292
+ $message = '';
293
+ foreach ($values['item_meta'] as $v) {
294
+ if (preg_match("/^\S+@\S+\.\S+$/", $v)) {
295
+ $sender_email = $v;
296
+ continue;
297
+ }
298
+ $message .= ' ' . $v;
299
+ }
300
+
301
+ $config = get_option('cleantalk_server');
302
+
303
+ $ct = new Cleantalk();
304
+ $ct->work_url = $config['ct_work_url'];
305
+ $ct->server_url = $options['server'];
306
+ $ct->server_ttl = $config['ct_server_ttl'];
307
+ $ct->server_changed = $config['ct_server_changed'];
308
+
309
+ $ct_request = new CleantalkRequest();
310
+
311
+ $ct_request->auth_key = $options['apikey'];
312
+ $ct_request->message = $message;
313
+ $ct_request->example = $example;
314
+ $ct_request->sender_email = $sender_email;
315
+ $ct_request->sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
316
+ $ct_request->agent = $ct_agent_version;
317
+ $ct_request->sender_info = $user_info;
318
+ $ct_request->js_on = $checkjs;
319
+ $ct_request->post_info = $post_info;
320
+
321
+ $ct_result = $ct->isAllowMessage($ct_request);
322
+ if ($ct->server_change) {
323
+ update_option(
324
+ 'cleantalk_server', array(
325
+ 'ct_work_url' => $ct->work_url,
326
+ 'ct_server_ttl' => $ct->server_ttl,
327
+ 'ct_server_changed' => time()
328
+ )
329
+ );
330
+ }
331
+
332
+ if ($ct_result->spam == 1) {
333
+ $errors['ct_error'] = '<br /><b>' . $ct_result->comment . '</b><br /><br />';
334
+ }
335
+
336
+ return $errors;
337
+ }
338
+
339
  /**
340
  * Public filter 'preprocess_comment' - Checks comment by cleantalk server
341
  * @param mixed[] $comment Comment data array
347
  // after processing WP makes redirect to post page with comment's form by GET request (see above)
348
  global $wpdb, $current_user, $comment_post_id, $ct_agent_version;
349
 
350
+ $options = ct_get_options();
351
+ if (ct_is_user_enable() === false || $options['comments_test'] == 0) {
352
  return $comment;
353
  }
354
 
365
  return $comment;
366
  }
367
 
 
 
368
  $comment_post_id = $comment['comment_post_ID'];
369
 
370
  $post = get_post($comment_post_id);
410
  $example['body'] = $post->post_content;
411
  $example['comments'] = null;
412
 
413
+ $last_comments = get_comments(array('status' => 'approve', 'number' => 10, 'post_id' => $comment_post_id));
414
  foreach ($last_comments as $post_comment){
415
  $example['comments'] .= "\n\n" . $post_comment->comment_content;
416
  }
593
  $comment['comment_content'] = ct_feedback($hash, $comment['comment_content'], 1);
594
  $comment['comment_approved'] = 1;
595
  wp_update_comment($comment);
596
+
597
+ delete_spam_comments();
598
+
599
  return true;
600
  }
601
 
610
  ct_feedback($hash, $comment['comment_content'], 0);
611
  $comment['comment_approved'] = 0;
612
  wp_update_comment($comment);
613
+
614
+ delete_spam_comments();
615
+
616
  return true;
617
  }
618
 
627
  ct_feedback($hash, $comment['comment_content'], 0);
628
  $comment['comment_approved'] = 'spam';
629
  wp_update_comment($comment);
630
+
631
+ delete_spam_comments();
632
+
633
  return true;
634
  }
635
 
644
  $hash = get_comment_meta($comment_id, 'ct_hash', true);
645
  $comment['comment_content'] = ct_unmark_red($comment['comment_content']);
646
  $comment['comment_content'] = ct_feedback($hash, $comment['comment_content'], 1);
647
+
648
+ delete_spam_comments();
649
+
650
  wp_update_comment($comment);
651
  }
652
 
689
  function ct_admin_init() {
690
  register_setting('cleantalk_settings', 'cleantalk_settings', 'ct_settings_validate');
691
  add_settings_section('cleantalk_settings_main', __('Main settings', 'cleantalk'), 'ct_section_settings_main', 'cleantalk');
692
+ add_settings_section('cleantalk_settings_anti_spam', __('Anti-spam settings', 'cleantalk'), 'ct_section_settings_anti_spam', 'cleantalk');
693
  add_settings_field('cleantalk_apikey', __('Access key', 'cleantalk'), 'ct_input_apikey', 'cleantalk', 'cleantalk_settings_main');
694
+ add_settings_field('cleantalk_autoPubRevelantMess', __('Publish relevant comments', 'cleantalk'), 'ct_input_autoPubRevelantMess', 'cleantalk', 'cleantalk_settings_main');
695
+ add_settings_field('cleantalk_remove_old_spam', __('Automatically delete spam comments', 'cleantalk'), 'ct_input_remove_old_spam', 'cleantalk', 'cleantalk_settings_main');
696
+ add_settings_field('cleantalk_comments_test', __('Comments form', 'cleantalk'), 'ct_input_comments_test', 'cleantalk', 'cleantalk_settings_anti_spam');
697
+ add_settings_field('cleantalk_formidable_test', __('Formidable Forms', 'cleantalk'), 'ct_input_formidable_test', 'cleantalk', 'cleantalk_settings_anti_spam');
698
  }
699
 
700
  /**
704
  return true;
705
  }
706
 
707
+ /**
708
+ * Admin callback function - Displays description of 'anti-spam' plugin parameters section
709
+ */
710
+ function ct_section_settings_anti_spam() {
711
+ return true;
712
+ }
713
+
714
  /**
715
  * @author Artem Leontiev
716
  * Admin callback function - Displays inputs of 'Publicate relevant comments' plugin parameter
720
  function ct_input_autoPubRevelantMess () {
721
  $options = ct_get_options();
722
  $value = $options['autoPubRevelantMess'];
 
 
723
  echo "<input type='radio' id='cleantalk_autoPubRevelantMess1' name='cleantalk_settings[autoPubRevelantMess]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_autoPubRevelantMess1'> " . __('Yes') . "</label>";
724
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
725
+ echo "<input type='radio' id='cleantalk_autoPubRevelantMess0' name='cleantalk_settings[autoPubRevelantMess]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_autoPubRevelantMess0'> " . __('No') . "</label>";
726
  admin_addDescriptionsFields(__('Relevant (not spam) comments will be automatic published at the blog', 'cleantalk'));
727
  }
728
+ /**
729
+ * @author Artem Leontiev
730
+ * Admin callback function - Displays inputs of 'Publicate relevant comments' plugin parameter
731
+ *
732
+ * @return null
733
+ */
734
+ function ct_input_remove_old_spam() {
735
+ $options = ct_get_options();
736
+ $value = $options['remove_old_spam'];
737
+ echo "<input type='radio' id='cleantalk_remove_old_spam1' name='cleantalk_settings[remove_old_spam]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam1'> " . __('Yes') . "</label>";
738
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
739
+ echo "<input type='radio' id='cleantalk_remove_old_spam0' name='cleantalk_settings[remove_old_spam]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_remove_old_spam0'> " . __('No') . "</label>";
740
+ admin_addDescriptionsFields(sprintf(__('Delete spam comments older than %d days.', 'cleantalk'), $options['spam_store_days']));
741
+ }
742
 
743
  /**
744
  * Admin callback function - Displays inputs of 'apikey' plugin parameter
752
  echo "<a target='__blank' style='margin-left: 10px' href='http://cleantalk.org/install/wordpress?step=2'>".__('Click here to get access key', 'cleantalk')."</a>";
753
  }
754
 
755
+ /**
756
+ * Admin callback function - Displays inputs of 'formidable_test' plugin parameter
757
+ */
758
+ function ct_input_formidable_test() {
759
+ $options = ct_get_options();
760
+ $value = $options['formidable_test'];
761
+ echo "<input type='radio' id='cleantalk_formidable_test1' name='cleantalk_settings[formidable_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_formidable_test1'> " . __('Yes') . "</label>";
762
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
763
+ echo "<input type='radio' id='cleantalk_formidable_test0' name='cleantalk_settings[formidable_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_formidable_test0'> " . __('No') . "</label>";
764
+ admin_addDescriptionsFields(__('Spam protection for feeback plugin <a href="http://wordpress.org/plugins/formidable/">Formidable Forms</a>', 'cleantalk'));
765
+ }
766
+
767
+ /**
768
+ * Admin callback function - Displays inputs of 'comments_test' plugin parameter
769
+ */
770
+ function ct_input_comments_test() {
771
+ $options = ct_get_options();
772
+ $value = $options['comments_test'];
773
+ echo "<input type='radio' id='cleantalk_comments_test1' name='cleantalk_settings[comments_test]' value='1' " . ($value == '1' ? 'checked' : '') . " /><label for='cleantalk_comments_test1'> " . __('Yes') . "</label>";
774
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
775
+ echo "<input type='radio' id='cleantalk_comments_test0' name='cleantalk_settings[comments_test]' value='0' " . ($value == '0' ? 'checked' : '') . " /><label for='cleantalk_comments_test0'> " . __('No') . "</label>";
776
+ admin_addDescriptionsFields(__('Spam protection WordPress comments', 'cleantalk'));
777
+ }
778
+
779
+
780
  /**
781
  * Admin callback function - Plugin parameters validator
782
  */
849
  echo '<div class="updated"><p>' . __("Please enter the Access Key in <a href=\"options-general.php?page=cleantalk\">CleanTalk plugin</a> settings to enable protection from spam in comments!", 'cleantalk') . '</p></div>';
850
 
851
  ct_send_feedback();
852
+
853
  return true;
854
  }
855
 
866
  * Tests plugin activation status
867
  * @return bool
868
  */
 
869
  function ct_active(){
870
  $ct_active = false;
871
  foreach (get_option('active_plugins') as $k => $v) {
875
 
876
  return $ct_active;
877
  }
878
+ /**
879
+ * Tests plugin activation status
880
+ * @return bool
881
+ */
882
+ function ct_plugin_active($plugin_name){
883
+ $active = false;
884
+ foreach (get_option('active_plugins') as $k => $v) {
885
+ if ($plugin_name == $v)
886
+ $active = true;
887
+ }
888
+ return $active;
889
+ }
890
 
891
  /**
892
  * Get ct_get_checkjs_value
898
  return md5($options['apikey'] . '+' . get_settings('admin_email'));
899
  }
900
 
901
+ /**
902
+ * Delete old spam comments
903
+ * @return null
904
+ */
905
+ function delete_spam_comments() {
906
+ $options = ct_get_options();
907
+
908
+ if ($options['remove_old_spam'] == 1) {
909
+ $last_comments = get_comments(array('status' => 'spam', 'number' => 1000, 'order' => 'ASC'));
910
+ foreach ($last_comments as $c) {
911
+ if (time() - strtotime($c->comment_date_gmt) > 86400 * $options['spam_store_days']) {
912
+ // Force deletion old spam comments
913
+ wp_delete_comment($c->comment_ID, true);
914
+ }
915
+ }
916
+ }
917
+
918
+
919
+ return null;
920
+ }
921
+
922
 
923
 
924
  ?>
i18n/cleantalk-ru_RU.mo CHANGED
Binary file