PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.9.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.9.1
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
← All changes | includes/Core/Util/HttpHelper.php +59 -47 1.22.9.1 View file →
@@ -1,59 +1,71 @@
1 1 <?php
2 +
2 3 namespace BitCode\BitForm\Core\Util;
3 4
4 5 final class HttpHelper
5 6 {
6 - public static function post($url, $data, $headers = null, $options = null)
7 - {
8 - $defaultOptions =[
9 - 'headers' => $headers,
10 - 'body' => $data,
11 - "timeout" => 30
12 - ];
13 -
14 - $options = wp_parse_args($options, $defaultOptions);
15 - $requestReponse = wp_remote_post($url, $options);
7 + public static function post($url, $data, $headers = null, $options = null)
8 + {
9 + $defaultOptions = [
10 + 'headers' => $headers,
11 + 'body' => $data,
12 + 'timeout' => 30
13 + ];
16 14
17 - if (is_wp_error($requestReponse)) {
18 - return $requestReponse;
19 - }
20 - $responseBody = wp_remote_retrieve_body($requestReponse);
21 - $jsonData = json_decode($responseBody);
22 - return \is_null($jsonData) ? $responseBody : $jsonData;
15 + $options = wp_parse_args($options, $defaultOptions);
16 + $requestReponse = wp_remote_post($url, $options);
17 + if (is_wp_error($requestReponse)) {
18 + return $requestReponse;
23 19 }
20 + // $responseCode = wp_remote_retrieve_response_code($requestReponse);
21 + // if (!\is_null($responseCode) && $responseCode != 200) {
22 + // return wp_remote_retrieve_response_message($requestReponse);
23 + // }
24 + $responseBody = wp_remote_retrieve_body($requestReponse);
25 + $jsonData = json_decode($responseBody);
26 + return \is_null($jsonData) ? $responseBody : $jsonData;
27 + }
24 28
25 - public static function get($url, $data, $headers = null, $options = null)
26 - {
27 - $defaultOptions =[
28 - 'headers' => $headers,
29 - 'body' => $data,
30 - "timeout" => 30
31 - ];
32 - $options = wp_parse_args($options, $defaultOptions);
33 - $requestReponse = wp_remote_get($url, $options);
34 - if (is_wp_error($requestReponse)) {
35 - return $requestReponse;
36 - }
37 - $responseBody = wp_remote_retrieve_body($requestReponse);
38 - $jsonData = json_decode($responseBody);
39 - return \is_null($jsonData) ? $responseBody : $jsonData;
29 + public static function get($url, $data, $headers = null, $options = null)
30 + {
31 + $defaultOptions = [
32 + 'headers' => $headers,
33 + 'body' => $data,
34 + 'timeout' => 30
35 + ];
36 + $options = wp_parse_args($options, $defaultOptions);
37 + $requestReponse = wp_remote_get($url, $options);
38 + if (is_wp_error($requestReponse)) {
39 + return $requestReponse;
40 40 }
41 + // $responseCode = wp_remote_retrieve_response_code($requestReponse);
42 + // if (!\is_null($responseCode) && $responseCode != 200) {
43 + // return wp_remote_retrieve_response_message($requestReponse);
44 + // }
45 + $responseBody = wp_remote_retrieve_body($requestReponse);
46 + $jsonData = json_decode($responseBody);
47 + return \is_null($jsonData) ? $responseBody : $jsonData;
48 + }
41 49
42 - public static function request($url, $type, $data, $headers = null, $options = null)
43 - {
44 - $defaultOptions =[
45 - 'method' => $type,
46 - 'headers' => $headers,
47 - 'body' => $data,
48 - "timeout" => 30
49 - ];
50 - $options = wp_parse_args($options, $defaultOptions);
51 - $requestReponse = wp_remote_request($url, $options);
52 - if (is_wp_error($requestReponse)) {
53 - return $requestReponse;
54 - }
55 - $responseBody = wp_remote_retrieve_body($requestReponse);
56 - $jsonData = json_decode($responseBody);
57 - return \is_null($jsonData) ? $responseBody : $jsonData;
50 + public static function request($url, $type, $data, $headers = null, $options = null)
51 + {
52 + $defaultOptions = [
53 + 'method' => $type,
54 + 'headers' => $headers,
55 + 'body' => $data,
56 + 'timeout' => 30
57 + ];
58 + $options = wp_parse_args($options, $defaultOptions);
59 + $requestReponse = wp_remote_request($url, $options);
60 + if (is_wp_error($requestReponse)) {
61 + return $requestReponse;
58 62 }
63 + // $responseCode = wp_remote_retrieve_response_code($requestReponse);
64 + // if (!\is_null($responseCode) && $responseCode != 200) {
65 + // return wp_remote_retrieve_response_message($requestReponse);
66 + // }
67 + $responseBody = wp_remote_retrieve_body($requestReponse);
68 + $jsonData = json_decode($responseBody);
69 + return \is_null($jsonData) ? $responseBody : $jsonData;
70 + }
59 71 }