Skip to content

Instantly share code, notes, and snippets.

@keithdevon
Created March 27, 2018 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithdevon/b76730f7b48714a924ee9a482b2ed3e6 to your computer and use it in GitHub Desktop.
Save keithdevon/b76730f7b48714a924ee9a482b2ed3e6 to your computer and use it in GitHub Desktop.
<?php
/**
* This function appends a class to the body depending on the environment.
*
* @param array $classes current body classes.
*
* @return array $classes any modification to the class array.
*/
function tgf_add_environment_class( $classes ) {
if ( WP_LOCAL ) {
$classes[] = 'env--local';
}
if ( WP_STAGING ) {
$classes[] = 'env--staging';
}
if ( WP_PRODUCTION ) {
$classes[] = 'env--production';
}
return $classes;
}
add_filter( 'body_class', 'tgf_add_environment_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment