Is there a way to test Bootstrap 3 viewport size in PHP?

I know I can use CSS to hide elements in Bootstrap 3 like this

<div class="hidden-sm">Hidden Content</div>

I also know that I can test the viewport size in Javascript like this:

Read More
if $(window).width() < 640 {
    // hide this content
}

What I’m curious to know is, is there any PHP function to test the viewport size? Specifically, what is the best practice for determining the current Bootstrap 3 viewport class in a WordPress context? It would be great if there was a function like this:

if ( is_viewport_sm() ) {
    // hide this content
    // run this loop
}

I know there are AJAX workarounds, but I figured someone might have some plugin or function to address such a common challenge.

Related posts

Leave a Reply