diff --git bp-activity/bp-activity-filters.php bp-activity/bp-activity-filters.php
index 603924f..678a1e2 100644
|
|
|
function bp_activity_at_name_filter( $content, $activity_id = 0 ) {
|
| 220 | 220 | if ( empty( $usernames ) ) |
| 221 | 221 | return $content; |
| 222 | 222 | |
| | 223 | // hide username content inside tags |
| | 224 | $replace_count = 0; |
| | 225 | $replacements = array(); |
| | 226 | foreach ( $usernames as $username ) { |
| | 227 | // prevent @ name linking inside a tags |
| | 228 | preg_match_all( '/(<a.*?(?!<\/a>)@' . $username . '.*?<\/a>)/', $content, $content_matches ); |
| | 229 | if ( !empty( $content_matches[1] ) ) { |
| | 230 | foreach ( $content_matches[1] as $replacement ) { |
| | 231 | $replacements[ '#BPAN' . $replace_count ] = $replacement; |
| | 232 | $content = str_replace( $replacement, '#BPAN' . $replace_count, $content ); |
| | 233 | $replace_count++; |
| | 234 | } |
| | 235 | } |
| | 236 | } |
| | 237 | |
| 223 | 238 | // Linkify the mentions with the username |
| 224 | 239 | foreach( (array) $usernames as $user_id => $username ) { |
| 225 | 240 | $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content ); |
| 226 | 241 | } |
| 227 | 242 | |
| | 243 | // put everything back |
| | 244 | if ( ! empty( $replacements ) ) { |
| | 245 | foreach ( $replacements as $placeholder => $original ) { |
| | 246 | $content = str_replace( $placeholder, $original, $content ); |
| | 247 | } |
| | 248 | } |
| | 249 | |
| 228 | 250 | // Return the content |
| 229 | 251 | return $content; |
| 230 | 252 | } |