Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Output a body class based on the WP development environment
<?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