Skip to content

Instantly share code, notes, and snippets.

@jrstaatsiii
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save jrstaatsiii/bb031f62950b918c0154 to your computer and use it in GitHub Desktop.

Select an option

Save jrstaatsiii/bb031f62950b918c0154 to your computer and use it in GitHub Desktop.
Is there a better way to filter Genesis structural class names?
<?php
/*
* How do I append a class "row" to the class "site-header" as opposed to recreating "site-header" like I am here?
*
*/
add_filter( 'genesis_attr_site-header', 'ssm_site_header' );
/*
* Add the appropriate foundation class to site-header
*
*/
function ssm_site_header() {
$attributes['class'] = 'site-header row';
return $attributes;
}
@mannieschumpert
Copy link

Maybe:

$classes = $attributes['class'];
$attributes['class'] = $classes . ' row';
return $attributes;

or:

$classes = $attributes['class'];
$myclasses = " row";
$attributes['class'] = $classes . $myclasses;
return $attributes;

@GaryJones
Copy link

<?php
add_filter( 'genesis_attr_site-header', 'ssm_site_header' );
/*
 * Add the appropriate foundation class to site-header 
 */
function ssm_site_header( $atts ) {
    $classes = explode( ' ', $atts['class'] );
    $classes[] = 'row';
    $atts['class'] = implode( ' ', array_unique( $classes ) );
    return $atts;
}

@iamcanadian1973
Copy link

Or an easier way so that you don't have to mess with any markup.

ex.

.wrap {
@extend .row;
}

.content {
@extend .large-9, .columns;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment