automattic / jetpack-device-detection
基于User-Agent头检测设备类型的方法。
v2.1.5
2024-09-16 14:36 UTC
Requires
- php: >=7.0
Requires (Dev)
- automattic/jetpack-changelogger: ^4.2.6
- yoast/phpunit-polyfills: ^1.1.1
Suggests
- automattic/jetpack-autoloader: Allow for better interoperability with other plugins that use this package.
- dev-trunk / 2.1.x-dev
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.1
- v2.0.0
- v1.5.1
- v1.5.0
- v1.4.27
- v1.4.26
- v1.4.25
- v1.4.24
- v1.4.23
- v1.4.22
- v1.4.21
- v1.4.20
- v1.4.19
- v1.4.18
- v1.4.17
- v1.4.16
- v1.4.15
- v1.4.14
- v1.4.13
- v1.4.12
- v1.4.11
- v1.4.10
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- 1.4.0
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- dev-prerelease
- dev-fix/slack-workflow-branch-detection
- dev-fix/release-branch-typo
- dev-update/generate-branch-plugin
- dev-release-v1.3.2
- dev-release-v1.3.1
- dev-feature/reorg
- dev-release-v1.3.0
- dev-release-v1.2.1
- dev-release-v1.2.0
- dev-release-v1.1.0
- dev-release-v1.0.0
This package is auto-updated.
Last update: 2024-09-18 03:17:43 UTC
README
检测设备类型的方法,源自jetpack_is_mobile
。
用法
检索设备信息。
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. * ); */
检测任何手机。
use Automattic\Jetpack\Device_Detection; $is_phone = Device_Detection::is_phone();
检测智能手机。
use Automattic\Jetpack\Device_Detection; $is_smartphone = Device_Detection::is_smartphone();
检测功能手机。
use Automattic\Jetpack\Device_Detection; $is_dumbphone = Device_Detection::is_phone() && ! Device_Detection::is_smartphone();
检测平板电脑。
use Automattic\Jetpack\Device_Detection; $is_tablet = Device_Detection::is_tablet();
检测桌面设备。
use Automattic\Jetpack\Device_Detection; $is_desktop = Device_Detection::is_desktop();
检测任何手持设备。
use Automattic\Jetpack\Device_Detection; $is_handheld = Device_Detection::is_handheld();
在您的WordPress插件中使用此包
如果您计划在WordPress插件中使用此包,我们建议您使用Jetpack Autoloader作为自动加载器。这将允许与其他使用此包的插件实现最大兼容性。
安全性
需要报告安全漏洞?请访问https://automattic.com/security/或直接访问我们的安全漏洞赏金网站https://hackerone.com/automattic。
许可协议
jetpack-device-detection遵循GNU通用公共许可证v2(或更高版本)