PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
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
← All changes | src/component/known-bots/class-known-bots.php +28 -1 6.2.3 → 6.3.0 View file →
@@ -37,9 +37,9 @@
37 37 */
38 38 public function get_all_bot_ips(): array {
39 39 $data = array();
40 40
41 - foreach ( $this->providers as $provider ) {
41 + foreach ( $this->get_providers() as $provider ) {
42 42 if ( $provider instanceof Bots_Interface ) {
43 43 $name = $provider->get_name();
44 44 $data[ $name ] = $this->get_or_set_bot_ips( $provider );
45 45 }
@@ -80,6 +80,33 @@
80 80 $key = 'wpdef_known_bot_ips_' . $name;
81 81 $ips = get_site_transient( $key );
82 82
83 83 return is_array( $ips ) && array() !== $ips ? $ips : array();
84 + }
85 +
86 + /**
87 + * Returns the registered bot providers.
88 + *
89 + * @return Bots_Interface[]
90 + */
91 + public function get_providers(): array {
92 + return $this->providers;
93 + }
94 +
95 + /**
96 + * Checks if the given IP and user agent match any registered known bot.
97 + *
98 + * @param string $ip The IP address to check.
99 + * @param string $user_agent Optional user agent string.
100 + *
101 + * @return bool
102 + */
103 + public function is_known_bot( string $ip, string $user_agent = '' ): bool {
104 + foreach ( $this->get_providers() as $provider ) {
105 + if ( $provider instanceof Bots_Interface && $provider->is_ua( $user_agent ) && $provider->is_ip( $ip ) ) {
106 + return true;
107 + }
108 + }
109 +
110 + return false;
84 111 }
85 112 }