2

I have a wordpress site which uses a plugin to provide a music player. This plugin uses frames to keep the music playing while the user browses the site.

Mobile devices have trouble with this because of the frames. When I disable the plugin then the mobile devices view the site fine.

I want to disable this plugin for anyone viewing the site on a mobile device.

Ideally I want to do this without writing any code, just using something that already exists.

Thanks!

1
  • 1
    To compliment the answers you have received below, I recommend the Adaptive Web Design ebook/book as a good read if you want to learn more about the subject. There's also numerous tutorials freely available online, Johannes Pille links to one, and toscho shows you how to achieve the same with JS. A combination CSS + JS approach is the best solution we have so far for mobile device handling unless you are prepared to design your own mobile-site from the ground up, which is going to lend on many of the same principals anyway.
    – Adam
    Commented Oct 18, 2012 at 11:18

3 Answers 3

1

This question is borderline within (if at all) the scope of WPSE as per the newly committed change to the FAQ.

If done "with code", the easiest would be to employ css media queries to hide the frame (or parent element) by its class or id.

For the sake of completeness, there is a WP core function that attempts to check for mobile devices - but that employs user agent sniffing and is hence not to be trusted as far as reliability is concerned (one of the few core functions not recommendable to use, imho).

Also for the sake of completeness only, there's the deactivate_plugins() core function. It also has a companion, activate_plugins(). deactivate_plugins() has a $silent (boolean) parameter, that prevents deactivation hooks from firing (i.e. database entries that would otherwise be deleted won't be lost). Hence you could execute either on the condition of what device your site is loaded on, but that would for one not be very efficient and for another I wouldn't know of any reliable server-side way of detecting the device.

Also what is a mobile device?
Several generations of smartphones, tablets, netbooks, laptops, desktops, TV Screens and a huge variety of pixel densities (the "Retina" screen wasn't the first one to go past 96ppi...).
--> The only reliable way of designing for different devices is via screen size and pixel density. And that's information you cannot gather server-side. And since you can't, you can't disable plugins based on it.

So here we are at either css or js.
Either way, media queries are it.

1
  • I accepted your answer because it is the most thorough, though I elected not to use the offending plugin at all. I will be learning more about css media queries though as that will help with some other projects.
    – Mnebuerquo
    Commented Nov 6, 2012 at 14:43
1

Do not disable the plugin, rewrite it to load the iframe on wide viewports only instead. Here is a sample code showing how that could be done.

As Johannes has explained, there is no way to detect a mobile device on the server side, and some mobile devices have a better resolution and internet connection than some other devices that are not seen as mobile.

1
  • I don't care about viewports. The problem is that some mobile browsers don't let you scroll within a frame. So you just can't see half the page. I need to just not use frames on those browsers, regardless of viewport.
    – Mnebuerquo
    Commented Oct 22, 2012 at 14:46
0

I'm about 95% sure that either WPTouch, or the Pro version of that plugin allows you to disable plugins for mobile users. But I don't know if it allows you to ONLY disable the plugins and still display your normal site... or if it forces you to use a mobile theme.

[edit]
Reading from the free version of plugin documentation and code:

Restricted Mode
Disallow other plugins from loading scripts into WPtouch's header and footer. Sometimes fixes incompatibilities and speeds up WPtouch.

This mode removes wp_head() and wp_footer() when displaying the mobile version. And it will block other scripts from loading, but not necessarily will block everything from another plugin's behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.