本文整理汇总了PHP中Mobile_Detect::mobileGrade方法的典型用法代码示例。如果您正苦于以下问题:PHP Mobile_Detect::mobileGrade方法的具体用法?PHP Mobile_Detect::mobileGrade怎么用?PHP Mobile_Detect::mobileGrade使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mobile_Detect
的用法示例。
在下文中一共展示了Mobile_Detect::mobileGrade方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?php
/**
* =============== CACTUSTHEMES.COM ===================
* ======== Cactusthemes Skeleton Framework ===========
* version 0.1 - created 29/4/2013
* ====================================================
*/
require_once 'utility-functions.php';
require_once locate_template('/inc/mobile-detect.php');
$detect = new Mobile_Detect();
global $_device_, $_device_name_, $_is_retina_;
$_device_ = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'mobile' : 'pc';
$_device_name_ = $detect->mobileGrade();
$_is_retina_ = $detect->isRetina();
/**
* Option Tree integration ===========
*/
/**
* Optional: set 'ot_show_pages' filter to false.
* This will hide the settings & documentation pages.
*/
add_filter('ot_show_pages', '__return_true');
/**
* Optional: set 'ot_show_new_layout' filter to false.
* This will hide the "New Layout" section on the Theme Options page.
*/
add_filter('ot_show_new_layout', '__return_false');
/**
* Required: set 'ot_theme_mode' filter to true.
*/
示例2: ac_get_device_classes
/**** Alleycat Mobile Detect ****/
/********************************/
// Detect whether this is a mobile device, etc and store global variables for use later within PHP
// Include the script
require_once 'Mobile_Detect.php';
// Setup
$detect = new Mobile_Detect();
// Use global variables to allow other parts of PHP to access the values. This avoids the use of sessions
global $ac_is_mobile;
global $ac_is_tablet;
global $ac_mobile_grade;
global $ac_touch_device;
// Get the values from the object
$ac_is_mobile = $detect->isMobile();
$ac_is_tablet = $detect->isTablet();
$ac_mobile_grade = $detect->mobileGrade();
$ac_touch_device = $ac_is_mobile || $ac_is_tablet;
// Returns css classes based on device
function ac_get_device_classes()
{
global $ac_is_mobile, $ac_is_tablet, $ac_touch_device;
$return = '';
if ($ac_is_mobile) {
$return .= ' ac-mobile ';
}
if ($ac_is_tablet) {
$return .= ' ac-tablet ';
}
if ($ac_touch_device) {
$return .= ' ac-touch-device ';
}
示例3: function
<?php
// Adds device information into timber context
add_filter('timber_context', function ($context) {
$detect = new Mobile_Detect();
$context['device'] = array('isMobile' => $detect->isMobile(), 'isTablet' => $detect->isTablet(), 'isPhone' => $detect->isMobile() && !$detect->isTablet(), 'mobileGrade' => $detect->mobileGrade());
return $context;
});