Skip to content

Automattic/jetpack-device-detection

v1.4.9
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 

Jetpack Device Detection

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();

About

[READ ONLY] A method to detect device types, originates from `jetpack_is_mobile`. This repository is a mirror, for issue tracking and development head to: https://github.com/automattic/jetpack

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Languages