PluginProbe ʕ •ᴥ•ʔ
Limit Login Attempts Security – Login Security, 2FA, Firewall, Brute Force Prevention / 3.2.4
Limit Login Attempts Security – Login Security, 2FA, Firewall, Brute Force Prevention v3.2.4
3.2.4 3.2.3 3.2.2 3.2.1 3.2.0 trunk 2.0.0 2.1.0 2.10.0 2.10.1 2.11.0 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.14.0 2.15.0 2.15.1 2.15.2 2.16.0 2.17.0 2.17.1 2.17.2 2.17.3 2.17.4 2.18.0 2.19.0 2.19.1 2.19.2 2.2.0 2.20.0 2.20.1 2.20.2 2.20.3 2.20.4 2.20.5 2.20.6 2.21.0 2.21.1 2.22.0 2.22.1 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.25.0 2.25.1 2.25.10 2.25.11 2.25.12 2.25.13 2.25.14 2.25.15 2.25.16 2.25.17 2.25.18 2.25.19 2.25.2 2.25.20 2.25.21 2.25.22 2.25.23 2.25.24 2.25.25 2.25.26 2.25.27 2.25.28 2.25.29 2.25.3 2.25.4 2.25.5 2.25.6 2.25.7 2.25.8 2.25.9 2.26.0 2.26.1 2.26.10 2.26.11 2.26.12 2.26.13 2.26.14 2.26.15 2.26.16 2.26.17 2.26.18 2.26.19 2.26.2 2.26.20 2.26.21 2.26.22 2.26.23 2.26.24 2.26.25 2.26.26 2.26.27 2.26.28 2.26.3 2.26.4 2.26.5 2.26.6 2.26.7 2.26.8 2.26.9 2.3.0 2.4.0 2.5.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.8.0 2.8.1 2.9.0 3.0.0 3.0.1 3.0.2 3.1.0
limit-login-attempts-reloaded / core / http / HttpTransportWp.php
limit-login-attempts-reloaded / core / http Last commit date
Http.php 2 weeks ago HttpTransportCurl.php 2 weeks ago HttpTransportFopen.php 2 weeks ago HttpTransportInterface.php 2 weeks ago HttpTransportWp.php 2 weeks ago
HttpTransportWp.php
79 lines
1 <?php
2
3 namespace LLAR\Core\Http;
4
5 class HttpTransportWp implements HttpTransportInterface {
6
7 /**
8 * @param $url
9 * @param array $options
10 *
11 * @return array
12 */
13 public function get( $url, $options = array() ) {
14 $response = wp_remote_get( $url, array(
15 'headers' => !empty( $options['headers'] ) ? $this->format_headers( $options['headers'] ) : array(),
16 'body' => !empty( $options['data'] ) ? $options['data'] : array()
17 ) );
18
19 return $this->prepare_response( $response );
20 }
21
22 /**
23 * @param $url
24 * @param array $options
25 *
26 * @return array
27 */
28 public function post( $url, $options = array() ) {
29 $response = wp_remote_post( $url, array(
30 'headers' => !empty( $options['headers'] ) ? $this->format_headers( $options['headers'] ) : array(),
31 'body' => !empty( $options['data'] ) ? json_encode( $options['data'], JSON_FORCE_OBJECT ) : null
32 ) );
33
34 return $this->prepare_response( $response );
35 }
36
37 /**
38 * @param $response
39 *
40 * @return array
41 */
42 private function prepare_response( $response ) {
43
44 $return = array(
45 'data' => null,
46 'status' => 0,
47 'error' => null
48 );
49
50 if( is_wp_error( $response ) ) {
51 $return['error'] = $response->get_error_message();
52 } else {
53 $return['data'] = wp_remote_retrieve_body( $response );
54 $return['status'] = intval( wp_remote_retrieve_response_code( $response ) );
55 }
56
57 return $return;
58 }
59
60 /**
61 * @param array $headers
62 *
63 * @return array
64 */
65 private function format_headers( $headers = array() ) {
66
67 $formatted_headers = array();
68
69 if( !empty( $headers ) ) {
70 foreach ( $headers as $header ) {
71 list( $name, $value ) = explode( ':', $header );
72
73 $formatted_headers[ trim( $name ) ] = trim( $value );
74 }
75 }
76
77 return $formatted_headers;
78 }
79 }