updated plugin ActivityPub version 3.3.3

This commit is contained in:
2024-10-09 12:44:17 +00:00
committed by Gitium
parent fb4b27bbc6
commit c54fa007bd
106 changed files with 7070 additions and 2918 deletions

View File

@ -1,36 +1,50 @@
<?php
/**
* BuddyPress integration class file.
*
* @package Activitypub
*/
namespace Activitypub\Integration;
/**
* Compatibility with the BuddyPress plugin
* Compatibility with the BuddyPress plugin.
*
* @see https://buddypress.org/
*/
class Buddypress {
/**
* Initialize the class, registering WordPress hooks
* Initialize the class, registering WordPress hooks.
*/
public static function init() {
\add_filter( 'activitypub_json_author_array', array( self::class, 'add_user_metadata' ), 11, 2 );
}
public static function add_user_metadata( $object, $author_id ) {
$object->url = bp_core_get_user_domain( $author_id ); //add BP member profile URL as user URL
/**
* Add BuddyPress user metadata to the author array.
*
* @param object $author The author object.
* @param int $author_id The author ID.
*
* @return object The author object.
*/
public static function add_user_metadata( $author, $author_id ) {
$author->url = bp_core_get_user_domain( $author_id ); // Add BP member profile URL as user URL.
// add BuddyPress' cover_image instead of WordPress' header_image
// Add BuddyPress' cover_image instead of WordPress' header_image.
$cover_image_url = bp_attachments_get_attachment( 'url', array( 'item_id' => $author_id ) );
if ( $cover_image_url ) {
$object->image = array(
$author->image = array(
'type' => 'Image',
'url' => $cover_image_url,
);
}
// change profile URL to BuddyPress' profile URL
$object->attachment['profile_url'] = array(
'type' => 'PropertyValue',
'name' => \__( 'Profile', 'activitypub' ),
// Change profile URL to BuddyPress' profile URL.
$author->attachment['profile_url'] = array(
'type' => 'PropertyValue',
'name' => \__( 'Profile', 'activitypub' ),
'value' => \html_entity_decode(
sprintf(
'<a rel="me" title="%s" target="_blank" href="%s">%s</a>',
@ -43,18 +57,18 @@ class Buddypress {
),
);
// replace blog URL on multisite
// 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
$user_blogs = get_blogs_of_user( $author_id ); // Get sites of user to send as AP metadata.
if ( ! empty( $user_blogs ) ) {
unset( $object->attachment['blog_url'] );
unset( $author->attachment['blog_url'] );
foreach ( $user_blogs as $blog ) {
if ( 1 !== $blog->userblog_id ) {
$object->attachment[] = array(
'type' => 'PropertyValue',
'name' => $blog->blogname,
$author->attachment[] = array(
'type' => 'PropertyValue',
'name' => $blog->blogname,
'value' => \html_entity_decode(
sprintf(
'<a rel="me" title="%s" target="_blank" href="%s">%s</a>',
@ -71,6 +85,6 @@ class Buddypress {
}
}
return $object;
return $author;
}
}