Last active
August 29, 2015 14:02
-
-
Save mannieschumpert/d056a1b81d0a15c4f76f to your computer and use it in GitHub Desktop.
A reusable solution for adding element classes in the Genesis framework.
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 | |
/** | |
* General function for adding element classes in Genesis | |
*/ | |
function add_gen_classes( $attr, $classes, $layout = NULL ){ | |
// If there's a layout parameter, and current layout does not match, return classes unchanged | |
// This part is pseudo code - not sure if this is the function for testing current layout | |
if ( $layout && ! genesis_site_layout( $layout ) ) | |
return $attr; | |
$classes = ''; | |
foreach( $classes as $class ){ | |
$classes .= ' ' . $class; | |
} | |
$attr['class'] .= $classes; | |
return $attr; | |
} | |
/* Using the function */ | |
add_filter( 'genesis_attr_site-header', function( $attr ){ | |
return add_gen_classes( $attr, array('row','other-class'), 'layout' ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment