bbp_get_reply_author_link( mixed $args = '' )
Return the author link of the reply
Description
Parameters
- $args
-
(Optional) If an integer, it is used as reply id.
Default value: ''
Return
(string) Author link of reply
Source
File: bp-forums/replies/template.php
function bbp_get_reply_author_link( $args = '' ) {
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
'post_id' => 0,
'link_title' => '',
'type' => 'both',
'size' => 80,
'sep' => ' ',
'show_role' => false
), 'get_reply_author_link' );
// Used as reply_id
if ( is_numeric( $args ) ) {
$reply_id = bbp_get_reply_id( $args );
} else {
$reply_id = bbp_get_reply_id( $r['post_id'] );
}
// Reply ID is good
if ( !empty( $reply_id ) ) {
// Get some useful reply information
$author_url = bbp_get_reply_author_url( $reply_id );
$anonymous = bbp_is_reply_anonymous( $reply_id );
// Tweak link title if empty
if ( empty( $r['link_title'] ) ) {
$link_title = sprintf( empty( $anonymous ) ? __( 'View %s\'s profile', 'buddyboss' ) : __( 'Visit %s\'s website', 'buddyboss' ), bbp_get_reply_author_display_name( $reply_id ) );
// Use what was passed if not
} else {
$link_title = $r['link_title'];
}
// Setup title and author_links array
$link_title = !empty( $link_title ) ? ' title="' . esc_attr( $link_title ) . '"' : '';
$author_links = array();
// Get avatar
if ( 'avatar' === $r['type'] || 'both' === $r['type'] ) {
$author_links['avatar'] = bbp_get_reply_author_avatar( $reply_id, $r['size'] );
}
// Get display name
if ( 'name' === $r['type'] || 'both' === $r['type'] ) {
$author_links['name'] = bbp_get_reply_author_display_name( $reply_id );
}
// Link class
$link_class = ' class="bbp-author-' . esc_attr( $r['type'] ) . '"';
// Add links if not anonymous and existing user
if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_reply_author_id( $reply_id ) ) ) {
$author_link = array();
// Assemble the links
foreach ( $author_links as $link => $link_text ) {
$link_class = ' class="bbp-author-' . $link . '"';
$author_link[] = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, $link_class, $link_text );
}
if ( true === $r['show_role'] ) {
$author_link[] = bbp_get_reply_author_role( array( 'reply_id' => $reply_id ) );
}
$author_link = implode( $r['sep'], array_filter( $author_link ) );
// No links if anonymous
} else {
$author_link = implode( $r['sep'], array_filter( $author_links ) );
}
// No replies so link is empty
} else {
$author_link = '';
}
return apply_filters( 'bbp_get_reply_author_link', $author_link, $r );
}
Changelog
| Version | Description |
|---|---|
| bbPress (r2717) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.