Skip to:
Content
Pages
Categories
Search
Top
Bottom

HTML tags appear in the forum posts

  • @amalsh

    Participant

    Hi dears,

    I’m having this issue: when I post in the forum (using the editor), HTML tags appear in the posts (topics and replies). What could the problem be?

    Thanks
    Hope

Viewing 15 replies - 1 through 15 (of 15 total)
  • @amalsh

    Participant

    @robkk

    Moderator

    some tags are considered restricted html to participants.

    as you might be a keymaster you could probably post that html no problem.

    to fix this you would need to add on to this function and add it into your child themes function.php file.

    https://gist.github.com/ntwb/7797990

    @amalsh

    Participant

    Thanks Robkk for your help! I tried the mentioned code but apparently it’s not working properly, I don’t know why! For example, I’m still having:
    <span style=”text-decoration: underline; color: #ff0000;”>test
    Although “span” is supposed to be treated in the code.

    Have I missed something?

    Thanks for your help
    Hope

    @robkk

    Moderator

    you have to add on to the code.

    the original is this

    // Span
    		'span'             => array(
    			'class'     => true,
    		),

    you would have to edit it like this

    // Span
    		'span'             => array(
    			'class'     => true,
                            'style'     => true,
    		),

    and probably the same thing for the paragraph tag ‘p’ , but for this you will need to just add it on like this.

    // Paragraph
    		'p'          => array(
    			'dir'    => true,
    			'style'     => true,
    		),

    basically any child elements of the tag add it in the function.

    @amalsh

    Participant

    Actually I already added ‘style’ to ‘span’, I added the paragraph ‘p’ as you mentioned but still the same issue!

    Here’s the part of the HTML page that is treated in the function but still HTML tags appear in the post:

    <p>
    <span style="text-decoration: underline; color:
    <a class="hashtag" rel="nofollow" href="http://localhost/wordpress/forums/search/?bbp_search=%23000080">#000080</a>
    ;”>
    <em>
    <strong>
    <span style="font-size: 12pt;font-family: arial,helvetica,sans-serif">test</span>
    </strong>
    </em>
    </p>

    Again, have I missed something?

    Thanks for your help
    Hope

    @davelr1

    Participant

    Is there any way instead of allowing the tag, just strip the code out?

    @robkk

    Moderator

    @amalsh

    I’m having this issue: when I post in the forum (using the editor), HTML tags appear in the posts (topics and replies).

    sorry for the late reply.

    you are just using the tinymce/visual editor buttons right?? And this issue only shows for what roles??

    or are you copying text from a different website and pasting it into the visual editor content??

    i tried testing it out earlier it worked for me as a participant , i have to check more because i was probably messing with the capabilities of my users.


    @davelr1

    you can probably use strip_tags() if you are going that way.

    @amalsh

    Participant

    Thanks Robkk for your reply! Actually I’m using the “bbPress Enable TinyMCE Visual Tab” plugin, I had to disable the full editor.. Isn’t there any solution for this?

    Thanks

    @robkk

    Moderator

    @amalsh

    I double checked your function , and there is a couple of mess ups in the code.

    <p>
    <span style="text-decoration: underline; color: //color should be here
    <a class="hashtag" rel="nofollow" href="http://localhost/wordpress/forums/search/?bbp_search=%23000080">#000080</a> //color hex should not be in here
    ;”> //should end with </span>
    <em>
    <strong>
    <span style="font-size: 12pt;font-family: arial,helvetica,sans-serif">test</span>
    </strong>
    </em>
    </p>

    In some cases copying and pasting text from another website into the tinymce visual editor may show the html still , so it is recommended to use the last function mentioned in this post.

    Enable Visual Editor

    This function works , if im missing something I might update it for users that usually use tinymce advanced with it so that every button should work properly.

    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,
    			'style'     => true,
    		),
    
    		// Paragraph
    		'p'          => array(
    			'dir'    => true,
    			'style'     => 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,
    		)
    	);
    }

    This function only works before the post is published , it does not magically fix old posts that were already published. You probably would have to edit old posts then resubmit for it to fix , but I am not sure.

    @amalsh

    Participant

    True, there’s a couple of mess ups in the code o_O but I’m writing directly into the forum using the full editor, not copying and pasting the text! Changing the text style using the editor generated this code! Strange! Could this be an issue from the editor itself? Have you tried the “bbPress Enable TinyMCE Visual Tab” plugin?

    Thanks for your help and time
    Hope

    @robkk

    Moderator

    @amalsh

    well looking at this and seeing class="hashtag"

    <a class="hashtag" rel="nofollow" href="http://localhost/wordpress/forums/search/?bbp_search=%23000080">#000080</a> //color hex should not be in here
    ;”>

    the issue is probably from this plugin if you are using it.

    deactivate that and see if tinymce works better after that.

    https://wordpress.org/support/plugin/hashbuddy

    @amalsh

    Participant

    @robkk You’re the best 🙂 I haven’t noticed this actually o_O Everything is working fine now after disabling the plugin..
    Many thanks
    Hope

    @maketheest

    Participant

    i have added this code from gist.github.com/ntwb/7797990 but html tags appeared on website like
    <!–more–>Go joging –> go jogging

    <span style=”line-height: 1.5;”>It’s help me have a good job–>It helps me have a good job</span>

    <!–more–>

    anyone have solution ?

    @evanevans333

    Participant

    Following. Also need solution.

    @ajtruckle

    Participant

    Thanks for this. I couldn’t work out why HTML tags were displaying for other users except me then I spotted the question about user roles.

    Adding this code in appears to fix the issue.

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