-
-
Save BeardedGinger/eb09a1fa3cf0e3ce0a65feee88c8fc64 to your computer and use it in GitHub Desktop.
Check whether a page contains a given body class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Conditional to check whether or not the body class contains a given class. | |
* | |
* @param string $class The class we're lookging for in the body class. | |
*/ | |
function has_body_class( $class ) { | |
$body_classes = get_body_class(); | |
return in_array( $class, $body_classes, true ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing this. It's exactly what I needed.