From: joshuaruesweg Date: Thu, 29 Oct 2020 12:55:47 +0000 (+0100) Subject: Add UserUtil::isTablet() method X-Git-Tag: 5.4.0_Alpha_1~656^2~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8342a0779f96495a43380a33fcc4cb2f72736af6;p=GitHub%2FWoltLab%2FWCF.git Add UserUtil::isTablet() method --- diff --git a/wcfsetup/install/files/lib/util/UserUtil.class.php b/wcfsetup/install/files/lib/util/UserUtil.class.php index f2d96ca1b0..39970a3cb6 100644 --- a/wcfsetup/install/files/lib/util/UserUtil.class.php +++ b/wcfsetup/install/files/lib/util/UserUtil.class.php @@ -140,6 +140,20 @@ final class UserUtil { return false; } + /** + * Checks if the User Agent gives an indicator about a tablet device. + * Heads up: This is only a basic test and can easily be falsified by the user. + * + * @since 5.4 + */ + public static function isTablet(string $userAgent): bool { + if (preg_match('/tab(let)|ipad/i', $userAgent)) { + return true; + } + + return false; + } + /** * Returns the readable browser for a given user agent. *