Allow custom CSS classes to be specified for [product] shortcode

This change allows custom CSS classes to be added to the output generated by the [product] shortcode. This is useful, for instance, when embedding a product into a regular post as an advertisement. With custom CSS classes, you can style it to be left or right aligned, floating, etc.
This commit is contained in:
Nick Ivanter 2015-02-24 23:32:35 +03:00
parent 2006c7217e
commit a1c9bac225
1 changed files with 8 additions and 1 deletions

View File

@ -466,7 +466,14 @@ class WC_Shortcodes {
wp_reset_postdata();
return '<div class="woocommerce">' . ob_get_clean() . '</div>';
$css_class = 'woocommerce';
if ( isset( $atts['class'] ) ) {
$css_class .= ' ' . $atts['class'];
}
return '<div class="' . esc_attr( $css_class ) . '">' . ob_get_clean() . '</div>';
}
/**