1] Try using a switch on the $style
variable to echo out the corresponding $return_string
depending on it's value.
2] Pay special attention to the default:
case, as it is what will be displayed if $style
is not set to clear
or white
. I set it to have no attribute, but you might want it to be different.
3] You can add as many cases as you need for the shortcode. Whatever the value of $style
is will determine which $return_string
is used.
function container($atts, $content = null) {
extract( shortcode_atts( array(
'style' => '',
), $atts ) );
switch ($style) {
case "clear":
$return_string = "<section class=\"wrapper special container style1\">". do_shortcode($content) ."</section>"; // Adds style1 if clear
break;
case "white":
$return_string = "<section class=\"wrapper special container style2\">". do_shortcode($content) ."</section>"; // Adds style2 if white
break;
default:
$return_string = "<section class=\"wrapper special container\">". do_shortcode($content) ."</section>"; // No Attribute (default)
break;
}
wp_reset_query();
return $return_string;
}