updated plugin ActivityPub
version 0.13.2
This commit is contained in:
parent
ca0d11e8cb
commit
a3fd251a0c
@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: ActivityPub
|
* Plugin Name: ActivityPub
|
||||||
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
|
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
|
||||||
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
|
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
|
||||||
* Version: 0.13.1
|
* Version: 0.13.2
|
||||||
* Author: Matthias Pfefferle
|
* Author: Matthias Pfefferle
|
||||||
* Author URI: https://notiz.blog/
|
* Author URI: https://notiz.blog/
|
||||||
* License: MIT
|
* License: MIT
|
||||||
@ -106,3 +106,12 @@ function flush_rewrite_rules() {
|
|||||||
}
|
}
|
||||||
\register_activation_hook( __FILE__, '\Activitypub\flush_rewrite_rules' );
|
\register_activation_hook( __FILE__, '\Activitypub\flush_rewrite_rules' );
|
||||||
\register_deactivation_hook( __FILE__, '\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' );
|
||||||
|
@ -139,6 +139,7 @@ class Inbox {
|
|||||||
|
|
||||||
$data = $request->get_params();
|
$data = $request->get_params();
|
||||||
$type = $request->get_param( 'type' );
|
$type = $request->get_param( 'type' );
|
||||||
|
$type = \strtolower( $type );
|
||||||
|
|
||||||
\do_action( 'activitypub_inbox', $data, $user_id, $type );
|
\do_action( 'activitypub_inbox', $data, $user_id, $type );
|
||||||
\do_action( "activitypub_inbox_{$type}", $data, $user_id );
|
\do_action( "activitypub_inbox_{$type}", $data, $user_id );
|
||||||
@ -173,6 +174,8 @@ class Inbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $users as $user ) {
|
foreach ( $users as $user ) {
|
||||||
|
$type = \strtolower( $type );
|
||||||
|
|
||||||
\do_action( 'activitypub_inbox', $data, $user->ID, $type );
|
\do_action( 'activitypub_inbox', $data, $user->ID, $type );
|
||||||
\do_action( "activitypub_inbox_{$type}", $data, $user->ID );
|
\do_action( "activitypub_inbox_{$type}", $data, $user->ID );
|
||||||
}
|
}
|
||||||
@ -216,9 +219,9 @@ class Inbox {
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
//'type' => 'enum',
|
//'type' => 'enum',
|
||||||
//'enum' => array( 'Create' ),
|
//'enum' => array( 'Create' ),
|
||||||
'sanitize_callback' => function( $param, $request, $key ) {
|
//'sanitize_callback' => function( $param, $request, $key ) {
|
||||||
return \strtolower( $param );
|
// return \strtolower( $param );
|
||||||
},
|
//},
|
||||||
);
|
);
|
||||||
|
|
||||||
$params['object'] = array(
|
$params['object'] = array(
|
||||||
@ -261,9 +264,9 @@ class Inbox {
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
//'type' => 'enum',
|
//'type' => 'enum',
|
||||||
//'enum' => array( 'Create' ),
|
//'enum' => array( 'Create' ),
|
||||||
'sanitize_callback' => function( $param, $request, $key ) {
|
//'sanitize_callback' => function( $param, $request, $key ) {
|
||||||
return \strtolower( $param );
|
// return \strtolower( $param );
|
||||||
},
|
//},
|
||||||
);
|
);
|
||||||
|
|
||||||
$params['object'] = array(
|
$params['object'] = array(
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
namespace Activitypub\Integration;
|
||||||
|
|
||||||
|
class Buddypress {
|
||||||
|
public static function init() {
|
||||||
|
\add_filter( 'activitypub_json_author_array', array( 'Activitypub\Integration\Buddypress', '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' 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(
|
||||||
|
'<a rel="me" title="' . \esc_attr( bp_core_get_user_domain( $author_id ) ) . '" target="_blank" href="' . \bp_core_get_user_domain( $author_id ) . '">' . \wp_parse_url( \bp_core_get_user_domain( $author_id ), \PHP_URL_HOST ) . '</a>',
|
||||||
|
\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(
|
||||||
|
'<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'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ Donate link: https://notiz.blog/donate/
|
|||||||
Tags: OStatus, fediverse, activitypub, activitystream
|
Tags: OStatus, fediverse, activitypub, activitystream
|
||||||
Requires at least: 4.7
|
Requires at least: 4.7
|
||||||
Tested up to: 5.8
|
Tested up to: 5.8
|
||||||
Stable tag: 0.13.1
|
Stable tag: 0.13.2
|
||||||
Requires PHP: 5.6
|
Requires PHP: 5.6
|
||||||
License: MIT
|
License: MIT
|
||||||
License URI: http://opensource.org/licenses/MIT
|
License URI: http://opensource.org/licenses/MIT
|
||||||
@ -88,6 +88,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides.
|
|||||||
|
|
||||||
Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
|
Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
|
||||||
|
|
||||||
|
= 0.13.2 =
|
||||||
|
|
||||||
|
* fix Follow issue AGAIN
|
||||||
|
|
||||||
= 0.13.1 =
|
= 0.13.1 =
|
||||||
|
|
||||||
* fix Inbox issue
|
* fix Inbox issue
|
||||||
|
@ -43,7 +43,7 @@ $json->publicKey = array(
|
|||||||
$json->tag = array();
|
$json->tag = array();
|
||||||
$json->attachment = array();
|
$json->attachment = array();
|
||||||
|
|
||||||
$json->attachment[] = array(
|
$json->attachment['blog_url'] = array(
|
||||||
'type' => 'PropertyValue',
|
'type' => 'PropertyValue',
|
||||||
'name' => \__( 'Blog', 'activitypub' ),
|
'name' => \__( 'Blog', 'activitypub' ),
|
||||||
'value' => \html_entity_decode(
|
'value' => \html_entity_decode(
|
||||||
@ -53,7 +53,7 @@ $json->attachment[] = array(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$json->attachment[] = array(
|
$json->attachment['profile_url'] = array(
|
||||||
'type' => 'PropertyValue',
|
'type' => 'PropertyValue',
|
||||||
'name' => \__( 'Profile', 'activitypub' ),
|
'name' => \__( 'Profile', 'activitypub' ),
|
||||||
'value' => \html_entity_decode(
|
'value' => \html_entity_decode(
|
||||||
@ -64,7 +64,7 @@ $json->attachment[] = array(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ( \get_the_author_meta( 'user_url', $author_id ) ) {
|
if ( \get_the_author_meta( 'user_url', $author_id ) ) {
|
||||||
$json->attachment[] = array(
|
$json->attachment['user_url'] = array(
|
||||||
'type' => 'PropertyValue',
|
'type' => 'PropertyValue',
|
||||||
'name' => \__( 'Website', 'activitypub' ),
|
'name' => \__( 'Website', 'activitypub' ),
|
||||||
'value' => \html_entity_decode(
|
'value' => \html_entity_decode(
|
||||||
@ -84,6 +84,9 @@ $json->endpoints = array(
|
|||||||
// filter output
|
// filter output
|
||||||
$json = \apply_filters( 'activitypub_json_author_array', $json, $author_id );
|
$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
|
* Action triggerd prior to the ActivityPub profile being created and sent to the client
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user