Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/17/2025 06:31:41 PM (5 months ago)
Author:
johnjamesjacoby
Message:

Tools - Unit Tests: allow mentions after '[' and '(' chars.

This commit fixes the suite of user-mentions unit tests, so that they no longer require an empty "class" attribute, and also so that mentions inside of common wrappers ((), [] ) are allowed.

See #3657.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/formatting.php

    r7364 r7368  
    455455 * Make mentions clickable in content areas
    456456 *
     457 * Allows ' ', '>', '[', and '(' before as '@' username mention
     458 *
    457459 * @since 2.6.0 bbPress (r6014)
    458460 *
     
    463465 */
    464466function bbp_make_mentions_clickable( $text = '' ) {
    465     return preg_replace_callback( '#([\s>])@([0-9a-zA-Z-_]+)#i', 'bbp_make_mentions_clickable_callback', $text );
     467    return preg_replace_callback(
     468        '#([\s>\[\(])\@([0-9a-zA-Z\-_]+)#i',
     469        'bbp_make_mentions_clickable_callback',
     470        $text
     471    );
    466472}
    467473
     
    508514
    509515    // Create the link to the user's profile
    510     $html   = '<a href="%1$s"' . $class . '>%2$s</a>';
    511     $url    = bbp_get_user_profile_url( $user->ID );
    512     $anchor = sprintf( $html, esc_url( $url ), esc_html( $matches[0] ) );
     516    $html    = '<a href="%1$s"%2$s>%3$s</a>';
     517    $url     = bbp_get_user_profile_url( $user->ID );
     518    $mention = '@' . $matches[2];
     519    $anchor  = sprintf( $html, esc_url( $url ), $class, esc_html( $mention ) );
    513520
    514521    // Prevent this link from being followed by bots
Note: See TracChangeset for help on using the changeset viewer.