Skip to content

Commit 2c11001

Browse files
authored
Merge pull request #54 from OpenSourceOrg/add/activitypub-migration
Add Actor migration
2 parents fdad000 + ae7d46d commit 2c11001

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ plugins/*
1616

1717
mu-plugins/*
1818
!mu-plugins/mu-autoloader.php
19+
!mu-plugins/activitypub-migration.php
1920
!mu-plugins/osi-event-list
2021
!mu-plugins/osi-sponsors-list
2122
!websub-compat.php
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Plugin Name: ActivityPub Migration
4+
* Plugin Description: Adds the `blog.opensource.org` to the Actors `alsoKnownAs` list.
5+
* Version: 1.0.0
6+
* Author: WordPress.com Special Projects
7+
* Author URI: https://wpspecialprojects.wordpress.com/
8+
*/
9+
10+
if ( ! defined( 'ABSPATH' ) ) {
11+
return;
12+
}
13+
14+
/**
15+
* Adds the `blog.opensource.org` to the Actors `alsoKnownAs` list.
16+
*
17+
* @param array $actor Actor as Array.
18+
*
19+
* @return array $actor Filtered Actor Array.
20+
*/
21+
function activitypub_actor_migration( array $actor ) {
22+
if ( ! $actor ) {
23+
return $actor;
24+
}
25+
26+
$host = wp_parse_url( get_home_url(), PHP_URL_HOST );
27+
$id = str_replace( $host, 'blog.' . $host, $actor['id'] );
28+
29+
$actor['alsoKnownAs'] = array( $id );
30+
return $actor;
31+
}
32+
add_filter( 'activitypub_activity_user_object_array', 'activitypub_actor_migration' );

0 commit comments

Comments
 (0)