How to detect the mobile app

If you want to detect that an user browse your website with the application you can use 3 way :

  • the body class wpappninja
  • the HTTP header HTTP_X_WPAPPNINJA
  • the PHP function is_wpappninja()

CSS

Show an element only on the app:

.myAppElement {
    display:none;
}

body.wpappninja .myAppElement {
    display:block;
}

Hide an element only on the app:

.myWebsiteElement {
    display:block;
}

body.wpappninja .myWebsiteElement {
    display:none;
}

PHP

Show an element only on the app:

if (isset($_SERVER['HTTP_X_WPAPPNINJA'])) {

    // in app

}

Still need help? Contact Us Contact Us