add_filter( "the_content","modify_content",1 );
function modify_content($content) {
$patterns = array();
$patterns[0] = '/<div.*?>/';
$patterns[1] = '/<\/div>/';
$replacements = array();
$replacements[2] = '';
$replacements[1] = '';
$content=preg_replace($patterns, $replacements, $content);
return $content;
}
--
John Davies
while (preg_match("/<div[*>]*>/",$content){
$content=preg_replace("/<div[^>]*>([^<\/div>]*)<\/div>/","\\1",$content);
}
ie it will remove all <div ...> ....<div> </div> </div> but actually
wrongly pair them to start with.
I think! Haven't tried it but I did wonder whether your original coding would
work with nested <div>s. A naughty blogger might like to test it!
--
Best wishes
John Logsdon
On reflection this will remove the first two <div>s then the first </div> so
you will be left with a </div>. It is probably better to parse the text so
that the pairs are correctly removed....:-( So that would mean using two
arrays and reversing the second one... A bit more messy but otherwise as I
say some enterprising person may try to break it.
So why not use
$content=strip_tags($content,"<div>");
anyway?
Hi, Thanks to both Mike and John for your replies to this problem, again much appreciated. The solution, as Mike pointed out, was in fact simply to move the code out of my plugin and into my theme functions file and it worked a treat.
John
--
See the group blog at http://mwug.info
You received this message because you are subscribed to the Google
Groups "Manchester WordPress User Group" group.
To post to this group, send email to
manchester-word...@googlegroups.com
To unsubscribe from this group, send email to
manchester-wordpress-...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/manchester-wordpress-user-group
Hi, Thanks to both Mike and John for your replies to this problem, again much appreciated. The solution, as Mike pointed out, was in fact simply to move the code out of my plugin and into my theme functions file and it worked a treat.
John