Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
BBP_Akismet::maybe_spam( array $post_data = array(), string $check = 'check', string $spam = 'spam' )
Ping Akismet service and check for spam/ham response
Description Description
Parameters Parameters
- $post_data
-
(Optional)
Default value: array()
- $check
-
(Optional) Accepts check|submit
Default value: 'check'
- $spam
-
(Optional) Accepts spam|ham
Default value: 'spam'
Return Return
(array) Array of post data
Source Source
File: includes/extend/akismet.php
private function maybe_spam( $post_data, $check = 'check', $spam = 'spam' ) { global $akismet_api_host, $akismet_api_port; // Define variables $query_string = $path = $response = ''; // Populate post data $post_data['blog'] = get_option( 'home' ); $post_data['blog_charset'] = get_option( 'blog_charset' ); $post_data['blog_lang'] = get_locale(); $post_data['referrer'] = wp_get_raw_referer(); $post_data['user_agent'] = bbp_current_author_ua(); // Loop through _POST args and rekey strings foreach ( $_POST as $key => $value ) { if ( is_string( $value ) ) { $post_data['POST_' . $key] = $value; } } // Keys to ignore $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ); // Loop through _SERVER args and remove allowed keys foreach ( $_SERVER as $key => $value ) { // Key should not be ignored if ( ! in_array( $key, $ignore, true ) && is_string( $value ) ) { $post_data[ $key ] = $value; // Key should be ignored } else { $post_data[ $key ] = ''; } } // Ready... foreach ( $post_data as $key => $data ) { $query_string .= $key . '=' . urlencode( wp_unslash( $data ) ) . '&'; } // Aim... if ( 'check' === $check ) { $path = '/1.1/comment-check'; } elseif ( 'submit' === $check ) { $path = '/1.1/submit-' . $spam; } // Fire! $response = ! apply_filters( 'bbp_bypass_check_for_spam', false, $post_data ) ? $this->http_post( $query_string, $akismet_api_host, $path, $akismet_api_port ) : false; // Check the high-speed cam if ( ! empty( $response[1] ) ) { $post_data['bbp_akismet_result'] = $response[1]; } else { $post_data['bbp_akismet_result'] = esc_html__( 'No response', 'bbpress' ); } // Return the post data, with the results of the external Akismet request return $post_data; }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |