updated plugin ActivityPub version 5.8.0

This commit is contained in:
2025-04-29 21:19:06 +00:00
committed by Gitium
parent 19dfd317cc
commit fdfbf76539
166 changed files with 14119 additions and 7163 deletions

View File

@ -42,6 +42,15 @@ class Extra_Fields {
$query = new \WP_Query( $args );
$fields = $query->posts ?? array();
/**
* Filters the extra fields for an ActivityPub actor.
*
* This filter allows developers to modify or add custom fields to an actor's
* profile.
*
* @param \WP_Post[] $fields Array of WP_Post objects representing the extra fields.
* @param int $user_id The ID of the user whose fields are being retrieved.
*/
return apply_filters( 'activitypub_get_actor_extra_fields', $fields, $user_id );
}
@ -54,7 +63,7 @@ class Extra_Fields {
*/
public static function get_formatted_content( $post ) {
$content = \get_the_content( null, false, $post );
$content = Link::the_content( $content, true );
$content = Link::the_content( $content );
if ( site_supports_blocks() ) {
$content = \do_blocks( $content );
}
@ -84,14 +93,7 @@ class Extra_Fields {
*/
public static function fields_to_attachments( $fields ) {
$attachments = array();
\add_filter(
'activitypub_link_rel',
function ( $rel ) {
$rel .= ' me';
return $rel;
}
);
\add_filter( 'activitypub_link_rel', array( self::class, 'add_rel_me' ) );
foreach ( $fields as $post ) {
$content = self::get_formatted_content( $post );
@ -105,7 +107,7 @@ class Extra_Fields {
),
);
$link_added = false;
$attachment = false;
// Add support for FEP-fb2a, for more information see FEDERATION.md.
$link_content = \trim( \strip_tags( $content, '<a>' ) );
@ -123,14 +125,17 @@ class Extra_Fields {
'type' => 'Link',
'name' => \get_the_title( $post ),
'href' => \esc_url( $tags->get_attribute( 'href' ) ),
'rel' => explode( ' ', $tags->get_attribute( 'rel' ) ),
);
$link_added = true;
$rel = $tags->get_attribute( 'rel' );
if ( $rel && \is_string( $rel ) ) {
$attachment['rel'] = \explode( ' ', $rel );
}
}
}
if ( ! $link_added ) {
if ( ! $attachment ) {
$attachment = array(
'type' => 'Note',
'name' => \get_the_title( $post ),
@ -145,6 +150,8 @@ class Extra_Fields {
$attachments[] = $attachment;
}
\remove_filter( 'activitypub_link_rel', array( self::class, 'add_rel_me' ) );
return $attachments;
}
@ -271,6 +278,16 @@ class Extra_Fields {
return '<!-- wp:paragraph --><p>' . $content . '</p><!-- /wp:paragraph -->';
}
/**
* Add the 'me' rel to the link.
*
* @param string $rel The rel attribute.
* @return string The modified rel attribute.
*/
public static function add_rel_me( $rel ) {
return $rel . ' me';
}
/**
* Checks if the user is the blog user.
*
@ -278,6 +295,6 @@ class Extra_Fields {
* @return bool True if the user is the blog user, otherwise false.
*/
private static function is_blog( $user_id ) {
return Users::BLOG_USER_ID === $user_id;
return Actors::BLOG_USER_ID === $user_id;
}
}