Last active
December 18, 2015 00:18
-
-
Save Shelob9/5695170 to your computer and use it in GitHub Desktop.
Foundation alert code short code and function. Automatically adds .alert-box, optional additional classes and thing to close alert. Default text also set. http://foundation.zurb.com/docs/components/alert-boxes.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function slug_alert_box($content,$class) { | |
if ($content == '') { | |
//use this to set a default alert or take out to allow shortcodes without content to be just blank boxes. | |
$content = 'DEFAULT ALERT TEXT'; | |
} | |
if ($class == '') { | |
$classes = 'alert-box'; | |
} | |
else { | |
$class = 'alert-box '.$class; | |
} | |
echo '<div data-alert class="'.$class.'">'.$content.'<a href="#" class="close">×</a></div>' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//[alert-box] or [alert-box class"additonal classes, nto including .alert-box" | |
function slug_alert_box_sc($atts, $content = null) { | |
extract(shortcode_atts(array( | |
'class' => 'alert-box' | |
), $atts)); | |
//use this to set a default alert or take out to allow shortcodes without content to be just blank boxes. | |
if ($content == '') { | |
$content = 'DEFAULT ALERT TEXT'; | |
} | |
if ($class == '') { | |
$classes = 'alert-box'; | |
} | |
else { | |
$classes = 'alert-box '.$class; | |
} | |
return '<div data-alert class="'.$classes.'">'.$content.'<a href="#" class="close">×</a></div>'; | |
} | |
add_shortcode("alert-box", "slug_alert_box_sc"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment