<?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. */
/**** 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 '; }
<?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; });