Here’s how to strip bad markup instead of encoding it
- 
		On some forums you might want to remove bad html markup that’s not allowed instead of encoding it into text. Here’s a mini-plugin to do just that. It also converts <b>into<strong>and<i>into<em>It only runs when posts are saved instead of each time they are displayed to keep things at full speed. Posts by Moderators and Administrators are not stripped. (note: for now it doesn’t obey backticks and will strip inside them) <?php
 /*
 Plugin Name: Strip Bad Markup
 Plugin URI: http://bbpress.org/plugins/topic/
 Description: removes tags that are not allowed in posts instead of encoding them
 Author: _ck_
 Author URI: http://bbShowcase.org
 Version: 0.0.1
 */
 
 add_filter('pre_post', 'strip_bad_markup',9);
 
 function strip_bad_markup($text) {
 if (!bb_current_user_can('moderate')) {
 $tags=bb_allowed_tags(); $tags['br']=true; $tags['p']=true; $tags = implode('|',array_keys($tags));
 $text=preg_replace(array("/<(/)?b>/si","/<(/)?i>/si"),array("<$1strong>","<$1em>"),$text);
 $text=preg_replace("/</?(?!($tags)).*?>/sim","", $text);
 }
 return $text;
 }
 
 ?>
Viewing 2 replies - 1 through 2 (of 2 total)
	
Viewing 2 replies - 1 through 2 (of 2 total)
	
- You must be logged in to reply to this topic.
 .
.