From c8b3555283990797220d246fe0ad5a31feeb30b0 Mon Sep 17 00:00:00 2001 From: anomiex Date: Wed, 19 Jul 2023 17:14:44 +0000 Subject: [PATCH] cli: Check node, php, and pnpm versions too (#31918) And also better handle the case where the program is not installed. Also fix the handler for "forgot to `pnpm install`", it wasn't working since #23966 added some unguarded `import`s in the `bin/jetpack.js` entry point. Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/5601946967 --- vendor/autoload.php | 25 + .../jetpack-device-detection/CHANGELOG.md | 194 ++ .../jetpack-device-detection/LICENSE.txt | 357 ++++ .../jetpack-device-detection/README.md | 86 + .../jetpack-device-detection/SECURITY.md | 38 + .../jetpack-device-detection/composer.json | 39 + .../src/class-device-detection.php | 219 +++ .../src/class-user-agent-info.php | 1572 +++++++++++++++++ .../src/functions.php | 36 + vendor/composer/ClassLoader.php | 585 ++++++ vendor/composer/InstalledVersions.php | 359 ++++ vendor/composer/LICENSE | 21 + vendor/composer/autoload_classmap.php | 12 + vendor/composer/autoload_namespaces.php | 9 + vendor/composer/autoload_psr4.php | 9 + vendor/composer/autoload_real.php | 37 + vendor/composer/autoload_static.php | 22 + vendor/composer/installed.json | 56 + vendor/composer/installed.php | 32 + 19 files changed, 3708 insertions(+) create mode 100644 vendor/autoload.php create mode 100644 vendor/automattic/jetpack-device-detection/CHANGELOG.md create mode 100644 vendor/automattic/jetpack-device-detection/LICENSE.txt create mode 100644 vendor/automattic/jetpack-device-detection/README.md create mode 100644 vendor/automattic/jetpack-device-detection/SECURITY.md create mode 100644 vendor/automattic/jetpack-device-detection/composer.json create mode 100644 vendor/automattic/jetpack-device-detection/src/class-device-detection.php create mode 100644 vendor/automattic/jetpack-device-detection/src/class-user-agent-info.php create mode 100644 vendor/automattic/jetpack-device-detection/src/functions.php create mode 100644 vendor/composer/ClassLoader.php create mode 100644 vendor/composer/InstalledVersions.php create mode 100644 vendor/composer/LICENSE create mode 100644 vendor/composer/autoload_classmap.php create mode 100644 vendor/composer/autoload_namespaces.php create mode 100644 vendor/composer/autoload_psr4.php create mode 100644 vendor/composer/autoload_real.php create mode 100644 vendor/composer/autoload_static.php create mode 100644 vendor/composer/installed.json create mode 100644 vendor/composer/installed.php diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 00000000..987143ea --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,25 @@ + +Copyright (C) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) year name of author +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. +This is free software, and you are welcome to redistribute it +under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in the program +`Gnomovision' (which makes passes at compilers) written by James Hacker. + +, 1 April 1989 +Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/vendor/automattic/jetpack-device-detection/README.md b/vendor/automattic/jetpack-device-detection/README.md new file mode 100644 index 00000000..67b47d38 --- /dev/null +++ b/vendor/automattic/jetpack-device-detection/README.md @@ -0,0 +1,86 @@ +# Jetpack Device Detection + +A method to detect device types, originates from `jetpack_is_mobile`. + + + +### Usage + +Retrieve device information. + +```php +use Automattic\Jetpack\Device_Detection; + +$device_info = Device_Detection::get_info(); + +/** + * array( + * 'is_phone' => (bool) Whether the current device is a mobile phone. + * 'is_smartphone' => (bool) Whether the current device is a smartphone. + * 'is_tablet' => (bool) Whether the current device is a tablet device. + * 'is_handheld' => (bool) Whether the current device is a handheld device. + * 'is_desktop' => (bool) Whether the current device is a laptop / desktop device. + * 'platform' => (string) Detected platform. + * 'is_phone_matched_ua' => (string) Matched UA. + * ); + */ +``` + +Detect any mobile phone. + +```php +use Automattic\Jetpack\Device_Detection; + +$is_phone = Device_Detection::is_phone(); +``` + +Detect a smartphone. + +```php +use Automattic\Jetpack\Device_Detection; + +$is_smartphone = Device_Detection::is_smartphone(); +``` + +Detect a dumbphone. + +```php +use Automattic\Jetpack\Device_Detection; + +$is_dumbphone = Device_Detection::is_phone() && ! Device_Detection::is_smartphone(); +``` + +Detect a tablet. + +```php +use Automattic\Jetpack\Device_Detection; + +$is_tablet = Device_Detection::is_tablet(); +``` + +Detect a desktop device. + +```php +use Automattic\Jetpack\Device_Detection; + +$is_desktop = Device_Detection::is_desktop(); +``` + +Detect any handheld device. + +```php +use Automattic\Jetpack\Device_Detection; + +$is_handheld = Device_Detection::is_handheld(); +``` +## Using this package in your WordPress plugin + +If you plan on using this package in your WordPress plugin, we would recommend that you use [Jetpack Autoloader](https://packagist.org/packages/automattic/jetpack-autoloader) as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well. + +## Security + +Need to report a security vulnerability? Go to [https://automattic.com/security/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic). + +## License + +jetpack-device-detection is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt) diff --git a/vendor/automattic/jetpack-device-detection/SECURITY.md b/vendor/automattic/jetpack-device-detection/SECURITY.md new file mode 100644 index 00000000..b4b46c0e --- /dev/null +++ b/vendor/automattic/jetpack-device-detection/SECURITY.md @@ -0,0 +1,38 @@ +# Security Policy + +Full details of the Automattic Security Policy can be found on [automattic.com](https://automattic.com/security/). + +## Supported Versions + +Generally, only the latest version of Jetpack has continued support. If a critical vulnerability is found in the current version of Jetpack, we may opt to backport any patches to previous versions. + +## Reporting a Vulnerability + +[Jetpack](https://jetpack.com/) is an open-source plugin for WordPress. Our HackerOne program covers the plugin software, as well as a variety of related projects and infrastructure. + +**For responsible disclosure of security issues and to be eligible for our bug bounty program, please submit your report via the [HackerOne](https://hackerone.com/automattic) portal.** + +Our most critical targets are: + +* Jetpack and the Jetpack composer packages (all within this repo) +* Jetpack.com -- the primary marketing site. +* cloud.jetpack.com -- a management site. +* wordpress.com -- the shared management site for both Jetpack and WordPress.com sites. + +For more targets, see the `In Scope` section on [HackerOne](https://hackerone.com/automattic). + +_Please note that the **WordPress software is a separate entity** from Automattic. Please report vulnerabilities for WordPress through [the WordPress Foundation's HackerOne page](https://hackerone.com/wordpress)._ + +## Guidelines + +We're committed to working with security researchers to resolve the vulnerabilities they discover. You can help us by following these guidelines: + +* Follow [HackerOne's disclosure guidelines](https://www.hackerone.com/disclosure-guidelines). +* Pen-testing Production: + * Please **setup a local environment** instead whenever possible. Most of our code is open source (see above). + * If that's not possible, **limit any data access/modification** to the bare minimum necessary to reproduce a PoC. + * **_Don't_ automate form submissions!** That's very annoying for us, because it adds extra work for the volunteers who manage those systems, and reduces the signal/noise ratio in our communication channels. + * To be eligible for a bounty, all of these guidelines must be followed. +* Be Patient - Give us a reasonable time to correct the issue before you disclose the vulnerability. + +We also expect you to comply with all applicable laws. You're responsible to pay any taxes associated with your bounties. diff --git a/vendor/automattic/jetpack-device-detection/composer.json b/vendor/automattic/jetpack-device-detection/composer.json new file mode 100644 index 00000000..56ab710b --- /dev/null +++ b/vendor/automattic/jetpack-device-detection/composer.json @@ -0,0 +1,39 @@ +{ + "name": "automattic/jetpack-device-detection", + "description": "A way to detect device types based on User-Agent header.", + "type": "jetpack-library", + "license": "GPL-2.0-or-later", + "require": {}, + "require-dev": { + "yoast/phpunit-polyfills": "1.0.4", + "automattic/jetpack-changelogger": "^3.3.7" + }, + "suggest": { + "automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package." + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "scripts": { + "phpunit": [ + "./vendor/phpunit/phpunit/phpunit --colors=always" + ], + "test-php": [ + "@composer phpunit" + ] + }, + "minimum-stability": "dev", + "prefer-stable": true, + "extra": { + "autotagger": true, + "mirror-repo": "Automattic/jetpack-device-detection", + "changelogger": { + "link-template": "https://github.com/Automattic/jetpack-device-detection/compare/v${old}...v${new}" + }, + "branch-alias": { + "dev-trunk": "1.4.x-dev" + } + } +} diff --git a/vendor/automattic/jetpack-device-detection/src/class-device-detection.php b/vendor/automattic/jetpack-device-detection/src/class-device-detection.php new file mode 100644 index 00000000..684e568c --- /dev/null +++ b/vendor/automattic/jetpack-device-detection/src/class-device-detection.php @@ -0,0 +1,219 @@ + (bool) Whether the current device is a mobile phone. + * 'is_smartphone' => (bool) Whether the current device is a smartphone. + * 'is_tablet' => (bool) Whether the current device is a tablet device. + * 'is_handheld' => (bool) Whether the current device is a handheld device. + * 'is_desktop' => (bool) Whether the current device is a laptop / desktop device. + * 'platform' => (string) Detected platform. + * 'is_phone_matched_ua' => (string) Matched UA. + * ); + */ + public static function get_info( $ua = '' ) { + $ua_info = new User_Agent_Info( $ua ); + + $info = array( + 'is_phone' => self::is_mobile( 'any', false, $ua_info ), + 'is_phone_matched_ua' => self::is_mobile( 'any', true, $ua_info ), + 'is_smartphone' => self::is_mobile( 'smart', false, $ua_info ), + 'is_tablet' => $ua_info->is_tablet(), + 'platform' => $ua_info->get_platform(), + ); + + $info['is_handheld'] = $info['is_phone'] || $info['is_tablet']; + $info['is_desktop'] = ! $info['is_handheld']; + + if ( function_exists( 'apply_filters' ) ) { + /** + * Filter the value of Device_Detection::get_info. + * + * @since 1.0.0 + * + * @param array $info Array of device information. + * @param string $ua User agent string passed to Device_Detection::get_info. + * @param User_Agent_Info $ua_info Instance of Automattic\Jetpack\Device_Detection\User_Agent_Info. + */ + $info = apply_filters( 'jetpack_device_detection_get_info', $info, $ua, $ua_info ); + } + return $info; + } + + /** + * Detects phone devices. + * + * @param string $ua User-Agent string. + * + * @return bool + */ + public static function is_phone( $ua = '' ) { + $device_info = self::get_info( $ua ); + return true === $device_info['is_phone']; + } + + /** + * Detects smartphone devices. + * + * @param string $ua User-Agent string. + * + * @return bool + */ + public static function is_smartphone( $ua = '' ) { + $device_info = self::get_info( $ua ); + return true === $device_info['is_smartphone']; + } + + /** + * Detects tablet devices. + * + * @param string $ua User-Agent string. + * + * @return bool + */ + public static function is_tablet( $ua = '' ) { + $device_info = self::get_info( $ua ); + return true === $device_info['is_tablet']; + } + + /** + * Detects desktop devices. + * + * @param string $ua User-Agent string. + * + * @return bool + */ + public static function is_desktop( $ua = '' ) { + $device_info = self::get_info( $ua ); + return true === $device_info['is_desktop']; + } + + /** + * Detects handheld (i.e. phone + tablet) devices. + * + * @param string $ua User-Agent string. + * + * @return bool + */ + public static function is_handheld( $ua = '' ) { + $device_info = self::get_info( $ua ); + return true === $device_info['is_handheld']; + } + + /** + * Determine if the current User Agent matches the passed $kind. + * + * @param string $kind Category of mobile device to check for. Either: any, dumb, smart. + * @param bool $return_matched_agent Boolean indicating if the UA should be returned. + * @param User_Agent_Info $ua_info Boolean indicating if the UA should be returned. + * + * @return bool|string Boolean indicating if current UA matches $kind. If `$return_matched_agent` is true, returns the UA string. + */ + private static function is_mobile( $kind, $return_matched_agent, $ua_info ) { + $kinds = array( + 'smart' => false, + 'dumb' => false, + 'any' => false, + ); + $first_run = true; + $matched_agent = ''; + + // If an invalid kind is passed in, reset it to default. + if ( ! isset( $kinds[ $kind ] ) ) { + $kind = 'any'; + } + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( filter_var( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ); + if ( strpos( $agent, 'ipad' ) ) { + return false; + } + + // Remove Samsung Galaxy tablets (SCH-I800) from being mobile devices. + if ( strpos( $agent, 'sch-i800' ) ) { + return false; + } + + if ( $ua_info->is_android_tablet() && false === $ua_info->is_kindle_touch() ) { + return false; + } + + if ( $ua_info->is_blackberry_tablet() ) { + return false; + } + + if ( $first_run ) { + $first_run = false; + + // checks for iPhoneTier devices & RichCSS devices. + if ( $ua_info->isTierIphone() || $ua_info->isTierRichCSS() ) { + $kinds['smart'] = true; + $matched_agent = $ua_info->matched_agent; + } + + if ( ! $kinds['smart'] ) { + // if smart, we are not dumb so no need to check. + $dumb_agents = $ua_info->dumb_agents; + + foreach ( $dumb_agents as $dumb_agent ) { + if ( false !== strpos( $agent, $dumb_agent ) ) { + $kinds['dumb'] = true; + $matched_agent = $dumb_agent; + + break; + } + } + + if ( ! $kinds['dumb'] ) { + if ( isset( $_SERVER['HTTP_X_WAP_PROFILE'] ) ) { + $kinds['dumb'] = true; + $matched_agent = 'http_x_wap_profile'; + } elseif ( isset( $_SERVER['HTTP_ACCEPT'] ) && ( preg_match( '/wap\.|\.wap/i', $_SERVER['HTTP_ACCEPT'] ) || false !== strpos( strtolower( $_SERVER['HTTP_ACCEPT'] ), 'application/vnd.wap.xhtml+xml' ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is doing the validating. + $kinds['dumb'] = true; + $matched_agent = 'vnd.wap.xhtml+xml'; + } + } + } + + if ( $kinds['dumb'] || $kinds['smart'] ) { + $kinds['any'] = true; + } + } + + $value = $kinds[ $kind ]; + + if ( $return_matched_agent ) { + $value = $matched_agent; + } + return $value; + } +} diff --git a/vendor/automattic/jetpack-device-detection/src/class-user-agent-info.php b/vendor/automattic/jetpack-device-detection/src/class-user-agent-info.php new file mode 100644 index 00000000..3984dc2d --- /dev/null +++ b/vendor/automattic/jetpack-device-detection/src/class-user-agent-info.php @@ -0,0 +1,1572 @@ +useragent = $ua; + } elseif ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + $this->useragent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This class is all about validating. + } + } + + /** + * This method detects the mobile User Agent name. + * + * @return string The matched User Agent name, false otherwise. + */ + public function get_mobile_user_agent_name() { + if ( $this->is_chrome_for_iOS() ) { // Keep this check before the safari rule. + return 'chrome-for-ios'; + } elseif ( $this->is_iphone_or_ipod( 'iphone-safari' ) ) { + return 'iphone'; + } elseif ( $this->is_ipad( 'ipad-safari' ) ) { + return 'ipad'; + } elseif ( $this->is_android_tablet() ) { // Keep this check before the android rule. + return 'android_tablet'; + } elseif ( $this->is_android() ) { + return 'android'; + } elseif ( $this->is_blackberry_10() ) { + return 'blackberry_10'; + } elseif ( $this->is_blackbeberry() ) { + return 'blackberry'; + } elseif ( $this->is_WindowsPhone7() ) { + return 'win7'; + } elseif ( $this->is_windows_phone_8() ) { + return 'winphone8'; + } elseif ( $this->is_opera_mini() ) { + return 'opera-mini'; + } elseif ( $this->is_opera_mini_dumb() ) { + return 'opera-mini-dumb'; + } elseif ( $this->is_opera_mobile() ) { + return 'opera-mobi'; + } elseif ( $this->is_blackberry_tablet() ) { + return 'blackberry_tablet'; + } elseif ( $this->is_kindle_fire() ) { + return 'kindle-fire'; + } elseif ( $this->is_PalmWebOS() ) { + return 'webos'; + } elseif ( $this->is_S60_OSSBrowser() ) { + return 'series60'; + } elseif ( $this->is_firefox_os() ) { + return 'firefoxOS'; + } elseif ( $this->is_firefox_mobile() ) { + return 'firefox_mobile'; + } elseif ( $this->is_MaemoTablet() ) { + return 'maemo'; + } elseif ( $this->is_MeeGo() ) { + return 'meego'; + } elseif ( $this->is_TouchPad() ) { + return 'hp_tablet'; + } elseif ( $this->is_facebook_for_iphone() ) { + return 'facebook-for-iphone'; + } elseif ( $this->is_facebook_for_ipad() ) { + return 'facebook-for-ipad'; + } elseif ( $this->is_twitter_for_iphone() ) { + return 'twitter-for-iphone'; + } elseif ( $this->is_twitter_for_ipad() ) { + return 'twitter-for-ipad'; + } elseif ( $this->is_wordpress_for_ios() ) { + return 'ios-app'; + } elseif ( $this->is_iphone_or_ipod( 'iphone-not-safari' ) ) { + return 'iphone-unknown'; + } elseif ( $this->is_ipad( 'ipad-not-safari' ) ) { + return 'ipad-unknown'; + } elseif ( $this->is_Nintendo_3DS() ) { + return 'nintendo-3ds'; + } else { + $agent = $this->useragent; + $dumb_agents = $this->dumb_agents; + foreach ( $dumb_agents as $dumb_agent ) { + if ( false !== strpos( $agent, $dumb_agent ) ) { + return $dumb_agent; + } + } + } + + return false; + } + + /** + * This method detects the mobile device's platform. All return strings are from the class constants. + * Note that this function returns the platform name, not the UA name/type. You should use a different function + * if you need to test the UA capabilites. + * + * @return string|bool Name of the platform, false otherwise. + */ + public function get_platform() { + if ( isset( $this->platform ) ) { + return $this->platform; + } + + if ( empty( $this->useragent ) ) { + return false; + } + + if ( strpos( $this->useragent, 'windows phone' ) !== false ) { + $this->platform = self::PLATFORM_WINDOWS; + } elseif ( strpos( $this->useragent, 'windows ce' ) !== false ) { + $this->platform = self::PLATFORM_WINDOWS; + } elseif ( strpos( $this->useragent, 'ipad' ) !== false ) { + $this->platform = self::PLATFORM_IPAD; + } elseif ( strpos( $this->useragent, 'ipod' ) !== false ) { + $this->platform = self::PLATFORM_IPOD; + } elseif ( strpos( $this->useragent, 'iphone' ) !== false ) { + $this->platform = self::PLATFORM_IPHONE; + } elseif ( strpos( $this->useragent, 'android' ) !== false ) { + if ( $this->is_android_tablet() ) { + $this->platform = self::PLATFORM_ANDROID_TABLET; + } else { + $this->platform = self::PLATFORM_ANDROID; + } + } elseif ( $this->is_kindle_fire() ) { + $this->platform = self::PLATFORM_ANDROID_TABLET; + } elseif ( $this->is_blackberry_10() ) { + $this->platform = self::PLATFORM_BLACKBERRY_10; + } elseif ( strpos( $this->useragent, 'blackberry' ) !== false ) { + $this->platform = self::PLATFORM_BLACKBERRY; + } elseif ( $this->is_blackberry_tablet() ) { + $this->platform = self::PLATFORM_BLACKBERRY; + } elseif ( $this->is_symbian_platform() ) { + $this->platform = self::PLATFORM_SYMBIAN; + } elseif ( $this->is_symbian_s40_platform() ) { + $this->platform = self::PLATFORM_SYMBIAN_S40; + } elseif ( $this->is_J2ME_platform() ) { + $this->platform = self::PLATFORM_J2ME_MIDP; + } elseif ( $this->is_firefox_os() ) { + $this->platform = self::PLATFORM_FIREFOX_OS; + } else { + $this->platform = false; + } + + return $this->platform; + } + + /** + * This method detects for UA which can display iPhone-optimized web content. + * Includes iPhone, iPod Touch, Android, WebOS, Fennec (Firefox mobile), etc. + */ + public function isTierIphone() { + if ( isset( $this->isTierIphone ) ) { + return $this->isTierIphone; + } + if ( $this->is_iphoneOrIpod() ) { + $this->matched_agent = 'iphone'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_android() ) { + $this->matched_agent = 'android'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_windows_phone_8() ) { + $this->matched_agent = 'winphone8'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_WindowsPhone7() ) { + $this->matched_agent = 'win7'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_blackberry_10() ) { + $this->matched_agent = 'blackberry-10'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_blackbeberry() && 'blackberry-webkit' === $this->detect_blackberry_browser_version() ) { + $this->matched_agent = 'blackberry-webkit'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_blackberry_tablet() ) { + $this->matched_agent = 'blackberry_tablet'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_PalmWebOS() ) { + $this->matched_agent = 'webos'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_TouchPad() ) { + $this->matched_agent = 'hp_tablet'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_firefox_os() ) { + $this->matched_agent = 'firefoxOS'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_firefox_mobile() ) { + $this->matched_agent = 'fennec'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_opera_mobile() ) { + $this->matched_agent = 'opera-mobi'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_MaemoTablet() ) { + $this->matched_agent = 'maemo'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_MeeGo() ) { + $this->matched_agent = 'meego'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_kindle_touch() ) { + $this->matched_agent = 'kindle-touch'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } elseif ( $this->is_Nintendo_3DS() ) { + $this->matched_agent = 'nintendo-3ds'; + $this->isTierIphone = true; + $this->isTierRichCss = false; + $this->isTierGenericMobile = false; + } else { + $this->isTierIphone = false; + } + return $this->isTierIphone; + } + + /** + * This method detects for UA which are likely to be capable + * but may not necessarily support JavaScript. + * Excludes all iPhone Tier UA. + */ + public function isTierRichCss() { + if ( isset( $this->isTierRichCss ) ) { + return $this->isTierRichCss; + } + if ( $this->isTierIphone() ) { + return false; + } + + // The following devices are explicitly ok. + if ( $this->is_S60_OSSBrowser() ) { + $this->matched_agent = 'series60'; + $this->isTierIphone = false; + $this->isTierRichCss = true; + $this->isTierGenericMobile = false; + } elseif ( $this->is_opera_mini() ) { + $this->matched_agent = 'opera-mini'; + $this->isTierIphone = false; + $this->isTierRichCss = true; + $this->isTierGenericMobile = false; + } elseif ( $this->is_blackbeberry() ) { + $detectedDevice = $this->detect_blackberry_browser_version(); + if ( + 'blackberry-5' === $detectedDevice + || 'blackberry-4.7' === $detectedDevice + || 'blackberry-4.6' === $detectedDevice + ) { + $this->matched_agent = $detectedDevice; + $this->isTierIphone = false; + $this->isTierRichCss = true; + $this->isTierGenericMobile = false; + } + } else { + $this->isTierRichCss = false; + } + + return $this->isTierRichCss; + } + + /** + * Detects if the user is using a tablet. + * props Corey Gilmore, BGR.com + * + * @return bool + */ + public function is_tablet() { + return ( 0 // Never true, but makes it easier to manage our list of tablet conditions. + || self::is_ipad() + || self::is_android_tablet() + || self::is_blackberry_tablet() + || self::is_kindle_fire() + || self::is_MaemoTablet() + || self::is_TouchPad() + ); + } + + /** + * Detects if the current UA is the default iPhone or iPod Touch Browser. + * + * DEPRECATED: use is_iphone_or_ipod + */ + public function is_iphoneOrIpod() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + if ( ( strpos( $ua, 'iphone' ) !== false ) || ( strpos( $ua, 'ipod' ) !== false ) ) { + if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + return false; + } else { + return true; + } + } else { + return false; + } + } + + /** + * Detects if the current UA is iPhone Mobile Safari or another iPhone or iPod Touch Browser. + * + * They type can check for any iPhone, an iPhone using Safari, or an iPhone using something other than Safari. + * + * Note: If you want to check for Opera mini, Opera mobile or Firefox mobile (or any 3rd party iPhone browser), + * you should put the check condition before the check for 'iphone-any' or 'iphone-not-safari'. + * Otherwise those browsers will be 'catched' by the iphone string. + * + * @param string $type Type of iPhone detection. + */ + public static function is_iphone_or_ipod( $type = 'iphone-any' ) { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + $is_iphone = ( strpos( $ua, 'iphone' ) !== false ) || ( strpos( $ua, 'ipod' ) !== false ); + $is_safari = ( false !== strpos( $ua, 'safari' ) ); + + if ( 'iphone-safari' === $type ) { + return $is_iphone && $is_safari; + } elseif ( 'iphone-not-safari' === $type ) { + return $is_iphone && ! $is_safari; + } else { + return $is_iphone; + } + } + + /** + * Detects if the current UA is Chrome for iOS + * + * The User-Agent string in Chrome for iOS is the same as the Mobile Safari User-Agent, with CriOS/ instead of Version/. + * - Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3 + */ + public static function is_chrome_for_iOS() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + if ( self::is_iphone_or_ipod( 'iphone-safari' ) === false ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( strpos( $ua, 'crios/' ) !== false ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current UA is Twitter for iPhone + * + * Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_5 like Mac OS X; nb-no) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8L1 Twitter for iPhone + * Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 Twitter for iPhone + */ + public static function is_twitter_for_iphone() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( strpos( $ua, 'ipad' ) !== false ) { + return false; + } + + if ( strpos( $ua, 'twitter for iphone' ) !== false ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current UA is Twitter for iPad + * + * Old version 4.X - Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8L1 Twitter for iPad + * Ver 5.0 or Higher - Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 Twitter for iPhone + */ + public static function is_twitter_for_ipad() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( strpos( $ua, 'twitter for ipad' ) !== false ) { + return true; + } elseif ( strpos( $ua, 'ipad' ) !== false && strpos( $ua, 'twitter for iphone' ) !== false ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current UA is Facebook for iPhone + * - Facebook 4020.0 (iPhone; iPhone OS 5.0.1; fr_FR) + * - Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_0 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.0.2;FBBV/4020.0;FBDV/iPhone3,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/5.0;FBSS/2; FBCR/O2;FBID/phone;FBLC/en_US;FBSF/2.0] + * - Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206 [FBAN/FBIOS;FBAV/5.0;FBBV/47423;FBDV/iPhone3,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/5.1.1;FBSS/2; FBCR/3ITA;FBID/phone;FBLC/en_US] + */ + public static function is_facebook_for_iphone() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( false === strpos( $ua, 'iphone' ) ) { + return false; + } + + if ( false !== strpos( $ua, 'facebook' ) && false === strpos( $ua, 'ipad' ) ) { + return true; + } elseif ( false !== strpos( $ua, 'fbforiphone' ) && false === strpos( $ua, 'tablet' ) ) { + return true; + } elseif ( false !== strpos( $ua, 'fban/fbios;' ) && false === strpos( $ua, 'tablet' ) ) { // FB app v5.0 or higher. + return true; + } else { + return false; + } + } + + /** + * Detects if the current UA is Facebook for iPad + * - Facebook 4020.0 (iPad; iPhone OS 5.0.1; en_US) + * - Mozilla/5.0 (iPad; U; CPU iPhone OS 5_0 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.0.2;FBBV/4020.0;FBDV/iPad2,1;FBMD/iPad;FBSN/iPhone OS;FBSV/5.0;FBSS/1; FBCR/;FBID/tablet;FBLC/en_US;FBSF/1.0] + * - Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10A403 [FBAN/FBIOS;FBAV/5.0;FBBV/47423;FBDV/iPad2,1;FBMD/iPad;FBSN/iPhone OS;FBSV/6.0;FBSS/1; FBCR/;FBID/tablet;FBLC/en_US] + */ + public static function is_facebook_for_ipad() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( false === strpos( $ua, 'ipad' ) ) { + return false; + } + + if ( false !== strpos( $ua, 'facebook' ) || false !== strpos( $ua, 'fbforiphone' ) || false !== strpos( $ua, 'fban/fbios;' ) ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current UA is WordPress for iOS + */ + public static function is_wordpress_for_ios() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + if ( false !== strpos( $ua, 'wp-iphone' ) ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current device is an iPad. + * They type can check for any iPad, an iPad using Safari, or an iPad using something other than Safari. + * + * Note: If you want to check for Opera mini, Opera mobile or Firefox mobile (or any 3rd party iPad browser), + * you should put the check condition before the check for 'iphone-any' or 'iphone-not-safari'. + * Otherwise those browsers will be 'catched' by the ipad string. + * + * @param string $type iPad type. + */ + public static function is_ipad( $type = 'ipad-any' ) { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + $is_ipad = ( false !== strpos( $ua, 'ipad' ) ); + $is_safari = ( false !== strpos( $ua, 'safari' ) ); + + if ( 'ipad-safari' === $type ) { + return $is_ipad && $is_safari; + } elseif ( 'ipad-not-safari' === $type ) { + return $is_ipad && ! $is_safari; + } else { + return $is_ipad; + } + } + + /** + * Detects if the current browser is Firefox Mobile (Fennec) + * + * See http://www.useragentstring.com/pages/Fennec/ + * Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.1.1) Gecko/20110415 Firefox/4.0.2pre Fennec/4.0.1 + * Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1 + */ + public static function is_firefox_mobile() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( strpos( $ua, 'fennec' ) !== false ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current browser is Firefox for desktop + * + * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox + * Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion + * The platform section will include 'Mobile' for phones and 'Tablet' for tablets. + */ + public static function is_firefox_desktop() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( false !== strpos( $ua, 'firefox' ) && false === strpos( $ua, 'mobile' ) && false === strpos( $ua, 'tablet' ) ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current browser is FirefoxOS Native browser + * + * Mozilla/5.0 (Mobile; rv:14.0) Gecko/14.0 Firefox/14.0 + */ + public static function is_firefox_os() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( strpos( $ua, 'mozilla' ) !== false && strpos( $ua, 'mobile' ) !== false && strpos( $ua, 'gecko' ) !== false && strpos( $ua, 'firefox' ) !== false ) { + return true; + } else { + return false; + } + } + + /** + * Detect modern Opera desktop + * + * Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 OPR/74.0.3911.203 + * + * Looking for "OPR/" specifically. + */ + public static function is_opera_desktop() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + if ( false === strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'OPR/' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + return false; + } + + return true; + } + + /** + * Detects if the current browser is Opera Mobile + * + * What is the difference between Opera Mobile and Opera Mini? + * - Opera Mobile is a full Internet browser for mobile devices. + * - Opera Mini always uses a transcoder to convert the page for a small display. + * (it uses Opera advanced server compression technology to compress web content before it gets to a device. + * The rendering engine is on Opera's server.) + * + * Opera/9.80 (Windows NT 6.1; Opera Mobi/14316; U; en) Presto/2.7.81 Version/11.00" + * Opera/9.50 (Nintendo DSi; Opera/507; U; en-US) + */ + public static function is_opera_mobile() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( strpos( $ua, 'opera' ) !== false && strpos( $ua, 'mobi' ) !== false ) { + return true; + } elseif ( strpos( $ua, 'opera' ) !== false && strpos( $ua, 'nintendo dsi' ) !== false ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current browser is Opera Mini + * + * Opera/8.01 (J2ME/MIDP; Opera Mini/3.0.6306/1528; en; U; ssr) + * Opera/9.80 (Android;Opera Mini/6.0.24212/24.746 U;en) Presto/2.5.25 Version/10.5454 + * Opera/9.80 (iPhone; Opera Mini/5.0.019802/18.738; U; en) Presto/2.4.15 + * Opera/9.80 (J2ME/iPhone;Opera Mini/5.0.019802/886; U; ja) Presto/2.4.15 + * Opera/9.80 (J2ME/iPhone;Opera Mini/5.0.019802/886; U; ja) Presto/2.4.15 + * Opera/9.80 (Series 60; Opera Mini/5.1.22783/23.334; U; en) Presto/2.5.25 Version/10.54 + * Opera/9.80 (BlackBerry; Opera Mini/5.1.22303/22.387; U; en) Presto/2.5.25 Version/10.54 + */ + public static function is_opera_mini() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( strpos( $ua, 'opera' ) !== false && strpos( $ua, 'mini' ) !== false ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current browser is Opera Mini, but not on a smart device OS(Android, iOS, etc) + * Used to send users on dumb devices to m.wor + */ + public static function is_opera_mini_dumb() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( self::is_opera_mini() ) { + if ( strpos( $ua, 'android' ) !== false || strpos( $ua, 'iphone' ) !== false || strpos( $ua, 'ipod' ) !== false + || strpos( $ua, 'ipad' ) !== false || strpos( $ua, 'blackberry' ) !== false ) { + return false; + } else { + return true; + } + } else { + return false; + } + } + + /** + * Detects if the current browser is a Windows Phone 7 device. + * ex: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910) + */ + public static function is_WindowsPhone7() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( false === strpos( $ua, 'windows phone os 7' ) ) { + return false; + } elseif ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + return false; + } else { + return true; + } + } + + /** + * Detects if the current browser is a Windows Phone 8 device. + * ex: Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; ARM; Touch; IEMobile/10.0; ; [;]) + */ + public static function is_windows_phone_8() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + if ( strpos( $ua, 'windows phone 8' ) === false ) { + return false; + } else { + return true; + } + } + + /** + * Detects if the current browser is on a Palm device running the new WebOS. This EXCLUDES TouchPad. + * + * Ex1: Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pre/1.1 + * Ex2: Mozilla/5.0 (webOS/1.4.0; U; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Version/1.0 Safari/532.2 Pixi/1.1 + */ + public static function is_PalmWebOS() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( false === strpos( $ua, 'webos' ) ) { + return false; + } elseif ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + return false; + } else { + return true; + } + } + + /** + * Detects if the current browser is the HP TouchPad default browser. This excludes phones wt WebOS. + * + * TouchPad Emulator: Mozilla/5.0 (hp-desktop; Linux; hpwOS/2.0; U; it-IT) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 Desktop/1.0 + * TouchPad: Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.0; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 TouchPad/1.0 + */ + public static function is_TouchPad() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $http_user_agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + if ( false !== strpos( $http_user_agent, 'hp-tablet' ) || false !== strpos( $http_user_agent, 'hpwos' ) || false !== strpos( $http_user_agent, 'touchpad' ) ) { + if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + return false; + } else { + return true; + } + } else { + return false; + } + } + + /** + * Detects if the current browser is the Series 60 Open Source Browser. + * + * OSS Browser 3.2 on E75: Mozilla/5.0 (SymbianOS/9.3; U; Series60/3.2 NokiaE75-1/110.48.125 Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413 + * + * 7.0 Browser (Nokia 5800 XpressMusic (v21.0.025)) : Mozilla/5.0 (SymbianOS/9.4; U; Series60/5.0 Nokia5800d-1/21.0.025; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413 + * + * Browser 7.1 (Nokia N97 (v12.0.024)) : Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/12.0.024; Profile/MIDP-2.1 Configuration/CLDC-1.1; en-us) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.12344 + */ + public static function is_S60_OSSBrowser() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + return false; + } + + $pos_webkit = strpos( $agent, 'webkit' ); + if ( false !== $pos_webkit ) { + // First, test for WebKit, then make sure it's either Symbian or S60. + if ( strpos( $agent, 'symbian' ) !== false || strpos( $agent, 'series60' ) !== false ) { + return true; + } else { + return false; + } + } elseif ( strpos( $agent, 'symbianos' ) !== false && strpos( $agent, 'series60' ) !== false ) { + return true; + } elseif ( strpos( $agent, 'nokia' ) !== false && strpos( $agent, 'series60' ) !== false ) { + return true; + } + + return false; + } + + /** + * Detects if the device platform is the Symbian Series 60. + */ + public static function is_symbian_platform() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + $pos_webkit = strpos( $agent, 'webkit' ); + if ( false !== $pos_webkit ) { + // First, test for WebKit, then make sure it's either Symbian or S60. + if ( strpos( $agent, 'symbian' ) !== false || strpos( $agent, 'series60' ) !== false ) { + return true; + } else { + return false; + } + } elseif ( strpos( $agent, 'symbianos' ) !== false && strpos( $agent, 'series60' ) !== false ) { + return true; + } elseif ( strpos( $agent, 'nokia' ) !== false && strpos( $agent, 'series60' ) !== false ) { + return true; + } elseif ( strpos( $agent, 'opera mini' ) !== false ) { + if ( strpos( $agent, 'symbianos' ) !== false || strpos( $agent, 'symbos' ) !== false || strpos( $agent, 'series 60' ) !== false ) { + return true; + } + } + + return false; + } + + /** + * Detects if the device platform is the Symbian Series 40. + * Nokia Browser for Series 40 is a proxy based browser, previously known as Ovi Browser. + * This browser will report 'NokiaBrowser' in the header, however some older version will also report 'OviBrowser'. + */ + public static function is_symbian_s40_platform() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( strpos( $agent, 'series40' ) !== false ) { + if ( strpos( $agent, 'nokia' ) !== false || strpos( $agent, 'ovibrowser' ) !== false || strpos( $agent, 'nokiabrowser' ) !== false ) { + return true; + } + } + + return false; + } + + /** + * Returns if the device belongs to J2ME capable family. + * + * @return bool + */ + public static function is_J2ME_platform() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( strpos( $agent, 'j2me/midp' ) !== false ) { + return true; + } elseif ( strpos( $agent, 'midp' ) !== false && strpos( $agent, 'cldc' ) ) { + return true; + } + return false; + } + + /** + * Detects if the current UA is on one of the Maemo-based Nokia Internet Tablets. + */ + public static function is_MaemoTablet() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + $pos_maemo = strpos( $agent, 'maemo' ); + if ( false === $pos_maemo ) { + return false; + } + + // Must be Linux + Tablet, or else it could be something else. + if ( strpos( $agent, 'tablet' ) !== false && strpos( $agent, 'linux' ) !== false ) { + if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + return false; + } else { + return true; + } + } else { + return false; + } + } + + /** + * Detects if the current UA is a MeeGo device (Nokia Smartphone). + */ + public static function is_MeeGo() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( false === strpos( $ua, 'meego' ) ) { + return false; + } elseif ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + return false; + } else { + return true; + } + } + + /** + * The is_webkit() method can be used to check the User Agent for an webkit generic browser. + */ + public static function is_webkit() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + $pos_webkit = strpos( $agent, 'webkit' ); + + if ( false !== $pos_webkit ) { + return true; + } else { + return false; + } + } + + /** + * Detects if the current browser is the Native Android browser. + * + * @return boolean true if the browser is Android otherwise false + */ + public static function is_android() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + $pos_android = strpos( $agent, 'android' ); + if ( false !== $pos_android ) { + if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + return false; + } else { + return true; + } + } else { + return false; + } + } + + /** + * Detects if the current browser is the Native Android Tablet browser. + * Assumes 'Android' should be in the user agent, but not 'mobile' + * + * @return boolean true if the browser is Android and not 'mobile' otherwise false + */ + public static function is_android_tablet() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + $pos_android = strpos( $agent, 'android' ); + $pos_mobile = strpos( $agent, 'mobile' ); + $post_android_app = strpos( $agent, 'wp-android' ); + + if ( false !== $pos_android && false === $pos_mobile && false === $post_android_app ) { + if ( self::is_opera_mini() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + return false; + } else { + return true; + } + } else { + return false; + } + } + + /** + * Detects if the current browser is the Kindle Fire Native browser. + * + * Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-84) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true + * Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-84) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=false + * + * @return boolean true if the browser is Kindle Fire Native browser otherwise false + */ + public static function is_kindle_fire() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_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+ + * + * @return boolean true if the browser is Kindle monochrome Native browser otherwise false + */ + public static function is_kindle_touch() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + $agent = strtolower( wp_unslash( $_SERVER['HTTP_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() ) { + return true; + } else { + return false; + } + } + + /** + * Detect if user agent is the WordPress.com Windows 8 app (used ONLY on the custom oauth stylesheet) + */ + public static function is_windows8_auth() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_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. + */ + public static function is_wordpress_for_win8() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_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. + */ + public static function is_wordpress_desktop_app() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_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+ + */ + public static function is_blackberry_tablet() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_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. + */ + public static function is_blackbeberry() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_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() || self::is_opera_mobile() || self::is_firefox_mobile() ) { + 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. + */ + public static function is_blackberry_10() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + return ( strpos( $agent, 'bb10' ) !== false ) && ( strpos( $agent, 'mobile' ) !== false ); + } + + /** + * 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 + * + * @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() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + if ( self::is_blackberry_10() ) { + return 'blackberry-10'; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_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 ( false === is_array( $version_num ) || 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 ( is_array( $version_num ) === false || 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 + * + * @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() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + + if ( self::is_blackberry_10() ) { + 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 ( false === is_array( $version_num ) || 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. + * + * @return bool + */ + public static function is_mobile_app() { + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $agent = strtolower( wp_unslash( $_SERVER['HTTP_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 + */ + public static function is_Nintendo_3DS() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + $ua = strtolower( wp_unslash( $_SERVER['HTTP_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? + * + * @return boolean + */ + public static function is_bot() { + static $is_bot = null; + + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + + if ( $is_bot === null ) { + $is_bot = self::is_bot_user_agent( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + } + + return $is_bot; + } + + /** + * 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; + } + + $bot_agents = array( + 'alexa', + 'altavista', + 'ask jeeves', + 'attentio', + 'baiduspider', + 'bingbot', + 'chtml generic', + 'crawler', + 'fastmobilecrawl', + 'feedfetcher-google', + 'firefly', + 'froogle', + 'gigabot', + 'googlebot', + 'googlebot-mobile', + 'heritrix', + 'httrack', + 'ia_archiver', + 'irlbot', + 'iescholar', + 'infoseek', + 'jumpbot', + 'linkcheck', + 'lycos', + 'mediapartners', + 'mediobot', + 'motionbot', + 'msnbot', + 'mshots', + 'openbot', + 'pss-webkit-request', + 'pythumbnail', + 'scooter', + 'slurp', + 'snapbot', + 'spider', + 'taptubot', + 'technoratisnoop', + 'teoma', + 'twiceler', + 'yahooseeker', + 'yahooysmcm', + 'yammybot', + 'ahrefsbot', + 'pingdom.com_bot', + 'kraken', + 'yandexbot', + 'twitterbot', + 'tweetmemebot', + 'openhosebot', + 'queryseekerspider', + 'linkdexbot', + 'grokkit-crawler', + 'livelapbot', + 'germcrawler', + 'domaintunocrawler', + 'grapeshotcrawler', + 'cloudflare-alwaysonline', + ); + + foreach ( $bot_agents as $bot_agent ) { + if ( false !== stripos( $ua, $bot_agent ) ) { + return true; + } + } + + return false; + } +} diff --git a/vendor/automattic/jetpack-device-detection/src/functions.php b/vendor/automattic/jetpack-device-detection/src/functions.php new file mode 100644 index 00000000..a530e7f9 --- /dev/null +++ b/vendor/automattic/jetpack-device-detection/src/functions.php @@ -0,0 +1,36 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var ?string */ + private $vendorDir; + + // PSR-4 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ + private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ + private $missingClasses = array(); + + /** @var ?string */ + private $apcuPrefix; + + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return string[] + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array[] + * @psalm-return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return array[] + * @psalm-return array + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return string[] Array of classname => path + * @psalm-return array + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + $includeFile = self::$includeFile; + $includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } + + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 00000000..51e734a7 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,359 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ +class InstalledVersions +{ + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 00000000..f27399a0 --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..059d5eb2 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,12 @@ + $vendorDir . '/automattic/jetpack-device-detection/src/class-device-detection.php', + 'Automattic\\Jetpack\\Device_Detection\\User_Agent_Info' => $vendorDir . '/automattic/jetpack-device-detection/src/class-user-agent-info.php', + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 00000000..15a2ff3a --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ +setClassMapAuthoritative(true); + $loader->register(true); + + return $loader; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 00000000..a8e8529e --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,22 @@ + __DIR__ . '/..' . '/automattic/jetpack-device-detection/src/class-device-detection.php', + 'Automattic\\Jetpack\\Device_Detection\\User_Agent_Info' => __DIR__ . '/..' . '/automattic/jetpack-device-detection/src/class-user-agent-info.php', + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->classMap = ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_10_0_alpha::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 00000000..232257fd --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,56 @@ +{ + "packages": [ + { + "name": "automattic/jetpack-device-detection", + "version": "1.4.26", + "version_normalized": "1.4.26.0", + "dist": { + "type": "path", + "url": "/tmp/jetpack-build/Automattic/jetpack-device-detection", + "reference": "bf77c8b509801c531708038c56a3a79d08358531" + }, + "require-dev": { + "automattic/jetpack-changelogger": "^3.3.7", + "yoast/phpunit-polyfills": "1.0.4" + }, + "suggest": { + "automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package." + }, + "type": "jetpack-library", + "extra": { + "autotagger": true, + "mirror-repo": "Automattic/jetpack-device-detection", + "changelogger": { + "link-template": "https://github.com/Automattic/jetpack-device-detection/compare/v${old}...v${new}" + }, + "branch-alias": { + "dev-trunk": "1.4.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "scripts": { + "phpunit": [ + "./vendor/phpunit/phpunit/phpunit --colors=always" + ], + "test-php": [ + "@composer phpunit" + ] + }, + "license": [ + "GPL-2.0-or-later" + ], + "description": "A way to detect device types based on User-Agent header.", + "transport-options": { + "relative": false + }, + "install-path": "../automattic/jetpack-device-detection" + } + ], + "dev": false, + "dev-package-names": [] +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 00000000..6df2e40e --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,32 @@ + array( + 'name' => 'automattic/wp-super-cache', + 'pretty_version' => 'dev-trunk', + 'version' => 'dev-trunk', + 'reference' => NULL, + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev' => false, + ), + 'versions' => array( + 'automattic/jetpack-device-detection' => array( + 'pretty_version' => '1.4.26', + 'version' => '1.4.26.0', + 'reference' => 'bf77c8b509801c531708038c56a3a79d08358531', + 'type' => 'jetpack-library', + 'install_path' => __DIR__ . '/../automattic/jetpack-device-detection', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'automattic/wp-super-cache' => array( + 'pretty_version' => 'dev-trunk', + 'version' => 'dev-trunk', + 'reference' => NULL, + 'type' => 'wordpress-plugin', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + ), +);