Skip to content

Commit

Permalink
Show Fediverse link in the author card.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbohacek committed Nov 21, 2022
1 parent 4b31f31 commit 89b6951
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 8 deletions.
12 changes: 10 additions & 2 deletions author-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ function bw_render_author_links( $helpers, $options ){ ?>
</a>
</li>
<?php } ?>
<?php if ( !empty( $options['fediverse_handle'] )){ ?>
<li>
<a class="btn mb-2" title="Fediverse" rel="me" href="<?php echo $options['fediverse_url']; ?>"><?php echo $options['fediverse_handle']; ?></a>
</li>
<?php } ?>
<?php if ( !empty( $options['twitter_handle'] )){ ?>
<li>
<a class="btn mb-2" title="Twitter" rel="me" href="https://twitter.com/<?php echo $options['twitter_handle']; ?>">@<?php echo $options['twitter_handle']; ?></a>
<a class="btn mb-2" title="Twitter" rel="me" href="https://twitter.com/<?php echo $options['twitter_handle']; ?>"><?php echo $options['twitter_handle']; ?></a>
</li>
<?php } ?>
</ul>
Expand All @@ -24,8 +29,11 @@ function bw_render_author_links( $helpers, $options ){ ?>
$author_info = array(
'botwiki_profile_page_url' => $botwiki_profile_page_url,
'website_url' => $website_url,
'twitter_handle' => $twitter_handle
'fediverse_handle' => $fediverse_handle,
'fediverse_url' => $fediverse_url,
'twitter_handle' => $twitter_handle,
);

?>

<div class="container card <?php
Expand Down
14 changes: 12 additions & 2 deletions author.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@
}

// $email = $author_data['user_email'];
$website_url = esc_attr( get_the_author_meta( 'user_url', $author_id ) );
$twitter_handle = str_replace('@', '', esc_attr( get_the_author_meta( 'twitter-handle', $author_id ) ) );
$website_url = esc_attr(get_the_author_meta('user_url', $author_id));
$fediverse_handle = esc_attr( get_the_author_meta('fediverse-handle', $author_id));

// @[email protected]

$fediverse_handle_array = explode('@', $fediverse_handle);
$fediverse_url = 'https://' .
$fediverse_handle_array[count($fediverse_handle_array)-1] .
'/' .
($fediverse_handle[0] === '@' ? '@' : '') .
$fediverse_handle_array[count($fediverse_handle_array)-2];
$twitter_handle = '@' . str_replace('@', '', esc_attr( get_the_author_meta( 'twitter-handle', $author_id ) ) );

$profile_img_url = esc_attr( get_the_author_meta( 'profile-img-url', $author_id ) );

Expand Down
3 changes: 2 additions & 1 deletion single.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ function get_network_name( $network ){
$profile_img_url = esc_attr( get_the_author_meta( 'profile-img-url', $author_id ) );

$website_url = esc_attr( get_the_author_meta( 'user_url', $author_id ) );
$twitter_handle = str_replace( '@', '', esc_attr( get_the_author_meta( 'twitter-handle', $author_id ) ) );
$fediverse_handle = esc_attr( get_the_author_meta( 'fediverse-handle', $author_id ) );
$twitter_handle = '@' . str_replace( '@', '', esc_attr( get_the_author_meta( 'twitter-handle', $author_id ) ) );

if ( empty( $profile_img_url ) ){
$profile_img_url = get_avatar_url( $author_id, array( 'size' => 360, 'scheme' => 'https' ) );
Expand Down
7 changes: 6 additions & 1 deletion template-submit-resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ function add_post_thumbnail( $post_id, $image_path, $description ){
}

if ( is_user_logged_in() && $_POST['disassociate-author-input'] === 'false' ){
$twitter_handle = str_replace('@', '', esc_attr( get_the_author_meta( 'twitter-handle', get_current_user_id() ) ) );
$fediverse_handle = esc_attr( get_the_author_meta( 'fediverse-handle', get_current_user_id() ) );
if ( !empty( $fediverse_handle ) ){
array_push( $resource_tags, $fediverse_handle );
}

$twitter_handle = '@' . str_replace('@', '', esc_attr( get_the_author_meta( 'twitter-handle', get_current_user_id() ) ) );
if ( !empty( $twitter_handle ) ){
array_push( $resource_tags, $twitter_handle );
}
Expand Down
3 changes: 2 additions & 1 deletion template-submit-your-bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ function get_network_name( $network_term_slug ){
}

if ( is_user_logged_in() && isset( $_POST['disassociate-author-input'] ) && $_POST['disassociate-author-input'] === 'false' ){
$twitter_handle = str_replace( '@', '', esc_attr( get_the_author_meta( 'twitter-handle', get_current_user_id() ) ) );
$twitter_handle = '@' . str_replace( '@', '', esc_attr( get_the_author_meta( 'twitter-handle', get_current_user_id() ) ) );
$fediverse_handle = esc_attr( get_the_author_meta( 'fediverse-handle', get_current_user_id() ) );

if ( !empty( $twitter_handle ) ){
array_push( $bot_tags, $twitter_handle );
Expand Down
4 changes: 3 additions & 1 deletion template-team-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class="text-sm-left text-md-center"
$botwiki_team_role = "Botwiki contributor.";
}
// $website_url = esc_attr( get_the_author_meta( 'user_url', $author_id ) );
// $twitter_handle = str_replace('@', '', esc_attr( get_the_author_meta( 'twitter-handle', $author_id ) ) );
// $twitter_handle = '@' . str_replace('@', '', esc_attr( get_the_author_meta( 'twitter-handle', $author_id ) ) );
// $fediverse_handle = esc_attr( get_the_author_meta( 'fediverse-handle', $author_id ) );

$profile_img_url = esc_attr( get_the_author_meta( 'profile-img-url', $author_id ) );

Expand Down Expand Up @@ -165,6 +166,7 @@ class="text-sm-left text-md-center"
}

$website_url = esc_attr( get_the_author_meta( 'user_url', $author_id ) );
$fediverse_handle = esc_attr( get_the_author_meta( 'fediverse-handle', $author_id ) );
$twitter_handle = str_replace('@', '', esc_attr( get_the_author_meta( 'twitter-handle', $author_id ) ) );
?>
<div class="col-xs-6 col-s-2 m-2 text-center">
Expand Down

0 comments on commit 89b6951

Please sign in to comment.