PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.2.3
Defender Security – Malware Scanner, Login Security & Firewall v6.2.3
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / component / trusted-proxy-preset / class-trusted-proxy-preset.php

class-trusted-proxy-preset.php in Defender Security – Malware Scanner, Login Security & Firewall 6.2.3, at src/component/trusted-proxy-preset/class-trusted-proxy-preset.php

88 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The trusted proxy preset class.
4 *
5 * @package WP_Defender\Component\Trusted_Proxy_Preset
6 */
7
8 namespace WP_Defender\Component\Trusted_Proxy_Preset;
9
10 use Exception;
11 use InvalidArgumentException;
12
13 /**
14 * Represents a trusted proxy preset.
15 */
16 class Trusted_Proxy_Preset {
17
18 /**
19 * Proxy preset name.
20 *
21 * @var string
22 */
23 private $proxy_preset = '';
24
25 /**
26 * Sets the proxy preset.
27 *
28 * @param string $proxy_preset Proxy preset name.
29 */
30 public function set_proxy_preset( string $proxy_preset ): void {
31 $this->proxy_preset = $proxy_preset;
32 }
33
34 /**
35 * Get proxy preset instance.
36 *
37 * @return mixed
38 * @throws InvalidArgumentException Unknown proxy type.
39 */
40 private function instance() {
41 switch ( $this->proxy_preset ) {
42 case Cloudflare_Proxy::PROXY_SLUG:
43 return wd_di()->get( Cloudflare_Proxy::class );
44 default:
45 throw new InvalidArgumentException( 'Unknown proxy type: ' . esc_html( $this->proxy_preset ) );
46 }
47 }
48
49 /**
50 * Get trusted preset IPs.
51 *
52 * @return mixed
53 */
54 public function get_ips() {
55 try {
56 return $this->instance()->get_ips();
57 } catch ( Exception $e ) {
58 return false;
59 }
60 }
61
62 /**
63 * Update trusted preset IPs.
64 *
65 * @return mixed
66 */
67 public function update_ips() {
68 try {
69 return $this->instance()->update_ips();
70 } catch ( Exception $e ) {
71 return false;
72 }
73 }
74
75 /**
76 * Delete trusted preset IPs.
77 *
78 * @return bool
79 */
80 public function delete_ips() {
81 try {
82 return $this->instance()->delete_ips();
83 } catch ( Exception $e ) {
84 return false;
85 }
86 }
87 }
88