PluginProbe
The WP Remote WordPress Plugin / 5.72
The WP Remote WordPress Plugin v5.72
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
wpremote / wp_api.php

wp_api.php in The WP Remote WordPress Plugin 5.72, at wp_api.php

43 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4 if (!class_exists('WPRWPAPI')) :
5 class WPRWPAPI {
6 public $settings;
7
8 public function __construct($settings) {
9 $this->settings = $settings;
10 }
11
12 public function pingbv($method, $body, $public = false) {
13 if ($public) {
14 return $this->do_request($method, $body, $public);
15 } else {
16 $api_public_key = $this->settings->getOption('bvApiPublic');
17 if (!empty($api_public_key) && (strlen($api_public_key) >= 32)) {
18 return $this->do_request($method, $body, $api_public_key);
19 }
20 }
21 }
22
23 public function do_request($method, $body, $pubkey) {
24 $account = WPRAccount::find($this->settings, $pubkey);
25 if (isset($account)) {
26 $url = $account->authenticatedUrl($method);
27 return $this->http_request($url, $body);
28 }
29 }
30
31 public function http_request($url, $body, $headers = array()) {
32 $_body = array(
33 'method' => 'POST',
34 'timeout' => 15,
35 'body' => $body
36 );
37 if (!empty($headers)) {
38 $_body['headers'] = $headers;
39 }
40 return wp_remote_post($url, $_body);
41 }
42 }
43 endif;