| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | return false; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | $settings = get_option('_fluentform_global_form_settings'); |
| 18 | - return $settings && ArrayHelper::get($settings, 'misc.akismet_status') == 'yes'; | |
| 18 | + return $settings && 'yes' == ArrayHelper::get($settings, 'misc.akismet_status'); | |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public static function isPluginEnabled() |
| 22 | 22 | { |
| @@ -30,35 +30,35 @@ | ||
| 30 | 30 | public static function isSpamSubmission($formData, $form) |
| 31 | 31 | { |
| 32 | 32 | global $akismet_api_host, $akismet_api_port; |
| 33 | 33 | $fields = self::getAkismetFields($formData, $form); |
| 34 | - $response = \Akismet::http_post( $fields, 'comment-check' ); | |
| 34 | + $response = \Akismet::http_post($fields, 'comment-check'); | |
| 35 | 35 | |
| 36 | - return ArrayHelper::get($response, 1) == 'true'; | |
| 36 | + return 'true' == ArrayHelper::get($response, 1); | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | protected static function getAkismetFields($data, $form) |
| 40 | 40 | { |
| 41 | 41 | $app = wpFluentForm(); |
| 42 | - $ip = $app->request->getIp(); | |
| 42 | + $ip = sanitize_text_field($app->request->getIp()); | |
| 43 | 43 | |
| 44 | 44 | $info = [ |
| 45 | - 'comment_type' => 'contact-form', | |
| 46 | - 'comment_author' => '', | |
| 45 | + 'comment_type' => 'contact-form', | |
| 46 | + 'comment_author' => '', | |
| 47 | 47 | 'comment_author_email' => '', |
| 48 | - 'comment_content' => '', | |
| 48 | + 'comment_content' => '', | |
| 49 | 49 | 'contact_form_subject' => $form->title, |
| 50 | - 'comment_author_IP' => $ip, | |
| 51 | - 'permalink' => urlencode($data['_wp_http_referer']), | |
| 52 | - 'user_ip' => preg_replace('/[^0-9., ]/', '', $ip), | |
| 53 | - 'user_agent' => $app->request->header('USER_AGENT'), | |
| 54 | - 'blog' => get_option('home') | |
| 50 | + 'comment_author_IP' => $ip, | |
| 51 | + 'permalink' => urlencode($data['_wp_http_referer']), | |
| 52 | + 'user_ip' => preg_replace('/[^0-9., ]/', '', $ip), | |
| 53 | + 'user_agent' => $app->request->header('USER_AGENT'), | |
| 54 | + 'blog' => get_option('home'), | |
| 55 | 55 | ]; |
| 56 | 56 | |
| 57 | 57 | $maps = [ |
| 58 | - 'input_name' => 'comment_author', | |
| 58 | + 'input_name' => 'comment_author', | |
| 59 | 59 | 'input_email' => 'comment_author_email', |
| 60 | - 'textarea' => 'comment_content' | |
| 60 | + 'textarea' => 'comment_content', | |
| 61 | 61 | ]; |
| 62 | 62 | $inputs = FormFieldsParser::getInputs($form, ['attributes']); |
| 63 | 63 | |
| 64 | 64 | foreach ($inputs as $input) { |
| @@ -73,12 +73,22 @@ | ||
| 73 | 73 | $info[$maps[$element]] = $value; |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | + | |
| 78 | + $info = apply_filters_deprecated( | |
| 79 | + 'fluentform_akismet_fields', | |
| 80 | + [ | |
| 81 | + $info, | |
| 82 | + $data, | |
| 83 | + $form | |
| 84 | + ], | |
| 85 | + FLUENTFORM_FRAMEWORK_UPGRADE, | |
| 86 | + 'fluentform/akismet_fields', | |
| 87 | + 'Use fluentform/akismet_fields instead of fluentform_akismet_fields.' | |
| 88 | + ); | |
| 77 | 89 | |
| 78 | - $info = apply_filters('fluentform_akismet_fields', $info, $data, $form); | |
| 90 | + $info = apply_filters('fluentform/akismet_fields', $info, $data, $form); | |
| 79 | 91 | |
| 80 | 92 | return http_build_query($info); |
| 81 | - | |
| 82 | 93 | } |
| 83 | - | |
| 84 | -} | |
| 94 | +} | |