Changeset 6591 for trunk/src/includes/topics/template.php
- Timestamp:
- 06/19/2017 09:46:29 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/topics/template.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/topics/template.php
r6583 r6591 1397 1397 'type' => 'both', 1398 1398 'size' => 80, 1399 'sep' => ' ',1399 'sep' => '', 1400 1400 'show_role' => false 1401 1401 ), 'get_topic_author_link' ); 1402 1402 1403 // Default return value 1404 $author_link = ''; 1405 1403 1406 // Used as topic_id 1404 if ( is_numeric( $args ) ) { 1405 $topic_id = bbp_get_topic_id( $args ); 1406 } else { 1407 $topic_id = bbp_get_topic_id( $r['post_id'] ); 1408 } 1407 $topic_id = is_numeric( $args ) 1408 ? bbp_get_topic_id( $args ) 1409 : bbp_get_topic_id( $r['post_id'] ); 1409 1410 1410 1411 // Topic ID is good … … 1417 1418 // Tweak link title if empty 1418 1419 if ( empty( $r['link_title'] ) ) { 1419 $title = empty( $anonymous ) ? __( 'View %s\'s profile', 'bbpress' ) : __( 'Visit %s\'s website', 'bbpress' );1420 1420 $author = bbp_get_topic_author_display_name( $topic_id ); 1421 $title = empty( $anonymous ) 1422 ? __( 'View %s\'s profile', 'bbpress' ) 1423 : __( 'Visit %s\'s website', 'bbpress' ); 1421 1424 $link_title = sprintf( $title, $author ); 1422 1425 … … 1427 1430 1428 1431 // Setup title and author_links array 1429 $link_title = ! empty( $link_title ) ? ' title="' . esc_attr( $link_title ) . '"' : '';1430 1432 $author_links = array(); 1431 1432 // Get avatar 1433 if ( 'avatar' === $r['type'] || 'both' === $r['type'] ) { 1433 $link_title = ! empty( $link_title ) 1434 ? ' title="' . esc_attr( $link_title ) . '"' 1435 : ''; 1436 1437 // Get avatar (unescaped, because HTML) 1438 if ( ( 'avatar' === $r['type'] ) || ( 'both' === $r['type'] ) ) { 1434 1439 $author_links['avatar'] = bbp_get_topic_author_avatar( $topic_id, $r['size'] ); 1435 1440 } 1436 1441 1437 // Get display name 1438 if ( 'name' === $r['type'] || 'both' === $r['type']) {1439 $author_links['name'] = bbp_get_topic_author_display_name( $topic_id);1442 // Get display name (escaped, because never HTML) 1443 if ( ( 'name' === $r['type'] ) || ( 'both' === $r['type'] ) ) { 1444 $author_links['name'] = esc_html( bbp_get_topic_author_display_name( $topic_id ) ); 1440 1445 } 1441 1446 … … 1445 1450 // Add links if not anonymous 1446 1451 if ( empty( $anonymous ) && bbp_user_has_profile( bbp_get_topic_author_id( $topic_id ) ) ) { 1452 1453 // Empty array 1454 $links = array(); 1447 1455 1448 1456 // Assemble the links 1449 1457 foreach ( $author_links as $link => $link_text ) { 1450 1458 $link_class = ' class="bbp-author-' . esc_attr( $link ) . '"'; 1451 $ author_link[]= sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, $link_class, $link_text );1459 $links[] = sprintf( '<a href="%1$s"%2$s%3$s>%4$s</a>', esc_url( $author_url ), $link_title, $link_class, $link_text ); 1452 1460 } 1453 1461 1462 // Role is not linked 1454 1463 if ( true === $r['show_role'] ) { 1455 $ author_link[] = bbp_get_topic_author_role( array( 'topic_id' => $topic_id ) );1464 $links[] = bbp_get_topic_author_role( array( 'topic_id' => $topic_id ) ); 1456 1465 } 1457 1466 1458 $author_link = implode( $r['sep'], $author_link ); 1459 1460 // No links if anonymous 1461 } else { 1462 $author_link = implode( $r['sep'], $author_links ); 1467 // Juggle 1468 $author_links = $links; 1469 unset( $links ); 1463 1470 } 1464 1471 1465 } else { 1466 $author_link = ''; 1467 } 1468 1469 // Filter & return 1470 return apply_filters( 'bbp_get_topic_author_link', $author_link, $args ); 1472 // Filter sections 1473 $sections = apply_filters( 'bbp_get_topic_author_links', $author_links, $r, $args ); 1474 1475 // Assemble sections into author link 1476 $author_link = implode( $r['sep'], $sections ); 1477 } 1478 1479 // Filter & return 1480 return apply_filters( 'bbp_get_topic_author_link', $author_link, $r, $args ); 1471 1481 } 1472 1482
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)