Last active
April 29, 2020 15:24
-
-
Save vburlak/71bfd0b5f19f623713f3 to your computer and use it in GitHub Desktop.
Replace Visual Composer initial classes with original Bootstrap 3 classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Replace Visual Composer initial classes with original Bootstrap 3 classes | |
* | |
* @author http://codecanyon.net/user/adambartholomew1 | |
* @source from http://pastebin.com/qJp9SXvP | |
* @package vc2twbs3classes | |
* @version 0.1 | |
*/ | |
$lCounter = 0; | |
$mCounter = 0; | |
$sCounter = 0; | |
$xsCounter = 0; | |
function custom_css_classes_for_vc_row_and_vc_column($class_string, $tag) { | |
global $lCounter, $mCounter, $sCounter, $xsCounter; | |
if($tag=='vc_row' || $tag=='vc_row_inner') { | |
$class_string = str_replace('vc_row-fluid', 'row', $class_string); | |
$lCounter = $mCounter = $sCounter = $xsCounter = 0; | |
} | |
if($tag=='vc_column' || $tag=='vc_column_inner') { | |
if($xsCounter >= 12) { | |
echo '<div class="clearfix visible-xs"></div>'; | |
$xsCounter = 0; | |
} | |
if($sCounter >= 12) { | |
echo '<div class="clearfix visible-sm"></div>'; | |
$sCounter = 0; | |
} | |
if($mCounter >= 12) { | |
echo '<div class="clearfix visible-md"></div>'; | |
$mCounter = 0; | |
} | |
if($lCounter >= 12) { | |
echo '<div class="clearfix visible-lg"></div>'; | |
$lCounter = 0; | |
} | |
$xsSize = $sSize = $mSize = $lSize = 0; | |
if(preg_match('/col-xs-(\d*)/', $class_string, $matches)) { | |
$xsSize = $matches[1]; | |
} | |
if(preg_match('/col-sm-(\d*)/', $class_string, $matches)) { | |
$sSize = $matches[1]; | |
} | |
if(preg_match('/col-md-(\d*)/', $class_string, $matches)) { | |
$mSize = $matches[1]; | |
} | |
if(preg_match('/col-lg-(\d*)/', $class_string, $matches)) { | |
$lSize = $matches[1]; | |
} | |
if(preg_match('/vc_span(\d*)/', $class_string, $matches)) { | |
if(!$xsSize) { | |
$xsSize = $matches[1]; | |
$class_string .= ' col-xs-'.$matches[1]; | |
} | |
if(!$sSize) { | |
$sSize = $matches[1]; | |
$class_string .= ' col-sm-'.$matches[1]; | |
} | |
if(!$mSize) { | |
$mSize = $matches[1]; | |
$class_string .= ' col-md-'.$matches[1]; | |
} | |
if(!$lSize) { | |
$lSize = $matches[1]; | |
$class_string .= ' col-lg-'.$matches[1]; | |
} | |
$xsCounter += $xsSize; | |
$sCounter += $sSize; | |
$mCounter += $mSize; | |
$lCounter += $lSize; | |
} | |
} | |
return $class_string; | |
} | |
// Filter to Replace default css class for vc_row shortcode and vc_column | |
add_filter('vc_shortcodes_css_class', 'custom_css_classes_for_vc_row_and_vc_column', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment