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:

<?php

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

    <p>I'm only on the app.</p>

<?php }

Show an element only on the website:

<?php

if (!isset($_SERVER['HTTP_X_WPAPPNINJA'])) { ?>

    <p>I'm only on the website.</p>

<?php }

Still need help? Contact Us Contact Us