Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Pothi Kalimuthu

    (@pothi)

    Indeed. There is an isiOS() method. You can see the list of examples at https://mobiledetect.net/ . You can play around with the demo at https://demo.mobiledetect.net/ .

    Thread Starter sadhaka

    (@sadhaka)

    Ah excellent. I should have taken a look at your plugin before asking the question!

    I take it that you’ve simply included Mobile_Detect.php and then added the conditional in your plugin script for wp_is_mobile to return true if isMobile() && !isTablet(), otherwise to return false.

    So this means that, simply by having your plugin installed, I have all the other methods available to me in Mobile_Detect.php ? I was a bit confused about that because I wasn’t sure how WordPress derives its wp_is_mobile in the first place.

    Plugin Author Pothi Kalimuthu

    (@pothi)

    So this means that, simply by having your plugin installed, I have all the other methods available to me in Mobile_Detect.php ?

    You are right. There is a difference, though. Mine uses a different class name to avoid conflicts with other plugins that include Mobile Detect library.

    The plugin itself is dead-simple to link Mobile_Detect.php and wp_is_mobile. If you don’t want wp_is_mobile to interfere, please do not install this plugin. Instead, download your own copy of Mobile_Detect.php file and use it as you wish.

    Some caching plugins use Mobile_Detect library as well. So, you may wish to use your own class to avoid conflicts.

    Thread Starter sadhaka

    (@sadhaka)

    It’s working very well, thanks.

    But is there a way to target “mobile phones” generally (i.e., phones, not tablets)? Unless, with the plugin, wp_is_mobile covers that ?

    Edit: I’m answering my own question here, but I guess this does it (tell me if I’m wrong):

    function custom_is_phone() {
    $IsPhone = false;
    $detectPlatform = new TinyWP_Mobile_Detect;
    if ($detectPlatform->isMobile()) {
    $IsPhone = true;
    } else {
    $IsPhone = false;
    }
    }

    Then using like:

    if ($IsPhone) {
    //whatever..
    }
    • This reply was modified 2 years, 7 months ago by sadhaka.
    Plugin Author Pothi Kalimuthu

    (@pothi)

    You are right. wp_is_mobile indeed covers mobile phones. We don’t need a custom function. For a list of available core functions, please see https://demo.mobiledetect.net/ . Basically, wp_is_mobile and isMobile() have the same functionality.

    • This reply was modified 2 years, 7 months ago by Pothi Kalimuthu. Reason: Removed iPhone detection example
    • This reply was modified 2 years, 7 months ago by Pothi Kalimuthu.
    Thread Starter sadhaka

    (@sadhaka)

    Thanks – but as far as I can see, there is no longer a way to detect just iPads anymore. I think I’ve tried every which way.

    I even tried at https://demo.mobiledetect.net and even there it always fails to detect just iPads.

    If you know of another way, do let me know!

    • This reply was modified 2 years, 7 months ago by sadhaka.
    Plugin Author Pothi Kalimuthu

    (@pothi)

    You are right. I just checked. iPads are no longer detected with the latest version of iPadOS and on Safari and on DuckDuckGo browser. On Google Chrome, it is detected correctly, though. Unfortunately, I don’t know any alternatives.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Possible to target only iOS with plugin installed?’ is closed to new replies.