定制 automattic/jetpack-device-detection 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

automattic/jetpack-device-detection

最新稳定版本:v3.3.0

Composer 安装命令:

composer require automattic/jetpack-device-detection

包简介

A way to detect device types based on User-Agent header.

README 文档

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

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 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/ or directly to our security bug bounty site https://hackerone.com/automattic.

License

jetpack-device-detection is licensed under GNU General Public License v2 (or later)

统计信息

  • 总下载量: 58.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 7
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-01-04