Skip to content

Commit

Permalink
Provide error message, catch warning, when Co-Authors Plus is active …
Browse files Browse the repository at this point in the history
…but a post has no coauthors.

To reproduce this issue, see Automattic/Co-Authors-Plus#637

Part of #1492
  • Loading branch information
benlk committed Dec 18, 2018
1 parent 3f78d05 commit 19d66e5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions inc/byline_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,23 @@ function generate_byline() {
$authors = implode( ', ', array_slice( $out, 0, -1 ) );
$authors .= ' <span class="and">' . __( 'and', 'largo' ) . '</span> ' . $out[$key];
} else {
$authors = $out[0];
if ( isset( $out[0] ) ) {
$authors = $out[0];
} else {
$cap_error_message = sprintf(
esc_html__( 'post %1$s should have at least one co-author, but has none!', 'largo' ),
$this->post_id
);
if ( WP_DEBUG || LARGO_DEBUG ) {
error_log(var_export( $cap_error_message, true));
}
$authors = sprintf(
'<!-- %1$s -->',
$cap_error_message
);
}
}


// Now assemble the One True Byline
ob_start();
echo '<span class="by-author"><span class="by">' . __( 'By', 'largo' ) . '</span> <span class="author vcard" itemprop="author">' . $authors . '</span></span>';
Expand Down

0 comments on commit 19d66e5

Please sign in to comment.