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/bots/class-google-bot.php +28 -1 6.2.0 → 6.3.0 View file →
@@ -9,9 +9,9 @@
9 9
10 10 /**
11 11 * This class is responsible for fetching and managing Google Bot IPs.
12 12 */
13 -class Google_Bot implements Bots_Interface {
13 +class Google_Bot extends Abstract_Bot {
14 14 /**
15 15 * Returns the name of the bot.
16 16 *
17 17 * @return string The name of the bot.
@@ -46,6 +46,33 @@
46 46 }
47 47 }
48 48
49 49 return $ips;
50 + }
51 +
52 + /**
53 + * Checks if the user agent belongs to Google.
54 + *
55 + * @param string $user_agent Optional user agent string to check.
56 + *
57 + * @return bool
58 + */
59 + public function is_ua( string $user_agent = '' ): bool {
60 + $ua = $this->normalize_ua( $user_agent );
61 + if ( '' === $ua ) {
62 + return false;
63 + }
64 +
65 + return false !== stristr( $ua, 'googlebot' );
66 + }
67 +
68 + /**
69 + * Checks if IP is from Google, based on DNS verification.
70 + *
71 + * @param string $ip The IP address to check.
72 + *
73 + * @return bool
74 + */
75 + public function is_ip( string $ip ): bool {
76 + return $this->verify_dns( $ip, '(^|\.)(googlebot\.com|google\.com)' );
50 77 }
51 78 }