Skip to content

stefanbohacek/fediverse-embeds-wordpress-plugin

Repository files navigation

Preview of multiple posts embedded with the Fediverse Embeds plugin.

Fediverse Embeds

Embed fediverse posts on your WordPress site. You can download it from the WordPress plugin directory, and read about the motivation behind this project on my blog.

Feedback and help will be very appreciated!

A few examples of the plugin in use:

Features

  • Show or hide post metrics

Two side-by-side screenshots comparing the same post with and without the number of likes/favorites, boosts/re-shares, and replies.

  • Automatic dark and light theme

A diagonally split screenshot of an embedded post, showing a light and dark version.

  • Labels for bots 🤖 and server admins 👑 (optional)
  • Labels for updated 📝 and deleted posts 🗑️ (see notes on how deleted posts are handled)

How to use

  1. Download and install the plugin.
  2. Add the embed code to your post.

Supported platforms

This plugin only works with fediverse platforms that provide embed code. This way, if you ever decide to stop using the plugin, your embeds will still work.

As more platforms add this feature, this plugin will continue to get updated.

Platform Supported
Mastodon ✔️ How to embed
Pleroma
Akkoma
Friendica
Misskey #17
Calckey #16
Peertube #2
Pixelfed #14

Privacy notice

When embedding a post from a fediverse server, the content of the post needs to be fetched from that server, which is then stored in your site's database. Based on the way you configure the plugin, additional requests will be made periodically to refresh the cached data.

When making requests to a third party server in general, the server will receive and may record the IP address of the server hosting your website.

Development

# install dependencies
npm install
# build front-end scripts and styles
npm run dev
# when adding new PHP classes inside `includes`
composer dumpautoload -o 

FAQ

Images or posts are not loading

Embed code

Please make sure to copy the full embed code, including the iframe and the script tag.

API Endpoints

Please make sure that you're not blocking /wp-json/ftf/* endpoints, either via a plugin like Disable WP REST API, or through server configuration or your firewall.

Note that individual servers have an option to prevent this plugin from loading data, see more details below.

How can I run my own code after all embeds are processed?

The plugin fires a custom ftf_fediverse_embeds_posts_processed event that passes the list of processed embeds. Here's an example of how it can be used:

document.addEventListener('ftf_fediverse_embeds_posts_processed', (event) => {
    // All embeds are ready.
    event.detail.forEach(embed => {
        // Do something with each embed.
    });
});

Or with jQuery:

$(document).on('ftf_fediverse_embeds_processed', () => {
    // All embeds are ready.
    $('.fediverse-post').each(() => {
        const $post = $(this);
        // Do something with each embed.
    });
});

How do I prevent this plugin from embedding my posts?

The plugin will use the following user agent when making requests to your fediverse servers:

FTF: Fediverse Embeds; WordPress/VERSION; https://WEBSITE.COM

VERSION is the version of the WordPress website making the request, and WEBSITE.COM is its URL, this is the default user agent used by WordPress.

The admin of your instance can then block any requests where the user agent contains FTF: Fediverse Embeds.