ubermenu_is_mobile

Filter Description

The ubermenu_is_mobile filter allows you to override the default mobile detection provided by wp_is_mobile. The main reason for this filter is that wp_is_mobile() considers tablets to be mobile devices, which is undesirable to some users. This filter allows you to set whatever mobile detection logic you like.

Hook Definition

ubermenu_is_mobile

Return true when mobile, false otherwise

$is_mobile
boolean – true if mobile device has been detected. By default, this is the output of wp_is_mobile()
$scenario
string – an optional string describing the scenario for which the mobile device is being detected. Useful if you want to return a different result based on different scenarios.

Example

One useful way to use this filter is to pair it with functions from another plugin, such as WP Mobile Detect

add_filter( 'ubermenu_is_mobile' , 'my_mobile_detection' , 10 , 2 );
function my_mobile_detection( $is_mobile, $scenario ){
  if( function_exists( 'wpmd_is_phone' ) ) return wpmd_is_phone(); //WP Mobile Detect plugin function 
  return $is_mobile;
}

On this page