Skip to content

Commit

Permalink
Error-free author bio output when a post has no author metadata.
Browse files Browse the repository at this point in the history
Cherry-picks some stuff from #1568
Part of the #1492 whack-a-mole
  • Loading branch information
benlk committed Nov 10, 2018
1 parent 51cbfdb commit 7e7b4cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 8 additions & 6 deletions inc/avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ function largo_has_gravatar( $email ) {
*/
function largo_has_avatar( $email ) {
$user = get_user_by( 'email', $email );
$result = largo_get_user_avatar_id( $user->ID );
if ( ! empty ( $result ) ) {
return true;
} else {
if ( largo_has_gravatar( $email ) ) {
if ( ! empty( $user ) ) {
$result = largo_get_user_avatar_id( $user->ID );
if ( ! empty ( $result ) ) {
return true;
}
} else {
if ( largo_has_gravatar( $email ) ) {
return true;
}
}
}
return false;
}
8 changes: 6 additions & 2 deletions inc/widgets/largo-author-bio.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@ function widget( $args, $instance ) {

// make sure we have at least one bio before we show the widget
foreach ( $authors as $key => $author ) {
$bio = trim( $author->description );
if ( !is_author() && empty( $bio ) ) {
if ( is_object( $author ) && isset( $author->description ) ) {
$bio = trim( $author->description );
} else {
$bio = '';
}
if ( ! is_author() && empty( $bio ) ) {
unset( $authors[$key] );
} else {
$bios .= $bio;
Expand Down

0 comments on commit 7e7b4cd

Please sign in to comment.