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::http_post( string $request, string $host, string $path, string $port = 80, string $ip = '' )
Submit data to Akismet service with unique bbPress User Agent
Description Description
This code is directly taken from the akismet_http_post() function and documented to bbPress 2.0 standard.
Parameters Parameters
- $request
-
(Required) The request we are sending
- $host
-
(Required) The host to send our request to
- $path
-
(Required) The path from the host
- $port
-
(Optional) The port to use
Default value: 80
- $ip
-
(Optional) Override $host with an IP address
Default value: ''
Return Return
(mixed) WP_Error on error, array on success, empty on failure
Source Source
File: includes/extend/akismet.php
private function http_post( $request, $host, $path, $port = 80, $ip = '' ) { // Preload required variables $bbp_version = bbp_get_version(); $http_host = $host; $blog_charset = get_option( 'blog_charset' ); $response = ''; // Untque User Agent $akismet_ua = "bbPress/{$bbp_version} | "; $akismet_ua .= 'Akismet/' . constant( 'AKISMET_VERSION' ); // Use specific IP (if provided) if ( ! empty( $ip ) && long2ip( ip2long( $ip ) ) ) { $http_host = $ip; } // Setup the arguments $http_args = array( 'body' => $request, 'headers' => array( 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . $blog_charset, 'Host' => $host, 'User-Agent' => $akismet_ua ), 'httpversion' => '1.0', 'timeout' => 15 ); // Where we are sending our request $akismet_url = 'http://' . $http_host . $path; // Send the request $response = wp_remote_post( $akismet_url, $http_args ); // Bail if the response is an error if ( is_wp_error( $response ) ) { return ''; } // No errors so return response return array( $response['headers'], $response['body'] ); }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |