Skip to content
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/Cleantalk/ApbctWP/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,24 @@ public static function sendRequest($data, $timeout = 10)
// Adding agent version to data
$data['agent'] = defined('APBCT_AGENT') ? APBCT_AGENT : '';

$options = ['timeout' => $timeout];
// Proxy settings from wp-config.php constants.
$options['proxy'] = WP_PROXY_HOST . ':' . WP_PROXY_PORT; // WP HTTP API branch
// cURL branch (avoid referencing CURLOPT_* when ext-curl is not available)
if ( function_exists('curl_init') && defined('CURLOPT_PROXY') && defined('CURLOPT_PROXYPORT') ) {
$options[CURLOPT_PROXY] = WP_PROXY_HOST;
$options[CURLOPT_PROXYPORT] = WP_PROXY_PORT;
Comment thread
Glomberg marked this conversation as resolved.
Outdated
if ( defined('WP_PROXY_USERNAME') && WP_PROXY_USERNAME !== '' && defined('CURLOPT_PROXYUSERPWD') ) {
$options[CURLOPT_PROXYUSERPWD] = WP_PROXY_USERNAME . ':' . (defined('WP_PROXY_PASSWORD') ? WP_PROXY_PASSWORD : '');
}
}
Comment on lines +87 to +99

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +86 to +99

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread
Copilot marked this conversation as resolved.

$http = new Request();

$request = $http->setUrl($url)
->setData($data)
->setPresets(['retry_with_socket'])
->setOptions(['timeout' => $timeout]);
->setOptions($options);
if ( isset($data['method_name']) ) {
$request->addCallback(
__CLASS__ . '::checkResponse',
Expand Down
Loading