Antispam Bee - Version 2.6.3

Version Description

  • English

    • Sorting for the Antispam Bee column in the spam comments overview
    • Code refactoring around the use of REQUEST_URI
    • Release time investment (Development & QA): 2,75 h
  • Deutsch

    • Sortierung fr die Antispam Bee Spalte in der Spam-bersicht
    • Code-Refactoring rund um die Nutzung von REQUEST_URI
    • Release-Zeitaufwand (Development & QA): 2,75 Stunden
Download this release

Release Info

Developer sergej.mueller
Plugin Icon 128x128 Antispam Bee
Version 2.6.3
Comparing to
See all releases

Code changes from version 2.6.2 to 2.6.3

Files changed (3) hide show
  1. antispam_bee.php +51 -31
  2. inc/columns.class.php +44 -1
  3. readme.txt +14 -1
antispam_bee.php CHANGED
@@ -8,7 +8,7 @@ Author: Sergej Müller
8
  Author URI: http://wpcoder.de
9
  Plugin URI: http://antispambee.com
10
  License: GPLv2 or later
11
- Version: 2.6.2
12
  */
13
 
14
  /*
@@ -57,7 +57,7 @@ class Antispam_Bee {
57
  * "Konstruktor" der Klasse
58
  *
59
  * @since 0.1
60
- * @change 2.6.1
61
  */
62
 
63
  public static function init()
@@ -210,6 +210,21 @@ class Antispam_Bee {
210
  'print_column_styles'
211
  )
212
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  }
214
  }
215
 
