Skip to content

Commit

Permalink
Fixed fediverse profile URL in author cards on article pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbohacek committed Jan 10, 2023
1 parent 270e984 commit 3524e3d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 2 additions & 0 deletions author-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function bw_render_author_links( $helpers, $options ){ ?>
</ul>
<?php }

$fediverse_url = $helpers->get_fediverse_url( $fediverse_handle );

$author_info = array(
'botwiki_profile_page_url' => $botwiki_profile_page_url,
'website_url' => $website_url,
Expand Down
7 changes: 1 addition & 6 deletions author.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@

// @[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];
$fediverse_url = $helpers->get_fediverse_url( $fediverse_handle );
$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
19 changes: 14 additions & 5 deletions includes/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ function make_screenshot( $options ){
mkdir( ABSPATH . 'temp/' , 0777, true );
}

log_this( 'make_screenshot', array(
'options' => $options,
'image_path' => $image_path,
'api_url' => $api_url
) );
// log_this( 'make_screenshot', array(
// 'options' => $options,
// 'image_path' => $image_path,
// 'api_url' => $api_url
// ) );

$ctx = stream_context_create( array( 'http' =>
array(
Expand Down Expand Up @@ -296,6 +296,15 @@ function get_screenshotable_url( $urls ){
return $screenshotable_url;
}

function get_fediverse_url( $handle ){
$handle_array = explode('@', $handle);
$fediverse_url = 'https://' .
$handle_array[count($handle_array)-1] .
'/' .
($handle[0] === '@' ? '@' : '') .
$handle_array[count($handle_array)-2];
return $fediverse_url;
}

function get_known_mastodon_instances(){
// TODO: Move these to a settings page for easier maintanance.
Expand Down

0 comments on commit 3524e3d

Please sign in to comment.