Changeset 4672
- Timestamp:
- 12/31/2012 01:21:33 PM (10 years ago)
- Location:
- trunk/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/core/functions.php
r4579 r4672 282 282 } 283 283 284 /** Mentions ******************************************************************/ 285 284 286 /** 285 287 * Searches through the content to locate usernames, designated by an @ sign. … … 321 323 322 324 // Skip if username does not exist or user is not active 323 $user _id = username_exists($username );324 if ( empty( $user _id ) || bbp_is_user_inactive( $user_id) )325 $user = get_user_by( 'slug', $username ); 326 if ( empty( $user->ID ) || bbp_is_user_inactive( $user->ID ) ) 325 327 continue; 326 328 327 329 // Replace name in content 328 $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bbp_get_user_profile_url( $user _id ) . "' rel='nofollow' class='bbp-mention-link $username'>@$username</a>", $content );330 $content = preg_replace( '/(@' . $username . '\b)/', "<a href='" . bbp_get_user_profile_url( $user->ID ) . "' rel='nofollow' class='bbp-mention-link {$username}'>@{$username}</a>", $content ); 329 331 } 330 332 -
trunk/includes/users/template-tags.php
r4617 r4672 241 241 242 242 return apply_filters( 'bbp_get_user_profile_link', $user_link, $user_id ); 243 } 244 245 /** 246 * Output a users nicename to the screen 247 * 248 * @since bbPress (r4671) 249 * 250 * @param int $user_id User ID whose nicename to get 251 * @param array $args before|after|user_id|force 252 */ 253 function bbp_user_nicename( $user_id = 0, $args = array() ) { 254 echo bbp_get_user_nicename( $user_id, $args ); 255 } 256 /** 257 * Return a users nicename to the screen 258 * 259 * @since bbPress (r4671) 260 * 261 * @param int $user_id User ID whose nicename to get 262 * @param array $args before|after|user_id|force 263 * @return string User nicename, maybe wrapped in before/after strings 264 */ 265 function bbp_get_user_nicename( $user_id = 0, $args = array() ) { 266 267 // Bail if no user ID passed 268 $user_id = bbp_get_user_id( $user_id, false, false ); 269 if ( empty( $user_id ) ) 270 return false; 271 272 // Parse default arguments 273 $r = bbp_parse_args( $args, array( 274 'user_id' => $user_id, 275 'before' => '', 276 'after' => '', 277 'force' => '' 278 ), 'get_user_nicename' ); 279 280 // Get the user data and nicename 281 if ( empty( $r['force'] ) ) { 282 $user = get_userdata( $user_id ); 283 $nicename = $user->user_nicename; 284 285 // Force the nicename to something else 286 } else { 287 $nicename = (string) $r['force']; 288 } 289 290 // Maybe wrap the nicename 291 $retval = !empty( $nicename ) ? ( $r['before'] . $nicename . $r['after'] ) : ''; 292 293 // Filter and return 294 return (string) apply_filters( 'bbp_get_user_nicename', $retval, $user_id, $args ); 243 295 } 244 296 … … 290 342 // Get username if not passed 291 343 if ( empty( $user_nicename ) ) { 292 $user = get_userdata( $user_id ); 293 if ( !empty( $user->user_nicename ) ) { 294 $user_nicename = $user->user_nicename; 295 } 344 $user_nicename = bbp_get_user_nicename( $user_id ); 296 345 } 297 346
Note: See TracChangeset
for help on using the changeset viewer.