Skip to content

Instantly share code, notes, and snippets.

@mannieschumpert
Last active August 29, 2015 14:02
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 mannieschumpert/d056a1b81d0a15c4f76f to your computer and use it in GitHub Desktop.
Save mannieschumpert/d056a1b81d0a15c4f76f to your computer and use it in GitHub Desktop.
A reusable solution for adding element classes in the Genesis framework.
<?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