Replies: 7 comments 4 replies
-
The question, now… where do we put that code in our version of the plugin? (this is probably a noob question, since I’m new to the PHP language itself.) Well, new to both PHP development and WP development in general. I am asking this because I was originally thinking of doing a Pleroma instance or a Friendica community for one of my community pages… but I think I might do a BuddyPress with AP integration instead…
From: Evan ***@***.***>
Sent: Friday, September 10, 2021 12:25 PM
To: pfefferle/wordpress-activitypub ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [pfefferle/wordpress-activitypub] Buddypress Integration (Discussion #131)
Hi! We started a discussion in the pull request thread for #122<#122> on general integration with Buddypress, using the available filters in the plugin. I thought it would make sense to move that conversation here so that we can have a proper space for it.
I will start by taking the code I shared in the thread and reducing it only to the code that would work for any buddypress instance (I will also keep the code that adds blogs of the user's sites, if the site is a multisite).
`function activitypub_metadata ($json, $author_id) {
$json = json_decode(json_encode($json), true);
//add BP member profile URL as user URL
$json['url'] = bp_core_get_user_domain( $author_id );
$cover_image_url = bp_attachments_get_attachment( 'url', array( 'item_id' => $author_id ) );
if ( $cover_image_url ) {
$json['image'] = array(
'type' => 'Image',
'url' => $cover_image_url,
);
}
//set up array for attachment data
$activitypub_meta = array();
//add specific metadata here
if (is_multisite()) {
$user_blogs = get_blogs_of_user($author_id); //get sites of user to send as AP metadata
foreach($user_blogs as $blog) {
if ($blog->userblog_id != 1) {
$activitypub_meta[] = array (
'type' => 'PropertyValue',
'name' => \__($blog->blogname, 'activitypub'),
'value' => \html_entity_decode(
'<a rel="me" title="' . \esc_attr( $blog->siteurl ) . '" target="_blank" href="' .$blog->siteurl. '">' . \wp_parse_url( $blog->siteurl, \PHP_URL_HOST ) . '</a>',
\ENT_QUOTES,
'UTF-8'
),
);
}
}
}
$json['attachment'] = $activitypub_meta;
return $json;
}
add_filter( 'activitypub_json_author_array', 'activitypub_metadata', 11, 2 );`
This code will :
* Change the AP URL to the Buddypress Member Profile instead of the Author archive URL
* Set the user's cover image (if they set one) as the AP header image (Mastodon cover image)
* If the site is a multisite, loop through the sites the user has created and pass them as AP metadata.
There is definitely still work that can be done here, specifically for the metadata, and deciding what metadata to pass, and how to make it flexible for different instances. But it's a good start, I think!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#131>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADS4MAGGSJO5KFVOZDGUNVLUBIWOJANCNFSM5DZVMCNQ>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Nom… I smell an upgrade somewhere? New feature, perhaps? (in other words, making the plugin support two-way AP… hence making WP+BP+AP yet another way of setting up a social network.) If I could implement it myself, believe me, I would.
From: Evan ***@***.***>
Sent: Sunday, September 12, 2021 11:02 AM
To: pfefferle/wordpress-activitypub ***@***.***>
Cc: Katherine M. Moss ***@***.***>; Comment ***@***.***>
Subject: Re: [pfefferle/wordpress-activitypub] Buddypress Integration (Discussion #131)
No problem :) I'd say the best place to put it would be creating a file called "bp-custom.php" in your plugins directory (wp-content/plugins) . This is a standard practice for adding custom code to Buddypress.
Another option, if you have a child theme, is to put the code in your functions.php file. This would have the code work at the theme level (when you have the theme activated on your site).
Just a heads up that AP integration via this plugin is only one-way. Users can be followed on the fediverse, but they can't follow fediverse users, or discover those users through Wordpress. Depending on your needs, if you are looking for a fully capable Activity Pub social network, Pleroma might be a better option.
Depending on what you want, of course! Plenty of interesting reasons to want to use BP as well.
The question, now… where do we put that code in our version of the plugin? (this is probably a noob question, since I’m new to the PHP language itself.) Well, new to both PHP development and WP development in general. I am asking this because I was originally thinking of doing a Pleroma instance or a Friendica community for one of my community pages… but I think I might do a BuddyPress with AP integration instead… From: Evan @.> Sent: Friday, September 10, 2021 12:25 PM To: pfefferle/wordpress-activitypub @.> Cc: Subscribed @.***> Subject: [pfefferle/wordpress-activitypub] Buddypress Integration (Discussion #131 <#131> ) Hi! We started a discussion in the pull request thread for #122 <#122> <#122 <#122> > on general integration with Buddypress, using the available filters in the plugin. I thought it would make sense to move that conversation here so that we can have a proper space for it. I will start by taking the code I shared in the thread and reducing it only to the code that would work for any buddypress instance (I will also keep the code that adds blogs of the user's sites, if the site is a multisite). function activitypub_metadata ($json, $author_id) { $json = json_decode(json_encode($json), true); //add BP member profile URL as user URL $json['url'] = bp_core_get_user_domain( $author_id ); $cover_image_url = bp_attachments_get_attachment( 'url', array( 'item_id' => $author_id ) ); if ( $cover_image_url ) { $json['image'] = array( 'type' => 'Image', 'url' => $cover_image_url, ); } //set up array for attachment data $activitypub_meta = array(); //add specific metadata here if (is_multisite()) { $user_blogs = get_blogs_of_user($author_id); //get sites of user to send as AP metadata foreach($user_blogs as $blog) { if ($blog->userblog_id != 1) { $activitypub_meta[] = array ( 'type' => 'PropertyValue', 'name' => \__($blog->blogname, 'activitypub'), 'value' => \html_entity_decode( '<a rel="me" title="' . \esc_attr( $blog->siteurl ) . '" target="_blank" href="' .$blog->siteurl. '">' . \wp_parse_url( $blog->siteurl, \PHP_URL_HOST ) . '</a>', \ENT_QUOTES, 'UTF-8' ), ); } } } $json['attachment'] = $activitypub_meta; return $json; } add_filter( 'activitypub_json_author_array', 'activitypub_metadata', 11, 2 ); This code will : * Change the AP URL to the Buddypress Member Profile instead of the Author archive URL * Set the user's cover image (if they set one) as the AP header image (Mastodon cover image) * If the site is a multisite, loop through the sites the user has created and pass them as AP metadata. There is definitely still work that can be done here, specifically for the metadata, and deciding what metadata to pass, and how to make it flexible for different instances. But it's a good start, I think! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub<#131 <#131> >, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADS4MAGGSJO5KFVOZDGUNVLUBIWOJANCNFSM5DZVMCNQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#131 (reply in thread)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADS4MAECLXNSLFC2IJUQRYDUBS6GLANCNFSM5DZVMCNQ> . <https://github.com/notifications/beacon/ADS4MAFOE6LKNGFLYA6QFQTUBS6GLA5CNFSM5DZVMCN2YY3PNVWWK3TUL52HS4DFWFCGS43DOVZXG2LPNZBW63LNMVXHJKTDN5WW2ZLOORPWSZGOAAKAPZQ.gif>
…-----BEGIN PGP SIGNATURE-----
iQaCBAEBCAVsFiEE2SSXi3YXhPCskJuQHUvM2VMHPsUFAmE+wivEjSYAmQENBGDp
9YoBCACf5izwK7hQt5btl4HSv/NVmQasIrWkJ32IlTxA94A5rEYwQftY0DykZSUC
oyBg8pck2AF+fnQG+WOJJ1L5Q0zmS0lraQmOT4ej2zb26/2C5K+aeMTCYdGhILeq
B2rdWkKaanT2UxNG9lx22SPRGhjlZFmOJ0zTZ5ODbpR50n8TzSjcEviVn2I6HQzY
nWfuIvKuzdWyDj7JhIbKNLTjcCjUvpte8zukNFdvL43xxIISRdCZyo+fDE+V6wbp
i2jr+27F8UXN2+aFxYJDZr6y4bBbvFxmeI0esrD1qjNw7wQFykC6EETBNBs1OW8H
EQZbT9vN1OUTJs51vqYZUCfCJedFABEBAAG0E2thdDg5ODlAb3V0bG9vay5jb22J
AVQEEwEIAD4WIQTZJJeLdheE8KyQm5AdS8zZUwc+xQUCYOpUqAIbIwUJA8I1dgUL
CQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRAdS8zZUwc+xWLoB/9693/SaU77mYRG
03sDtrAgm5rlM9AEy43d/AfLUwIuXG7BGRyzTvZMEacbxOPtT0KOfJcGGSThqkix
kUYWuuYFazJO8l7JEET+ZuZ4zkRVQbHSvFvdfnA3a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CnWyHu31fbcZl1oyMPOshCrxzApC35oieBIa1nfgVdSd7RnB7nK9hhGq
F6rqLgE0VmWmsZxtSKkxUPEb5IZ+sKotZl7nNEnH8VgFEKJfaRlJUR5rRzVvSbsN
VNhkQEkACgkQHUvM2VMHPsWdvwf+LcWGuRwKB4BoCqLcvS7SseVz8xh14xfxhuYq
tsfKZdB5L+WhnXX2qfuohyaDypsOmakyiQr3uha16cvj1RKCV5HdAP7DUt0YEN+g
daj8VitBTsJAFA88kmqLpa2W6b05xbFgGI5wsxbeJBbmhfE4h7pVJ6xPBB99bcFK
EZuSoIOhy5DiqT1Xs3/nfHaj2xCQcEyqn4rEWQ19fF4SBdSBNbKXMhzkWlmB8Hlq
K2cn+P7FyUaU1lmKV1UrN4FOj5K/UrXbOOUEaHquNIep/g10odle2Ll04mbvw5fg
hGtdIs/haiimyfd/1YGqovpWPSAAdXuGMSEJvAvKGX4aZZKU4A==
=ztTA
-----END PGP SIGNATURE-----
|
Beta Was this translation helpful? Give feedback.
-
I would love to add this code to the plugin directly. Is there a simple way to check if a WordPress installation has BuddyPress enabled? |
Beta Was this translation helpful? Give feedback.
-
@skysarwer do I simply have to install the BuddyPress plugin to check your code? |
Beta Was this translation helpful? Give feedback.
-
Awesome!
From: Evan ***@***.***>
Sent: Wednesday, September 15, 2021 10:06 AM
To: pfefferle/wordpress-activitypub ***@***.***>
Cc: Katherine M. Moss ***@***.***>; Comment ***@***.***>
Subject: Re: [pfefferle/wordpress-activitypub] Buddypress Integration (Discussion #131)
Yes!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#131 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADS4MAGEASQWAWUO3ZUJDB3UCCR4ZANCNFSM5DZVMCNQ>.
|
Beta Was this translation helpful? Give feedback.
-
Just submitted a proposal based on the code of @skysarwer #132 |
Beta Was this translation helpful? Give feedback.
-
I see #132 seems to work for authors of a blog but what about just regular BuddyPress users? Is this a level of integration that is possible/wanted, at least optionally? I would love to be able to give users the option of publishing their posts to AP on a post-by-post basis. |
Beta Was this translation helpful? Give feedback.
-
Hi! We started a discussion in the pull request thread for #122 on general integration with Buddypress, using the available filters in the plugin. I thought it would make sense to move that conversation here so that we can have a proper space for it.
I will start by taking the code I shared in the thread and reducing it only to the code that would work for any buddypress instance (I will also keep the code that adds blogs of the user's sites, if the site is a multisite).
This code will :
There is definitely still work that can be done here, specifically for the metadata, and deciding what metadata to pass, and how to make it flexible for different instances. But it's a good start, I think!
Beta Was this translation helpful? Give feedback.
All reactions