WidgetOptions / widget-options

Additional Widget options for better widget control. Available on
https://widget-options.com/
GNU General Public License v3.0
35 stars 16 forks source link

hide on devices not working #20

Closed fabienlege closed 7 years ago

fabienlege commented 7 years ago

Try to check hide on mobile => widget visible everywhere Try to check hide on desktop => widget visible everywhere Try to check show on desktop => widget visible everywhere Try to check show/hide on anything => widget visible everywhere in any case

phpbits commented 7 years ago

Hi,

Can you provide screenshot? Thanks!

Cheers, Jeffrey

joerhoney commented 7 years ago

screen shot 2017-09-11 at 6 53 55 pm

joerhoney commented 7 years ago

You're just hiding the widget areas with CSS. You should be checking whether the device is mobile, tablet or desktop, before outputting your widget. If it is to be "hidden" on the device, don't output it at all, as it only consumes bandwidth, load time, etc.

I'd suggest using require_once 'Mobile_Detect.php'; (you can download the script here) and use the Mobile_Detect class in your plugin. Please be sure to check if the class already exists before inclusion though, so you don't break any of my plugins like one other author did. ;)

phpbits commented 7 years ago

Yes! It's best to hide widget via CSS media query to be compatible with caching plugins. No need to other third-party script. If you want to use PHP condition, you can use the Display Widget Logic option and add wp_is_mobile() . I hope this can fix your issue. Thanks!

Cheers, Jeffrey

joerhoney commented 7 years ago

I see. Yes, I suppose that's workable. Thanks for bringing up that point and for the workaround for those who don't want to bother with caching.

phpbits commented 7 years ago

@joerhoney you are very welcome :) Feel free to let me know if you have any other questions. Will be closing this ticket now. Thanks!

Cheers, Jeffrey