wp_is_mobile()
does not have any filters or ways to override. What you’ll need to do is build a wrapper of your own around wp_is_mobile()
and use that in your code where you’ve used wp_is_mobile()
.
Something like the following prototype could work for you. Ultimately a better option over the URL parameter might be to use a cookie value that you set/clear based on the user selected preference. See the PHP documentation on setcookie() for more on cookies.
function my_is_mobile() {
static $is_mobile;
if (isset($is_mobile)) return $is_mobile;
if (isset($_REQUEST['mobile']) && $_REQUEST['mobile'] == "no")) {
$is_mobile = false;
return $is_mobile;
}
$is_mobile = wp_is_mobile();
return $is_mobile;
}