最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Disabling Wp_is_mobile from backend?

programmeradmin1浏览0评论

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 1
Add a comment  | 

1 Answer 1

Reset to default 2

It 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.

发布评论

评论列表(0)

  1. 暂无评论