Usage
PHP
nebula()->is_mobile()
Parameters
This function does not accept any parameters. Is this incorrect?
Source File
Located in /libs/Utilities/Device.php on line 15.
1 Hook
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"pre_nebula_is_mobile"Need a new filter hook? Request one here.
Actions
This function has no action hooks available. Request one?
PHP
public function is_mobile(){
$override = apply_filters('pre_nebula_is_mobile', null);
if ( isset($override) ){return $override;}
//Check User Agent Client Hints
if ( isset($_SERVER['HTTP_SEC_CH_UA_MOBILE']) && $_SERVER['HTTP_SEC_CH_UA_MOBILE'] === '?1' ){ //if Sec-CH-UA-Mobile client hint is ?1
return true;
}
global $is_iphone;
if ( wp_is_mobile() || $is_iphone ){
return true;
}
return false;
}
Override
To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):
PHP
add_filter('pre_nebula_is_mobile', 'my_custom_is_mobile');
function my_custom_is_mobile(){
//Write your own code here
return true; //Return true to prevent the original function from running afterwords
}
You can completely disable this PHP function with a single line actions:
PHP
add_filter('pre_nebula_is_mobile', '__return_false');