Created
October 15, 2020 12:13
-
-
Save wpmark/f6ac2be5c4af575dba64224c84d5f6ab to your computer and use it in GitHub Desktop.
Output a body class based on the WP development environment
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 | |
/** | |
* Adds a body class for the environment. | |
* | |
* @param array $classes The current array of body classes. | |
* @return array The new array of body classes. | |
*/ | |
function hd_env_body_class( $classes ) { | |
// if WP environment function exists. | |
if ( function_exists( 'wp_get_environment_type' ) ) { | |
// add the environment to the body class. | |
$classes[] = 'env--' . wp_get_environment_type(); | |
} | |
return $classes; | |
} | |
add_filter( 'body_class', 'hd_env_body_class', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment