# wpremote/4.82/wp_api.php

The WP Remote WordPress Plugin, version 4.82. 43 lines.

- Page: https://pluginprobe.com/plugins/wpremote/4.82/code/wp_api.php
- Raw: https://pluginprobe.com/plugins/wpremote/4.82/raw/wp_api.php
- Modified: 2022-02-17T12:29:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpremote/4.82/code/wp_api.php#L10-L20`.

```php
<?php

if (!defined('ABSPATH')) exit;
if (!class_exists('WPRWPAPI')) :
	class WPRWPAPI {
		public $settings;

		public function __construct($settings) {
			$this->settings = $settings;
		}

		public function pingbv($method, $body, $public = false) {
			if ($public) {
				return $this->do_request($method, $body, $public);
			} else {
				$api_public_key = $this->settings->getOption('bvApiPublic');
				if (!empty($api_public_key) && (strlen($api_public_key) >= 32)) {
					return $this->do_request($method, $body, $api_public_key);
				}
			}
		}

		public function do_request($method, $body, $pubkey) {
			$account = WPRAccount::find($this->settings, $pubkey);
			if (isset($account)) {
				$url = $account->authenticatedUrl($method);
				return $this->http_request($url, $body);
			}
		}

		public function http_request($url, $body, $headers = array()) {
			$_body = array(
				'method' => 'POST',
				'timeout' => 15,
				'body' => $body
			);
			if (!empty($headers)) {
				$_body['headers'] = $headers;
			}
			return wp_remote_post($url, $_body);
		}
	}
endif;
```
