Bootstrap Shortcodes for WordPress - Version 3.1.2

Version Description

  • Tested to work in WordPress 3.9
  • Fix and document collapsibles "Active" state
  • Fix uninitialized variables causing errors in debug mode
  • Fix "Active" tab, carousel checking, should work better now
  • Fix media button icon in Internet Explorer
Download this release

Release Info

Developer FoolsRun
Plugin Icon Bootstrap Shortcodes for WordPress
Version 3.1.2
Comparing to
See all releases

Code changes from version 3.1.1 to 3.1.2

README.md CHANGED
@@ -6,7 +6,7 @@ This is a plugin for WordPress that adds shortcodes for easier use of the Bootst
6
  ## Requirements
7
  This plugin won't do anything if you don't have WordPress theme built with the [Bootstrap](http://getbootstrap.com/) framework. **This plugin does not include the Bootstrap framework**.
8
 
9
- The plugin is tested to work with ```Bootstrap 3``` and ```WordPress 3.8```.
10
 
11
  This plugin contains a ```composer.json``` file for those of you who manage your PHP dependencies with [Composer](https://getcomposer.org).
12
 
@@ -701,7 +701,7 @@ html | Insert HTML into the tooltip | optional | true, false | false
701
 
702
  ### Collapse
703
  [collapsibles]
704
- [collapse title="Collapse 1" state="active"]
705
 
706
  [/collapse]
707
  [collapse title="Collapse 2"]
6
  ## Requirements
7
  This plugin won't do anything if you don't have WordPress theme built with the [Bootstrap](http://getbootstrap.com/) framework. **This plugin does not include the Bootstrap framework**.
8
 
9
+ The plugin is tested to work with ```Bootstrap 3``` and ```WordPress 3.9```.
10
 
11
  This plugin contains a ```composer.json``` file for those of you who manage your PHP dependencies with [Composer](https://getcomposer.org).
12
 
701
 
702
  ### Collapse
703
  [collapsibles]
704
+ [collapse title="Collapse 1" active="true"]
705
 
706
  [/collapse]
707
  [collapse title="Collapse 2"]
bootstrap-shortcodes.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Bootstrap 3 Shortcodes
4
  Plugin URI: http://wp-snippets.com/freebies/bootstrap-shortcodes or https://github.com/filipstefansson/bootstrap-shortcodes
5
  Description: The plugin adds a shortcodes for all Bootstrap elements.
6
- Version: 3.1.1
7
  Author: Filip Stefansson, Simon Yeldon, and Michael W. Delaney
8
  Author URI:
9
  License: GPL2
@@ -389,11 +389,11 @@ class BoostrapShortcodes {
389
 
390
  extract( shortcode_atts( array(
391
  "xclass" => false,
392
- "data" => false
393
  ), $atts ) );
394
 
395
  $class = 'dropdown-header';
396
- $class .= ( $xclass ) ? ' ' . $xclass : '';
397
 
398
  $data_props = $this->parse_data_attributes( $data );
399
 
@@ -535,8 +535,8 @@ class BoostrapShortcodes {
535
 
536
  $class = 'progress';
537
  $class .= ( $striped ) ? ' progress-striped' : '';
538
- $class .= ( $animated ) ? ' active' : '';
539
- $class .= ( $xclass ) ? ' ' . $xclass : '';
540
 
541
  $data_props = $this->parse_data_attributes( $data );
542
 
@@ -565,8 +565,8 @@ class BoostrapShortcodes {
565
  ), $atts ) );
566
 
567
  $class = 'progress-bar';
568
- $class .= ( $type ) ? ' progress-bar-' . $type : '';
569
- $class .= ( $xclass ) ? ' ' . $xclass : '';
570
 
571
  $data_props = $this->parse_data_attributes( $data );
572
 
@@ -876,6 +876,8 @@ class BoostrapShortcodes {
876
  $class = '';
877
  $class .= ( $xclass ) ? ' ' . $xclass : '';
878
 
 
 
879
  return sprintf(
880
  '<li><a href="%s" class="%s"%s>%s</a></li>',
881
  esc_url( $link ),
@@ -1186,16 +1188,15 @@ class BoostrapShortcodes {
1186
  $tabs = array();
1187
  $GLOBALS['tabs_default_active'] = true;
1188
  foreach( $atts_map as $check ) {
1189
- if( $check["tab"]["active"] ) {
1190
  $GLOBALS['tabs_default_active'] = false;
1191
  }
1192
  }
1193
  $i = 0;
1194
  foreach( $atts_map as $tab ) {
1195
-
1196
  $tabs[] = sprintf(
1197
  '<li%s><a href="#%s" data-toggle="tab">%s</a></li>',
1198
- ( ($tab["tab"]["active"]) || ($GLOBALS['tabs_default_active'] && $i == 0) ) ? ' class="active"' : '',
1199
  'custom-tab-' . $GLOBALS['tabs_count'] . '-' . sanitize_title( $tab["tab"]["title"] ),
1200
  $tab["tab"]["title"]
1201
  );
@@ -1318,8 +1319,8 @@ class BoostrapShortcodes {
1318
  $panel_class .= ( $type ) ? ' panel-' . $type : ' panel-default';
1319
  $panel_class .= ( $xclass ) ? ' ' . $xclass : '';
1320
 
1321
- $collapse_class = 'panel-collapse collapse';
1322
- $collapse_class .= ( $active ) ? ' in' . $type : '';
1323
 
1324
  $parent = 'custom-collapse-'. $GLOBALS['collapsibles_count'];
1325
  $current_collapse = $parent . '-'. sanitize_title( $title );
@@ -1352,7 +1353,6 @@ class BoostrapShortcodes {
1352
  *
1353
  * bs_carousel
1354
  *
1355
- * @author Filip Stefansson
1356
  * @since 1.0
1357
  *
1358
  *-------------------------------------------------------------------------------------*/
@@ -1363,7 +1363,7 @@ class BoostrapShortcodes {
1363
  else
1364
  $GLOBALS['carousel_count'] = 0;
1365
 
1366
- $GLOBALS['tabs_default_count'] = 0;
1367
 
1368
  extract( shortcode_atts( array(
1369
  "interval" => false,
@@ -1384,21 +1384,20 @@ class BoostrapShortcodes {
1384
 
1385
  $atts_map = bs_attribute_map( $content );
1386
 
1387
- // Extract the tab titles for use in the tab widget.
1388
  if ( $atts_map ) {
1389
  $indicators = array();
1390
  $GLOBALS['carousel_default_active'] = true;
1391
  foreach( $atts_map as $check ) {
1392
- if( $check["carousel-item"]["active"] ) {
1393
  $GLOBALS['carousel_default_active'] = false;
1394
- }
1395
  }
1396
- // Extract the tab titles for use in the tab widget.
1397
  $i = 0;
1398
  foreach( $atts_map as $slide ) {
1399
  $indicators[] = sprintf(
1400
  '<li class="%s" data-target="%s" data-slide-to="%s"></li>',
1401
- ( ($slide["carousel-item"]["active"]) || ($GLOBALS['carousel_default_active'] && $i == 0) ) ? 'active' : '',
1402
  esc_attr( '#' . $id ),
1403
  esc_attr( '#' . $i )
1404
  );
@@ -1409,9 +1408,9 @@ class BoostrapShortcodes {
1409
  '<div class="%s" id="%s" data-ride="carousel"%s%s%s%s>%s<div class="%s">%s</div>%s%s</div>',
1410
  esc_attr( $div_class ),
1411
  esc_attr( $id ),
1412
- ( $interval ) ? sprintf( ' data-interval="%"', (int) $interval ) : '',
1413
- ( $pause ) ? sprintf( ' data-pause="%"', esc_attr( $pause ) ) : '',
1414
- ( $wrap ) ? sprintf( ' data-wrap="%"', esc_attr( $wrap ) ) : '',
1415
  ( $data_props ) ? ' ' . $data_props : '',
1416
  ( $indicators ) ? '<ol class="carousel-indicators">' . implode( $indicators ) . '</ol>' : '',
1417
  esc_attr( $inner_class ),
@@ -1782,16 +1781,16 @@ function bs_popover( $atts, $content = null ) {
1782
 
1783
  $previous_value = libxml_use_internal_errors(TRUE);
1784
  $dom = new DOMDocument;
1785
- $dom->loadXML($content);
1786
  libxml_clear_errors();
1787
  libxml_use_internal_errors($previous_value);
1788
- foreach($dom->getElementsByTagName('img') as $image) {
1789
- $image->setAttribute('class', $image->getAttribute('class') . ' ' . esc_attr( $class ));
1790
  if( $data ) {
1791
  $data = explode( '|', $data );
1792
  foreach( $data as $d ):
1793
- $d = explode(',',$d);
1794
- $image->setAttribute('data-'.$d[0],trim($d[1]));
1795
  endforeach;
1796
  }
1797
  }
@@ -1818,18 +1817,19 @@ function bs_popover( $atts, $content = null ) {
1818
 
1819
  $previous_value = libxml_use_internal_errors(TRUE);
1820
  $dom = new DOMDocument;
1821
- $dom->loadXML($content);
1822
  libxml_clear_errors();
1823
- libxml_use_internal_errors($previous_value); if( ! $dom->documentElement ) {
1824
- $element = $dom->createElement('div', $content);
 
1825
  $dom->appendChild($element);
1826
  }
1827
  $dom->documentElement->setAttribute('class', $dom->documentElement->getAttribute('class') . ' ' . esc_attr( $class ));
1828
  if( $data ) {
1829
  $data = explode( '|', $data );
1830
  foreach( $data as $d ):
1831
- $d = explode(',',$d);
1832
- $dom->documentElement->setAttribute('data-'.$d[0],trim($d[1]));
1833
  endforeach;
1834
  }
1835
  $return = $dom->saveXML();
@@ -1899,7 +1899,7 @@ function bs_popover( $atts, $content = null ) {
1899
  $a_class = '';
1900
  $a_class .= ( $xclass ) ? ' ' . $xclass : '';
1901
 
1902
- $div_class = 'modal fade';
1903
  $div_class .= ( $size ) ? ' bs-modal-' . $size : '';
1904
 
1905
  $id = 'custom-modal-' . sanitize_title( $title );
3
  Plugin Name: Bootstrap 3 Shortcodes
4
  Plugin URI: http://wp-snippets.com/freebies/bootstrap-shortcodes or https://github.com/filipstefansson/bootstrap-shortcodes
5
  Description: The plugin adds a shortcodes for all Bootstrap elements.
6
+ Version: 3.1.2
7
  Author: Filip Stefansson, Simon Yeldon, and Michael W. Delaney
8
  Author URI:
9
  License: GPL2
389
 
390
  extract( shortcode_atts( array(
391
  "xclass" => false,
392
+ "data" => false
393
  ), $atts ) );
394
 
395
  $class = 'dropdown-header';
396
+ $class .= ( $xclass ) ? ' ' . $xclass : '';
397
 
398
  $data_props = $this->parse_data_attributes( $data );
399
 
535
 
536
  $class = 'progress';
537
  $class .= ( $striped ) ? ' progress-striped' : '';
538
+ $class .= ( $animated ) ? ' active' : '';
539
+ $class .= ( $xclass ) ? ' ' . $xclass : '';
540
 
541
  $data_props = $this->parse_data_attributes( $data );
542
 
565
  ), $atts ) );
566
 
567
  $class = 'progress-bar';
568
+ $class .= ( $type ) ? ' progress-bar-' . $type : '';
569
+ $class .= ( $xclass ) ? ' ' . $xclass : '';
570
 
571
  $data_props = $this->parse_data_attributes( $data );
572
 
876
  $class = '';
877
  $class .= ( $xclass ) ? ' ' . $xclass : '';
878
 
879
+ $data_props = $this->parse_data_attributes( $data );
880
+
881
  return sprintf(
882
  '<li><a href="%s" class="%s"%s>%s</a></li>',
883
  esc_url( $link ),
1188
  $tabs = array();
1189
  $GLOBALS['tabs_default_active'] = true;
1190
  foreach( $atts_map as $check ) {
1191
+ if( !empty($check["tab"]["active"]) ) {
1192
  $GLOBALS['tabs_default_active'] = false;
1193
  }
1194
  }
1195
  $i = 0;
1196
  foreach( $atts_map as $tab ) {
 
1197
  $tabs[] = sprintf(
1198
  '<li%s><a href="#%s" data-toggle="tab">%s</a></li>',
1199
+ ( !empty($tab["tab"]["active"]) || ($GLOBALS['tabs_default_active'] && $i == 0) ) ? ' class="active"' : '',
1200
  'custom-tab-' . $GLOBALS['tabs_count'] . '-' . sanitize_title( $tab["tab"]["title"] ),
1201
  $tab["tab"]["title"]
1202
  );
1319
  $panel_class .= ( $type ) ? ' panel-' . $type : ' panel-default';
1320
  $panel_class .= ( $xclass ) ? ' ' . $xclass : '';
1321
 
1322
+ $collapse_class = 'panel-collapse';
1323
+ $collapse_class .= ( $active ) ? ' in' : ' collapse';
1324
 
1325
  $parent = 'custom-collapse-'. $GLOBALS['collapsibles_count'];
1326
  $current_collapse = $parent . '-'. sanitize_title( $title );
1353
  *
1354
  * bs_carousel
1355
  *
 
1356
  * @since 1.0
1357
  *
1358
  *-------------------------------------------------------------------------------------*/
1363
  else
1364
  $GLOBALS['carousel_count'] = 0;
1365
 
1366
+ $GLOBALS['carousel_default_count'] = 0;
1367
 
1368
  extract( shortcode_atts( array(
1369
  "interval" => false,
1384
 
1385
  $atts_map = bs_attribute_map( $content );
1386
 
1387
+ // Extract the slide titles for use in the carousel widget.
1388
  if ( $atts_map ) {
1389
  $indicators = array();
1390
  $GLOBALS['carousel_default_active'] = true;
1391
  foreach( $atts_map as $check ) {
1392
+ if( !empty($check["carousel-item"]["active"]) ) {
1393
  $GLOBALS['carousel_default_active'] = false;
1394
+ }
1395
  }
 
1396
  $i = 0;
1397
  foreach( $atts_map as $slide ) {
1398
  $indicators[] = sprintf(
1399
  '<li class="%s" data-target="%s" data-slide-to="%s"></li>',
1400
+ ( !empty($slide["carousel-item"]["active"]) || ($GLOBALS['carousel_default_active'] && $i == 0) ) ? 'active' : '',
1401
  esc_attr( '#' . $id ),
1402
  esc_attr( '#' . $i )
1403
  );
1408
  '<div class="%s" id="%s" data-ride="carousel"%s%s%s%s>%s<div class="%s">%s</div>%s%s</div>',
1409
  esc_attr( $div_class ),
1410
  esc_attr( $id ),
1411
+ ( $interval ) ? sprintf( ' data-interval="%d"', $interval ) : '',
1412
+ ( $pause ) ? sprintf( ' data-pause="%s"', esc_attr( $pause ) ) : '',
1413
+ ( $wrap ) ? sprintf( ' data-wrap="%s"', esc_attr( $wrap ) ) : '',
1414
  ( $data_props ) ? ' ' . $data_props : '',
1415
  ( $indicators ) ? '<ol class="carousel-indicators">' . implode( $indicators ) . '</ol>' : '',
1416
  esc_attr( $inner_class ),
1781
 
1782
  $previous_value = libxml_use_internal_errors(TRUE);
1783
  $dom = new DOMDocument;
1784
+ $dom->loadXML( $content );
1785
  libxml_clear_errors();
1786
  libxml_use_internal_errors($previous_value);
1787
+ foreach( $dom->getElementsByTagName( 'img' ) as $image ) {
1788
+ $image->setAttribute( 'class', $image->getAttribute( 'class' ) . ' ' . esc_attr( $class ) );
1789
  if( $data ) {
1790
  $data = explode( '|', $data );
1791
  foreach( $data as $d ):
1792
+ $d = explode( ',', $d );
1793
+ $image->setAttribute( 'data-'.$d[0], trim( $d[1] ) );
1794
  endforeach;
1795
  }
1796
  }
1817
 
1818
  $previous_value = libxml_use_internal_errors(TRUE);
1819
  $dom = new DOMDocument;
1820
+ $dom->loadXML( $content );
1821
  libxml_clear_errors();
1822
+ libxml_use_internal_errors( $previous_value );
1823
+ if( ! $dom->documentElement ) {
1824
+ $element = $dom->createElement( 'div', $content );
1825
  $dom->appendChild($element);
1826
  }
1827
  $dom->documentElement->setAttribute('class', $dom->documentElement->getAttribute('class') . ' ' . esc_attr( $class ));
1828
  if( $data ) {
1829
  $data = explode( '|', $data );
1830
  foreach( $data as $d ):
1831
+ $d = explode( ',', $d );
1832
+ $dom->documentElement->setAttribute( 'data-'.$d[0], trim( $d[1] ) );
1833
  endforeach;
1834
  }
1835
  $return = $dom->saveXML();
1899
  $a_class = '';
1900
  $a_class .= ( $xclass ) ? ' ' . $xclass : '';
1901
 
1902
+ $div_class = 'modal fade';
1903
  $div_class .= ( $size ) ? ' bs-modal-' . $size : '';
1904
 
1905
  $id = 'custom-modal-' . sanitize_title( $title );
composer.json CHANGED
@@ -27,6 +27,6 @@
27
  "type": "wordpress-plugin",
28
  "require": {
29
  "php": ">=5.3.2",
30
- "composer/installers": "v1.0.6"
31
  }
32
  }
27
  "type": "wordpress-plugin",
28
  "require": {
29
  "php": ">=5.3.2",
30
+ "composer/installers": "1.0.*@dev"
31
  }
32
  }
includes/actions-filters.php CHANGED
@@ -24,7 +24,7 @@ function add_bootstrap_button() {
24
 
25
  //append the icon
26
  printf(
27
- '<a title="%1$s" href="%2$s" class="thickbox button add_media" style="padding-left: 0px; padding-right: 0px;"><span class="bs_bootstrap-logo wp-media-buttons-icon"></span></a>',
28
  esc_attr( $title ),
29
  esc_url( '#TB_inline?width=640&height=650&inlineId=' . $popup_id )
30
  //sprintf( '<img src="%s" style="height: 20px; position: relative; top: -2px;">', esc_url( $img ) )
24
 
25
  //append the icon
26
  printf(
27
+ '<a title="%1$s" href="%2$s" class="thickbox button add_media bootstrap-shortcodes-button" style="padding-left: 0px; padding-right: 0px;"><span class="bs_bootstrap-logo wp-media-buttons-icon"></span></a>',
28
  esc_attr( $title ),
29
  esc_url( '#TB_inline?width=640&height=650&inlineId=' . $popup_id )
30
  //sprintf( '<img src="%s" style="height: 20px; position: relative; top: -2px;">', esc_url( $img ) )
includes/bootstrap-shortcodes-help.php CHANGED
@@ -42,6 +42,16 @@ $html = MarkdownExtra::defaultTransform($text);
42
  win.send_to_editor(paras);
43
  });
44
  });
 
 
 
 
 
 
 
 
 
 
45
  </script>
46
  <div style="display:none;" id="bootstrap-shortcodes-help-popup">
47
  <div id="bootstrap-shortcodes-help">
42
  win.send_to_editor(paras);
43
  });
44
  });
45
+ </script>
46
+ <script type="text/javascript">
47
+ jQuery( '.bootstrap-shortcodes-button' ).each( function( index, value ) {
48
+ var h = window.innerHeight * .85;
49
+ var href = jQuery( this ).attr('href');
50
+ var find = 'height=650';
51
+ var replace = '&height='+h;
52
+ href = href.replace( find, replace )
53
+ jQuery( this ).attr( 'href', href );
54
+ } );
55
  </script>
56
  <div style="display:none;" id="bootstrap-shortcodes-help-popup">
57
  <div id="bootstrap-shortcodes-help">
includes/help/bs-font.css CHANGED
@@ -1,6 +1,6 @@
1
  @font-face {
2
- font-family: 'Bootstrap-Shortcodes-for-WordPress';
3
- src:url('fonts/Bootstrap-Shortcodes-for-WordPress.eot?-o1r0ap');
4
  src:url('fonts/Bootstrap-Shortcodes-for-WordPress.eot?#iefix-o1r0ap') format('embedded-opentype'),
5
  url('fonts/Bootstrap-Shortcodes-for-WordPress.woff?-o1r0ap') format('woff'),
6
  url('fonts/Bootstrap-Shortcodes-for-WordPress.ttf?-o1r0ap') format('truetype'),
@@ -9,8 +9,13 @@
9
  font-style: normal;
10
  }
11
 
12
- [class^="bs_"], [class*=" bs_"] {
13
- font-family: 'Bootstrap-Shortcodes-for-WordPress' !important;
 
 
 
 
 
14
  speak: none;
15
  font-style: normal;
16
  font-weight: normal;
@@ -22,11 +27,3 @@
22
  -webkit-font-smoothing: antialiased;
23
  -moz-osx-font-smoothing: grayscale;
24
  }
25
- .bs_bootstrap-logo {
26
- padding: 0 3px;
27
- }
28
- .bs_bootstrap-logo:before {
29
- font-family: 'Bootstrap-Shortcodes-for-WordPress' !important;
30
- content: "\e600" !important;
31
- color: #6f5499 !important;
32
- }
1
  @font-face {
2
+ font-family: 'bss4wp';
3
+ src:url('fonts/Bootstrap-Shortcodes-for-WordPress.eot?-o1r0ap') format('embedded-opentype');
4
  src:url('fonts/Bootstrap-Shortcodes-for-WordPress.eot?#iefix-o1r0ap') format('embedded-opentype'),
5
  url('fonts/Bootstrap-Shortcodes-for-WordPress.woff?-o1r0ap') format('woff'),
6
  url('fonts/Bootstrap-Shortcodes-for-WordPress.ttf?-o1r0ap') format('truetype'),
9
  font-style: normal;
10
  }
11
 
12
+ .bs_bootstrap-logo {
13
+ padding: 0 3px;
14
+ }
15
+ .wp-media-buttons .add_media span.bs_bootstrap-logo:before {
16
+ font-family: 'bss4wp' !important;
17
+ content: "\e600" !important;
18
+ color: #6f5499 !important;
19
  speak: none;
20
  font-style: normal;
21
  font-weight: normal;
27
  -webkit-font-smoothing: antialiased;
28
  -moz-osx-font-smoothing: grayscale;
29
  }
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: filipstefansson, nodley, FoolsRun
3
  Tags: bootstrap, shortcode, shortcodes, responsive, grid
4
  Requires at least: 3.8
5
- Tested up to: 3.8
6
- Stable tag: 3.1.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -68,6 +68,13 @@ No, we assume you are already working with a WordPress theme that includes the B
68
 
69
  == Changelog ==
70
 
 
 
 
 
 
 
 
71
  = 3.1.1 =
72
  * Support new parameters introduced in Bootstrap 3.1.x
73
  * Use custom icon-font for editor button
2
  Contributors: filipstefansson, nodley, FoolsRun
3
  Tags: bootstrap, shortcode, shortcodes, responsive, grid
4
  Requires at least: 3.8
5
+ Tested up to: 3.9
6
+ Stable tag: 3.1.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
68
 
69
  == Changelog ==
70
 
71
+ = 3.1.2 =
72
+ * Tested to work in WordPress 3.9
73
+ * Fix and document collapsibles "Active" state
74
+ * Fix uninitialized variables causing errors in debug mode
75
+ * Fix "Active" tab, carousel checking, should work better now
76
+ * Fix media button icon in Internet Explorer
77
+
78
  = 3.1.1 =
79
  * Support new parameters introduced in Bootstrap 3.1.x
80
  * Use custom icon-font for editor button