automattic / jetpack-device-detection
A way to detect device types based on User-Agent header.
Installs: 28 308
Dependents: 3
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 2
Type:jetpack-library
Requires (Dev)
- automattic/jetpack-changelogger: ^3.3.1
- yoast/phpunit-polyfills: 1.0.4
- dev-trunk / 1.4.x-dev
- 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: 2023-02-06 22:35:10 UTC
README
A method to detect device types, originates from jetpack_is_mobile
.
Usage
Retrieve device information.
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.
use Automattic\Jetpack\Device_Detection; $is_phone = Device_Detection::is_phone();
Detect a smartphone.
use Automattic\Jetpack\Device_Detection; $is_smartphone = Device_Detection::is_smartphone();
Detect a dumbphone.
use Automattic\Jetpack\Device_Detection; $is_dumbphone = Device_Detection::is_phone() && ! Device_Detection::is_smartphone();
Detect a tablet.
use Automattic\Jetpack\Device_Detection; $is_tablet = Device_Detection::is_tablet();
Detect a desktop device.
use Automattic\Jetpack\Device_Detection; $is_desktop = Device_Detection::is_desktop();
Detect any handheld device.
use Automattic\Jetpack\Device_Detection; $is_handheld = Device_Detection::is_handheld();