Skip to content

Commit

Permalink
Improve the display of boosted posts (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk authored Feb 18, 2025
1 parent 19ea2b7 commit 70cec2d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
1 change: 1 addition & 0 deletions feed-parsers/class-feed-parser-activitypub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,7 @@ public static function friends_post_author_meta( $friend_user ) {
array(
'url' => $meta['attributedTo']['id'],
'name' => $meta['attributedTo']['name'],
'handle' => self::convert_actor_to_mastodon_handle( $meta['attributedTo']['id'] ),
'summary' => wp_strip_all_tags( $meta['attributedTo']['summary'] ),
)
);
Expand Down
2 changes: 1 addition & 1 deletion friends.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion friends.css.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions friends.scss
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ h2#page-title a.dashicons {
height: .5em;
}

.follow-button span.name {
.boosted .follow-button, .boosted .follow-button span.name {
display: none;
}

.follow-button:hover span.name {
.boosted:hover .follow-button {
display: inline;
}

Expand Down
1 change: 0 additions & 1 deletion includes/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,6 @@ public function friend_posts_query( $query ) {
$query->set( 'author__not_in', $hide_from_friends_page );
}
}

return $query;
}
}
24 changes: 22 additions & 2 deletions templates/frontend/parts/activitypub/follow-link.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,25 @@
* @package Friends
*/

?>
<a href="<?php echo esc_url( add_query_arg( 'url', $args['url'], admin_url( 'admin.php?page=add-friend' ) ) ); ?>" class="has-icon-left follow-button" title="<?php echo esc_attr( $args['summary'] ); ?>"><span class="dashicons dashicons-plus"></span><?php echo wp_kses( /* translators: %s is a username. */ sprintf( __( 'Follow %s', 'friends' ), '<span class="name">' . esc_html( $args['name'] ) . '</span>' ), array( 'span' => array( 'class' => true ) ) ); ?></a>
?><span class="boosted" title="<?php echo esc_attr( $args['name'] . ' (' . $args['handle'] . '): ' . $args['summary'] ); ?>">
<?php
echo wp_kses(
sprintf(
// translators: %s is a username.
__( 'boosted %s', 'friends' ),
'<a href="' . esc_url( add_query_arg( 'url', $args['url'], admin_url( 'admin.php?page=add-friend' ) ) ) . '" class="has-icon-left follow-button" title="' . esc_attr( $args['summary'] ) . '"><span class="dashicons dashicons-plus"></span>' . wp_kses( /* translators: %s is a username. */ sprintf( __( 'Follow %s', 'friends' ), '<span class="name">' . esc_html( $args['name'] ) . '</span>' ), array( 'span' => array( 'class' => true ) ) ) . '</a>' .
'<a href="' . esc_url( $args['url'] ) . '" class="name">' . esc_html( $args['name'] ) . '</a>'
),
array(
'a' => array(
'href' => true,
'class' => true,
),
'span' => array(
'class' => true,
),

)
);
?>
</span>
5 changes: 0 additions & 5 deletions templates/frontend/parts/header-status.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@
<a href="<?php echo esc_attr( $friend_user->get_local_friends_page_url() ); ?>">
<strong><?php echo esc_html( $friend_user->display_name ); ?></strong>
</a>
<?php if ( $override_author_name && trim( str_replace( $override_author_name, '', $author_name ) ) === $author_name ) : ?>
<a href="<?php echo esc_attr( $friend_user->get_local_friends_page_url() ); ?>">
<?php echo esc_html( $override_author_name ); ?>
</a>
<?php endif; ?>
<?php do_action( 'friends_post_author_meta', $friend_user ); ?>
<?php else : ?>
<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>">
Expand Down

0 comments on commit 70cec2d

Please sign in to comment.