MIGHTYminnow / mm-components

[WordPress] Custom components and functionality for WordPress.
3 stars 2 forks source link

Clean up the way classes are added using an array, the base $tag param, and implode() #13

Closed MickeyKay closed 9 years ago

MickeyKay commented 9 years ago

Right now, classes are being added to many shortcodes in a not great way, like so:

// Setup button classes.
$class = 'button';
$class .= ' ' . $atts['class'];
$class .= ' ' . $atts['style'];
$class .= ' ' . $atts['border_style'];
$class .= ' ' . $atts['color'];
$class .= ' ' . $atts['font_style'];
$class .= ' ' . $atts['size'];

Let's clean that up by at least using an array with explode, like so:

// Setup button classes.
$class[] = $tag;
$class[]= $atts['class'];
$class[] = $atts['style'];

And ideally, it'd be even better to automate this whole thing and regulate our class syntax to always be something like {att_key}-{att_value} - like so:

// Setup button classes.
foreach( $atts as $key => $value ) {
    if ( '' != $value ) {
        $class[] = "$key-$value";
    }
}
BraadMartin commented 9 years ago

This issue has mostly been resolved. There may be a few components left that are doing_it_wrong, but each component now has a maintainer and we're bringing them all up to spec.