diff --git a/activitypub.php b/activitypub.php
index a52a6d5..41188af 100644
--- a/activitypub.php
+++ b/activitypub.php
@@ -106,3 +106,12 @@ function flush_rewrite_rules() {
}
\register_activation_hook( __FILE__, '\Activitypub\flush_rewrite_rules' );
\register_deactivation_hook( __FILE__, '\flush_rewrite_rules' );
+
+/**
+ * Only load code that needs BuddyPress to run once BP is loaded and initialized.
+ */
+function enable_buddypress_features() {
+ require_once \dirname( __FILE__ ) . '/integration/class-buddypress.php';
+ \Activitypub\Integration\Buddypress::init();
+}
+add_action( 'bp_include', '\Activitypub\enable_buddypress_features' );
diff --git a/integration/class-buddypress.php b/integration/class-buddypress.php
new file mode 100644
index 0000000..1087f47
--- /dev/null
+++ b/integration/class-buddypress.php
@@ -0,0 +1,58 @@
+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
+ $cover_image_url = bp_attachments_get_attachment( 'url', array( 'item_id' => $author_id ) );
+
+ if ( $cover_image_url ) {
+ $object->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' ),
+ 'value' => \html_entity_decode(
+ '' . \wp_parse_url( \bp_core_get_user_domain( $author_id ), \PHP_URL_HOST ) . '',
+ \ENT_QUOTES,
+ 'UTF-8'
+ ),
+ );
+
+ // 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 ( ! empty( $user_blogs ) ) {
+ unset( $object->attachment['blog_url'] );
+
+ foreach ( $user_blogs as $blog ) {
+ if ( 1 !== $blog->userblog_id ) {
+ $object->attachment[] = array(
+ 'type' => 'PropertyValue',
+ 'name' => $blog->blogname,
+ 'value' => \html_entity_decode(
+ '' . \wp_parse_url( $blog->siteurl, \PHP_URL_HOST ) . '',
+ \ENT_QUOTES,
+ 'UTF-8'
+ ),
+ );
+ }
+ }
+ }
+ }
+
+ return $object;
+ }
+}
diff --git a/templates/author-json.php b/templates/author-json.php
index ccaa167..c5d39a5 100644
--- a/templates/author-json.php
+++ b/templates/author-json.php
@@ -43,7 +43,7 @@ $json->publicKey = array(
$json->tag = array();
$json->attachment = array();
-$json->attachment[] = array(
+$json->attachment['blog_url'] = array(
'type' => 'PropertyValue',
'name' => \__( 'Blog', 'activitypub' ),
'value' => \html_entity_decode(
@@ -53,7 +53,7 @@ $json->attachment[] = array(
),
);
-$json->attachment[] = array(
+$json->attachment['profile_url'] = array(
'type' => 'PropertyValue',
'name' => \__( 'Profile', 'activitypub' ),
'value' => \html_entity_decode(
@@ -64,7 +64,7 @@ $json->attachment[] = array(
);
if ( \get_the_author_meta( 'user_url', $author_id ) ) {
- $json->attachment[] = array(
+ $json->attachment['user_url'] = array(
'type' => 'PropertyValue',
'name' => \__( 'Website', 'activitypub' ),
'value' => \html_entity_decode(
@@ -84,6 +84,9 @@ $json->endpoints = array(
// filter output
$json = \apply_filters( 'activitypub_json_author_array', $json, $author_id );
+// migrate to ActivityPub standard
+$json->attachment = array_values( $json->attachment );
+
/*
* Action triggerd prior to the ActivityPub profile being created and sent to the client
*/