Simple way to do some Visual Composer Grid cleanup, when you are using Bootstrap within your theme. This removes and cleans up classes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
add_filter('vc_shortcodes_css_class', function ($class_string, $tag) { $tags_to_clean = [ 'vc_row', 'vc_column', 'vc_row_inner', 'vc_column_inner' ]; if (in_array($tag, $tags_to_clean)) { $class_string = str_replace(' wpb_row', '', $class_string); $class_string = str_replace(' vc_row-fluid', '', $class_string); $class_string = str_replace(' vc_column_container', '', $class_string); $class_string = str_replace('wpb_column', '', $class_string); // replace vc_, but exclude any custom css // attached via vc_custom_XXX (negative lookahead) $class_string = preg_replace('/vc_(?!custom)/i', '', $class_string); // replace all vc_ // $class_string = preg_replace('/vc_/i', '', $class_string); } $class_string = preg_replace('|col-sm|', 'col-sm', $class_string); return $class_string; }, 10, 2); |
Visual Composer for WordPress
Bootstrap / Bootstrap Sass
Ich bin ein Full-Stack-Entwickler. Meine Expertise umfasst:
Ich liebe die Entwicklung, das Design und kenne mich auch mit Serverarchitekturen aus. Ich würde mich nie vollständig fühlen, wenn einer der Bereiche fehlen würde.
Ich habe ein breites Interessengebiet, deshalb tauche ich ständig in neue Technologien ein und erweitere mein Wissen, wo immer es nötig ist. Die Technologien entwickeln sich schnell und ich genieße es, die neuesten Technologien zu nutzen.
Abgesehen davon bin ich ein friedliebender Kerl, der versucht, Leute um sich herum zu haben, die dasselbe denken. Ich glaube wirklich an das Prinzip: "Wenn man jemandem hilft, wird einem jemand helfen, wenn man es braucht."
When you replace „vc_“ it removes the background image in a row. Not sure why.
Quick fix: add
$class_string = str_replace('custom_', 'vc_custom_', $class_string);
Alex
Or even better using a negative lookahead :)
$class_string = preg_replace('/vc_(?!custom)/i', '', $class_string);
Updated the above code accordingly.
Enjoy
Alex
Hey Alex, great job! So we can forget about the .container and container-fluid wrapper class from bootstrap or how do you handle that?
Hi,
it will behave just like a standard bootstrap theme. Some tweaks might be needed, depending on addons used or special use cases.
Alex