Skip to content

Commit

Permalink
Don't display source elements if not available.
Browse files Browse the repository at this point in the history
If the 'Source' array key is empty, do not display the source portion of the Tweet.
  • Loading branch information
joedolson committed Mar 10, 2021
1 parent 78caa62 commit d4b0f13
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/wpt-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,13 @@ function wpt_twitter_feed( $instance ) {

if ( $instance['source'] ) {
$source = $tweet['source'];
// Translators: 1 - time string, 2 - name of Tweet app, 3 - Link to Tweet.
$timetweet = sprintf( __( '<a href="%3$s">about %1$s ago</a> via %2$s', 'wp-to-twitter' ), human_time_diff( strtotime( $tweet['created_at'] ) ), $source, 'http://twitter.com/' . $posted_by . "/status/$tweet[id_str]" );
if ( '' !== $source ) {
// Translators: 1 - time string, 2 - name of Tweet app, 3 - Link to Tweet.
$timetweet = sprintf( __( '<a href="%3$s">about %1$s ago</a> via %2$s', 'wp-to-twitter' ), human_time_diff( strtotime( $tweet['created_at'] ) ), $source, 'http://twitter.com/' . $posted_by . "/status/$tweet[id_str]" );
} else {
// Translators: 1 - time string, 2 - Link to Tweet.
$timetweet = sprintf( __( '<a href="%2$s">about %1$s ago</a>', 'wp-to-twitter' ), human_time_diff( strtotime( $tweet['created_at'] ) ), $source, 'http://twitter.com/' . $posted_by . "/status/$tweet[id_str]" );
}
} else {
// Translators: 1 - time string; 2 - link to Tweet.
$timetweet = sprintf( __( '<a href="%2$s">about %1$s ago</a>', 'wp-to-twitter' ), human_time_diff( strtotime( $tweet['created_at'] ) ), "http://twitter.com/$posted_by/status/$tweet[id_str]" );
Expand Down

0 comments on commit d4b0f13

Please sign in to comment.