updated plugin ActivityPub version 9.1.0

This commit is contained in:
2026-07-28 15:03:10 +00:00
committed by Gitium
parent bf428f0e45
commit ff806e1811
217 changed files with 6098 additions and 3025 deletions

View File

@ -60,13 +60,13 @@ class Buddypress {
*/
public static function add_user_metadata( $author, $author_id ) {
if ( \function_exists( 'bp_members_get_user_url' ) ) {
$author->url = bp_members_get_user_url( $author_id );
$author->url = \bp_members_get_user_url( $author_id );
} else {
$author->url = bp_core_get_user_domain( $author_id );
$author->url = \bp_core_get_user_domain( $author_id );
}
// Add BuddyPress' cover_image instead of WordPress' header_image.
$cover_image_url = bp_attachments_get_attachment( 'url', array( 'item_id' => $author_id ) );
$cover_image_url = \bp_attachments_get_attachment( 'url', array( 'item_id' => $author_id ) );
if ( $cover_image_url ) {
$author->image = array(
@ -80,7 +80,7 @@ class Buddypress {
'type' => 'PropertyValue',
'name' => \__( 'Profile', 'activitypub' ),
'value' => \html_entity_decode(
sprintf(
\sprintf(
'<a rel="me" title="%s" target="_blank" href="%s">%s</a>',
\esc_attr( $author->url ),
\esc_url( $author->url ),
@ -92,8 +92,8 @@ class Buddypress {
);
// Replace blog URL on multisite.
if ( is_multisite() ) {
$user_blogs = get_blogs_of_user( $author_id ); // Get sites of user to send as AP metadata.
if ( \is_multisite() ) {
$user_blogs = \get_blogs_of_user( $author_id ); // Get sites of user to send as AP metadata.
if ( ! empty( $user_blogs ) ) {
unset( $author->attachment['blog_url'] );
@ -104,7 +104,7 @@ class Buddypress {
'type' => 'PropertyValue',
'name' => $blog->blogname,
'value' => \html_entity_decode(
sprintf(
\sprintf(
'<a rel="me" title="%s" target="_blank" href="%s">%s</a>',
\esc_attr( $blog->siteurl ),
$blog->siteurl,

View File

@ -20,7 +20,7 @@ class Classic_Editor {
public static function init() {
\add_filter( 'activitypub_attachments_media_markup', array( self::class, 'filter_attachments_media_markup' ), 10, 2 );
\add_filter( 'activitypub_attachment_ids', array( self::class, 'filter_attached_media_ids' ), 10, 2 );
\add_action( 'add_meta_boxes', array( self::class, 'add_meta_box' ) );
\add_action( 'add_meta_boxes', array( self::class, 'add_meta_box' ), 10, 2 );
\add_action( 'save_post', array( self::class, 'save_meta_data' ) );
if ( \function_exists( 'classicpress_version' ) ) {
@ -41,11 +41,11 @@ class Classic_Editor {
return $markup;
}
$type = strtok( \get_post_mime_type( $attachment_ids[0] ), '/' );
$type = \strtok( \get_post_mime_type( $attachment_ids[0] ), '/' );
// Single video or audio file: use media shortcode.
if ( 1 === \count( $attachment_ids ) && ( 'video' === $type || 'audio' === $type ) ) {
return sprintf(
return \sprintf(
'[%1$s src="%2$s"]',
\esc_attr( $type ),
\esc_url( \wp_get_attachment_url( $attachment_ids[0] ) )
@ -53,7 +53,7 @@ class Classic_Editor {
}
// Multiple attachments or images: use gallery shortcode.
return '[gallery ids="' . implode( ',', $attachment_ids ) . '" link="none"]';
return '[gallery ids="' . \implode( ',', $attachment_ids ) . '" link="none"]';
}
/**
@ -104,14 +104,26 @@ class Classic_Editor {
/**
* Add ActivityPub meta box to the post editor.
*
* @param string $post_type The post type.
* @param string $post_type The post type.
* @param \WP_Post|null $post The post being edited.
*/
public static function add_meta_box( $post_type ) {
public static function add_meta_box( $post_type, $post = null ) {
// Only add for post types that support ActivityPub.
if ( ! \post_type_supports( $post_type, 'activitypub' ) ) {
return;
}
/*
* The block editor ships its own ActivityPub panel, so the classic meta box must not be
* added there. With the Classic Editor plugin in switchable mode a post can still open in
* the block editor, where both would otherwise render and the meta box's save_post handler
* would overwrite the panel's value. The function_exists() check keeps ClassicPress and
* other block-less setups (where use_block_editor_for_post() is absent) safe.
*/
if ( $post instanceof \WP_Post && \function_exists( 'use_block_editor_for_post' ) && \use_block_editor_for_post( $post ) ) {
return;
}
\add_meta_box(
'activitypub-settings',
\__( 'Fediverse ⁂', 'activitypub' ),
@ -184,7 +196,7 @@ class Classic_Editor {
<span class="howto">
<?php \esc_html_e( 'Quoting allows others to cite your post while adding their own commentary.', 'activitypub' ); ?>
<?php
printf(
\printf(
/* translators: %s: The current site default quote policy. Note the leading space. */
\esc_html__( ' Site default: %s', 'activitypub' ),
\esc_html( self::get_quote_policy_label( $default_quote_policy ) )

View File

@ -72,7 +72,7 @@ class Enable_Mastodon_Apps {
is_user_type_disabled( 'user' ) &&
! is_user_type_disabled( 'blog' ) &&
// Check if the blog user is permissible for this user.
user_can( $user_id, 'activitypub' )
\user_can( $user_id, 'activitypub' )
) {
return Actors::BLOG_USER_ID;
}
@ -94,7 +94,7 @@ class Enable_Mastodon_Apps {
$user_id = self::maybe_map_user_to_blog( $user_id );
$user = Actors::get_by_id( $user_id );
if ( ! $user || is_wp_error( $user ) ) {
if ( ! $user || \is_wp_error( $user ) ) {
return $data;
}
@ -154,7 +154,7 @@ class Enable_Mastodon_Apps {
private static function set_extra_fields( $user_id, $fields ) {
// The Mastodon API submits a simple hash for every field.
// We can reasonably assume a similar order for our operations below.
$ids = wp_list_pluck( Extra_Fields::get_actor_fields( $user_id ), 'ID' );
$ids = \wp_list_pluck( Extra_Fields::get_actor_fields( $user_id ), 'ID' );
$is_blog = Actors::BLOG_USER_ID === $user_id;
$post_type = $is_blog ? Extra_Fields::BLOG_POST_TYPE : Extra_Fields::USER_POST_TYPE;
@ -243,7 +243,7 @@ class Enable_Mastodon_Apps {
$mastodon_followers[] = $account;
}
return array_merge( $mastodon_followers, $followers );
return \array_merge( $mastodon_followers, $followers );
}
/**
@ -262,20 +262,20 @@ class Enable_Mastodon_Apps {
}
}
if ( $user_data || ( is_numeric( $user_id ) && $user_id ) ) {
if ( $user_data || ( \is_numeric( $user_id ) && $user_id ) ) {
// Only augment.
return $user_data;
}
$user = Actors::get_by_various( $user_id );
if ( $user && ! is_wp_error( $user ) ) {
if ( $user && ! \is_wp_error( $user ) ) {
return $user_data;
}
$uri = Webfinger_Util::resolve( $user_id );
if ( ! $uri || is_wp_error( $uri ) ) {
if ( ! $uri || \is_wp_error( $uri ) ) {
return $user_data;
}
@ -299,7 +299,7 @@ class Enable_Mastodon_Apps {
$user_id_to_use = self::maybe_map_user_to_blog( $user_id );
$user = Actors::get_by_id( $user_id_to_use );
if ( ! $user || is_wp_error( $user ) ) {
if ( ! $user || \is_wp_error( $user ) ) {
return $user_data;
}
@ -311,7 +311,7 @@ class Enable_Mastodon_Apps {
$account->acct = $account->username;
$account->display_name = $user->get_name();
$account->note = $user->get_summary();
$account->source['note'] = wp_strip_all_tags( $account->note, true );
$account->source['note'] = \wp_strip_all_tags( $account->note, true );
$account->url = $user->get_url();
$icon = $user->get_icon();
@ -379,13 +379,13 @@ class Enable_Mastodon_Apps {
* @return Status|null The Mastodon API status object, or null if the post is not found
*/
private static function api_post_status( $post_id ) {
$post = Factory::get_transformer( get_post( $post_id ) );
if ( is_wp_error( $post ) ) {
$post = Factory::get_transformer( \get_post( $post_id ) );
if ( \is_wp_error( $post ) ) {
return null;
}
$data = $post->to_object()->to_array();
$account = self::api_account_internal( null, get_post_field( 'post_author', $post_id ) );
$account = self::api_account_internal( null, \get_post_field( 'post_author', $post_id ) );
return self::activity_to_status( $data, $account, $post_id );
}
@ -551,7 +551,7 @@ class Enable_Mastodon_Apps {
if ( ! $q ) {
return $search_data;
}
$q = sanitize_text_field( wp_unslash( $q ) );
$q = \sanitize_text_field( \wp_unslash( $q ) );
$followers = Followers::get_many( $user_id, 40, null, array( 's' => $q ) );
if ( ! $followers ) {
@ -582,9 +582,9 @@ class Enable_Mastodon_Apps {
* @return array The filtered args.
*/
public static function api_get_posts_query_args( $args ) {
if ( isset( $args['author'] ) && is_string( $args['author'] ) ) {
if ( isset( $args['author'] ) && \is_string( $args['author'] ) ) {
$uri = Webfinger_Util::resolve( $args['author'] );
if ( $uri && ! is_wp_error( $uri ) ) {
if ( $uri && ! \is_wp_error( $uri ) ) {
$args['activitypub'] = $uri;
unset( $args['author'] );
}
@ -609,7 +609,7 @@ class Enable_Mastodon_Apps {
$object = $item;
}
if ( ! isset( $object['type'] ) || ! in_array( $object['type'], array( 'Article', 'Note' ), true ) || ! $account ) {
if ( ! isset( $object['type'] ) || ! \in_array( $object['type'], array( 'Article', 'Note' ), true ) || ! $account ) {
return null;
}
@ -634,7 +634,7 @@ class Enable_Mastodon_Apps {
}
if ( ! empty( $object['attachment'] ) ) {
$status->media_attachments = array_map(
$status->media_attachments = \array_map(
static function ( $attachment ) {
$default_attachment = array(
'url' => null,
@ -645,11 +645,11 @@ class Enable_Mastodon_Apps {
'blurhash' => null,
);
$attachment = array_merge( $default_attachment, $attachment );
$attachment = \array_merge( $default_attachment, $attachment );
$media_attachment = new Media_Attachment();
$media_attachment->id = $attachment['url'];
$media_attachment->type = strtok( $attachment['mediaType'], '/' );
$media_attachment->type = \strtok( $attachment['mediaType'], '/' );
$media_attachment->url = $attachment['url'];
$media_attachment->preview_url = $attachment['url'];
$media_attachment->description = $attachment['name'];
@ -689,12 +689,12 @@ class Enable_Mastodon_Apps {
$data = get_remote_metadata_by_actor( $args['activitypub'] );
if ( ! $data || is_wp_error( $data ) || ! isset( $data['outbox'] ) ) {
if ( ! $data || \is_wp_error( $data ) || ! isset( $data['outbox'] ) ) {
return $statuses;
}
$outbox = Http::get_remote_object( $data['outbox'], true );
if ( is_wp_error( $outbox ) || ! isset( $outbox['first'] ) ) {
if ( \is_wp_error( $outbox ) || ! isset( $outbox['first'] ) ) {
return $statuses;
}
@ -718,11 +718,11 @@ class Enable_Mastodon_Apps {
}
$posts = Http::get_remote_object( $url, true );
if ( is_wp_error( $posts ) ) {
if ( \is_wp_error( $posts ) ) {
return $statuses;
}
$new_statuses = array_map(
$new_statuses = \array_map(
static function ( $item ) use ( $account, $args ) {
if ( $args['exclude_replies'] ) {
if ( isset( $item['object']['inReplyTo'] ) && $item['object']['inReplyTo'] ) {
@ -733,15 +733,15 @@ class Enable_Mastodon_Apps {
},
$posts['orderedItems']
);
$activitypub_statuses = array_merge( $activitypub_statuses, array_filter( $new_statuses ) );
$activitypub_statuses = \array_merge( $activitypub_statuses, \array_filter( $new_statuses ) );
$url = $posts['next'] ?? null;
if ( count( $activitypub_statuses ) >= $limit ) {
if ( \count( $activitypub_statuses ) >= $limit ) {
break;
}
}
return array_slice( $activitypub_statuses, 0, $limit );
return \array_slice( $activitypub_statuses, 0, $limit );
}
/**
@ -957,7 +957,7 @@ class Enable_Mastodon_Apps {
*/
public static function api_get_replies( $context, $post_id, $url ) {
$meta = Http::get_remote_object( $url, true );
if ( is_wp_error( $meta ) || ! isset( $meta['replies']['first']['next'] ) ) {
if ( \is_wp_error( $meta ) || ! isset( $meta['replies']['first']['next'] ) ) {
return $context;
}
@ -966,7 +966,7 @@ class Enable_Mastodon_Apps {
} elseif ( isset( $meta['replies']['first']['next'] ) ) {
$replies_url = $meta['replies']['first']['next'];
$replies = Http::get_remote_object( $replies_url, true );
if ( is_wp_error( $replies ) || ! isset( $replies['items'] ) ) {
if ( \is_wp_error( $replies ) || ! isset( $replies['items'] ) ) {
return $context;
}
} else {
@ -974,22 +974,22 @@ class Enable_Mastodon_Apps {
}
foreach ( $replies['items'] as $reply ) {
if ( isset( $reply['id'] ) && is_string( $reply['id'] ) && isset( $reply['content'] ) && is_string( $reply['content'] ) ) {
if ( isset( $reply['id'] ) && \is_string( $reply['id'] ) && isset( $reply['content'] ) && \is_string( $reply['content'] ) ) {
$status = $reply;
} else {
if ( is_string( $reply ) ) {
if ( \is_string( $reply ) ) {
$url = $reply;
} elseif ( isset( $reply['url'] ) && is_string( $reply['url'] ) ) {
} elseif ( isset( $reply['url'] ) && \is_string( $reply['url'] ) ) {
$url = $reply['url'];
} else {
continue;
}
$response = Http::get( $url, array(), true );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) {
if ( \is_wp_error( $response ) || \wp_remote_retrieve_response_code( $response ) !== 200 ) {
continue;
}
$status = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! $status || is_wp_error( $status ) ) {
$status = \json_decode( \wp_remote_retrieve_body( $response ), true );
if ( ! $status || \is_wp_error( $status ) ) {
continue;
}
}

View File

@ -100,7 +100,7 @@ class Jetpack {
$comment_types[] = 'quote';
$comment_types[] = 'repost';
return array_unique( $comment_types );
return \array_unique( $comment_types );
}
/**
@ -124,19 +124,19 @@ class Jetpack {
if ( empty( $feed['feed_id'] ) ) {
return $actions; // No feed_id available on WPCOM.
}
$url = sprintf( 'https://wordpress.com/reader/feeds/%d', (int) $feed['feed_id'] );
$url = \sprintf( 'https://wordpress.com/reader/feeds/%d', (int) $feed['feed_id'] );
} else {
$url = sprintf( 'https://wordpress.com/reader/feeds/lookup/%s', rawurlencode( $item['identifier'] ) );
$url = \sprintf( 'https://wordpress.com/reader/feeds/lookup/%s', \rawurlencode( $item['identifier'] ) );
}
return array_merge(
return \array_merge(
array(
'reader' => sprintf(
'reader' => \sprintf(
'<a href="%1$s" target="_blank">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
esc_url( $url ),
esc_html__( 'View Feed', 'activitypub' ),
\esc_url( $url ),
\esc_html__( 'View Feed', 'activitypub' ),
/* translators: Hidden accessibility text. */
esc_html__( '(opens in a new tab)', 'activitypub' )
\esc_html__( '(opens in a new tab)', 'activitypub' )
),
),
$actions

View File

@ -181,11 +181,11 @@ RewriteRule ^ - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+isjson]
$htaccess = $wp_filesystem->get_contents( $htaccess_file );
// If marker exists, remove the old block first.
if ( strpos( $htaccess, $marker ) !== false ) {
if ( \strpos( $htaccess, $marker ) !== false ) {
// Remove existing marker block.
$pattern = '/# BEGIN ' . preg_quote( $marker, '/' ) . '.*?# END ' . preg_quote( $marker, '/' ) . '\r?\n?/s';
$htaccess = preg_replace( $pattern, '', $htaccess );
$htaccess = trim( $htaccess );
$pattern = '/# BEGIN ' . \preg_quote( $marker, '/' ) . '.*?# END ' . \preg_quote( $marker, '/' ) . '\r?\n?/s';
$htaccess = \preg_replace( $pattern, '', $htaccess );
$htaccess = \trim( $htaccess );
}
// If rules are empty, just return (for removal case).
@ -215,7 +215,7 @@ RewriteRule ^ - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+isjson]
require_once ABSPATH . 'wp-admin/includes/file.php';
// phpcs:ignore WordPress.PHP.NoSilencedErrors
if ( @file_exists( \get_home_path() . '.htaccess' ) ) {
if ( @\file_exists( \get_home_path() . '.htaccess' ) ) {
/** The htaccess file resides in ABSPATH */
$htaccess_file = \get_home_path() . '.htaccess';
}

View File

@ -26,7 +26,7 @@ class Nodeinfo {
\add_filter( 'nodeinfo_data', array( self::class, 'add_nodeinfo_data' ), 10, 2 );
\add_filter( 'nodeinfo2_data', array( self::class, 'add_nodeinfo2_data' ) );
\add_filter( 'wellknown_nodeinfo_data', array( self::class, 'add_wellknown_nodeinfo_data' ) );
\add_filter( 'nodeinfo_discovery', array( self::class, 'add_wellknown_nodeinfo_data' ) );
}
/**
@ -38,7 +38,7 @@ class Nodeinfo {
* @return array The extended array.
*/
public static function add_nodeinfo_data( $nodeinfo, $version ) {
$nodeinfo = wp_parse_args(
$nodeinfo = \wp_parse_args(
$nodeinfo,
array(
'version' => $version,
@ -66,11 +66,11 @@ class Nodeinfo {
$nodeinfo['protocols'][] = 'activitypub';
$nodeinfo['services']['inbound'] = array_merge(
$nodeinfo['services']['inbound'] = \array_merge(
$nodeinfo['services']['inbound'],
array( 'gnusocial' )
);
$nodeinfo['services']['outbound'] = array_merge(
$nodeinfo['services']['outbound'] = \array_merge(
$nodeinfo['services']['outbound'],
array( 'friendica', 'gnusocial', 'mediagoblin', 'wordpress' )
);
@ -129,7 +129,7 @@ class Nodeinfo {
*/
private static function get_staff() {
// Get all admin users with the cap activitypub.
$admins = get_users(
$admins = \get_users(
array(
'role' => 'administrator',
'orderby' => 'ID',
@ -138,8 +138,8 @@ class Nodeinfo {
'fields' => 'ID',
)
);
$admins = array_map( array( Webfinger::class, 'get_user_resource' ), $admins );
$admins = \array_map( array( Webfinger::class, 'get_user_resource' ), $admins );
return array_values( array_filter( $admins ) );
return \array_values( \array_filter( $admins ) );
}
}

View File

@ -25,7 +25,7 @@ class Opengraph {
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
if ( ! function_exists( 'opengraph_metadata' ) ) {
if ( ! \function_exists( 'opengraph_metadata' ) ) {
\add_action( 'wp_head', array( self::class, 'add_meta_tags' ) );
}
@ -94,7 +94,7 @@ class Opengraph {
* Output Open Graph <meta> tags in the page header.
*/
public static function add_meta_tags() {
$metadata = apply_filters( 'opengraph_metadata', array() );
$metadata = \apply_filters( 'opengraph_metadata', array() );
foreach ( $metadata as $key => $value ) {
if ( empty( $key ) || empty( $value ) ) {
continue;
@ -102,10 +102,10 @@ class Opengraph {
$value = (array) $value;
foreach ( $value as $v ) {
printf(
\printf(
'<meta property="%1$s" name="%1$s" content="%2$s" />' . PHP_EOL,
esc_attr( $key ),
esc_attr( $v )
\esc_attr( $key ),
\esc_attr( $v )
);
}
}

View File

@ -40,6 +40,30 @@ class Podlove_Podcast_Publisher extends Post {
return $this->episode;
}
/**
* Returns the summary for the ActivityPub Item.
*
* @return string|null The summary or null.
*/
protected function get_summary() {
$episode = $this->get_episode();
// Notes carry no summary, so there is nothing to override for them.
if ( $episode && 'Note' !== $this->get_type() ) {
// Sanitize like generate_post_summary() does, since Podlove stores the summary as raw user input.
$summary = \strip_shortcodes( (string) $episode->summary );
$summary = \wp_strip_all_tags( $summary );
$summary = \trim( \html_entity_decode( $summary, ENT_QUOTES, 'UTF-8' ) );
// Federate the episode summary explicitly; Podlove keeps it out of post_content.
if ( '' !== $summary ) {
return $summary;
}
}
return parent::get_summary();
}
/**
* Gets the attachment for a podcast episode.
*
@ -77,7 +101,7 @@ class Podlove_Podcast_Publisher extends Post {
}
// Only include audio and video files.
if ( ! in_array( $file_type->type, array( 'audio', 'video' ), true ) ) {
if ( ! \in_array( $file_type->type, array( 'audio', 'video' ), true ) ) {
continue;
}
@ -89,15 +113,15 @@ class Podlove_Podcast_Publisher extends Post {
}
$attachment = array(
'type' => \esc_attr( ucfirst( $file_type->type ) ),
'url' => \esc_url( $file_url ),
'type' => \esc_attr( \ucfirst( $file_type->type ) ),
'url' => \esc_url_raw( $file_url ),
'mediaType' => \esc_attr( $file_type->mime_type ),
'name' => \esc_attr( $episode->title() ?? '' ),
);
// Add duration if available (in ISO 8601 format).
$duration = $episode->get_duration( 'seconds' );
if ( $duration && is_numeric( $duration ) && (int) $duration > 0 ) {
if ( $duration && \is_numeric( $duration ) && (int) $duration > 0 ) {
$attachment['duration'] = seconds_to_iso8601( (int) $duration );
}
@ -110,7 +134,7 @@ class Podlove_Podcast_Publisher extends Post {
if ( $icon ) {
foreach ( $attachments as $key => $attachment ) {
$attachments[ $key ]['icon'] = \esc_url( $icon );
$attachments[ $key ]['icon'] = \esc_url_raw( $icon );
}
}
}
@ -137,7 +161,7 @@ class Podlove_Podcast_Publisher extends Post {
$image = $episode->cover_art_with_fallback();
if ( $image && method_exists( $image, 'url' ) ) {
if ( $image && \method_exists( $image, 'url' ) ) {
return $image->url();
}
@ -165,7 +189,7 @@ class Podlove_Podcast_Publisher extends Post {
$duration_seconds = $episode->get_duration( 'seconds' );
// Ensure we have a valid numeric duration.
if ( ! $duration_seconds || ! is_numeric( $duration_seconds ) ) {
if ( ! $duration_seconds || ! \is_numeric( $duration_seconds ) ) {
return null;
}

View File

@ -30,8 +30,8 @@ class Seriously_Simple_Podcasting extends Post {
public function get_attachment() {
$post = $this->item;
$attachment = array(
'type' => \esc_attr( ucfirst( \get_post_meta( $post->ID, 'episode_type', true ) ?? 'Audio' ) ),
'url' => \esc_url( \get_post_meta( $post->ID, 'audio_file', true ) ),
'type' => \esc_attr( \ucfirst( \get_post_meta( $post->ID, 'episode_type', true ) ?? 'Audio' ) ),
'url' => \esc_url_raw( \get_post_meta( $post->ID, 'audio_file', true ) ),
'name' => \esc_attr( \get_the_title( $post->ID ) ?? '' ),
);
@ -41,7 +41,7 @@ class Seriously_Simple_Podcasting extends Post {
}
if ( $icon ) {
$attachment['icon'] = \esc_url( object_to_uri( $icon ) );
$attachment['icon'] = \esc_url_raw( object_to_uri( $icon ) );
}
return array( $attachment );

View File

@ -114,15 +114,15 @@ class Surge {
$config_file = false;
// phpcs:ignore WordPress.PHP.NoSilencedErrors
if ( @file_exists( ABSPATH . 'wp-config.php' ) ) {
if ( @\file_exists( ABSPATH . 'wp-config.php' ) ) {
/** The config file resides in ABSPATH */
$config_file = ABSPATH . 'wp-config.php';
// phpcs:ignore WordPress.PHP.NoSilencedErrors
} elseif ( @file_exists( dirname( ABSPATH ) . '/wp-config.php' ) && ! @file_exists( dirname( ABSPATH ) . '/wp-settings.php' ) ) {
} elseif ( @\file_exists( \dirname( ABSPATH ) . '/wp-config.php' ) && ! @\file_exists( \dirname( ABSPATH ) . '/wp-settings.php' ) ) {
/** The config file resides one level above ABSPATH but is not part of another installation */
$config_file = dirname( ABSPATH ) . '/wp-config.php';
$config_file = \dirname( ABSPATH ) . '/wp-config.php';
}
/**

View File

@ -39,17 +39,17 @@ class Webfinger {
public static function add_user_discovery( $jrd, $uri, $user ) {
$user = Actors::get_by_id( $user->ID );
if ( ! $user || is_wp_error( $user ) ) {
if ( ! $user || \is_wp_error( $user ) ) {
return $jrd;
}
$jrd['subject'] = sprintf( 'acct:%s', $user->get_webfinger() );
$jrd['subject'] = \sprintf( 'acct:%s', $user->get_webfinger() );
$jrd['aliases'][] = $user->get_id();
$jrd['aliases'][] = $user->get_url();
$jrd['aliases'][] = $user->get_alternate_url();
$jrd['aliases'] = array_unique( $jrd['aliases'] );
$jrd['aliases'] = array_values( $jrd['aliases'] );
$jrd['aliases'] = \array_unique( $jrd['aliases'] );
$jrd['aliases'] = \array_values( $jrd['aliases'] );
$jrd['links'][] = array(
'rel' => 'self',
@ -81,11 +81,11 @@ class Webfinger {
$user->get_alternate_url(),
);
$aliases = array_unique( $aliases );
$aliases = array_values( $aliases );
$aliases = \array_unique( $aliases );
$aliases = \array_values( $aliases );
$profile = array(
'subject' => sprintf( 'acct:%s', $user->get_webfinger() ),
'subject' => \sprintf( 'acct:%s', $user->get_webfinger() ),
'aliases' => $aliases,
'links' => array(
array(
@ -120,7 +120,7 @@ class Webfinger {
* @return array The jrd array.
*/
public static function add_interaction_links( $jrd ) {
if ( ! is_array( $jrd ) ) {
if ( ! \is_array( $jrd ) ) {
return $jrd;
}

View File

@ -33,9 +33,9 @@ class WPML {
return $lang;
}
$language_details = apply_filters( 'wpml_post_language_details', null, $post->ID );
$language_details = \apply_filters( 'wpml_post_language_details', null, $post->ID );
if ( is_array( $language_details ) && isset( $language_details['language_code'] ) ) {
if ( \is_array( $language_details ) && isset( $language_details['language_code'] ) ) {
$lang = $language_details['language_code'];
}

View File

@ -99,7 +99,7 @@ class Yoast_Seo {
// Get Yoast SEO options.
$yoast_options = \get_option( 'wpseo_titles' );
if ( ! is_array( $yoast_options ) ) {
if ( ! \is_array( $yoast_options ) ) {
return false;
}
@ -114,7 +114,7 @@ class Yoast_Seo {
*/
private static function is_attachment_supported() {
$supported_post_types = \get_option( 'activitypub_support_post_types', array( 'post' ) );
return in_array( 'attachment', $supported_post_types, true );
return \in_array( 'attachment', $supported_post_types, true );
}
/**
@ -168,7 +168,7 @@ class Yoast_Seo {
// Get Yoast SEO options.
$yoast_options = \get_option( 'wpseo_titles' );
if ( ! is_array( $yoast_options ) ) {
if ( ! \is_array( $yoast_options ) ) {
return false;
}

View File

@ -7,9 +7,11 @@
namespace Activitypub\Integration;
use Activitypub\Autoloader;
use function Activitypub\site_supports_blocks;
\Activitypub\Autoloader::register_path( __NAMESPACE__, __DIR__ );
Autoloader::register_path( __NAMESPACE__, __DIR__ );
/**
* Initialize the ActivityPub integrations.
@ -137,7 +139,7 @@ function plugin_init() {
* @see https://wordpress.org/plugins/seriously-simple-podcasting/
*/
if ( \defined( 'SSP_VERSION' ) ) {
add_filter(
\add_filter(
'activitypub_transformer',
static function ( $transformer, $data, $object_class ) {
if (

View File

@ -111,12 +111,14 @@ class Connector extends \WP_Stream\Connector {
/**
* Callback for activitypub_handled_follow.
*
* @param array $activity The ActivityPub activity data.
* @param int|null $user_id The local user ID, or null if not applicable.
* @param mixed $state Status or WP_Error object indicating the result of the follow handling.
* @param \WP_Post|null $context The WP_Post object representing the remote actor/follower.
* @param array $activity The ActivityPub activity data.
* @param int|int[] $user_ids The local user ID(s) of the followed actor(s).
* @param bool $success Whether the follow was handled successfully.
* @param \WP_Post|\WP_Error $context The remote actor/follower, or WP_Error on failure.
*/
public function callback_activitypub_handled_follow( $activity, $user_id, $state, $context ) {
public function callback_activitypub_handled_follow( $activity, $user_ids, $success, $context ) {
// The hook passes an array of user IDs; Stream's log() builds a WP_User from this, so coerce to a single integer.
$user_id = (int) ( \is_array( $user_ids ) ? \reset( $user_ids ) : $user_ids );
$actor_url = \is_object( $context ) && ! \is_wp_error( $context ) ? $context->guid : $activity['actor'];
$this->log(
@ -238,8 +240,6 @@ class Connector extends \WP_Stream\Connector {
$object_title = \get_userdata( $author_id )->display_name;
} elseif ( Actors::BLOG_USER_ID === $author_id ) {
$object_title = \__( 'Blog User', 'activitypub' );
} elseif ( Actors::APPLICATION_USER_ID === $author_id ) {
$object_title = \__( 'Application User', 'activitypub' );
}
}
}

View File

@ -13,9 +13,7 @@ if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$accept = strtolower( $_SERVER['HTTP_ACCEPT'] );
if ( str_contains( $accept, 'text/html' ) ) {
$representation = 'html';
} elseif (
if (
str_contains( $accept, 'application/json' ) ||
str_contains( $accept, 'application/activity+json' ) ||
str_contains( $accept, 'application/ld+json' )