PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.4
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.4
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
bit-form / includes / Core / Util / HttpHelper.php

HttpHelper.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 1.4, at includes/Core/Util/HttpHelper.php

71 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace BitCode\BitForm\Core\Util;
3
4 final class HttpHelper
5 {
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);
16 if (is_wp_error($requestReponse)) {
17 return $requestReponse;
18 }
19 // $responseCode = wp_remote_retrieve_response_code($requestReponse);
20 // if (!\is_null($responseCode) && $responseCode != 200) {
21 // return wp_remote_retrieve_response_message($requestReponse);
22 // }
23 $responseBody = wp_remote_retrieve_body($requestReponse);
24 $jsonData = json_decode($responseBody);
25 return \is_null($jsonData) ? $responseBody : $jsonData;
26 }
27
28 public static function get($url, $data, $headers = null, $options = null)
29 {
30 $defaultOptions =[
31 'headers' => $headers,
32 'body' => $data,
33 "timeout" => 30
34 ];
35 $options = wp_parse_args($options, $defaultOptions);
36 $requestReponse = wp_remote_get($url, $options);
37 if (is_wp_error($requestReponse)) {
38 return $requestReponse;
39 }
40 // $responseCode = wp_remote_retrieve_response_code($requestReponse);
41 // if (!\is_null($responseCode) && $responseCode != 200) {
42 // return wp_remote_retrieve_response_message($requestReponse);
43 // }
44 $responseBody = wp_remote_retrieve_body($requestReponse);
45 $jsonData = json_decode($responseBody);
46 return \is_null($jsonData) ? $responseBody : $jsonData;
47 }
48
49 public static function request($url, $type, $data, $headers = null, $options = null)
50 {
51 $defaultOptions =[
52 'method' => $type,
53 'headers' => $headers,
54 'body' => $data,
55 "timeout" => 30
56 ];
57 $options = wp_parse_args($options, $defaultOptions);
58 $requestReponse = wp_remote_request($url, $options);
59 if (is_wp_error($requestReponse)) {
60 return $requestReponse;
61 }
62 // $responseCode = wp_remote_retrieve_response_code($requestReponse);
63 // if (!\is_null($responseCode) && $responseCode != 200) {
64 // return wp_remote_retrieve_response_message($requestReponse);
65 // }
66 $responseBody = wp_remote_retrieve_body($requestReponse);
67 $jsonData = json_decode($responseBody);
68 return \is_null($jsonData) ? $responseBody : $jsonData;
69 }
70 }
71