Support » Plugin: Widget Logic » Hide on mobile ?

  • Resolved Bertrand66

    (@bertrand66)


    Hello,

    Many thanks for this very clever plugin, easy to use for DIY like me. And there is always a DIY with a damn question, and this one is me :).

    Is there a code to hide the widget on mobile ?

    Thanks in advanced.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author WPChef

    (@wpchefgadget)

    Hi Bertrand66,

    Thank you for your feedback! Right now there is no code to hide a widget on mobile, it might appear in the next versions though.

    tapiohuuhaa

    (@tapiohuuhaa)

    It is very complicated. I don’t know any other way that just detect the browser and environment. I made this function, which covers most mobile browsers:

    function tap_is_mobile(){
    global $_SERVER;
    $Firefox=strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Firefox’);
    $Tablet=strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Tablet’);
    $Android=strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Android’);
    $Chrome=strpos($_SERVER[‘HTTP_USER_AGENT’], ‘Chrome’);
    $iPad=strpos($_SERVER[‘HTTP_USER_AGENT’], ‘iPad’);
    $iPhone=strpos($_SERVER[‘HTTP_USER_AGENT’], ‘iPhone’);
    $mobile=($Chrome && $Android) || ($Firefox &&($Android || $Tablet)) || $iPad || $iPhone;
    return $mobile;
    }

    Can I use is_tap_mobile() with this plugin?

    Bertrand66

    (@bertrand66)

    Thanks, for info I was able to do my settings with Widget Options, but their conditional behaviour is not as good as Widget Logic.

    I tested with widget logic tap_is_mobile() – it worked OK. Setting my own function as condition, the widget was shown only in mobile devices and not on desktop devices.

    I use normally Widget Context plugin because I use much my own PHP code with Code Snippet.

    But I just tested that I could use also my own functions for limiting visibility.
    I can now set something to show only on mobile/computer by using the function, I created instead of hiding something with CSS.

    With your own conditions you can set as exact conditions as you need.

    I deactivated widget logic now because there is only one issue, which I would need it and I have hided an element with CSS on mobile.

    Maybe I active it and limite visibility for mobile with this plugin, where I can.

    @tapiohuuhaa – How did you end up? I would like to have a widget disabled on server-site for Mobile devices, instead of with fx. Javascript or CSS.

    See above – I can’t explain better.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hide on mobile ?’ is closed to new replies.