Skip to content

Instantly share code, notes, and snippets.

@wpmark
Created October 15, 2020 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wpmark/f6ac2be5c4af575dba64224c84d5f6ab to your computer and use it in GitHub Desktop.
Save wpmark/f6ac2be5c4af575dba64224c84d5f6ab to your computer and use it in GitHub Desktop.
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