Skip to:
Content
Pages
Categories
Search
Top
Bottom

Topic editor turn shortcode in HTML

  • @angelorocha

    Participant

    When i insert a shortcode in bbpress topic editor, when editing the topic it converts the shortcode to HTML, how to solve this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • @angelorocha

    Participant

    Eg:

    On insert topic:

    On Edit topic:

    @robin-w

    Moderator

    html is not allowed for security purposes, but if you want to enable all or some then

    add_filter( 'bbp_kses_allowed_tags', 'ntwb_bbpress_custom_kses_allowed_tags' );
    
    function ntwb_bbpress_custom_kses_allowed_tags() {
    	return array(
    
    		// Links
    		'a'          => array(
    			'class'    => true,
    			'href'     => true,
    			'title'    => true,
    			'rel'      => true,
    			'class'    => true,
    			'target'    => true,
    		),
    
    		// Quotes
    		'blockquote' => array(
    			'cite'     => true,
    		),
    		
    		// Div
    		'div' => array(
    			'class'     => true,
    		),
    		
    		// Span
    		'span'             => array(
    			'class'     => true,
    		),
    		
    		// Code
    		'code'       => array(),
    		'pre'        => array(
    			'class'  => true,
    		),
    
    		// Formatting
    		'em'         => array(),
    		'strong'     => array(),
    		'del'        => array(
    			'datetime' => true,
    		),
    
    		// Lists
    		'ul'         => array(),
    		'ol'         => array(
    			'start'    => true,
    		),
    		'li'         => array(),
    
    		// Images
    		'img'        => array(
    			'class'    => true,
    			'src'      => true,
    			'border'   => true,
    			'alt'      => true,
    			'height'   => true,
    			'width'    => true,
    		),
    
    		// Tables
    		'table'      => array(
    			'align'    => true,
    			'bgcolor'  => true,
    			'border'   => true,
    		),
    		'tbody'      => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'td'         => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'tfoot'      => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'th'         => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'thead'      => array(
    			'align'    => true,
    			'valign'   => true,
    		),
    		'tr'         => array(
    			'align'    => true,
    			'valign'   => true,
    		)
    	);
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets

    @angelorocha

    Participant

    Hi Robin W.
    This solution allow Model Viewer Tag, but bbpress editor keeps converting my shortcode to html, how to solve this?

    Thanks.

    @robin-w

    Moderator

    um…that’s what shortcodes are for ???

    if you just want the shortcode displayed without bbpress interpreting it, then use the ‘code’

    eg

    [model_viewer ID'...']

    @angelorocha

    Participant

    Yes, I’m inserting the shortcode, but when editing the topic, bbpress converts the shortcode to HTML, see the images, I don’t know why that happens.

    @robin-w

    Moderator

    from your image, it is because you have not use the CODE in your post.

    so you show

    [model_viewer...etc]

    when if you do not want wordpress to translate this you should have

    `[model_viewer…etc] with a second tick at the end, then when you edit it will stay as the code

    @angelorocha

    Participant

    Thanks for your help, but I don’t think you understand my problem, sorry for my bad English.

    See the real problem:

    @robin-w

    Moderator

    ok, thanks I now understand.

    Sorry, that’s the way WordPress works – not a loot I can do to help.

    The shortcode is rendered when you publish, and when you edit I think it does not like that you ared using html – maybe a permission issue.

    I cannot really help further

    @robin-w

    Moderator

    ok, thanks I now understand.

    Sorry, that’s the way WordPress works – not a loot I can do to help.

    The shortcode is rendered when you publish, and when you edit I think it does not like that you ared using html – maybe a permission issue.

    I cannot really help further

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar