Skip to content

Commit

Permalink
fix: get_the_author() returns null for LinkedIn. Closes #132.
Browse files Browse the repository at this point in the history
  • Loading branch information
rilwis committed May 23, 2024
1 parent 5c10479 commit aea0bdd
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/MetaTags/LinkedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,16 @@ public function output(): void {
return;
}

$author = $this->get_author();
$author = get_the_author_meta( 'display_name', get_queried_object()->post_author );
$author = apply_filters( 'slim_seo_linkedin_author', $author );
if ( $author ) {
echo '<meta name="author" content="' . esc_attr( $author ) . '">', "\n";
}

$date = $this->get_date();
$date = gmdate( 'c', strtotime( get_queried_object()->post_date_gmt ) );
$date = apply_filters( 'slim_seo_linkedin_date', $date );
if ( $date ) {
echo '<meta name="date" content="' . esc_attr( $date ) . '">', "\n";
}
}

private function get_author(): string {
return get_the_author();
}

private function get_date(): string {
return ( string ) gmdate( 'c', strtotime( get_queried_object()->post_date_gmt ) );
}
}
}

0 comments on commit aea0bdd

Please sign in to comment.