使用代码在移动屏幕上禁用PHP插件?

I have this plugin called "WP FLOAT", I want to disable it when it detects a small screen size, lets say smaller than 400px. Is there a line of PHP code I can paste in one of the plugin's files to make this happen?

These are the only files for the plugin:

wp-float/wp-float(.)php

wp-float/readme(.)txt

wp-float/js/jquery.hoverIntent.minified(.)js

wp-float/js/jquery.easing(.)js

wp-float/js/wp-float-button(.)js

wp-float/js/jquery.floater.2.2(.)js

wp-float/js/button-wpfloat(.)php

What would I paste and in which file? Thanks

well you can remove properly with jquery after you get the current size of screen or with media querys in css.

I don't think you can do that, because PHP is on the server, there is no way to get the size of the screen from it.

However, you could use javascript to redirect to the current page and disable the plugin:

if(!isset( $_GET['r'] ) )     
{
  $script = "<script>";
  $script .= 'document.location="' . $_SERVER['PHP_SELF']. '?r=1&width=screen.width';
  $script .= "</script>";
  echo $script;
}     
else {
  if( isset( $_GET['width'] ) && $_GET['width'] < 400 )
    // Disable plugin
}

I would suggest you to change the plugin or look for another workaround, because I believe this is gonna be a little slow.

As Nicolas said, there's no way to access the client screen size on server side unless we have previously sent that information from the client side, JavaScript for example.

But, headers brings us a nice information. So, if you're looking to disable it for, let's say, mobile devices, which we can assume they won't have a big screen, you can try reading the headers of the request to get the browser's agent, lets say, in PHP:

if (preg_match('/iphone|android|blackberry|nokia/i'),$_SERVER['HTTP_USER_AGENT']))
    echo "Looks like a small screen device...";

You could also try this PHP class for detecting mobile devices: http://code.google.com/p/php-mobile-detect/

Later you can do something like this

require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;

if ($detect->isMobile()) {
    echo "It's a phone or tablet";
}

if($detect->isTablet()){
    echo "It's a tablet";
}

if ($detect->isMobile() && !$detect->isTablet()) {
    echo "It's a phone ;)";
}