plugins - How to allow HTML tags into WP Bakery (formerly Visual Composer) `textfield` parameter

While writing a custom element for WC Bakery (formerly Visual Composer) I've discovered that the HTML tags are bein

While writing a custom element for WC Bakery (formerly Visual Composer) I've discovered that the HTML tags are being stripped from the textfield parameter type. It's sanitizing the textfield value by default.

I could not find a way to disable the textfield sanitization.

How can I allow HTML tags to be entered into this field?

While writing a custom element for WC Bakery (formerly Visual Composer) I've discovered that the HTML tags are being stripped from the textfield parameter type. It's sanitizing the textfield value by default.

I could not find a way to disable the textfield sanitization.

How can I allow HTML tags to be entered into this field?

Share Improve this question edited Oct 1, 2018 at 8:18 Eh Jewel asked Dec 25, 2017 at 7:25 Eh JewelEh Jewel 8553 gold badges14 silver badges29 bronze badges 4
  • 2 the trick with this is to only do edittion on the "text" tab and never switch to "visual" tab – Temani Afif Commented Dec 25, 2017 at 7:45
  • @TemaniAfif thats not related to this question, its not written very clearly but its about writing custom elements for Visual Composer (now WP Bakery), which just has a plain text area but if you try to add complex html into it then it gets stripped. Seems to work for simple stuff like strong though. – rtpHarry Commented Sep 29, 2018 at 9:23
  • @rtpHarry I know this very well :) and it's related because the solution I use everyday is to consider the text tab where you can add code like want but if you switch to visual tab some of the code will disappear so I never switch to visual tab ;) – Temani Afif Commented Sep 29, 2018 at 9:30
  • @TemaniAfif yes you are correct that you shouldn't swap the text tab to visual or it will mess up your markup -- but thats not whats being asked about here. Op is asking about the Visual Composer textfield param type which I linked to in my answer below. It's front end is not the tinymce based editor, it is a simple, plain textarea tag and it will strip the html in some situations. – rtpHarry Commented Sep 29, 2018 at 10:54
Add a comment  | 

2 Answers 2

Reset to default 4

You need to change the type from textarea to textarea_raw_html:

  • https://kb.wpbakery/docs/inner-api/vc_map/

Under the section "Available type values" it says:

textarea_raw_html: Text area, its content will be coded into base64 (this allows you to store raw js or raw html code)

Although I'm not sure why they can base64 encode the output from this but not the textarea_html box with its nice formatting - an annoying limitation.

UPDATE It looks like you have to jump through some hoops when you switch to the textarea_raw_html param type.

To use the value you need to manually decode it with:

$atts['some_param'] =  rawurldecode( base64_decode( $atts['some_param'] ) );

If you pass the vc_map param as param_name = 'content' the html wont get stripped off. The problem is you can only put one content.

array(
                'type' => 'textarea',
                'heading' => esc_html__( 'Texto', 'bauhaus' ),
                'param_name' => 'content',
                'holder' => 'div'
            ),
add_shortcode( 'custom_bloque_informativo', 'custom_bloque_informativo_func' );
function custom_bloque_informativo_func( $atts, $content ) {
    ob_start();
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744728989a4590351.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信