Tag: fediwp26

New features in ActivityPub plugin version 1.0

After a lot of work, version 1.0 of the ActivityPub plugin for WordPress was released. The overall usability has been improved and some of the most requested features were implemented.

The biggest addition is the blog-wide ActivityPub profile. And you can freely set the ID for it. Before you could only follow individual WordPress accounts. That is bit of a hassle, if you want to see all posts. Now you can even decide if authors can be followed or not. So you have more control over which profiles are active.

Screenshot of the profiles settings

A big question for a lot of people is, how you can follow someone and who is following authors. This information was only available in the WordPress admin interface, but now you can add 2 blocks to your website:

  • Fediverse Followers
  • Follow me on the Fediverse

The blocks can also be used as widgets in classic themes, not just in block themes.

ActivityPub blocks in the widget area of the WordPress Customizer

Unfortunately, using these blocks have a significant performance impact, loading almost 2 MB of JavaScript. I will not be using them for now. A GitHub issue was already raised. Hopefully this will improve soon.

Of course, a lot of minor improvements and fixes were included in version 1.0. Have a look at the changelog for a full list. And version 1.0.1 has quickly followed the initial release.

Writing blog posts for ActivityPub

Should ActivityPub posts be written differently from blog posts? That is the question I’m asking myself since posting to the Fediverse with WordPress.

For wee.press I started with the regular settings of the ActivityPub plugin. Turns out that by default the full content is posted, minus some formatting.

Post in Mastodon starting with: This WordPress site uses the ActivityPub plugin …

A couple of things stood out to me:

  • The title of the post wasn’t included. Blog posts have titles, but Mastodon posts don’t. So that makes some kind of sense.
  • People will read posts in an app. Saying “This WordPress site” makes little sense, when it appears on someone’s timeline. Spelling out the site name makes it more clear in other contexts.
  • Full posts are uncommon on Mastodon and similar ActivityPub services.

Luckily, you can customise the output for ActivityPub. I changed it to include the title and a link to the article. Most people will be used to seeing short posts. Personally, I prefer not to see the long posts inside the timeline, because it disrupts the reading flow when scrolling. Also long texts differ too much from typical posts.

ActivityPub settings for: Post-Content, Number of images, Activity-Object-Type, Supported post types

I also added hash tags and hash categories, because this way it can be easier found on Mastodon. I have to admit that it took me a couple of seconds to realise what “hashcats” stands for 😸 The hash tags are plain text, so they support the native functionality in apps. The plugin has the ability to link to the WordPress tag page, but I doubt I will ever use that.

The default for attached images is 3, but I changed that to 1. My posts focus mostly on writing about WordPress and less showing lots of photos or screenshots.

Pages are not that interesting in timelines, so I only enabled posts to get listed.

I still have to look into how WordPress post formats work. In the past this wasn’t very useful to me, so I never used them. But with ActivityPub this functionality might make more sense. I guess I have to read up on how Activity-Object-Types are intended to be used.

It would be nice to have the ability to select the output for each post individually. If I post photos from an event, I probably would want to post all photos. Or occasionally add an extra link or a handle, not just the article URL. How I would like to post, will likely evolve over time, as I get more experienced using ActivityPub.

Fixing a Surge cache issue with ActivityPub

wee.press is a WordPress site that uses the ActivityPub plugin to add functionality to interact with Fediverse platforms, like Mastodon. This makes it possible for people to directly follow posts without visiting the web site. But after my last post, some people told me that the post was returning raw code, not the regular web page. Oh no 😱!

I suspected this could be caused by caching. Only sometimes the post was displaying code. And this is a typical issue, because there are only two hard problems in computer science:

  1. Cache invalidation
  2. Naming things
  3. Off-by-one errors

This site uses the Surge caching plugin. I remembered reading about this problem somewhere. After some duckduckgoing, I found the post that Dominik Schilling wrote about the HTTP Accept header. Turns out that you can save different caches based on the requested content. For ActivityPub this would be application/activity+json, and not text/html.

To change the caching behaviour for Surge, you will have to create a caching file. You are free to name this file and where to put it. For example, you can call it cache-config.php and put it next to the wp-config.php file. In this file you can define the different variants that should be cached. For this site, a variant for html (the default) and json are defined. Below is the code to achieve this.

<?php
$config['variants']['representation'] = 'html';
if (
  isset( $_SERVER['HTTP_ACCEPT'] ) &&
  preg_match(
    '%^application\/((activity|ld)\+)?json$%i',
    $_SERVER['HTTP_ACCEPT']
  ) 
) { 
  $config['variants']['representation'] = 'json';
}

return $config; 

To activate the file, you will have define the location of the caching file in the wp-config.php.

define( 'WP_CACHE_CONFIG', __DIR__ . '/cache-config.php' );

WP_CACHE_CONFIG is a specific setting for the Surge plugin, not a global setting, despite what the name might suggest.

So now all problems are gone (hopefully) and you can read the posts like you would expect.

Using WordPress as an ActivityPub instance

ActivityPub is a W3C standard, I mean recommendation. And WordPress supports it! Not by default, but for now, with a plugin. So, what does that mean? And why should you care?

With the ActivityPub protocol you can publish posts and automatically send notifications to people who follow your blog. People can also comment on your posts. Lots of platforms support it, including Mastodon, Pleroma, MissKey, Calckey Firefish, and others. And there are rumours that more networks will support it soon: Tumblr, Threads by Instagram/Facebook/Meta?

The power of ActivityPub is that any system can use it and also talk to other systems. So people can follow your WordPress posts on Mastodon. It’s kind of like subscribing to a RSS feed, but with the possibility to comment. This is often called the Fediverse, although some people say that the Fediverse is broader than just ActivityPub.

Most implementations have a Twitter-like feel, but there are systems that have a different use case:

  • Pixelfed, for photos/images (like Instagram).
  • WriteFreely, for writing.
  • Lemmy, for links (like Reddit).
  • Mobilizon, for events (like Facebook Events or Meetup.com).
  • PeerTube, for videos (like YouTube).
  • Owncast, for live streaming (like Twitch)
  • Funkwhale, for podcasts and music (like Spotify).

The WordPress plugin is mainly focusing on the publishing part of the protocol. Reactions are handled like WordPress comments. It’s not intended to follow other accounts. The plugin is under active development, so the functionality might change over time. For now, you can only follow individual authors. So subscribing to all posts by different authors is not possible. But a solution is in the works.

If you want to keep up-to-date, I recommend following the ActivityPub plugin creator @pfefferle@mastodon.social. You can contribute on GitHub, if you want to help to improve the plugin.

So connect your WordPress site with the Fediverse and install the ActivityPub plugin. Be aware that some webhosters might (partially) block ActivityPub. Detected issues will show up in the site health dashboard inside WordPress.

This site supports ActivityPub. You can follow posts @walterebert@wee.press. I’m still trying to learn how to use this thing. Watch this space for updates.