• Resolved alexandruvladilie

    (@alexandruvladilie)


    Hello,

    I have a problem with the cache plugin when I use wp_is_mobile_function(). if the cache is active, this function does not work well. on the desktop version it detects the mobile version and vice versa. Please let me know if there are settings available to avoid this problem.

    Thank you!

    Vlad

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Georgi Ganchev

    (@georgiganchev)

    Hello Vlad,

    I checked the page in question and I am not able to detect any issues with it. It would be helpful if you provide a detailed analysis of how are you testing your page, where you see the results in question, and how we can replicate the same.

    In addition our plugin has a Browser-specific Caching functionality where caching is generated separately for specific browsers and is advised to be enabled in cases where a component is generating mobile version of your website.

    You can also create a sample PHP file to see if a page is detected properly using this code:

    <?php
    // Check if the "mobile" word exists in User-Agent
    $isMob = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "mobile"));
    
    // Check if the "tablet" word exists in User-Agent
    $isTab = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "tablet"));
    
    // Platform check
    $isWin = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "windows"));
    $isAndroid = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "android"));
    $isIPhone = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "iphone"));
    $isIPad = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "ipad"));
    $isIOS = $isIPhone || $isIPad;
    
    if($isMob){
        if($isTab){
            echo 'Using Tablet Device...';
        }else{
            echo 'Using Mobile Device...';
        }
    }else{
        echo 'Using Desktop...';
    }
    
    if($isIOS){
        echo 'iOS';
    }elseif($isAndroid){
        echo 'ANDROID';
    }elseif($isWin){
        echo 'WINDOWS';
    }
    ?>

    In case you still experience any issues I would advise you to check your template documentation for any specifics when serving particular sources to different devices.

    If you experience a problem only with a specific page, you may exclude it from being cached through SiteGround Optimizer > Caching > Exclude URLs from Caching.

    Best regards,
    Georgi Ganchev
    SiteGround.com

    Thread Starter alexandruvladilie

    (@alexandruvladilie)

    Hello and thanks for the answer!

    We cannot replicate because we’ve disabled “File-Based Caching” in order to work on production website. On our staging website we do not have the option to do this as we do not have a SiteGround server for staging. If we enable this option, then for some random time is working and then is getting desktop version on mobile. There is no timeframe or number of accesses on the page, but is doing this random.

    We cannot exclude the URL from cache because it is for the entire website.

    We’ve build a different header/footer/page content for mobile and in this case we have 2 website versions.

    Plugin Support Georgi Ganchev

    (@georgiganchev)

    Hello @alexandruvladilie

    I am afraid that without option to replicate the issue, we cannot provide any further advice or proof this is somehow related with our plugin functionalities.

    I tested the given page on mobile and desktop browsers and I am able to see the proper versions as well as the correct wp_is_mobile output.

    If possible please enable the file-based caching and once the issue is present, open a Helpdesk request through your SiteGround Client Area with the steps that we need to take to encounter the issue so we can check things further.

    Please be aware that Staging copies created through the Site tools panel do not utilize caching.

    Best regards,
    Georgi Ganchev
    SiteGround.com

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘WordPress detect mobile function is not working’ is closed to new replies.