add_filter( 'comment_text', 'mh_commenttaglink' , 50 );
function mh_commenttaglink( $text ) {
// RegEx to find #tag, #hyphen-tag with letters and numbers
$mh_regex = "/\#[a-zA-Z0-9-]+/";
// Use that RegEx and populate the hits into an array
preg_match_all( $mh_regex , $text , $mh_matches );
// If there's any hits then loop though those and replace those hits with a link
for ( $mh_count = 0; $mh_count < count( $mh_matches[0] ); $mh_count++ )
{
$mh_old = $mh_matches[0][$mh_count];
$mh_old_lesshash = str_replace( '#' , ' ' , $mh_old );
$mh_new = str_replace( $mh_old , '<a href="' . get_bloginfo( url ) . '/?s=%23' . $mh_old_lesshash . '"/ rel="tag">' . $mh_old . '</a>' , $mh_matches[0][$mh_count] );
$text = str_replace( $mh_old , $mh_new , $text );
}
// Return any substitutions
return $text;
}
I have a small custom plugin for wordpress here that converts all hashtagged terms in post comments into searchable links.
I know this plugin is causing the issue as it only buggers off after deactivation, I just cant see where in this code I need to edit something out or add somethign in to prevent it.
More experienced eyes would be appreciated.