bbp_get_topic_author_link( mixed|int $args = '' )
Return the author link of the topic
Description
Parameters
- $args
-
(Optional) If it is an integer, it is used as topic id. Optional.
Default value: ''
Return
(string) Author link of topic
Source
File: bp-forums/topics/template.php
1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 | function bbp_get_topic_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_topic_author_link' ); // Used as topic_id if ( is_numeric ( $args ) ) { $topic_id = bbp_get_topic_id( $args ); } else { $topic_id = bbp_get_topic_id( $r [ 'post_id' ] ); } // Topic ID is good if ( ! empty ( $topic_id ) ) { // Get some useful topic information $author_url = bbp_get_topic_author_url( $topic_id ); $anonymous = bbp_is_topic_anonymous( $topic_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_topic_author_display_name( $topic_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_topic_author_avatar( $topic_id , $r [ 'size' ] ); } // Get display name if ( 'name' === $r [ 'type' ] || 'both' === $r [ 'type' ] ) { $author_links [ 'name' ] = bbp_get_topic_author_display_name( $topic_id ); } // Link class $link_class = ' class="bbp-author-' . esc_attr( $r [ 'type' ] ) . '"' ; // Add links if not anonymous if ( empty ( $anonymous ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) { $author_link = array (); // Assemble the links foreach ( $author_links as $link => $link_text ) { $link_class = ' class="bbp-author-' . esc_attr( $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_topic_author_role( array ( 'topic_id' => $topic_id ) ); } $author_link = implode( $r [ 'sep' ], $author_link ); // No links if anonymous } else { $author_link = implode( $r [ 'sep' ], $author_links ); } } else { $author_link = '' ; } return apply_filters( 'bbp_get_topic_author_link' , $author_link , $args ); } |
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.