Skip to content

Commit

Permalink
Merge pull request #1118 from INN/1117-twitter-guest-author-post-soci…
Browse files Browse the repository at this point in the history
…al-links

Attempted fixes for #1117, where post_author twitter account is used instead of coauthor
  • Loading branch information
aschweigert committed Feb 7, 2016
2 parents 773796f + 972732e commit 876da0d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions inc/post-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ function largo_post_social_links( $echo = true ) {

$output = '<div class="largo-follow post-social clearfix">';

$values = get_post_custom( $post->ID );

if ( $utilities['facebook'] === '1' ) {
$fb_share = '<span class="facebook"><a target="_blank" href="http://www.facebook.com/sharer/sharer.php?u=%1$s"><i class="icon-facebook"></i><span class="hidden-phone">%2$s</span></a></span>';
$output .= sprintf(
Expand All @@ -212,7 +214,6 @@ function largo_post_social_links( $echo = true ) {

// If there are coauthors, use a coauthor twitter handle, otherwise use the normal author twitter handle
// If there is a custom byline, don't try to use the author byline.
$values = get_post_custom( $post->ID );
if ( function_exists( 'coauthors_posts_links' ) && !isset( $values['largo_byline_text'] ) ) {
$coauthors = get_coauthors( $post->ID );
$author_twitters = array();
Expand All @@ -226,7 +227,7 @@ function largo_post_social_links( $echo = true ) {
}
// in the event that there are more than one author twitter accounts, we fall back to the org account
// @link https://github.com/INN/Largo/issues/1088
} else if ( !isset( $values['largo_byline_text'] ) ) {
} else if ( empty($via) && !isset( $values['largo_byline_text'] ) ) {
$user = get_the_author_meta( 'twitter' );
if ( !empty( $user ) ) {
$via = '&via=' . rawurlencode( largo_twitter_url_to_username( $user ) );
Expand Down Expand Up @@ -292,10 +293,14 @@ function largo_post_social_links( $echo = true ) {
}

// Try to get the author's Twitter link
$twitter_username = get_user_meta( $post->post_author, 'twitter', true );
if ( ! empty( $twitter_username ) ) {
$twitter_link = 'https://twitter.com/' . $twitter_username;
$more_social_links[] = '<li><a href="' . $twitter_link . '"><i class="icon-twitter"></i> <span>Follow this author</span></a></li>';
// Commented out until we get a better grasp of coauthors
// Don't do this if we have a custom byline text
if ( ! function_exists('get_coauthors') && !isset( $values['largo_byline_text'] ) ) {
$twitter_username = get_user_meta( $post->post_author, 'twitter', true );
if ( ! empty( $twitter_username ) ) {
$twitter_link = 'https://twitter.com/' . $twitter_username;
$more_social_links[] = '<li><a href="' . $twitter_link . '"><i class="icon-twitter"></i> <span>Follow this author</span></a></li>';
}
}

if ( count( $more_social_links ) ) {
Expand Down

0 comments on commit 876da0d

Please sign in to comment.