Accordions & Toggles

Accordion Code

[container padding=»10px 0″][title size=»small» align=»center» <?php
/*
Plugin Name: Templatemela Shortcodes
Plugin URI: http://www.templatemela.com
Description: Templatemela Custom Shortcodes for templatemela wordpress themes.
Version: 1.0
Author: Templatemela
Author URI: http://www.templatemela.com
*/

/***************** accordion ****************/

function shortcode_accordion($atts, $content = null) {

extract(shortcode_atts(array(
‘style’    => ‘1’
), $atts));

$output = »;
$output .= ‘

‘;
$output .=    do_shortcode($content);
$output .=    ‘

‘;
return $output;
}
add_shortcode(‘tm_accordion’, ‘shortcode_accordion’);

function shortcode_single_accordion($atts, $content = null)
{
extract(shortcode_atts(array(
‘title’ => ‘Click here to hide/show Div’
), $atts));
$output = »;
$output .= ‘

‘;
$output .= ‘

‘.$title.’

</a>’;
$output .= ‘

‘.do_shortcode($content).’

‘;
$output .=    ‘</div>’;
return $output;
}
add_shortcode(‘accordion’, ‘shortcode_single_accordion’);

/******************************Newsletter*******************************/
function shortcode_newsletter_text($atts, $content = null){
extract(shortcode_atts(array(
‘text1’ => »,
‘text2’ => »,
‘description’ => »,
), $atts));
$output = »;
$output .= ‘

‘;
$output .= ‘

‘;
$output .= ‘

‘;
if(!empty($text1))
$output .= ‘<h1 class=»simple-type small-title»>’.$text1.'</h1>’;
if(!empty($text2))
$output .= ‘

‘.$text2.’

‘;
if(!empty($description))
$output .= ‘

‘.$description.’

‘;
$output .= ‘

‘;
return $output;
}
add_shortcode(‘newsletter_text’, ‘shortcode_newsletter_text’);

/***************** Toggle ****************/
function shortcode_toggle($atts, $content = null) {

extract(shortcode_atts(array(
‘style’    => ‘1’
), $atts));

$output = »;
$output .= ‘

‘;
$output .=    do_shortcode($content);
$output .=    ‘

‘;
return $output;
}
add_shortcode(‘tm_toggle’, ‘shortcode_toggle’);

function shortcode_single_toggle($atts, $content = null)
{
extract(shortcode_atts(array(
‘title’ => ‘Click here to hide/show Div’
), $atts));
$output = »;
$output .= ‘

‘;
$output .= ‘

‘.$title.’

</a>’;
$output .= ‘

‘.do_shortcode($content).’

‘;
$output .=    ‘</div>’;
return $output;
}
add_shortcode(‘toggle’, ‘shortcode_single_toggle’);

/***************** Horizontal Tab ****************/

$maintab_div = »;

function tabs_group($atts, $content = null ) {
global $maintab_div;
extract(shortcode_atts(array(
‘tab_type’ => ‘horizontal’,
‘style’    => ‘1’
), $atts));

switch ($tab_type) {
case ‘vertical’ :
$element_class = ‘vertical_tab’;
break;
default :
$element_class = ‘horizontal_tab’;
break;
break;
}

$maintab_div = »;
$output = ‘

    ‘;
    $output.= do_shortcode($content).’

‘;
$output.= ‘

‘.$maintab_div.’

‘;
return $output;
}
add_shortcode(‘tm_tabs’, ‘tabs_group’);

function tab($atts, $content = null) {
global $maintab_div;

static $oddeven_class=0;
$oddeven_class++;
$newclass = »;
$output = »;
if($oddeven_class % 2 == 0) { $newclass .= «even»; } else  { $newclass .= «odd»; }

extract(shortcode_atts(array(
‘title’ => »,
), $atts));
$dummy_title = «‘. __( ‘Tab’, ‘templatemela’ ) .'»;

if($title != NULL) {
$output .= ‘<li class=»‘.$newclass.'»><a href=»#»>’.$title.'<span class=»leftarrow»></span></a></li>’;
} else {
$output .= ‘<li class=»‘.$newclass.'»><a href=»#»>’.$dummy_title.'<span class=»leftarrow»></span></a></li>’;
}
$maintab_div.= ‘

‘.$content.’

‘;
return $output;
}
add_shortcode(‘tm_tab’, ‘tab’);

/***************** Testimonial ****************/
function shortcode_testimonials($atts, $content = null, $code) {
extract(shortcode_atts(array(
‘style’ => ‘1’,
‘type’ => ‘grid’,
‘items_per_column’ => 3,
‘number_of_posts’ => 5,
‘image_width’ => 50,
‘image_height’ => 50,
‘background_color’ => ‘F7F7F7’
), $atts));

global $post;
$i = 1;
$args = array(
‘posts_per_page’ => $number_of_posts,
‘post_status’ => ‘publish’,
‘post_type’ => ‘testimonial’,
);
$testimonial_array = get_posts($args);
$testimonial_count = count($testimonial_array);
$output = »;
if($testimonial_count > 0 ):
$output .= ‘

‘;
if($type == «slider») {
if($testimonial_count > $items_per_column)
$output .= ‘