Strip HTML Tabs from forum
-
Hi,
When people copy text into the forums, there are always extra HTML characters added. How can i remove the same.
Here’s what is happening : http://prnt.sc/cjj0m7
Can somebody have a solution for the same.
Thanks
-
This is a common issue while using bbPress and activating TInyMCE. Not all html tags and attributes are unrestricted for every participant.
You can download this plugin and edit the function and add on to it what html tags you want to allow in your forums. There is an example for tables in the plugin, you will need span style.
@robkk, That would be to allow additional tags, right?
In this case it looks like tags are getting into the content that already are not allowed by default. The screen shot shows a span tag, which is not included in the bbPress allowed list in bbpress/includes/common/formatting.php.
I have also seen this happen with TinyMCE activated. It seems to be iOS users and they claim that they haven’t pasted anything, but I have not observed this for myself yet.
Oh shoot your right Doug. I might have suggested the wrong thing.
I have also seen this happen with TinyMCE activated. It seems to be iOS users and they claim that they haven’t pasted anything, but I have not observed this for myself yet.
I have no idea if it could be IOS specific?? I can check I guess?? Damn thats weird if it is.
You will need to use this since you copied text to your forums. Pasting other articles content in the Visual Editor in TinyMCE could end up posting the HTML content, its recommended to post any articles content into the HTML editor, but you can also use this PHP code snippet from this guide below, that I think Doug did add, that would help resolve this issue that could be caused pasting articles in the visual editor for any further posts submitted.
function bbp_tinymce_paste_plain_text( $plugins = array() ) { $plugins[] = 'paste'; return $plugins; } add_filter( 'bbp_get_tiny_mce_plugins', 'bbp_tinymce_paste_plain_text' );
https://codex.bbpress.org/enable-visual-editor/
For editing the already messed up posts, I think you can just copy the original post, edit it, and paste the text into the HTML editor over the original content and hopefully that would fix it. THere might be also a chance of it going away just by editing it, then just republishing after you used the code snippet.
I found the pieces and bits necessary to make this happen.
// ALTER TinyMCE INIT FOR VISUAL EDITOR ON FORUM TOPICS AND REPLIES // SOURCE: https://bbpress.org/forums/topic/alter-mceinit-for-visual-editor-on-topics/ // Enable visual editor on tinymce in bbPress function bbp_enable_visual_editor( $args = array() ) { $args['tinymce'] = true; return $args; } add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' ); // Enable TinyMCE paste plugin function bbp_add_paste_plugin($args) { $args[] = 'paste'; return $args; } add_filter( 'teeny_mce_plugins', 'bbp_add_paste_plugin'); // ADDS A JQUERY PASTE PREPROCESSOR TO REMOVE DISALLOWED TAGS WHILE PASTING // SOURCE https://jonathannicol.com/blog/2015/02/19/clean-pasted-text-in-wordpress/ function configure_tinymce($in) { $in['paste_preprocess'] = "function(plugin, args){ // Strip all HTML tags except those we have whitelisted var whitelist = 'a,p,span,b,strong,i,em,h3,h4,h5,h6,ul,li,ol'; var stripped = jQuery('<div>' + args.content + '</div>'); var els = stripped.find('*').not(whitelist); for (var i = els.length - 1; i >= 0; i--) { var e = els[i]; jQuery(e).replaceWith(e.innerHTML); } // Strip all class and id attributes stripped.find('*').removeAttr('id').removeAttr('class'); // Return the clean HTML args.content = stripped.html(); }"; return $in; } add_filter('teeny_mce_before_init','configure_tinymce', 99999999999);
- You must be logged in to reply to this topic.