Hooking into comment_text() to add surrounding tag
Try to lower the priority of your function, maybe there is some formatting function which you precede.
add_filter('comment_text', 'stefan_wrap_comment_text', 1000);
Ouch, just stumbled over the file wp-includes/default-filters.php
and found out that there are several filters applied to the same function per default:
add_filter( 'comment_text', 'wptexturize' );add_filter( 'comment_text', 'convert_chars' );add_filter( 'comment_text', 'make_clickable', 9 );add_filter( 'comment_text', 'force_balance_tags', 25 ); add_filter( 'comment_text', 'convert_smilies', 20 );add_filter( 'comment_text', 'wpautop', 30 );
The last filter with priority 30 calls the function wpautop() that is used for replacing double line breaks with <p>...</p>
. Per default add_filter() registers new filters on priority 10. Changing my filter to be the last by choosing a higher number everything works fine.
// This doesn't work because default priority is 10:// add_filter('comment_text', 'stefan_wrap_comment_text');// Add a lower priority (higher number) to apply this filter at last: add_filter('comment_text', 'stefan_wrap_comment_text', 99);