Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Added shortcodes for rows and cols, documentation for all shortcodes #242

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ __________

We’ve built in some shortcodes so you can easily add UI elements found in Bootstrap.

| Shortcode | Arguments | Bootstrap Component |
| ------------- | ------------- | ------------- |
| [button] | type, size, url, text | http://getbootstrap.com/css/#buttons |
| [alert]...[/alert] | type, close, text | http://getbootstrap.com/components/#alerts-dismissible |
| [block-message]...[/block-message] | type, close, text | http://getbootstrap.com/components/#alerts |
| [blockquote]...[/blockquote] | float, cite | http://getbootstrap.com/css/#type-blockquotes |
| [row]...[/row] | id | http://getbootstrap.com/css/#grid-example-basic
| [col]...[/col] | id, size, span | http://getbootstrap.com/css/#grid-example-basic



Sidebars
________

Expand Down
27 changes: 27 additions & 0 deletions library/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,33 @@ function blockquotes( $atts, $content = null ) {
add_shortcode('blockquote', 'blockquotes');


function rows($atts, $content = null) {
extract( shortcode_atts( array(
'id' => ''
), $atts));
return "<div id='" . $id . "' class='row'>" . do_shortcode($content) . "</div>";
}
add_shortcode('row', 'rows');

function cols($atts, $content = null) {
extract( shortcode_atts( array(
'id' => '',
'size' => 'md', /* xs, sm, md, lg */
'span' => '6' /* 1-12 */
), $atts ));

if($span > 12 || $span < 1) {
$span = 6;
}
if(!preg_match('/xs|sm|md|lg/', $size)) {
$size = "md";
}

$output = "<div id='" . $id . "' class='col-" . $size . "-" . $span . "'>";
$output .= $content;
$output .= "</div>";
return $output;
}
add_shortcode('col', 'cols');

?>