Skip to content

Commit

Permalink
Create and document Thumbnails shortcode
Browse files Browse the repository at this point in the history
  • Loading branch information
FoolsRun committed Sep 18, 2013
1 parent b77e92b commit 7644e83
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The plugin doesn't support all Bootstrap elements yet, but most of them.
* [Panels](#panels)
* [Media Objects](#media-objects)
* [Jumbotron](#jumbotron)
* [Thumbnails](#thumbnails)

## Usage

Expand Down Expand Up @@ -251,3 +252,10 @@ Parameter | Description | Required | Values | Default
title | The jumbotron title | optional | Any text | none

[Bootstrap jumbotron documentation](http://getbootstrap.com/components/#jumbotron)

### Thumbnails
[thumbnail] … [/thumbnail]
[thumbnail] … [/thumbnail]
[thumbnail] … [/thumbnail]

[Bootstrap thumbnails documentation](http://getbootstrap.com/components/#thumbnails)
22 changes: 22 additions & 0 deletions bootstrap-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ function add_shortcodes() {
add_shortcode('media-body', array( $this, 'bs_media_body' ));
add_shortcode('jumbotron', array( $this, 'bs_jumbotron' ));
add_shortcode('lead', array( $this, 'bs_lead' ));
add_shortcode('thumbnail', array( $this, 'bs_thumbnail' ));
}


Expand Down Expand Up @@ -692,6 +693,27 @@ function bs_lead( $atts, $content = null ) {

}

/*--------------------------------------------------------------------------------------
*
* bs_thumbnail
*
*
*-------------------------------------------------------------------------------------*/
function bs_thumbnail( $atts, $content = null ) {
$classes = "thumbnail";
if ( preg_match('/<a.*? class=".*?" \/>/', $content) ) {
$return = preg_replace('/(<a.*? class=".*?)(".*?>)/', '$1 ' . $classes . '$2', $content);
}
elseif ( preg_match('/<a.*? \/>/', $content) ) {
$return = preg_replace('/(<a.*?)>/', '$1 class="' . $classes . '" >', $content);
}
else {
$return = '<div class="thumbnail">' . $content . '</div>';
}
return $return;

}

}

new BoostrapShortcodes();

0 comments on commit 7644e83

Please sign in to comment.