@@ -1072,27 +1087,30 @@ class Antispam_Bee {
1072
  * Überprüfung der POST-Werte
1073
  *
1074
  * @since 0.1
1075
- * @change 2.4.2
1076
  */
1077
 
1078
  public static function precheck_incoming_request()
1079
  {
1080
- /* Nur Frontend */
1081
- if ( is_feed() or is_trackback() or self::_is_mobile() ) {
1082
  return;
1083
  }
1084
 
1085
- /* Allgemeine Werte */
1086
- $request_url = self::get_key($_SERVER, 'REQUEST_URI');
1087
- $hidden_field = self::get_key($_POST, 'comment');
1088
- $plugin_field = self::get_key($_POST, self::$_secret);
1089
 
1090
- /* Falsch verbunden */
1091
- if ( empty($_POST) or empty($request_url) or strpos($request_url, 'wp-comments-post.php') === false ) {
1092
  return;
1093
  }
1094
 
1095
- /* Felder prüfen */
 
 
 
 
1096
  if ( empty($hidden_field) && !empty($plugin_field) ) {
1097
  $_POST['comment'] = $plugin_field;
1098
  unset($_POST[self::$_secret]);
@@ -1106,7 +1124,7 @@ class Antispam_Bee {
1106
  * Prüfung der eingehenden Anfragen auf Spam
1107
  *
1108
  * @since 0.1
1109
- * @change 2.6.1
1110
  *
1111
  * @param array $comment Unbehandelter Kommentar
1112
  * @return array $comment Behandelter Kommentar
@@ -1117,6 +1135,7 @@ class Antispam_Bee {
1117
  /* Add client IP */
1118
  $comment['comment_author_IP'] = self::get_client_ip();
1119
 
 
1120
  add_filter(
1121
  'pre_comment_user_ip',
1122
  array(
@@ -1125,43 +1144,44 @@ class Antispam_Bee {
1125
  )
1126
  );
1127
 
1128
- /* Server-Werte */
1129
- $url = self::get_key($_SERVER, 'REQUEST_URI');
 
1130
 
1131
- /* Leere Werte? */
1132
- if ( empty($url) ) {
1133
  return self::_handle_spam_request(
1134
  $comment,
1135
  'empty'
1136
  );
1137
  }
1138
 
1139
- /* Ping-Optionen */
1140
  $ping = array(
1141
  'types' => array('pingback', 'trackback', 'pings'),
1142
  'allowed' => !self::get_option('ignore_pings')
1143
  );
1144
 
1145
- /* Kommentar */
1146
- if ( strpos($url, 'wp-comments-post.php') !== false && !empty($_POST) ) {
1147
- /* Filter ausführen */
1148
  $status = self::_verify_comment_request($comment);
1149
 
1150
- /* Spam lokalisiert */
1151
- if ( !empty($status['reason']) ) {
1152
  return self::_handle_spam_request(
1153
  $comment,
1154
  $status['reason']
1155
  );
1156
  }
1157
 
1158
- /* Trackback */
1159
  } else if ( in_array(self::get_key($comment, 'comment_type'), $ping['types']) && $ping['allowed'] ) {
1160
- /* Filter ausführen */
1161
  $status = self::_verify_trackback_request($comment);
1162
 
1163
- /* Spam lokalisiert */
1164
- if ( !empty($status['reason']) ) {
1165
  return self::_handle_spam_request(
1166
  $comment,
1167
  $status['reason'],
@@ -1253,7 +1273,7 @@ class Antispam_Bee {
1253
  $body = self::get_key($comment, 'comment_content');
1254
 
1255
  /* Leere Werte ? */
1256
- if ( empty($url) or empty($body) ) {
1257
  return array(
1258
  'reason' => 'empty'
1259
  );
@@ -1605,7 +1625,7 @@ class Antispam_Bee {
1605
  }
1606
 
1607
  /* IP abfragen */
1608
- $response = wp_remote_get(
1609
  esc_url_raw(
1610
  sprintf(
1611
  'https://geoip.maxmind.com/a?l=%s&i=%s',
@@ -1652,7 +1672,7 @@ class Antispam_Bee {
1652
  private static function _is_dnsbl_spam($ip)
1653
  {
1654
  /* Start request */
1655
- $response = wp_remote_get(
1656
  esc_url_raw(
1657
  sprintf(
1658
  'http://www.stopforumspam.com/api?ip=%s&f=json',
@@ -1806,7 +1826,7 @@ class Antispam_Bee {
1806
  );
1807
 
1808
  /* IP abfragen */
1809
- $response = wp_remote_get(
1810
  esc_url_raw(
1811
  sprintf(
1812
  'https://translate.google.com/translate_a/t?client=x&text=%s',
8
  Author URI: http://wpcoder.de
9
  Plugin URI: http://antispambee.com
10
  License: GPLv2 or later
11
+ Version: 2.6.3
12
  */
13
 
14
  /*
57
  * "Konstruktor" der Klasse
58
  *
59
  * @since 0.1
60
+ * @change 2.6.3
61
  */
62
 
63
  public static function init()
210
  'print_column_styles'
211
  )
212
  );
213
+
214
+ add_filter(
215
+ 'manage_edit-comments_sortable_columns',
216
+ array(
217
+ 'Antispam_Bee_Columns',
218
+ 'register_sortable_columns'
219
+ )
220
+ );
221
+ add_action(
222
+ 'pre_get_posts',
223
+ array(
224
+ 'Antispam_Bee_Columns',
225
+ 'set_orderby_query'
226
+ )
227
+ );
228
  }
229
  }
230
 
1087
  * Überprüfung der POST-Werte
1088
  *
1089
  * @since 0.1
1090
+ * @change 2.6.3
1091
  */
1092
 
1093
  public static function precheck_incoming_request()
1094
  {
1095
+ /* Skip if not a comment request */
1096
+ if ( is_feed() OR is_trackback() OR empty($_POST) OR self::_is_mobile() ) {
1097
  return;
1098
  }
1099
 
1100
+ /* Request params */
1101
+ $request_uri = self::get_key($_SERVER, 'REQUEST_URI');
1102
+ $request_path = parse_url($request_uri, PHP_URL_PATH);
 
1103
 
1104
+ /* Request check */
1105
+ if ( strpos($request_path, 'wp-comments-post.php') === false ) {
1106
  return;
1107
  }
1108
 
1109
+ /* Form fields */
1110
+ $hidden_field = self::get_key($_POST, 'comment');
1111
+ $plugin_field = self::get_key($_POST, self::$_secret);
1112
+
1113
+ /* Fields check */
1114
  if ( empty($hidden_field) && !empty($plugin_field) ) {
1115
  $_POST['comment'] = $plugin_field;
1116
  unset($_POST[self::$_secret]);
1124
  * Prüfung der eingehenden Anfragen auf Spam
1125
  *
1126
  * @since 0.1
1127
+ * @change 2.6.3
1128
  *
1129
  * @param array $comment Unbehandelter Kommentar
1130
  * @return array $comment Behandelter Kommentar
1135
  /* Add client IP */
1136
  $comment['comment_author_IP'] = self::get_client_ip();
1137
 
1138
+ /* Hook client IP */
1139
  add_filter(
1140
  'pre_comment_user_ip',
1141
  array(
1144
  )
1145
  );
1146
 
1147
+ /* Request params */
1148
+ $request_uri = self::get_key($_SERVER, 'REQUEST_URI');
1149
+ $request_path = parse_url($request_uri, PHP_URL_PATH);
1150
 
1151
+ /* Empty path? */
1152
+ if ( empty($request_path) ) {
1153
  return self::_handle_spam_request(
1154
  $comment,
1155
  'empty'
1156
  );
1157
  }
1158
 
1159
+ /* Defaults */
1160
  $ping = array(
1161
  'types' => array('pingback', 'trackback', 'pings'),
1162
  'allowed' => !self::get_option('ignore_pings')
1163
  );
1164
 
1165
+ /* Is a comment */
1166
+ if ( strpos($request_path, 'wp-comments-post.php') !== false && ! empty($_POST) ) {
1167
+ /* Verify request */
1168
  $status = self::_verify_comment_request($comment);
1169
 
1170
+ /* Treat the request as spam */
1171
+ if ( ! empty($status['reason']) ) {
1172
  return self::_handle_spam_request(
1173
  $comment,
1174
  $status['reason']
1175
  );
1176
  }
1177
 
1178
+ /* Is a trackback */
1179
  } else if ( in_array(self::get_key($comment, 'comment_type'), $ping['types']) && $ping['allowed'] ) {
1180
+ /* Verify request */
1181
  $status = self::_verify_trackback_request($comment);
1182
 
1183
+ /* Treat the request as spam */
1184
+ if ( ! empty($status['reason']) ) {
1185
  return self::_handle_spam_request(
1186
  $comment,
1187
  $status['reason'],
1273
  $body = self::get_key($comment, 'comment_content');
1274
 
1275
  /* Leere Werte ? */
1276
+ if ( empty($url) OR empty($body) ) {
1277
  return array(
1278
  'reason' => 'empty'
1279
  );
1625
  }
1626
 
1627
  /* IP abfragen */
1628
+ $response = wp_safe_remote_request(
1629
  esc_url_raw(
1630
  sprintf(
1631
  'https://geoip.maxmind.com/a?l=%s&i=%s',
1672
  private static function _is_dnsbl_spam($ip)
1673
  {
1674
  /* Start request */
1675
+ $response = wp_safe_remote_request(
1676
  esc_url_raw(
1677
  sprintf(
1678
  'http://www.stopforumspam.com/api?ip=%s&f=json',
1826
  );
1827
 
1828
  /* IP abfragen */
1829
+ $response = wp_safe_remote_request(
1830
  esc_url_raw(
1831
  sprintf(
1832
  'https://translate.google.com/translate_a/t?client=x&text=%s',
inc/columns.class.php CHANGED
@@ -51,7 +51,7 @@ final class Antispam_Bee_Columns {
51
  }
52
 
53
  /* Init data */
54
- $spam_reason = get_comment_meta($comment_id, $column , true);
55
  $spam_reasons = Antispam_Bee::$defaults['reasons'];
56
 
57
  /* Empty values? */
@@ -67,6 +67,49 @@ final class Antispam_Bee_Columns {
67
  }
68
 
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  /**
71
  * Print CSS for the plugin column
72
  *
51
  }
52
 
53
  /* Init data */
54
+ $spam_reason = get_comment_meta($comment_id, $column, true);
55
  $spam_reasons = Antispam_Bee::$defaults['reasons'];
56
 
57
  /* Empty values? */
67
  }
68
 
69
 
70
+ /**
71
+ * Register plugin sortable columns on comments screen
72
+ *
73
+ * @since 2.6.3
74
+ * @change 2.6.3
75
+ *
76
+ * @param array $columns Registered columns
77
+ * @return array $columns Columns with AB field
78
+ */
79
+
80
+ public static function register_sortable_columns($columns)
81
+ {
82
+ $columns['antispam_bee_reason'] = 'antispam_bee_reason';
83
+
84
+ return $columns;
85
+ }
86
+
87
+
88
+ /**
89
+ * Adjust orderby query
90
+ *
91
+ * @since 2.6.3
92
+ * @change 2.6.3
93
+ *
94
+ * @param object $query Current WordPress query
95
+ */
96
+
97
+ public static function set_orderby_query($query)
98
+ {
99
+ /* Order by value */
100
+ $orderby = $query->get('orderby');
101
+
102
+ /* Skip if not our case */
103
+ if ( empty($orderby) OR $orderby !== 'antispam_bee_reason' ) {
104
+ return;
105
+ }
106
+
107
+ /* Set orderby values */
108
+ $query->set( 'meta_key', 'antispam_bee_reason' );
109
+ $query->set( 'orderby', 'meta_value' );
110
+ }
111
+
112
+
113
  /**
114
  * Print CSS for the plugin column
115
  *
readme.txt CHANGED
@@ -79,8 +79,8 @@ Fragen rund ums Plugin werden gern per E-Mail beantwortet. Beachtet auch die [Gu
79
 
80
 
81
  = Unterstützung =
82
- * [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN)
83
  * [Flattr](https://flattr.com/t/1323822)
 
84
  * [Wishlist](https://www.amazon.de/registry/wishlist/2U5I7F9649LOJ/)
85
 
86
 
@@ -104,6 +104,19 @@ Fragen rund ums Plugin werden gern per E-Mail beantwortet. Beachtet auch die [Gu
104
 
105
  == Changelog ==
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  = 2.6.2 =
108
 
109
  * **English**
79
 
80
 
81
  = Unterstützung =
 
82
  * [Flattr](https://flattr.com/t/1323822)
83
+ * [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN)
84
  * [Wishlist](https://www.amazon.de/registry/wishlist/2U5I7F9649LOJ/)
85
 
86
 
104
 
105
  == Changelog ==
106
 
107
+ = 2.6.3 =
108
+
109
+ * **English**
110
+ * Sorting for the Antispam Bee column in the spam comments overview
111
+ * Code refactoring around the use of REQUEST_URI
112
+ * *Release time investment (Development & QA): 2,75 h*
113
+
114
+ * **Deutsch**
115
+ * Sortierung für die Antispam Bee Spalte in der Spam-Übersicht
116
+ * Code-Refactoring rund um die Nutzung von REQUEST_URI
117
+ * *Release-Zeitaufwand (Development & QA): 2,75 Stunden*
118
+
119
+
120
  = 2.6.2 =
121
 
122
  * **English**