bbp_make_mentions_clickable_callback( array $matches = array() )
Callback to convert mention matches to HTML A tag.
Description Description
Parameters Parameters
- $matches
-
(Optional) Regular expression matches in the current text blob.
Default value: array()
Return Return
(string) Original text if no user exists, or link to user profile.
Source Source
File: includes/common/formatting.php
function bbp_make_mentions_clickable_callback( $matches = array() ) { // Get user; bail if not found $user = get_user_by( 'slug', $matches[1] ); if ( empty( $user ) || bbp_is_user_inactive( $user->ID ) ) { return $matches[0]; } // Filter classes $classes = (array) apply_filters( 'bbp_make_mentions_clickable_classes', array( 'bbp-user-id-' . $user->ID, 'bbp-user-mention' ) ); // Escape & implode if not empty, otherwise an empty string $class_str = ! empty( $classes ) ? implode( ' ', array_map( 'sanitize_html_class', $classes ) ) : ''; // Create the link to the user's profile $url = bbp_get_user_profile_url( $user->ID ); $clicky = '<a href="%1$s" class="' . esc_attr( $class_str ) . '">%2$s</a>'; $anchor = sprintf( $clicky, esc_url( $url ), esc_html( $matches[0] ) ); $link = bbp_rel_nofollow( $anchor ); return $link; }
Changelog Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |