Include Mastodon Feed

Beskrivelse

Plugin der leverer en Gutenberg-blok og en [include-mastodon-feed]-shortcode, så Mastodon-feeds nemt kan integreres på WordPress-sider. Understøtter både personlige feeds og tag-feeds.

Konto- og opslagbilleder lazy-loades, hvis preserveImageAspectRatio er sat til true (standard: false).

Pluginet er skrevet i PHP og genererer JavaScript til at hente og vise Mastodon-feedet. Ingen særlige biblioteker er nødvendige.

Styling fungerer ud af boksen For et flot tilpasset kolonnelayout kan du se den fremragende Columns Guide af @oldrup – med WordPress’ egne Gutenberg-blokke (pattern JSON-fil inkluderet) og lidt CSS-magi.

Blokke

Dette plugin giver 1 blok.

  • Mastodon Feed Embed the latest public posts of a Mastodon user

Installation

  1. Upload mappen “include-mastodon-feed” til mappen “/wp-content/plugins/”.
  2. Aktivér pluginet via menuen “Plugins” i WordPress.
  3. Indsæt blokken “Mastodon Feed” i Gutenberg-editoren eller shortcode “[include-mastodon-feed]” på en vilkårlig side.

Shortcode-eksempel

[include-mastodon-feed instance="YOUR-INSTANCE" account="YOUR-ACCOUNT-ID"]

Shortcode-attributter

  • instance (påkrævet)
    Domænenavn for instansen uden https:// (fx example.org)

  • account (påkrævet)
    Konto-ID (et langt tal – se FAQ for hvordan du finder det)

  • tag
    Brug tag i stedet for account, hvis du vil indlejre et tag-feed i stedet for et personligt feed

  • cache
    Om WordPress skal cache API-kald til Mastodon-serveren (standard: false)
    Bemærk: aktiveres automatisk for feeds, hvor auth bruges

  • auth
    Auth-nøgle der skal bruges, hvis Mastodon-serverens API kræver godkendelse

  • limit
    Maksimalt antal statusser (standard: 20)

  • excludeReplies
    Udeluk svar til andre konti (standard: false)

  • excludeConversationStarters
    Udeluk statusser, der starter med en brugeromtale (standard: false)

  • excludeBoosts
    Udeluk boosted statusser (standard: false)

  • onlyPinned
    Vis kun fastgjorte statusser (standard: false)

  • onlyMedia
    Vis kun statusser, der indeholder medier (standard: false)

  • preserveImageAspectRatio
    Bevar billedformatet (standard: false)

  • imageSize
    Indlæs små preview-billeder eller store billeder i høj kvalitet (standard: preview, full)

  • imageLink
    Link billede til status eller billede (standard: status, image)

  • tagged
    Vis kun statusser, der er tagget med det angivne tagnavn (standard: false)
    Ingen # foran, ikke versalfølsomt, fx: tagged=”tagname”

  • excludeTags
    Udeluk statusser, der er tagget med et af de angivne tagnavne (standard: false)
    Kommasepareret liste af tags, ingen # foran, ikke versalfølsomt, fx: excludeTags=”tag1,tag2″

  • linkTarget
    Mål for alle links, fx vil en ny fane være “_blank” (standard: _self)

  • showPreviewCards
    Vis preview-kort (standard: true)

  • hideStatusMeta
    Skjul status-metaoplysninger; skjuler automatisk også dato og tid (standard: false)

  • hideDateTime
    Skjul dato og tid i status-metaoplysninger (standard: false)

  • darkmode
    Aktiver mørk tilstand (standard: false)

  • text-loading
    Indlæsnings-tekst (standard: Loading Mastodon feed…)

  • text-noStatuses
    Tekst når der ikke er nogen statusser (standard: No statuses available)

  • text-boosted
    Tekst der angiver boosted statusser (standard: boosted 🚀)

  • text-viewOnInstance
    Linktekst til visning af status på instansen (standard: view on instance)

  • text-showContent
    Tekst til indholdsadvarselsknapper (standard: Show content)

  • text-permalinkPre
    Tekst før opslagets permalink (dato & tid) (standard: on)

  • text-permalinkPost
    Tekst efter opslagets permalink (dato & tid) (standard: )

  • text-edited
    Tekst der angiver redigerede opslag (standard: (edited))

  • date-locale
    Locale for datostrengen, brugt i toLocaleString() (standard: en-US)

Yderligere tilpasninger

Du kan definere flere plugin-konstanter for at sætte tilpassede standardindstillinger, der gælder på hele sitet (fx kan datoindstillinger kun sættes som PHP-konstant for at afhjælpe en XSS-sårbarhed).

  1. Åbn din wp-config.php-fil
  2. Find linjen /* Add any custom values between this line and the "stop editing" line. */
  3. Definér de indstillinger, du vil overskrive, mellem linjen fra trin #2 og /* That's all, stop editing! Happy publishing. */

Se den medfølgende fil config-example.php for en komplet liste over understøttede indstillinger.

Flot kolonnelayout-eksempel

Se den fremragende Columns Guide af @oldrup, der bruger WordPress’ egne Gutenberg-blokke (pattern JSON-fil inkluderet) og lidt tilpasset CSS-magi:

FAQ

Hvordan finder jeg mit konto-ID?

Du er velkommen til at bruge dette praktiske lookup-værktøj

Der er flere måder at slå dit ID op manuelt på.

Som instansadministrator kan du nemt se dit bruger-ID i admin-backend.

Som almindelig bruger kan du prøve en API v2-søgning for at finde dit ID.

API v2-noter:
* Skift example.org til din egen instans
* Erstat username med dit brugernavn.

Brug følgende URL for at få dit ID:

https://example.org/api/v2/search?q=username@example.org&resolve=false&limit=5

Hvordan fungerer caching?

Server-side caching er som standard deaktiveret. Når det er deaktiveret, vil hver sideindlæsning udløse en ny API-forespørgsel til din Mastodon-instans for hvert feed. Det er sådan den offentlige feeds-API er tænkt og er normalt ikke et problem.

Hvis du har et site med meget trafik og vil skåne din Mastodon-instans, kan du aktivere caching globalt eller pr. shortcode. Når det er aktiveret, caches feedet som standard i 5 minutter.

Pluginet bruger automatisk enhver aktiveret cache-plugin eller WordPress’ interne transient-cache (= WordPress-databasen). Kun JSON-svaret med statusser caches – medier leveres stadig direkte fra Mastodon-instansen.

Bemærk: Hvis din Mastodon-instans kræver API-godkendelse, aktiveres server-side caching automatisk for alle feeds, der bruger godkendelse. På den måde bliver din auth-token ikke eksponeret for besøgende.

API-godkendelse

Hvis din Mastodon-server kræver API-godkendelse, kan du bruge parameteren auth.

BEMÆRK
Tilføj IKKE din API-auth-token direkte i pluginets shortcode

For at undgå at eksponere auth-token for besøgende skal du tage ekstra skridt
for at sætte godkendelsesunderstøttelse op

Se nederst i config-example.php for et detaljeret konfigurationseksempel

Trin til opsætning af API-godkendelse:

  1. Log ind på din Mastodon-instans og gå til Settings > Development (https://yourinstance.example.org/settings/applications)
  2. Opret en ny applikation (vilkårligt navn, markér kun én scope: read:statuses)
  3. Tilføj auth-mapping-konfigurationen til din wp-config.php (se nederst i den medfølgende config-example.php)
  4. Tilføj din tilpassede auth-reference til din shortcode

Kendte problemer / Todo

  • udvide Gutenberg-blokkens muligheder (understøtte flere indstillinger, aktivere forhåndsvisning i backend)
  • integrere i18n i translate.wordpress.org i stedet for tekstkonstanter

Anmeldelser

22. december, 2025 1 svar
For almost a year now, I’ve been using Include Mastodon Feed on my personal blog and a pro bono client-site. The plugin is very flexible and with the meaningful HTML structure and class names, so I can style the posts in almost any thinkable way — just as it should be. The developer is very responsive and continuously improving the plugin. During 2025 that includes: Major performance improvements, including server side caching and lazy-loading. Major accessibility improvements initiated at the Global Accessibility Awareness Day. Support for even more attachment file formats like video and audio. Include Mastodon Feed is, to me, the obvious replacement for Facebook or Instagram feed embeds. It just works and does not require a premium plugin subscription or ever-changing API updates. Along with the ActivityPub plugin, Include Mastodon Feeds allows for productive, easy and fun integration with the Fediverse. I highly recommend it and it easily deserves five stars. ⭐⭐⭐⭐⭐
17. april, 2025 1 svar
add-on works well and has good customizations. i was a bit confused about how “account id” differs from “account name”. but i got it working, and it’s great that there’s options for image aspect ratios and everything. thank you, developer!
7. maj, 2024 2 svar
Does what you need it to do in a simple way and can be customised with simple CSS to match the look and feel of your site.I would love to see some config options on how things are displayed:* Show / hide date & time at the top of each toot.* More placement options for the avatar.
17. april, 2024 1 svar
Love this plugin! Very easy to adjust the shortcode to customise the feed contents (eg. to exclude replies or boosts, to only show posts with images or with a certain tag etc). And if you are happy adding custom CSS to your wordpress, also fairly simple to get things looking just the way you want them. So happy this plugin exists.
11. november, 2023
thanks a lot! Works charming …
Læs alle 16 anmeldelser

Bidragsydere & udviklere

“Include Mastodon Feed” er open source-software. Følgende personer har bidraget til dette plugin.

Bidragsydere

“Include Mastodon Feed” er blevet oversat til 4 sprog. Tak til oversætterne for deres bidrag.

Oversæt “Include Mastodon Feed” til dit eget sprog.

Interesseret i udvikling?

Gennemse koden, tjek SVN repository, eller abonner på udviklerloggen via RSS.

Ændringslog

2.1.3

  • feat: add User-Agent header when going through PHP (auth only) – which enables GoToSocial compatibility (thank you @chris@hallo.ween.de)

2.1.2

  • fix: load css before most themes load css to not override custom css styling (priority 5 in WordPress queue)

2.1.1

  • feat: load css & js only on pages that actually have a feed
  • fix: when Gutenberg block was used as pattern it did not persist “limit” correctly

2.1.0

  • feat: Gutenberg block now includes an account ID lookup tool, supports tag timelines and the post tag filter

2.0.1

  • fix: added missing permission_callback to register_rest_route to avoid PHP Notice (thank you @h4r1m4u)

2.0.0

  • feat: introducing the “Mastodon Feed” Gutenberg block – backwards compatible… shortcode will always be supported too
  • feat: increased required PHP version to 8.2 since there are no security updates for any version 8.1 or less
  • fix: INCLUDE_MASTODON_FEED_CACHE_DURATION constant name

1.17.0

  • feat: added server side caching (see included config-example.php for global CACHE and CACHE_DURATION settings1). cache can be set as short code param as well.
  • feat: added API authentication support

1.16.0

  • fix: local instance video urls
  • feat: added audio media support
  • feat: added excludeTags shortcode attribute – Exclude statuses that are tagged, posts containing any one of the given tags (comma separated list) will be excluded. Note: can lead to empty status list as the filtering is handled client-side. Mastodon API does not support this parameter natively. (thank you @zambunny)

1.15.1

  • fix: added line break

1.15.0

  • feat: now supports video attachments

1.14.0

  • accessibility: add HTML lang attribute for even better screen reader support (thank you @oldrup@mastodon.green)

1.13.1

  • fix: removed unnecessary, broken aria-label functionality

1.13

Special release for Global Accessibility Awareness Day
in collaboration with @oldrup@mastodon.green

Happy Accesssibility Day

  • accessibility (fix): image alt attributes – initial implementation was faulty
  • accessibility: added alt text to image / gifv attachments
  • accessibility: added alt text to avatar images
  • accessibility: added alt text to preview card media
  • accessibility: added descriptive aria-labels
  • accessibility: increased default text / background color contrast
  • accessibility: switched from DIV to semantic OL / LI structure

1.12

  • accessibility: added image alt attribute (thank you @oldrup@mastodon.green)

1.11

  • now favoring preview_url (smaler size) instead of remote_url (full size) for image previews (thank you @oldrup@mastodon.green)

1.10

  • added image lazy loading for account and post images – post image lazy loading only works with preserveImageAspectRatio set to true (thank you @oldrup@mastodon.green)

1.9.11

  • fixed typo (thank you @hjek)
  • cleaned up code after 1.9.10 release

1.9.10

  • fixed XSS vulnerability: removed support for date-options as shortcode attribute completely – to mitigate an XSS vulnerability where authenticated attackers with contributor permission could insert malicious JavaScript (still can be set as constant in PHP code)

1.9.9

  • fixed esc_url context that previously broke the URL for the Mastodon API JS ajax request (thank you @beach@illo.social)

1.9.8

  • fix broken date-locale and date-options parameters (thank you @crusy@chaos.social)
  • improved string excaping for text parameters and added url escaping
  • removed unnecessary output buffering
  • fix license SPDX Identifier

1.9.7

  • fix option to either display smaller image media attachment previews (default) or large image versions (thank you @beach@illo.social)

1.9.6

  • fixed XSS vulnerability where authenticated attackers with contributor permissions could insert malicious JavaScript

1.9.5

  • added option to either display smaller image media attachment previews (default) or large image versions (thank you @beach@illo.social)
  • added option to point image media attachment links to either status (default) or image

1.9.4

  • added option to hide status meta information and date/time (thank you @PaulKingtiger@dice.camp)
  • added tag support – you can now embed tag feeds (thank you @martin@openedtech.social)
  • added option to show embedded images in original aspect ratio (thank you @beach@illo.social)
  • fix: correctly inject repeating emojis in display names and status texts (thank you @kanigsson@discuss.systems)

1.9.3

  • fix: improved excludeConversationStarters detection (did not work correctly)
  • fix: undid last refactor to load JS inline with markup instead footer to fix problem with JS that was added to footer even if shortcode was not visibly rendered

1.9.2

  • fix: style for embedded videos / GIFs
  • refactor: play gifv on mouseover
  • refactor: load markup related javascript in footer instead of embedding it directly with the html markup

1.9.1

  • refactor: show meaningful message if no statuses are available
  • fix: broken excludeConversationStarters logic

1.9.0

  • added option to exclude conversation starters (posts that start with a user mention)

1.8.1

  • fix: boolean param validation was wonky
  • fix: stop links from overflowing (thanks to https://github.com/moan0s for contributing)
  • refactoring: improved styling of embedded images

1.8.0

  • added option to show/hide preview cards
  • refactoring: introducing plugin namespace
  • refactoring: improved debug console output

1.7.0

  • bumped tested wordpress version to 6.2
  • added option to customize permalink text (before and after date/time)
  • added option to customize text indicating edited posts

1.6.0

  • image attachments are now clickable (link to original status)

1.5.0

  • added option to show only statuses with specific tag
  • added option to set link target to make links open in new tab
  • added option to set maximum number of statuses

1.4.2

  • fixed styling issue with emojis in account display name

1.4.1

  • fixed styling issue with boosted account links

1.4.0

  • removed “view on instance” link and made date info clickable instead
  • added custom date locale and format option
  • fixed emoji and inline link styling issues in content blocks
  • fixed an issue with gifv media attachments
  • refactored option sanitizing and filtering

1.3.1

  • updated documentation that plugin constants for setting custom default options have to be defined in wp-config.php, as the previous config.php file gets removed with every automatic plugin update
  • removed config.php support

1.3.0

  • added new feed options: excludeReplies, onlyPinned, onlyMedia

1.2.0

  • fixed broken JavaScript if post included media attachments other than images
  • fixed custom “view on instance” option
  • added option for custom content warning button text
  • added option to exclude boosted statuses
  • added support for gifv media attachments

1.1.0

  • added support for more custom text overrides (loading, boosted, view on instnace)
  • switched to showing static avatars, animated avatars only on hover

1.0.1

  • escaped options when echoing them
  • secured local file inclusion
  • changed versioning to semantic versioning – now including patch number

1.0

  • Initial release