ted=false * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return boolean true if the browser is Kindle Fire Native browser otherwise false */ public static function is_kindle_fire( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. $pos_silk = strpos( $agent, 'silk/' ); $pos_silk_acc = strpos( $agent, 'silk-accelerated=' ); if ( false !== $pos_silk && false !== $pos_silk_acc ) { return true; } else { return false; } } /** * Detects if the current browser is the Kindle Touch Native browser * * Mozilla/5.0 (X11; U; Linux armv7l like Android; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/533.2+ Kindle/3.0+ * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return boolean true if the browser is Kindle monochrome Native browser otherwise false */ public static function is_kindle_touch( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. $pos_kindle_touch = strpos( $agent, 'kindle/3.0+' ); if ( false !== $pos_kindle_touch && false === self::is_kindle_fire( $user_agent ) ) { return true; } else { return false; } } /** * Detect if user agent is the WordPress.com Windows 8 app (used ONLY on the custom oauth stylesheet) * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. */ public static function is_windows8_auth( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. $pos = strpos( $agent, 'msauthhost' ); if ( false !== $pos ) { return true; } else { return false; } } /** * Detect if user agent is the WordPress.com Windows 8 app. * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. */ public static function is_wordpress_for_win8( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. $pos = strpos( $agent, 'wp-windows8' ); if ( false !== $pos ) { return true; } else { return false; } } /** * Detect if user agent is the WordPress.com Desktop app. * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. */ public static function is_wordpress_desktop_app( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. $pos = strpos( $agent, 'WordPressDesktop' ); if ( false !== $pos ) { return true; } else { return false; } } /** * The is_blackberry_tablet() method can be used to check the User Agent for a RIM blackberry tablet. * The user agent of the BlackBerry® Tablet OS follows a format similar to the following: * Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.8+ (KHTML, like Gecko) Version/0.0.1 Safari/534.8+ * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. */ public static function is_blackberry_tablet( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. $pos_playbook = stripos( $agent, 'PlayBook' ); $pos_rim_tablet = stripos( $agent, 'RIM Tablet' ); if ( ( false === $pos_playbook ) || ( false === $pos_rim_tablet ) ) { return false; } else { return true; } } /** * The is_blackbeberry() method can be used to check the User Agent for a blackberry device. * Note that opera mini on BB matches this rule. * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. */ public static function is_blackbeberry( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. $pos_blackberry = strpos( $agent, 'blackberry' ); if ( false !== $pos_blackberry ) { if ( self::is_opera_mini( $user_agent ) || self::is_opera_mobile( $user_agent ) || self::is_firefox_mobile( $user_agent ) ) { return false; } else { return true; } } else { return false; } } /** * The is_blackberry_10() method can be used to check the User Agent for a BlackBerry 10 device. * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. */ public static function is_blackberry_10( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. return ( strpos( $agent, 'bb10' ) !== false ) && ( strpos( $agent, 'mobile' ) !== false ); } /** * Determines whether a desktop platform is Linux OS * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return bool */ public static function is_linux_desktop( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } if ( ! preg_match( '/linux/i', wp_unslash( $user_agent ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. return false; } return true; } /** * Determines whether a desktop platform is Mac OS * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return bool */ public static function is_mac_desktop( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } if ( ! preg_match( '/macintosh|mac os x/i', wp_unslash( $user_agent ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. return false; } return true; } /** * Determines whether a desktop platform is Windows OS * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return bool */ public static function is_windows_desktop( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } if ( ! preg_match( '/windows|win32/i', wp_unslash( $user_agent ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. return false; } return true; } /** * Determines whether a desktop platform is Chrome OS * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return bool */ public static function is_chrome_desktop( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } if ( ! preg_match( '/chrome/i', wp_unslash( $user_agent ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. return false; } return true; } /** * Retrieve the blackberry OS version. * * Return strings are from the following list: * - blackberry-10 * - blackberry-7 * - blackberry-6 * - blackberry-torch //only the first edition. The 2nd edition has the OS7 onboard and doesn't need any special rule. * - blackberry-5 * - blackberry-4.7 * - blackberry-4.6 * - blackberry-4.5 * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return string Version of the BB OS. * If version is not found, get_blackbeberry_OS_version will return boolean false. */ public static function get_blackbeberry_OS_version( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } if ( self::is_blackberry_10( $user_agent ) ) { return 'blackberry-10'; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. $pos_blackberry = stripos( $agent, 'blackberry' ); if ( false === $pos_blackberry ) { // Not a blackberry device. return false; } // Blackberry devices OS 6.0 or higher. // Mozilla/5.0 (BlackBerry; U; BlackBerry 9670; en) AppleWebKit/534.3+ (KHTML, like Gecko) Version/6.0.0.286 Mobile Safari/534.3+. // Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, Like Gecko) Version/6.0.0.141 Mobile Safari/534.1+. // Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0 Mobile Safari/534.11+. $pos_webkit = stripos( $agent, 'webkit' ); if ( false !== $pos_webkit ) { // Detected blackberry webkit browser. $pos_torch = stripos( $agent, 'BlackBerry 9800' ); if ( false !== $pos_torch ) { return 'blackberry-torch'; // Match the torch first edition. the 2nd edition should use the OS7 and doesn't need any special rule. } elseif ( preg_match( '#Version\/([\d\.]+)#i', $agent, $matches ) ) { // Detecting the BB OS version for devices running OS 6.0 or higher. $version = $matches[1]; $version_num = explode( '.', $version ); if ( count( $version_num ) <= 1 ) { return 'blackberry-6'; // not a BB device that match our rule. } else { return 'blackberry-' . $version_num[0]; } } else { // if doesn't match returns the minimun version with a webkit browser. we should never fall here. return 'blackberry-6'; // not a BB device that match our rule. } } // Blackberry devices <= 5.XX. // BlackBerry9000/5.0.0.93 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/179. if ( preg_match( '#BlackBerry\w+\/([\d\.]+)#i', $agent, $matches ) ) { $version = $matches[1]; } else { return false; // not a BB device that match our rule. } $version_num = explode( '.', $version ); if ( count( $version_num ) <= 1 ) { return false; } $version_num_major = (int) $version_num[0]; $version_num_minor = (int) $version_num[1]; if ( 5 === $version_num_major ) { return 'blackberry-5'; } elseif ( 4 === $version_num_major && 7 === $version_num_minor ) { return 'blackberry-4.7'; } elseif ( 4 === $version_num_major && 6 === $version_num_minor ) { return 'blackberry-4.6'; } elseif ( 4 === $version_num_major && 5 === $version_num_minor ) { return 'blackberry-4.5'; } else { return false; } } /** * Retrieve the blackberry browser version. * * Return string are from the following list: * - blackberry-10 * - blackberry-webkit * - blackberry-5 * - blackberry-4.7 * - blackberry-4.6 * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return string Type of the BB browser. * If browser's version is not found, detect_blackbeberry_browser_version will return boolean false. */ public static function detect_blackberry_browser_version( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. if ( self::is_blackberry_10( $user_agent ) ) { return 'blackberry-10'; } $pos_blackberry = strpos( $agent, 'blackberry' ); if ( false === $pos_blackberry ) { // Not a blackberry device. return false; } $pos_webkit = strpos( $agent, 'webkit' ); if ( ! ( false === $pos_webkit ) ) { return 'blackberry-webkit'; } else { if ( ! preg_match( '#BlackBerry\w+\/([\d\.]+)#i', $agent, $matches ) ) { return false; // not a BB device that match our rule. } $version_num = explode( '.', $matches[1] ); if ( count( $version_num ) <= 1 ) { return false; } $version_num_major = (int) $version_num[0]; $version_num_minor = (int) $version_num[1]; if ( 5 === $version_num_major ) { return 'blackberry-5'; } elseif ( 4 === $version_num_major && 7 === $version_num_minor ) { return 'blackberry-4.7'; } elseif ( 4 === $version_num_major && 6 === $version_num_minor ) { return 'blackberry-4.6'; } else { // A very old BB device is found or this is a BB device that doesn't match our rules. return false; } } } /** * Checks if a visitor is coming from one of the WordPress mobile apps. * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return bool */ public static function is_mobile_app( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $agent = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. if ( isset( $_SERVER['X_USER_AGENT'] ) && preg_match( '|wp-webos|', $_SERVER['X_USER_AGENT'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is validating. return true; // Wp4webos 1.1 or higher. } $app_agents = array( 'wp-android', 'wp-blackberry', 'wp-iphone', 'wp-nokia', 'wp-webos', 'wp-windowsphone' ); // the mobile reader on iOS has an incorrect UA when loading the reader // currently it is the default one provided by the iOS framework which // causes problems with 2-step-auth // User-Agent WordPress/3.1.4 CFNetwork/609 Darwin/13.0.0. $app_agents[] = 'wordpress/3.1'; foreach ( $app_agents as $app_agent ) { if ( false !== strpos( $agent, $app_agent ) ) { return true; } } return false; } /** * Detects if the current browser is Nintendo 3DS handheld. * * Example: Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7498.US * can differ in language, version and region * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. */ public static function is_Nintendo_3DS( $user_agent = null ) { $user_agent = self::maybe_get_user_agent_from_server( $user_agent ); if ( empty( $user_agent ) ) { return false; } $ua = strtolower( wp_unslash( $user_agent ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. if ( strpos( $ua, 'nintendo 3ds' ) !== false ) { return true; } return false; } /** * Was the current request made by a known bot? * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return boolean */ public static function is_bot( $user_agent = null ) { static $is_bot = null; if ( null === $user_agent ) { if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { return false; } $user_agent = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. // Use cached result only when using the default $_SERVER['HTTP_USER_AGENT']. if ( $is_bot === null ) { $is_bot = self::is_bot_user_agent( $user_agent ); } return $is_bot; } if ( empty( $user_agent ) ) { return false; } // Don't use cache when a custom user agent is provided. return self::is_bot_user_agent( $user_agent ); } /** * Is the given user-agent a known bot? * If you want an is_bot check for the current request's UA, use is_bot() instead of passing a user-agent to this method. * * @param string $ua A user-agent string. * * @return boolean */ public static function is_bot_user_agent( $ua = null ) { if ( empty( $ua ) ) { return false; } // Some sourced via // https://github.com/ua-parser/uap-core/blob/432e95f6767cc8bab4c20c255784cd6f7e93bc15/regexes.yaml#L151 $bot_agents = array( // Microsoft/Bing https://www.bing.com/webmasters/help/which-crawlers-does-bing-use-8c184ec0 'bingbot', // Bing/Copilot 'adidxbot', // Bing Ads 'bingpreview', // Generates page snapshots for Bing 'bingvideopreview', // Generates previews of videos for Bing 'microsoft', // Google https://developers.google.com/search/docs/crawling-indexing/google-common-crawlers 'adsbot-google', 'appengine-google', 'feedfetcher-google', 'mediapartners-google', 'storebot-google', // https://developers.google.com/search/docs/crawling-indexing/google-common-crawlers#google-storebot 'google sketchup', 'google-cloudbertexbot', // https://developers.google.com/search/docs/crawling-indexing/google-common-crawlers#google-cloudvertexbot 'google-extended', // Gemini https://developers.google.com/search/docs/crawling-indexing/google-common-crawlers#google-extended 'google-inspectiontool', // https://developers.google.com/search/docs/crawling-indexing/google-common-crawlers 'google-safety;', // https://www.google.com/bot.html 'googlebot-mobile', 'googlebot', // and googlebot-[image,video,news,] https://developers.google.com/search/docs/crawling-indexing/google-common-crawlers#googlebot 'googleother', // and googleother-[video,image] https://developers.google.com/search/docs/crawling-indexing/google-common-crawlers#googleother // OpenAI https://platform.openai.com/docs/bots 'gptbot', // Crawler 'chatgpt-user', // ChatGPT on behalf of user 'oai-searchbot', // ChatGPT search features // Anthropic 'claudebot', // chat citation fetch https://support.anthropic.com/en/articles/8896518 'claude-web', // web-focused crawl https://darkvisitors.com/agents/claude-web 'anthropic-ai', // bulk model training https://darkvisitors.com/agents/anthropic-ai // Perplexity 'perplexitybot', // index builder https://docs.perplexity.ai/guides/bots 'perplexity-user', // human-triggered visit https://docs.perplexity.ai/guides/bots // Meta https://developers.facebook.com/docs/sharing/webmasters/web-crawlers/ 'facebookbot', // AI data scraper https://darkvisitors.com/agents/facebookbot 'facebookexternalhit', // shares https://developers.facebook.com/docs/sharing/webmasters/web-crawlers/#identify 'facebookcatalog', // shares https://developers.facebook.com/docs/sharing/webmasters/web-crawlers/#identify 'meta-webindexer', // Meta AI search indexer https://developers.facebook.com/docs/sharing/webmasters/web-crawlers/#meta-webindexer 'meta-externalads', // web crawler improving ads https://developers.facebook.com/docs/sharing/webmasters/web-crawlers/#meta-externalads 'meta-externalagent', // training AI models https://developers.facebook.com/docs/sharing/webmasters/web-crawlers/#identify-2 'meta-externalfetcher', // user-initiated fetches, may skip robots.txt https://developers.facebook.com/docs/sharing/webmasters/web-crawlers/#identify-3 // Semrush https://www.semrush.com/bot/ 'semrushbot', 'siteauditbot', // Other bots (alphabetized list) '123metaspider-bot', '1470.net crawler', '50.nu', '8bo crawler bot', 'aboundex', 'ahrefsbot', 'ai2bot', // AI2 crawler for LLMm training https://allenai.org/crawler 'alexa', 'altavista', 'amazonbot', // https://developer.amazon.com/amazonbot 'applebot', // https://support.apple.com/en-ca/HT204683 'arcgis hub indexer', 'archive.org_bot', // http://archive.org/details/archive.org_bot 'archiver', 'ask jeeves', 'attentio', 'baiduspider', 'blexbot', 'blitzbot', 'blogbridge', 'bloglovin', 'bne.es_bot', // https://www.bne.es/es/colecciones/archivo-web-espanola/aviso-webmasters 'boardreader blog indexer', 'boardreader favicon fetcher', 'boitho.com-dc', 'botseer', 'bubing', 'bytespider', // ByteDance (owner of TikTok) to train LLMs for Doubao https://darkvisitors.com/agents/bytespider 'catchpoint', 'ccbot', // CommonCrawl non-profit https://commoncrawl.org/ccbot 'charlotte', 'checklinks', 'chtml generic', 'cityreview robot', 'cloudflare-alwaysonline', 'clumboot', 'coccocbot', // Coc Coc https://darkvisitors.com/agents/coccocbot-web 'cohere-ai', // Cohere AI https://darkvisitors.com/agents/cohere-ai 'comodo http', 'comodo-webinspector-crawler', 'converacrawler', 'cookieinformationscanner', // Internal ref p1699315886066389-slack-C0438NHCLSY 'crawl-e', 'crawlconvera', 'crawldaddy', 'crawler', 'crawlfire', 'csimplespider', 'dataforseobot', // https://www.dataforseo.com/dataforseo-bot 'daumoa', 'diffbot', // https://docs.diffbot.com/docs/how-to-use-custom-user-agents-with-extract-apis & https://darkvisitors.com/agents/diffbot 'domaintunocrawler', 'dotbot', // https://darkvisitors.com/agents/dotbot 'duckassistbot', // DuckDuckGo AI Assistant https://darkvisitors.com/agents/duckassistbot 'elisabot', 'ezlynxbot', // https://www.ezoic.com/bot 'fastmobilecrawl', 'feed seeker bot', 'feedbin', 'feedburner', 'finderbots', 'findlinks', 'firefly', 'flamingo_searchengine', 'followsite bot', 'froogle', 'furlbot', 'genieo', 'germcrawler', 'gigabot', 'gomezagent', 'gonzo1', 'grapeshotcrawler', 'grokkit-crawler', 'grub-client', 'gsa-crawler', 'heritrix', 'hiddenmarket', 'holmes', 'hoowwwer', 'htdig', 'httrack', 'ia_archiver', 'icarus6j', 'icc-crawler', 'ichiro', 'iconsurf', 'iescholar', 'iltrovatore', 'index crawler', 'infoseek', 'infuzapp', 'innovazion crawler', 'internetarchive', 'irlbot', 'jbot', 'job roboter', 'jumpbot', 'kaloogabot', 'kiwistatus spider', 'kraken', 'kurzor', 'larbin', 'leia', 'lesnikbot', 'lijit crawler', 'linguee bot', 'linkaider', 'linkcheck', 'linkdexbot', 'linkedinbot', 'linkfluence', // http://linkfluence.com/ 'linkwalker', // https://www.linkwalker.com/ 'lite bot', 'livelapbot', 'llaut', 'lycos', 'mail.ru_bot', 'masidani_bot', 'masscan', 'mediapartners', 'mediobot', 'mj12bot', 'mogimogi', 'mojeekbot', // https://www.mojeek.com/bot.html 'motionbot', 'mozdex', 'mshots', 'msnbot', 'msrbot', 'mtps feed aggregation system', 'netresearch', 'netvibes', 'newsgator', 'ning', 'nutch', 'nymesis', 'objectssearch', 'ogscrper', 'omgili', // Webz.io web crawler for a data seller https://darkvisitors.com/agents/omgili 'oozbot', 'openbot', 'openhosebot', 'orbiter', 'pagepeeker', 'pagesinventory', 'paxleframework', 'peeplo screenshot bot', 'phpcrawl', 'pingdom.com_bot', 'plantynet_webrobot', 'pompos', 'pss-webkit-request', 'pythumbnail', 'queryseekersp ider', 'queryseekerspider', 'qwantify', 'read%20later', 'reaper', 'redcarpet', 'retreiver', 'riddler', 'rival iq', 'scollspider', 'scooter', 'scrapy', 'scrubby', 'searchsight', 'seekbot', 'semanticdiscovery', 'seostats', 'simplepie', 'simplerss', 'simpy', 'sitecat webbot', 'sitecon', 'slack-imgproxy', 'slackbot-linkexpanding', 'slurp', 'snapbot', 'snapchat', // https://developers.snap.com/robots 'snappy', 'speedy spider', 'spider', 'squrl java', 'stringer', 'taptubot', 'technoratisnoop', 'teoma', 'theusefulbot', 'thumbshots.ru', 'thumbshotsbot', 'timpibot', // LLM trainer https://darkvisitors.com/agents/timpibot 'tiny tiny rss', 'trendictionbot', // http://www.trendiction.de/bot; 'trends crawler', 'tweetmemebot', 'twiceler', 'twitterbot', // https://developer.x.com/en/docs/x-for-websites/cards/guides/getting-started#crawling 'url2png', 'usyd-nlp-spider', 'vagabondo', 'voilabot', 'vortex', 'votay bot', 'voyager', 'wasalive.bot', 'web-sniffer', 'webthumb', 'wesee', 'whatsapp', 'whatweb', 'wire', 'wordpress', 'wotbox', 'wp-e2e-tests', // WordPress e2e tests 'www.almaden.ibm.com', 'xenu', 'yacybot', // http://yacy.net/bot.html 'yahoo! slurp', 'yahooseeker', 'yahooysmcm', 'yammybot', 'yandexbot', 'yottaamonitor', 'youbot', // You.com AI assistant https://darkvisitors.com/agents/youbot 'yowedo', 'zao-crawler', 'zao', 'zebot_www.ze.bz', 'zoombot', // SEOZOom https://darkvisitors.com/agents/zoombot 'zooshot', 'zyborg', ); foreach ( $bot_agents as $bot_agent ) { if ( false !== stripos( $ua, $bot_agent ) ) { return true; } } return false; } /** * Is the current request from an agent? * * Detects bots, crawlers, AI assistants, and programmatic HTTP clients. * Useful for showing machine-readable hints or alternative content to non-browser clients. * * @param string|null $user_agent Optional. User agent string to check. If not provided, uses $_SERVER['HTTP_USER_AGENT']. * * @return bool True if the request appears to be from an agent. */ public static function is_agent( $user_agent = null ) { static $cached_ua = null; static $cached_result = null; if ( null === $user_agent ) { if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { // Empty User-Agent is likely programmatic - real browsers always send one. return true; } $user_agent = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. // Use cache for default user agent, but invalidate if UA changed. if ( $cached_ua === $user_agent && null !== $cached_result ) { return $cached_result; } $cached_ua = $user_agent; $cached_result = self::is_agent_user_agent( $user_agent ); /** This filter is documented below. */ if ( function_exists( 'apply_filters' ) ) { $cached_result = apply_filters( 'jetpack_is_agent', $cached_result, $user_agent ); } return $cached_result; } if ( empty( $user_agent ) ) { // Empty User-Agent is likely programmatic. return true; } $result = self::is_agent_user_agent( $user_agent ); /** * Filter to customize agent detection. * * @param bool $is_agent Whether the request is from an agent. * @param string $user_agent The user agent string. */ if ( function_exists( 'apply_filters' ) ) { $result = apply_filters( 'jetpack_is_agent', $result, $user_agent ); } return $result; } /** * Is the given user-agent from an agent? * * @param string $ua A user-agent string. * * @return bool True if the user-agent appears to be from an agent. */ private static function is_agent_user_agent( $ua ) { if ( self::is_bot_user_agent( $ua ) ) { return true; } // HTTP libraries and programmatic clients (alphabetized). $http_clients = array( 'aiohttp', 'axios', 'curl/', 'go-http-client', 'got/', 'guzzlehttp', 'httpie', 'httpx', 'insomnia', 'java/', 'libwww-perl', 'node-fetch', 'okhttp', 'postman', 'python-requests', 'python-urllib', 'ruby', 'undici', 'wget/', ); foreach ( $http_clients as $client ) { if ( false !== stripos( $ua, $client ) ) { return true; } } return false; } } 1 - Uncaught Error: Class 'Automattic\Jetpack\Device_Detection\User_Agent_Info' not found in /home/st20space2tech/public_html/site/wp-content/plugins/jetpack/class.jetpack.php:699 Stack trace: #0 /home/st20space2tech/public_html/site/wp-includes/class-wp-hook.php(341): Jetpack->{closure}('') #1 /home/st20space2tech/public_html/site/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters(NULL, Array) #2 /home/st20space2tech/public_html/site/wp-includes/plugin.php(522): WP_Hook->do_action(Array) #3 /home/st20space2tech/public_html/site/wp-settings.php(622): do_action('plugins_loaded') #4 /home/st20space2tech/public_html/site/wp-config.php(92): require_once('/home/st20space...') #5 /home/st20space2tech/public_html/site/wp-load.php(50): require_once('/home/st20space...') #6 /home/st20space2tech/public_html/site/wp-blog-header.php(13): require_once('/home/st20space...') #7 /home/st20space2tech/public_html/site/index.php(17): require('/home/st20space...') #8 {main} thrown - /home/st20space2tech/public_html/site/wp-content/plugins/jetpack/class.jetpack.php - 699