Skip to content

Commit

Permalink
feat: real author links for avatar and author name
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffersonrabb committed May 4, 2020
1 parent e2f72f5 commit 4dedb72
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions class-newspack-blocks-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,19 @@ public static function newspack_blocks_get_author_info( $object ) {
} else {
$author_avatar = coauthors_get_avatar( $author, 48 );
}
$author_link = null;
if ( function_exists( 'coauthors_posts_links' ) ) {
$author_link = get_author_posts_url( $author->ID, $author->user_nicename );
}
$author_data[] = array(
/* Get the author name */
'display_name' => esc_html( $author->display_name ),
/* Get the author avatar */
'avatar' => wp_kses_post( $author_avatar ),
/* Get the author ID */
'id' => $author->ID,
/* Get the author Link */
'author_link' => $author_link,
);
}
else :
Expand All @@ -181,6 +187,8 @@ public static function newspack_blocks_get_author_info( $object ) {
'avatar' => get_avatar( $object['author'], 48 ),
/* Get the author ID */
'id' => $object['author'],
/* Get the author Link */
'author_link' => get_author_posts_url( $object['author'] ),
);
endif;

Expand Down
4 changes: 2 additions & 2 deletions src/shared/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { RawHTML } from '@wordpress/element';
export const formatAvatars = authorInfo =>
authorInfo.map( author => (
<span className="avatar author-avatar" key={ author.id }>
<a className="url fn n" href="#">
<a className="url fn n" href={ author.author_link }>
<RawHTML>{ author.avatar }</RawHTML>
</a>
</span>
Expand All @@ -20,7 +20,7 @@ export const formatByline = authorInfo => (
return [
...accumulator,
<span className="author vcard" key={ author.id }>
<a className="url fn n" href="#">
<a className="url fn n" href={ author.author_link }>
{ author.display_name }
</a>
</span>,
Expand Down

0 comments on commit 4dedb72

Please sign in to comment.