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