I'm using a wordpress theme that makes use of wp_is_mobile function, but reacts badly on many occasion, as it's being called in many files, I was wondering if you are aware of a wordpress plugin that would maybe 'disable' that functionnality or pretend we're never on mobile ?
Thank you!
I'm using a wordpress theme that makes use of wp_is_mobile function, but reacts badly on many occasion, as it's being called in many files, I was wondering if you are aware of a wordpress plugin that would maybe 'disable' that functionnality or pretend we're never on mobile ?
Thank you!
Share Improve this question asked Jun 24, 2020 at 15:38 user2850378user2850378 11 Answer
Reset to default 2It seems like your theme may be using the wp_is_mobile
function incorrectly as it should not be used for theme specific styling, etc and is also unreliable as it only inspects the browser User-Agent. As I don't know what your theme is, I cannot say for definite if that is the case but see this answer for more information about that if you're interested.
As for the function itself, it will also have the boolean value pass through a filter under the same name before it is returned, wp_is_mobile
. But yes, it is entirely possible for a plugin, or theme, to cause the function to return falsey values.
I don't know of a specific plugin but if you would like to disable it yourself, you can add the following to the top of your theme functions.php
file.
add_filter( 'wp_is_mobile', function( $is_mobile ) {
if ( is_admin() ) {
return $is_mobile;
}
return false;
} );
This will disable wp_is_mobile
in your theme but allow it to work correctly when viewing your admin panel.