';
// $return .= remove_wpautop($content);
// $return .= '';
// return $return;
// }
function remove_wpautop($content) {
$content = do_shortcode( shortcode_unautop($content) );
$content = preg_replace( '#^<\/p>|^
|
$#', '', $content );
return $content;
}
// shortcodes in shortcodes
add_filter('the_content', 'do_shortcode');
// Allow shortcodes in widget text
add_filter('widget_text', 'do_shortcode');
add_shortcode('recent_posts', 'recent_posts');
add_shortcode('button', 'shortcode_button');
add_shortcode("youtube", "youtube");
add_shortcode('vimeo', 'vimeo');
add_shortcode('checklist', 'checklist');
add_shortcode('icon', 'icon');
add_shortcode('collapsibles', 'bs_collapsibles');
add_shortcode('collapse', 'bs_collapse');
add_shortcode( 'testimonial', 'testimonial_func' );
add_shortcode('tabs', 'bs_tabs');
add_shortcode('tab', 'bs_tab');
add_shortcode('tabsvertical', 'bs_tabs_vertical');
add_shortcode('separ_line', 'separ_line');
add_shortcode('br', 'br');
add_shortcode('jcarousel', 'shortcode_jcarousel');
add_shortcode('slide', 'shortcode_slide');
add_shortcode("googlemap", "google_maps_shortcode");
add_shortcode("slider_frame", "slider_frame_shortcode");
add_shortcode("separator", "separator_shortcode");
add_shortcode("my_columns", "my_columns_shortcode");
add_shortcode("my_column", "my_column_shortcode");
add_shortcode("my_teaser_grid", "my_teaser_grid_shortcode");
// add_shortcode("twitter_widget", "twitter_widget_shortcode");
// [my_columns][/my_columns]
// [my_column width="1/1"]...[/my_column]
// [my_columns][my_column width="1/2"]...[/my_column][my_column width="1/2"]...[/my_column][/my_columns]
// [my_columns][my_column width="1/3"]...[/my_column][my_column width="1/3"]...[/my_column][my_column width="1/3"]...[/my_column][/my_columns]
// [my_columns][my_column width="1/4"]...[/my_column][my_column width="1/4"]...[/my_column][my_column width="1/4"]...[/my_column][my_column width="1/4"]...[/my_column][/my_columns]
// 2/3 + 1/3 [my_columns][my_column width="2/3"]...[/my_column][my_column width="1/3"]...[/my_column][/my_columns]
function my_columns_shortcode( $atts, $content = null ) {
$output = '';
$output .= '
';
$output .= remove_wpautop($content);
$output .= '
';
return $output;
}
// [my_column width="1/2"][/my_column]
function my_column_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'width' => '',
), $atts ) );
if ($width == '1/2') {$span = 6;}
if ($width == '1/3') {$span = 4;}
if ($width == '1/4') {$span = 3;}
if ($width == '2/3') {$span = 8;}
if ($width == '3/4') {$span = 9;}
if ($width == '5/6') {$span = 10;}
if ($width == '1/6') {$span = 2;}
$output = '';
$output .= '';
$output .= remove_wpautop($content);
$output .= '
';
return $output;
}
// the_widget('WP_Widget_Wptuts_Twitter_Widget', $instance, $args);
// [twitter_widget]
// function twitter_widget_shortcode( $atts, $content = null ) {
// $output = '';
// $output .= '';
// $output .= the_widget('WP_Widget_Wptuts_Twitter_Widget', $instance, $args);
// $output .= '';
// return $output;
// }
// [my_teaser_grid count="3"]
function my_teaser_grid_shortcode ($atts, $content = null) {
extract( shortcode_atts( array(
'grid_layout' => 'title_thumbnail_text',
'count' => '6'
), $atts ) );
$output = '';
$output .= '';
$output .= '';
$output .= '
';
// The Query
$args = array(
'orderby' => 'none',
'post_type' => 'portfolio',
'posts_per_page' => $count
);
$the_query = new WP_Query($args);
// The Loop
while ( $the_query->have_posts() ) :
$the_query->the_post();
if ( has_post_thumbnail() ) {
$output .= '- ';
$output .= '';
$post_id = $the_query->post->ID;
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
$large_image_url = wp_get_attachment_image_src( $post_thumbnail_id, 'large');
$output .= '';
$content = get_the_excerpt();
$output .= '';
$output .= '
';
}
endwhile;
$output .= '
';
$output .= '
';
return $output;
}
// button
function shortcode_button($atts, $content = null) {
return '' .remove_wpautop($content). '';
}
// video from youtube
function youtube($atts, $content = null) {
return '';
}
// video from vimeo
function vimeo($atts) {
return '';
}
// add an unondered check list
function checklist( $atts, $content = null ) {
return '' .remove_wpautop($content). '
';
}
// icons
function icon($atts) {
return '' . ' ';
}
// Twitter Bootstrap Tabs - horizontal
function bs_tabs( $atts, $content = null ) {
if( isset($GLOBALS['tabs_count']) )
$GLOBALS['tabs_count']++;
else
$GLOBALS['tabs_count'] = 0;
$defaults = array();
extract( shortcode_atts( $defaults, $atts ) );
// Extract the tab titles for use in the tab widget.
preg_match_all( '/tab title="([^\"]+)"/i', $content, $matches, PREG_OFFSET_CAPTURE );
$tab_titles = array();
if( isset($matches[1]) ){ $tab_titles = $matches[1]; }
$output = '';
if( count($tab_titles) ){
$output .= '';
$i = 0;
foreach( $tab_titles as $tab ){
if($i == 0)
$output .= '- ';
else
$output .= '
- ';
$output .= '' . $tab[0] . '
';
$i++;
}
$output .= '
';
$output .= '';
$output .= remove_wpautop($content);
$output .= '
';
} else {
$output .= remove_wpautop($content);
}
return $output;
}
function bs_tab( $atts, $content = null ) {
if( !isset($GLOBALS['current_tabs']) ) {
$GLOBALS['current_tabs'] = $GLOBALS['tabs_count'];
$state = 'active';
} else {
if( $GLOBALS['current_tabs'] == $GLOBALS['tabs_count'] ) {
$state = '';
} else {
$GLOBALS['current_tabs'] = $GLOBALS['tabs_count'];
$state = 'active';
}
}
$defaults = array( 'title' => 'Tab');
extract( shortcode_atts( $defaults, $atts ) );
return ''. remove_wpautop($content) .'
';
}
// Twitter Bootstrap Tabs - vertical
function bs_tabs_vertical( $atts, $content = null ) {
if( isset($GLOBALS['tabs_count']) )
$GLOBALS['tabs_count']++;
else
$GLOBALS['tabs_count'] = 0;
$defaults = array();
extract( shortcode_atts( $defaults, $atts ) );
// Extract the tab titles for use in the tab widget.
preg_match_all( '/tab title="([^\"]+)"/i', $content, $matches, PREG_OFFSET_CAPTURE );
$tab_titles = array();
if( isset($matches[1]) ){ $tab_titles = $matches[1]; }
$output = '';
if( count($tab_titles) ){
$output .= '';
$i = 0;
foreach( $tab_titles as $tab ){
if($i == 0)
$output .= '- ';
else
$output .= '
- ';
$output .= '' . $tab[0] . '
';
$i++;
}
$output .= '
';
$output .= '';
$output .= remove_wpautop($content);
$output .= '
';
} else {
$output .= remove_wpautop($content);
}
return $output;
}
// toggle
function bs_collapsibles( $atts, $content = null ) {
if( isset($GLOBALS['collapsibles_count']) )
$GLOBALS['collapsibles_count']++;
else
$GLOBALS['collapsibles_count'] = 0;
$defaults = array();
extract( shortcode_atts( $defaults, $atts ) );
// Extract the tab titles for use in the tab widget.
preg_match_all( '/collapse title="([^\"]+)"/i', $content, $matches, PREG_OFFSET_CAPTURE );
$tab_titles = array();
if( isset($matches[1]) ){ $tab_titles = $matches[1]; }
$output = '';
if( count($tab_titles) ){
$output .= '';
$output .= remove_wpautop( $content );
$output .= '
';
} else {
$output .= remove_wpautop( $content );
}
return $output;
}
function bs_collapse( $atts, $content = null ) {
if( !isset($GLOBALS['current_collapse']) )
$GLOBALS['current_collapse'] = 0;
else
$GLOBALS['current_collapse']++;
$defaults = array( 'title' => 'Tab', 'state' => '');
extract( shortcode_atts( $defaults, $atts ) );
if (!empty($state))
$state = 'in';
return '
' . remove_wpautop( $content ) . '
';
}
// recent posts
function recent_posts($atts) {
$output = '';
$category = $atts['category'];
$showposts = $atts['showposts'];
$recent_posts = new WP_Query( array(
'post_type' => 'post',
'showposts' => $showposts,
'cat' => $category
));
while($recent_posts->have_posts()): $recent_posts->the_post();
$timem = get_the_time('M');
$timed = get_the_time('d');
$output .= '';
if($atts['date'] == "yes"):
$output .= ''.$timed.''.$timem.'
';
endif;
if($atts['title'] == "yes"):
$output .= '';
endif;
if($atts['excerpt'] == "yes"):
if($atts['excerpt_as_link'] == "yes"):
$output .= ''.get_the_excerpt().'';
else: $output .= kama_excerpt("maxchar=150");
endif;
endif;
$output .= '';
endwhile;
wp_reset_postdata();
return $output;
}
// line break
function br($atts, $content = null) {
return '
';
}
// separ-line
function separ_line($atts, $content = null) {
return '';
}
// Jcarousel [jcarousel visible="1" scroll="1" auto="0" wrap="both" space="1"][slide]content[/slide][/jcarousel]
// Jcarousel [jcarousel height="150" itemwidth="231" scroll="1" auto="no" wrap="both" space="2"][slide]content[/slide][/jcarousel]
function shortcode_jcarousel($atts, $content = null) {
extract(shortcode_atts(array(
// 'visible' => '1',
'scroll' => '2',
'auto' => 'no',
'wrap' => 'both',
'space' => '5',
'height' => '150',
'itemwidth' => '235',
'images' => ''
), $atts));
$counter_jc = null;
global $counter_jc;
if( isset($counter_jc) ) {
$counter_jc++;
}
else
$counter_jc = 0;
$script = '';
$output .= '';
if ($images) {
$images = explode( ',', $images);
$i = 0;
foreach ( $images as $attach_id ) {
$img = array();
$img[$i] = wp_get_attachment_image_src( $attach_id, 'large' );
$output .= '
';
$i++;
}
} else $output .= remove_wpautop($content);
// $output .= remove_wpautop($content);
$output .= '
';
$output .= '
';
$output .= '
';
$output .= $script;
return $output;
}
function shortcode_slide($atts, $content = null) {
$output = '';
$output .= '';
$output .= remove_wpautop($content);
$output .= '';
return $output;
}
// Google map
function google_maps_shortcode($atts, $content = null) {
extract(shortcode_atts(array(
"width" => '100%',
"height" => '323',
"src" => ''
), $atts));
return '';
}
function testimonial_func( $atts, $content = null ) { // New function parameter $content is added!
extract( shortcode_atts( array(
'name' => '',
'link' => ''
), $atts ) );
$content = wpb_js_remove_wpautop($content); // fix unclosed/unwanted paragraph tags in $content
$str .= '';
$str .= '
';
$str .= $content;
$str .= '
';
if($atts['name']):
$str .= '
';
$str .= '
'.$atts['name'].'';
if($atts['link']):
$str .= '
'.$atts['link'].'';
endif;
$str .= '
';
endif;
$str .= '
';
return $str;
}
// [slider_frame framew="" frameh="" slideralias=""][/slider_frame]
function slider_frame_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'framew' => '286',
'frameh' => '390',
'slideralias' => 'slider2',
'image' => '',
'frame_position' => 'under'
), $atts ) );
$counter_slider = null;
global $counter_slider;
if( isset($counter_slider) ) {
$counter_slider++;
}
else
$counter_slider = 0;
$output = '';
if ($image) {
$img = wp_get_attachment_image_src( $image, 'large' );
$output .= '

';
} else $output .= remove_wpautop($content);
$output .= '
'.do_shortcode('[rev_slider '.$slideralias.']').'
';
$output .= '
';
$frame_position_index = 1;
if ($frame_position == 'above') {
$frame_position_index = 100;
}
$script = '';
$output .= $script;
return $output;
}
// [slider_frame framew="" frameh="" slideralias=""][/slider_frame]
// function slider_frame_shortcode( $atts, $content = null ) {
// extract( shortcode_atts( array(
// 'framew' => '286',
// 'frameh' => '390',
// 'slideralias' => 'slider2'
// ), $atts ) );
// $output = '';
// return $output;
// }
// [separator]
// [separator variant=""]
// [separator variant="" color="" height=""]
function separator_shortcode( $atts ) {
extract( shortcode_atts( array(
'variant' => '1',
'color' => '',
'height' => ''
), $atts ) );
if (!$variant) {
$variant = 1;
}
$output = '';
return $output;
}
// add buttons in tinymce editor
add_action('init', 'add_button');
function add_button() {
if ( current_user_can('edit_posts') && current_user_can('edit_pages') )
{
add_filter('mce_external_plugins', 'add_plugin');
add_filter('mce_buttons_3', 'register_button');
}
}
function register_button($buttons) {
array_push($buttons, "quote", "button", "youtube", "vimeo", "checklist", "icon", "tabs", "tabsvertical", "accordion", "testimonial", "recent_posts", "br", "jcarousel", "slider_frame", "separline", "my_column12", "my_column13", "my_column14", "my_column23", "my_column34", "my_column56", "my_column16");
return $buttons;
}
function add_plugin($plugin_array) {
$plugin_array['quote'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['button'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['youtube'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['vimeo'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['checklist'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['icon'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['tabs'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['tabsvertical'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['accordion'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['testimonial'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['recent_posts'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['br'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['jcarousel'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['slider_frame'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['separline'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['my_column12'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['my_column13'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['my_column14'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['my_column23'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['my_column34'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['my_column56'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
$plugin_array['my_column16'] = get_bloginfo('template_url').'/tinymce-kit/customcodes.js';
return $plugin_array;
}
?>