Permalink
Browse files

adding accordion shortcode

  • Loading branch information...
1 parent 50beacb commit c120a317b6c3e30267f14177a3a673ab6ac6072a Nick DiMatteo committed Apr 26, 2012
Showing with 27 additions and 0 deletions.
  1. +27 −0 inc/roots-custom.php
View
@@ -498,6 +498,33 @@ function team_list($atts) {
//make it a short code
add_shortcode('team', 'team_list');
+//make slugs
+function slug($str)
+{
+ $str = strtolower(trim($str));
+ $str = str_replace("'", '', $str);
+ $str = preg_replace('/[^a-z0-9-]/', '-', $str);
+ $str = preg_replace('/-+/', "-", $str);
+ return $str;
+}
+
+//create accordion short code
+function accordion_shortcode( $atts, $content = null ) {
+ extract( shortcode_atts( array(
+ 'title' => 'accordion',
+ ), $atts ) );
+
+ $slug = slug($title);
+
+ $accordion = '<div class="accordion">';
+ $accordion .= '<a class="no-ajaxy" data-toggle="collapse" data-target="#' . $slug . '">' . esc_attr($title) . ' <i class="icon-collapse"></i></a>';
+ $accordion .= '<div id="' . $slug . '" class="collapse">';
+ $accordion .= '<div class="wrapper">';
+
+ return $accordion . $content . '</div></div></div>';
+}
+add_shortcode( 'accordion', 'accordion_shortcode' );
+

0 comments on commit c120a31

Please sign in to comment.