Skip to content

Commit

Permalink
Allow emojis in descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Dec 31, 2024
1 parent 43142d9 commit a1e665d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions feed-parsers/class-feed-parser-activitypub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1101,10 +1101,11 @@ private function handle_incoming_update_person( $activity, User_Feed $user_feed
if ( ! class_exists( 'WP_Text_Diff_Renderer_inline', false ) ) {
require ABSPATH . WPINC . '/wp-diff.php';
}
$diff = new \Text_Diff( explode( ' ', $friend_user->description ), explode( ' ', $activity['summary'] ) );
$summary = wp_encode_emoji( $activity['summary'] );
$diff = new \Text_Diff( explode( ' ', $friend_user->description ), explode( ' ', $summary ) );
$renderer = new \WP_Text_Diff_Renderer_inline();
$details['summary'] = $renderer->render( $diff );
$friend_user->description = $activity['summary'];
$friend_user->description = $summary;
$message .= ' ' . __( 'Updated description.', 'friends' );
}
if ( ! empty( $activity['icon']['url'] ) && $friend_user->get_avatar_url() !== $activity['icon']['url'] ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@ public function process_admin_add_friend( $vars ) {
$avatar = $feed_details['avatar'];
}
if ( ! $description && ! empty( $feed_details['description'] ) ) {
$description = $feed_details['description'];
$description = wp_encode_emoji( $feed_details['description'] );
}
}

Expand Down
7 changes: 6 additions & 1 deletion templates/frontend/author-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
)
);
} else {
if ( $args['friend_user']->get_avatar_url() ) {
?>
<img src="<?php echo esc_attr( $args['friend_user']->get_avatar_url() ); ?>" alt="<?php echo esc_attr( $args['friend_user']->display_name ); ?>" class="avatar" width="36" height="36" style="vertical-align: middle;" />
<?php
}
echo esc_html( $args['friend_user']->display_name );
}
?>
Expand All @@ -52,7 +57,7 @@
<p>
<?php
echo wp_kses(
str_replace( '</p>', '<br/>', $args['friend_user']->description ),
make_clickable( str_replace( '</p>', '<br/>', $args['friend_user']->description ) ),
array(
'a' => array( 'href' => array() ),
'span' => array( 'class' => array() ),
Expand Down

0 comments on commit a1e665d

Please sign in to comment.