2016-05-05 2 views
-1

Ich habe Wordpress, auf dem Display Handy Ich möchte einige Datei js von php entfernen? Danke allen.Wie Datei js auf Version Mobile von PHP zu entfernen?

+0

Wenn Sie eine andere js laden möchten, wenn Sie in Mobile sind, geben Sie es mit php bedingungsbedingt. Dies kann [Hilfe] (http://stackoverflow.com/questions/4117555/simplet-way-to-detect-a-mobile-device) – VipindasKS

+0

Werfen Sie einen Blick auf die folgenden Ressourcen: https://wordpress.org/plugins/wp-mobile-detect/oder https://codex.wordpress.org/Function_Reference/wp_is_mobile. – andreivictor

Antwort

0

Need-Check ist die Seitenanzeige in Mobile.

So:

function isMobile() 
{ 
    if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) 
    { 
     return true; 
    } 

    if (isset ($_SERVER['HTTP_VIA'])) 
    { 
     return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false; 
    } 

    if (isset ($_SERVER['HTTP_USER_AGENT'])) 
    { 
     $clientkeywords = array ('nokia', 
      'sony', 
      'ericsson', 
      'mot', 
      'samsung', 
      'htc', 
      'sgh', 
      'lg', 
      'sharp', 
      'sie-', 
      'philips', 
      'panasonic', 
      'alcatel', 
      'lenovo', 
      'iphone', 
      'ipod', 
      'blackberry', 
      'meizu', 
      'android', 
      'netfront', 
      'symbian', 
      'ucweb', 
      'windowsce', 
      'palm', 
      'operamini', 
      'operamobi', 
      'openwave', 
      'nexusone', 
      'cldc', 
      'midp', 
      'wap', 
      'mobile' 
      ); 

     if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) 
     { 
      return true; 
     } 
    } 

    if (isset ($_SERVER['HTTP_ACCEPT'])) 
    { 
     if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) 
     { 
      return true; 
     } 
    } 
    return false; 
} 

Dann können Sie die JS-Datei geladen wurde.

Verwandte Themen