Last active
December 15, 2015 04:08
-
-
Save szbl/5198918 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/* | |
Plugin Name: Sizeable Body Classer | |
Author: theandystratton | |
Author URI: http://sizeableinteractive.com | |
Description: Add to your functions.php to have quick functions for adding body classes. Simply run the following code before get_header(): szbl_add_body_class( 'some-body-class' ); | |
Version: 0.1 | |
License: GPL2 | |
*/ | |
function szbl_add_body_class( $class, $return = false ) | |
{ | |
static $classes; | |
if ( is_null( $classes ) ) | |
$classes = array(); | |
if ( $return ) | |
return $classes; | |
$classes[] = $class; | |
} | |
add_filter( 'body_class', 'szbl_body_class_filter' ); | |
function szbl_body_class_filter( $classes ) | |
{ | |
$new_classes = szbl_add_body_class( '', true ); | |
$classes[] = implode( ' ', $new_classes ); | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment