janboddez / addon-for-activitypub

ActivityPub add-on plugin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActivityPub Add-on

Somewhat modifies the ActivityPub plugin’s behavior. Probably not ready for production. 😆

All features can be switched on or off separately. All of this is subject to change. No warranties whatsoever.

Options

Local-only Category

Posts (of any post type, as long as it supports WordPress’ built-in categories) in this category will not get “federated” and remain “local-only.”

Unlisted Category

Posts in this category will appear “unlisted” (or “less public”) on various Fediverse instances. (Whether you also hide these posts on, e.g., your site’s homepage, is up to you!)

To instead use, e.g., a custom field or post format, to decide if a post should be “unlisted,” there’s this filter (which takes precedence over whatever category, if any, was selected):

add_filter( 'addon_for_activitypub_is_unlisted', function ( $is_unlisted, $post_or_comment ) {
  if ( $post_or_comment instanceof \WP_Post && has_post_format( 'aside', $post_or_comment ) ) {
    return true;
  }

  return $is_unlisted;
}, 10, 2 );

Unlisted Comments

Have (all) comments appear “unlisted.” (Not sure if this is in any way useful, but, “Why not?”)

Edit Notifications

Receive an email when an earlier “Fediverse” comment is modified.

Limit Updates

Don’t send Update activities when nothing’s changed. (Note that “nothing” is rather relative here. E.g., an Update might still get federated even if a post’s ActivityPub representation, which could contain only an excerpt, hasn’t actually changed, but the “real” post content did. Also, this whole thing might conflict with how you’ve set up ActivityPub, so beware.)

Enable “Replies”

While the ActivityPub plugin will “federate” your replies to “Fediverse” comments, it does not (yet) support outright replying to others’ posts.

This setting addresses that, but only for posts marked up as replies. (It will attempt to detect if the “target post” supports the ActivityPub protocol. If so, the target post’s author will receive a notification, and your reply will appear “correctly threaded” on other Fediverse instances, too.)

Enable “Reposts”

Similar to replies; This should translate “reposts” into “boosts” (or “reblogs”) on Mastodon and other Fediverse platforms.

Content Templates

This plugin also adds “post type templates.” There’s no separate setting for them.

Either one or more template files exist—or not.

Template files go in your (child) theme, and may be called, e.g., wp-content/themes/your-child-theme/activitypub/content-{$post->post_type}.php. Here’s one example called content-indieblocks_note.php, for a custom post type with an indieblocks_note slug:

<?php

if ( ! defined( 'ABSPATH' ) ) {
  exit;
}
?>

<?php echo apply_filters( 'the_content', $post->post_content ); ?>
<p><a href="<?php echo esc_url( get_permalink( $post ) ); ?>"><?php echo esc_html( get_permalink( $post ) ); ?></a></p>

The idea here is that you could append custom fields and whatnot.

User Profiles

These are somewhat like the “post type templates” above.

In this case, the plugin would look for a file called wp-content/themes/your-child-theme/activitypub/profile-user-{$user->ID}.php.

Big difference with “content templates” is that this file has to return an array, which can hold up to 4 fields.

Here’s one example called profile-user-3.php, for the user with ID 3:

<?php

// Prevent direct access.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

return array(
	'Blog'        => home_url(),
	'IndieBlocks' => 'https://indieblocks.xyz',
	'Feed Reader' => 'https://feedreader.site',
	'Location'    => '🇧🇪🇳🇱',
);

About

ActivityPub add-on plugin.

License:GNU General Public License v3.0


Languages

Language:PHP 99.5%Language:Shell 0.5%