Changeset 6380 for trunk/src/includes/common/formatting.php
- Timestamp:
- 03/17/2017 05:55:58 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/common/formatting.php
r6347 r6380 460 460 */ 461 461 function bbp_make_mentions_clickable( $text = '' ) { 462 return preg_replace_callback( '# ([\s>])@([0-9a-zA-Z-_]+)#i', 'bbp_make_mentions_clickable_callback', $text );462 return preg_replace_callback( '#@([0-9a-zA-Z-_]+)#i', 'bbp_make_mentions_clickable_callback', $text ); 463 463 } 464 464 … … 468 468 * @since 2.6.0 (r6014) 469 469 * 470 * @param array $matches Single Regex Match.471 * 472 * @return string HTML A tag withlink to user profile.470 * @param array $matches Regular expression matches in the current text blob. 471 * 472 * @return string Original text if no user exists, or link to user profile. 473 473 */ 474 474 function bbp_make_mentions_clickable_callback( $matches = array() ) { 475 475 476 476 // Get user; bail if not found 477 $user = get_user_by( 'slug', $matches[ 2] );477 $user = get_user_by( 'slug', $matches[1] ); 478 478 if ( empty( $user ) || bbp_is_user_inactive( $user->ID ) ) { 479 479 return $matches[0]; … … 488 488 // Escape & implode if not empty, otherwise an empty string 489 489 $class_str = ! empty( $classes ) 490 ? implode( ' ', array_map( ' esc_attr', $classes ) )490 ? implode( ' ', array_map( 'sanitize_html_class', $classes ) ) 491 491 : ''; 492 492 493 493 // Create the link to the user's profile 494 494 $url = bbp_get_user_profile_url( $user->ID ); 495 $clicky = '<a href="%1$s" class="' . $class_str . '">@%2$s</a>';496 $anchor = sprintf( $clicky, esc_url( $url ), esc_html( $ user->user_nicename) );495 $clicky = '<a href="%1$s" class="' . esc_attr( $class_str ) . '">%2$s</a>'; 496 $anchor = sprintf( $clicky, esc_url( $url ), esc_html( $matches[0] ) ); 497 497 $link = bbp_rel_nofollow( $anchor ); 498 498 499 return $ matches[1] . $link;499 return $link; 500 500 } 501 501
Note: See TracChangeset
for help on using the changeset viewer.