wp_is_mobile()判断用户是否为手机移动端设备浏览

目录

描述

This Conditional Tag checks if the user is visiting using a mobile device. This is a boolean function, meaning it returns either TRUE or FALSE.
Works through the detection of the browser user agent string ($_SERVER['HTTP_USER_AGENT'])

wp_is_mobile() 描述

用法

<?php wp_is_mobile(); ?>

wp_is_mobile() 用法

参数

This tag does not accept any parameters.

wp_is_mobile() 参数

示例

You should realize that this does not detect a mobile phone specifically, as a tablet is considered a mobile device. Check the Plugins area for several helpful alternatives. It also should not be used for themes.

wp_is_mobile() 示例

历史

  • 4.0 -- Works by testing HTTP_USER_AGENT for any of the following : [ Mobile, Android, Silk/, Kindle, BlackBerry, Opera Mini, OperaMobi ]. Does not consider resolution, window width, or any other factors.
  • 添加于 版本: 3.4

wp_is_mobile() 历史

源文件

wp_is_mobile() 函数的代码位于 wp-includes/vars.php.

wp_is_mobile() 源文件