| 1 |
<?php |
| 2 |
//Shortcode for accordion |
| 3 |
function virtue_toolkit_accordion_shortcode_function($atts, $content ) { |
| 4 |
extract(shortcode_atts(array( |
| 5 |
'id' => rand(1, 999) |
| 6 |
), $atts)); |
| 7 |
global $kt_pane_count, $kt_panes; |
| 8 |
$kt_pane_count = 0; |
| 9 |
$kt_panes = array(); |
| 10 |
$return = ''; |
| 11 |
do_shortcode( $content ); |
| 12 |
if( is_array( $kt_panes ) && !empty($kt_panes)){ |
| 13 |
$i = 0; |
| 14 |
foreach( $kt_panes as $tab ){ |
| 15 |
if ($i % 2 == 0) { |
| 16 |
$eo = "even"; |
| 17 |
} else { |
| 18 |
$eo = "odd"; |
| 19 |
} |
| 20 |
$tabs[] = '<div class="panel panel-default panel-'.esc_attr($eo).'"><div class="panel-heading"><a class="accordion-toggle '.esc_attr($tab['open']).'" data-toggle="collapse" data-parent="#accordionname'.esc_attr($id).'" href="#collapse'.esc_attr($id.$tab['link']).'"><h5><i class="icon-minus kt-icon-minus primary-color"></i><i class="icon-plus kt-icon-plus"></i>'.wp_kses_post($tab['title']).'</h5></a></div><div id="collapse'.esc_attr($id.$tab['link']).'" class="panel-collapse collapse '.esc_attr($tab['in']).'"><div class="panel-body postclass">'.do_shortcode($tab['content']).'</div></div></div>'; |
| 21 |
$i++; |
| 22 |
} |
| 23 |
$return = "\n".'<div class="panel-group kt-accordion" id="accordionname'.esc_attr($id).'">'.implode( "\n", $tabs ).'</div>'."\n"; |
| 24 |
} |
| 25 |
return $return; |
| 26 |
} |
| 27 |
|
| 28 |
function virtue_toolkit_accordion_pane_function($atts, $content ) { |
| 29 |
extract(shortcode_atts(array( |
| 30 |
'title' => 'Pane %d', |
| 31 |
'start' => '' |
| 32 |
), $atts)); |
| 33 |
if (!empty($start) || $start == 'closed') { |
| 34 |
$open = ''; |
| 35 |
} else { |
| 36 |
$open = 'collapsed'; |
| 37 |
} |
| 38 |
if (!empty($start) || $start == 'closed') { |
| 39 |
$in = 'in'; |
| 40 |
} else { |
| 41 |
$in = ''; |
| 42 |
} |
| 43 |
global $kt_pane_count, $kt_panes; |
| 44 |
$x = $kt_pane_count; |
| 45 |
$kt_panes[$x] = array( 'title' => $title, 'open' => $open, 'in' => $in, 'link' => $kt_pane_count, 'content' => $content ); |
| 46 |
|
| 47 |
$kt_pane_count++; |
| 48 |
} |
| 49 |
function virtue_toolkit_tab_shortcode_function($atts, $content ) { |
| 50 |
extract(shortcode_atts(array( |
| 51 |
'id' => rand(1, 9999), |
| 52 |
'style' => '1', |
| 53 |
), $atts)); |
| 54 |
global $kt_tab_count, $kt_tabs; |
| 55 |
$kt_tab_count = 0; |
| 56 |
$kt_tabs = array(); |
| 57 |
$return = ''; |
| 58 |
do_shortcode( $content ); |
| 59 |
if( is_array( $kt_tabs ) && !empty($kt_tabs)) { |
| 60 |
foreach( $kt_tabs as $nav ){ |
| 61 |
$tabnav[] = '<li class="'.esc_attr($nav['active']).'"><a href="#sctab'.esc_attr($id.$nav['link']).'">'.wp_kses_post($nav['title']).'</a></li>'; |
| 62 |
} |
| 63 |
foreach( $kt_tabs as $tab ){ |
| 64 |
$tabs[] = '<div class="tab-pane clearfix '.esc_attr($tab['active']).'" id="sctab'.esc_attr($id.$tab['link']).'">'.do_shortcode( $tab['content']).'</div>'; |
| 65 |
} |
| 66 |
|
| 67 |
$return = "\n".'<ul class="nav nav-tabs sc_tabs kt-tabs kt-sc-tabs kt-tabs-style'.esc_attr($style).'">'.implode( "\n", $tabnav ).'</ul> <div class="tab-content kt-tab-content postclass">'.implode( "\n", $tabs ).'</div>'."\n"; |
| 68 |
} |
| 69 |
return $return; |
| 70 |
} |
| 71 |
function virtue_toolkit_tab_pane_function($atts, $content ) { |
| 72 |
extract(shortcode_atts(array( |
| 73 |
'title' => 'Tab %d', |
| 74 |
'start' => '' |
| 75 |
), $atts)); |
| 76 |
if (!empty($start)) { |
| 77 |
$active = 'active'; |
| 78 |
} else { |
| 79 |
$active = ''; |
| 80 |
} |
| 81 |
global $kt_tab_count, $kt_tabs; |
| 82 |
|
| 83 |
$x = $kt_tab_count; |
| 84 |
$kt_tabs[$x] = array( 'title' => $title, 'active' => $active, 'link' => $kt_tab_count, 'content' => $content ); |
| 85 |
|
| 86 |
$kt_tab_count++; |
| 87 |
} |
| 88 |
|
| 89 |
//Shortcode for columns |
| 90 |
function virtue_toolkit_column_shortcode_function( $atts, $content ) { |
| 91 |
return '<div class="row">'.do_shortcode($content).'</div>'; |
| 92 |
} |
| 93 |
function virtue_toolkit_hcolumn_shortcode_function( $atts, $content ) { |
| 94 |
return '<div class="row">'.do_shortcode($content).'</div>'; |
| 95 |
} |
| 96 |
function virtue_toolkit_column11_function( $atts, $content ) { |
| 97 |
return '<div class="col-md-11">'.do_shortcode($content).'</div>'; |
| 98 |
} |
| 99 |
function virtue_toolkit_column10_function( $atts, $content ) { |
| 100 |
return '<div class="col-md-10">'.do_shortcode($content).'</div>'; |
| 101 |
} |
| 102 |
function virtue_toolkit_column9_function( $atts, $content ) { |
| 103 |
return '<div class="col-md-9">'.do_shortcode($content).'</div>'; |
| 104 |
} |
| 105 |
function virtue_toolkit_column8_function( $atts, $content ) { |
| 106 |
return '<div class="col-md-8">'.do_shortcode($content).'</div>'; |
| 107 |
} |
| 108 |
function virtue_toolkit_column7_function( $atts, $content ) { |
| 109 |
return '<div class="col-md-7">'.do_shortcode($content).'</div>'; |
| 110 |
} |
| 111 |
function virtue_toolkit_column6_function( $atts, $content ) { |
| 112 |
return '<div class="col-md-6">'.do_shortcode($content).'</div>'; |
| 113 |
} |
| 114 |
function virtue_toolkit_column5_function( $atts, $content ) { |
| 115 |
return '<div class="col-md-5">'.do_shortcode($content).'</div>'; |
| 116 |
} |
| 117 |
function virtue_toolkit_column4_function( $atts, $content ) { |
| 118 |
return '<div class="col-md-4">'.do_shortcode($content).'</div>'; |
| 119 |
} |
| 120 |
function virtue_toolkit_column3_function( $atts, $content ) { |
| 121 |
return '<div class="col-md-3">'.do_shortcode($content).'</div>'; |
| 122 |
} |
| 123 |
function virtue_toolkit_column2_function( $atts, $content ) { |
| 124 |
return '<div class="col-md-2">'.do_shortcode($content).'</div>'; |
| 125 |
} |
| 126 |
function virtue_toolkit_column1_function( $atts, $content ) { |
| 127 |
return '<div class="col-md-1">'.do_shortcode($content).'</div>'; |
| 128 |
} |
| 129 |
//Shortcode for Icons |
| 130 |
function virtue_toolkit_icon_shortcode_function( $atts) { |
| 131 |
extract(shortcode_atts(array( |
| 132 |
'icon' => '', |
| 133 |
'size' => '', |
| 134 |
'color' => '', |
| 135 |
'float'=> '' |
| 136 |
), $atts)); |
| 137 |
if ($float != '') { |
| 138 |
$output = '<i class="'.esc_attr($icon).'" style="font-size:'.esc_attr($size).'; color:'.esc_attr($color).'; float:'.esc_attr($float).'; padding:10px;"></i>'; |
| 139 |
} else { |
| 140 |
$output = '<i class="'.esc_attr($icon).'" style="font-size:'.esc_attr($size).'; color:'.esc_attr($color).';"></i>'; |
| 141 |
} |
| 142 |
return $output; |
| 143 |
} |
| 144 |
// Video Shortcode |
| 145 |
function virtue_toolkit_video_shortcode_function( $atts, $content) { |
| 146 |
extract(shortcode_atts(array( |
| 147 |
'width' => '', |
| 148 |
), $atts)); |
| 149 |
if(!empty($width)) { |
| 150 |
$output = '<div style="max-width:'.esc_attr($width).'px;"><div class="videofit">'.wp_kses_post($content).'</div></div>'; |
| 151 |
} else { |
| 152 |
$output = '<div class="videofit">'.wp_kses_post($content).'</div>'; |
| 153 |
} |
| 154 |
return $output; |
| 155 |
} |
| 156 |
// Based on Ultimate Shortcodes youtube and vimeo shortcodes |
| 157 |
function virtue_toolkit_youtube_shortcode_function( $atts, $content) { |
| 158 |
// Prepare data |
| 159 |
$atts = shortcode_atts(array( |
| 160 |
'url' => false, |
| 161 |
'width' => 600, |
| 162 |
'height' => 400, |
| 163 |
'maxwidth' => '', |
| 164 |
'autoplay' => 'false', |
| 165 |
'controls' => 'true', |
| 166 |
'hidecontrols' => 'false', |
| 167 |
'fs' => 'true', |
| 168 |
'loop' => 'false', |
| 169 |
'rel' => 'false', |
| 170 |
'vq' => '', |
| 171 |
'modestbranding' => 'false', |
| 172 |
'theme' => 'dark' |
| 173 |
), $atts, 'kad_youtube' ); |
| 174 |
$return = array(); |
| 175 |
$params = array(); |
| 176 |
|
| 177 |
if ( !$atts['url'] ){ |
| 178 |
return '<p class="error">YouTube: ' . __( 'please specify correct url', 'virtue-toolkit' ) . '</p>'; |
| 179 |
} |
| 180 |
$id = ( preg_match( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $atts['url'], $match ) ) ? $match[1] : false; |
| 181 |
// Check that url is specified |
| 182 |
if ( !$id ) { |
| 183 |
return '<p class="error">YouTube: ' . __( 'please specify correct url', 'virtue-toolkit' ) . '</p>'; |
| 184 |
} |
| 185 |
// Prepare params |
| 186 |
if($atts['hidecontrols'] == 'true') {$atts['controls'] = 'false';} |
| 187 |
foreach ( array('autoplay', 'controls', 'fs', 'modestbranding', 'theme', 'rel', 'loop' ) as $param ) $params[$param] = str_replace( array( 'false', 'true', 'alt' ), array( '0', '1', '2' ), $atts[$param] ); |
| 188 |
// Prepare player parameters |
| 189 |
if(!empty($atts['vq']) ) {$params['vq'] = $atts['vq']; } |
| 190 |
$params = http_build_query( $params ); |
| 191 |
if($atts['maxwidth']) {$maxwidth = 'style="max-width:'.esc_attr($atts['maxwidth']).'px;"';} else{ $maxwidth = '';} |
| 192 |
// Create player |
| 193 |
$return[] = '<div class="kad-youtube-shortcode videofit" '.$maxwidth.' >'; |
| 194 |
$return[] = '<iframe width="' . esc_attr($atts['width']) . '" height="' . esc_attr($atts['height']) . '" src="//www.youtube.com/embed/' . esc_attr($id) . '?' . esc_attr($params) . '" frameborder="0" allowfullscreen="true"></iframe>'; |
| 195 |
$return[] = '</div>'; |
| 196 |
// Return result |
| 197 |
return implode( '', $return ); |
| 198 |
} |
| 199 |
function virtue_toolkit_vimeo_shortcode_function( $atts, $content) { |
| 200 |
$atts = shortcode_atts( array( |
| 201 |
'url' => false, |
| 202 |
'width' => 600, |
| 203 |
'height' => 400, |
| 204 |
'maxwidth' => '', |
| 205 |
'autoplay' => 'no' |
| 206 |
), $atts, 'vimeo' ); |
| 207 |
|
| 208 |
if ( !$atts['url'] ){ |
| 209 |
return '<p class="error">Vimeo: ' . __( 'please specify correct url', 'virtue-toolkit' ) . '</p>'; |
| 210 |
} |
| 211 |
$id = ( preg_match( '~(?:<iframe [^>]*src=")?(?:https?:\/\/(?:[\w]+\.)*vimeo\.com(?:[\/\w]*\/videos?)?\/([0-9]+)[^\s]*)"?(?:[^>]*></iframe>)?(?:<p>.*</p>)?~ix', $atts['url'], $match ) ) ? $match[1] : false; |
| 212 |
// Check that url is specified |
| 213 |
if ( !$id ) { |
| 214 |
return '<p class="error">Vimeo: ' . __( 'please specify correct url', 'virtue-toolkit' ) . '</p>'; |
| 215 |
} |
| 216 |
$return = array(); |
| 217 |
if($atts['maxwidth']) { |
| 218 |
$maxwidth = 'style="max-width:'.esc_attr($atts['maxwidth']).'px;"'; |
| 219 |
} else{ |
| 220 |
$maxwidth = ''; |
| 221 |
} |
| 222 |
$autoplay = ( $atts['autoplay'] === 'yes' ) ? '&autoplay=1' : ''; |
| 223 |
// Create player |
| 224 |
$return[] = '<div class="kad-vimeo-shortcode videofit '.$maxwidth.'">'; |
| 225 |
$return[] = '<iframe width="' . esc_attr($atts['width']) . '" height="' . esc_attr($atts['height']) .'" src="//player.vimeo.com/video/' . esc_attr($id) . '?title=0&byline=0&portrait=0&color=ffffff' .esc_attr($autoplay) . '" frameborder="0" allowfullscreen="true"></iframe>'; |
| 226 |
$return[] = '</div>'; |
| 227 |
|
| 228 |
// Return result |
| 229 |
return implode( '', $return ); |
| 230 |
} |
| 231 |
//Button |
| 232 |
function virtue_toolkit_button_shortcode_function( $atts) { |
| 233 |
extract(shortcode_atts(array( |
| 234 |
'id' => rand(1, 999), |
| 235 |
'bcolor' => '', |
| 236 |
'bhovercolor' => '', |
| 237 |
'thovercolor' => '', |
| 238 |
'link' => '', |
| 239 |
'text' => '', |
| 240 |
'target' => '_self', |
| 241 |
'tcolor' => '', |
| 242 |
), $atts)); |
| 243 |
$output = '<a href="'.esc_url($link).'" class="btn button btn-shortcode kad-btn kad-btn-primary" id="kadbtn'.esc_attr($id).'" target="'.esc_attr($target).'" style="'; |
| 244 |
if(!empty($bcolor)) { |
| 245 |
$output .= 'background-color:'.esc_attr($bcolor).';'; |
| 246 |
} |
| 247 |
if(!empty($tcolor)) { |
| 248 |
$output .= 'color:'.esc_attr($tcolor).';'; |
| 249 |
} |
| 250 |
$output .= '"'; |
| 251 |
if($thovercolor == $tcolor) {$thovercolor = null;} |
| 252 |
if(!empty($bhovercolor) || !empty($thovercolor)) { |
| 253 |
$output .= 'onMouseOver="this.style.background=\''.esc_attr($bhovercolor).'\',this.style.color=\''.esc_attr($thovercolor).'\'" onMouseOut="this.style.background=\''.esc_attr($bcolor).'\', this.style.color=\''.esc_attr($tcolor).'\'"'; |
| 254 |
} |
| 255 |
$output .= '>'.wp_kses_post($text).'</a>'; |
| 256 |
|
| 257 |
return $output; |
| 258 |
} |
| 259 |
function virtue_toolkit_blockquote_shortcode_function( $atts, $content) { |
| 260 |
extract(shortcode_atts(array( |
| 261 |
'align' => 'center', |
| 262 |
), $atts)); |
| 263 |
switch ($align) |
| 264 |
{ |
| 265 |
case "center": |
| 266 |
$output = '<div class="blockquote blockquote-full postclass clearfix">' . do_shortcode(wp_kses_post($content)) . '</div>'; |
| 267 |
break; |
| 268 |
|
| 269 |
case "left": |
| 270 |
$output = '<div class="blockquote blockquote-left postclass clearfix">' . do_shortcode(wp_kses_post($content)) . '</div>'; |
| 271 |
break; |
| 272 |
|
| 273 |
case "right": |
| 274 |
$output = '<div class="blockquote blockquote-right postclass clearfix">' . do_shortcode(wp_kses_post($content)) . '</div>'; |
| 275 |
break; |
| 276 |
} |
| 277 |
return $output; |
| 278 |
} |
| 279 |
function virtue_toolkit_pullquote_shortcode_function( $atts, $content) { |
| 280 |
extract( shortcode_atts( array( |
| 281 |
'align' => 'center' |
| 282 |
), $atts )); |
| 283 |
|
| 284 |
switch ($align) |
| 285 |
{ |
| 286 |
case "center": |
| 287 |
$output = '<div class="pullquote pullquote-center">' . do_shortcode(wp_kses_post($content)) . '</div>'; |
| 288 |
break; |
| 289 |
|
| 290 |
case "right": |
| 291 |
$output = '<div class="pullquote pullquote-right">' . do_shortcode(wp_kses_post($content)) . '</div>'; |
| 292 |
break; |
| 293 |
|
| 294 |
case "left": |
| 295 |
$output = '<div class="pullquote pullquote-left">' . do_shortcode(wp_kses_post($content)) . '</div>'; |
| 296 |
break; |
| 297 |
} |
| 298 |
|
| 299 |
return $output; |
| 300 |
} |
| 301 |
function virtue_toolkit_hrule_function( ) { |
| 302 |
return '<div class="hrule clearfix"></div>'; |
| 303 |
} |
| 304 |
function virtue_toolkit_hrpadding10_function( ) { |
| 305 |
return '<div class="space_20 clearfix"></div>'; |
| 306 |
} |
| 307 |
function virtue_toolkit_hrpadding20_function( ) { |
| 308 |
return '<div class="space_40 clearfix"></div>'; |
| 309 |
} |
| 310 |
function virtue_toolkit_hrpadding40_function( ) { |
| 311 |
return '<div class="space_80 clearfix"></div>'; |
| 312 |
} |
| 313 |
function virtue_toolkit_clearfix_function( ) { |
| 314 |
return '<div class="clearfix"></div>'; |
| 315 |
} |
| 316 |
function virtue_toolkit_columnhelper_function( ) { |
| 317 |
return ''; |
| 318 |
} |
| 319 |
function virtue_toolkit_register_shortcodes(){ |
| 320 |
add_shortcode('accordion', 'virtue_toolkit_accordion_shortcode_function'); |
| 321 |
add_shortcode('pane', 'virtue_toolkit_accordion_pane_function'); |
| 322 |
add_shortcode('tabs', 'virtue_toolkit_tab_shortcode_function'); |
| 323 |
add_shortcode('tab', 'virtue_toolkit_tab_pane_function'); |
| 324 |
add_shortcode('columns', 'virtue_toolkit_column_shortcode_function'); |
| 325 |
add_shortcode('hcolumns', 'virtue_toolkit_hcolumn_shortcode_function'); |
| 326 |
add_shortcode('span11', 'virtue_toolkit_column11_function'); |
| 327 |
add_shortcode('span10', 'virtue_toolkit_column10_function'); |
| 328 |
add_shortcode('span9', 'virtue_toolkit_column9_function'); |
| 329 |
add_shortcode('span8', 'virtue_toolkit_column8_function'); |
| 330 |
add_shortcode('span7', 'virtue_toolkit_column7_function'); |
| 331 |
add_shortcode('span6', 'virtue_toolkit_column6_function'); |
| 332 |
add_shortcode('span5', 'virtue_toolkit_column5_function'); |
| 333 |
add_shortcode('span4', 'virtue_toolkit_column4_function'); |
| 334 |
add_shortcode('span3', 'virtue_toolkit_column3_function'); |
| 335 |
add_shortcode('span2', 'virtue_toolkit_column2_function'); |
| 336 |
add_shortcode('span1', 'virtue_toolkit_column1_function'); |
| 337 |
add_shortcode('columnhelper', 'virtue_toolkit_columnhelper_function'); |
| 338 |
add_shortcode('icon', 'virtue_toolkit_icon_shortcode_function'); |
| 339 |
add_shortcode('pullquote', 'virtue_toolkit_pullquote_shortcode_function'); |
| 340 |
add_shortcode('blockquote', 'virtue_toolkit_blockquote_shortcode_function'); |
| 341 |
add_shortcode('btn', 'virtue_toolkit_button_shortcode_function'); |
| 342 |
add_shortcode('hr', 'virtue_toolkit_hrule_function'); |
| 343 |
add_shortcode('space_20', 'virtue_toolkit_hrpadding10_function'); |
| 344 |
add_shortcode('space_40', 'virtue_toolkit_hrpadding20_function'); |
| 345 |
add_shortcode('space_80', 'virtue_toolkit_hrpadding40_function'); |
| 346 |
add_shortcode('kad_youtube', 'virtue_toolkit_youtube_shortcode_function'); |
| 347 |
add_shortcode('kt_youtube', 'virtue_toolkit_youtube_shortcode_function'); |
| 348 |
add_shortcode('kad_vimeo', 'virtue_toolkit_vimeo_shortcode_function'); |
| 349 |
add_shortcode('kt_vimeo', 'virtue_toolkit_vimeo_shortcode_function'); |
| 350 |
add_shortcode('clear', 'virtue_toolkit_clearfix_function'); |
| 351 |
} |
| 352 |
add_action( 'init', 'virtue_toolkit_register_shortcodes'); |
| 353 |
|
| 354 |
|
| 355 |
function virtue_toolkit_register_button( $buttons ) { |
| 356 |
if ( empty( $buttons ) ) { |
| 357 |
$buttons = array(); |
| 358 |
} |
| 359 |
array_push( $buttons, "|", "kadcolumns" ); |
| 360 |
array_push( $buttons, "|", "kaddivider" ); |
| 361 |
array_push( $buttons, "|", "kadaccordion" ); |
| 362 |
array_push( $buttons, "|", "kadquote" ); |
| 363 |
array_push( $buttons, "|", "kadbtn" ); |
| 364 |
array_push( $buttons, "|", "kadicon" ); |
| 365 |
array_push( $buttons, "|", "kadyoutube" ); |
| 366 |
array_push( $buttons, "|", "kadvimeo" ); |
| 367 |
|
| 368 |
return $buttons; |
| 369 |
} |
| 370 |
function virtue_toolkit_add_plugin( $plugin_array ) { |
| 371 |
$plugin_array['kadcolumns'] = VIRTUE_TOOLKIT_URL . '/shortcodes/columns/columns_shortgen.js'; |
| 372 |
$plugin_array['kadicon'] = VIRTUE_TOOLKIT_URL . '/shortcodes/icons/icon_shortgen.js'; |
| 373 |
$plugin_array['kadaccordion'] = VIRTUE_TOOLKIT_URL . '/shortcodes/accordion/accordion_shortgen.js'; |
| 374 |
$plugin_array['kadyoutube'] = VIRTUE_TOOLKIT_URL . '/shortcodes/youtube/youtube_shortgen.js'; |
| 375 |
$plugin_array['kadvimeo'] = VIRTUE_TOOLKIT_URL . '/shortcodes/vimeo/vimeo_shortgen.js'; |
| 376 |
$plugin_array['kadquote'] = VIRTUE_TOOLKIT_URL . '/shortcodes/pullquote/quote_shortgen.js'; |
| 377 |
$plugin_array['kadbtn'] = VIRTUE_TOOLKIT_URL . '/shortcodes/btns/btns_shortgen.js'; |
| 378 |
$plugin_array['kaddivider'] = VIRTUE_TOOLKIT_URL . '/shortcodes/divider/divider_shortgen.js'; |
| 379 |
return $plugin_array; |
| 380 |
} |
| 381 |
function virtue_toolkit_tinymce_shortcode_button() { |
| 382 |
|
| 383 |
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) { |
| 384 |
return; |
| 385 |
} |
| 386 |
if ( get_user_option('rich_editing') == 'true' ) { |
| 387 |
add_filter( 'mce_external_plugins', 'virtue_toolkit_add_plugin' ); |
| 388 |
add_filter( 'mce_buttons_3', 'virtue_toolkit_register_button', 50 ); |
| 389 |
} |
| 390 |
|
| 391 |
} |
| 392 |
add_action('init', 'virtue_toolkit_tinymce_shortcode_button'); |
| 393 |
|
| 394 |
// Clean up Shortcodes |
| 395 |
function virtue_toolkit_content_clean_shortcodes($content){ |
| 396 |
$array = array ( |
| 397 |
'<p>[' => '[', |
| 398 |
']</p>' => ']', |
| 399 |
']<br />' => ']' |
| 400 |
); |
| 401 |
$content = strtr($content, $array); |
| 402 |
return $content; |
| 403 |
} |
| 404 |
add_filter('the_content', 'virtue_toolkit_content_clean_shortcodes'); |
| 405 |
function virtue_toolkit_widget_clean_shortcodes($text){ |
| 406 |
$array = array ( |
| 407 |
'<p>[' => '[', |
| 408 |
']</p>' => ']', |
| 409 |
'<p></p>' => '', |
| 410 |
']<br />' => ']', |
| 411 |
'<br />[' => '[' |
| 412 |
); |
| 413 |
$text = strtr($text, $array); |
| 414 |
return $text; |
| 415 |
} |
| 416 |
add_filter('widget_text', 'virtue_toolkit_widget_clean_shortcodes'); |
| 417 |
add_filter('widget_text', 'do_shortcode', 50); |
| 418 |
|