Include Mastodon Feed

Include Mastodon Feed

توسط

Plugin that provides a Gutenberg block and an [include-mastodon-feed] shortcode to easily integrate mastodon feeds into wordpress pages. Supports personal and tag feeds.

Account and post images are lazy loaded if preserveImageAspectRatio is set to true (default: false).

The plugin is written in PHP and generates native JavaScript to fetch and render the mastodon feed. No special libraries needed.

  1. Upload the “include-mastodon-feed” directory to the “/wp-content/plugins/” directory.
  2. Activate the plugin through the “Plugins” menu in WordPress.
  3. Insert the “Mastodon Feed” block in Gutenberg editor or the “[include-mastodon-feed]” shortcode into any page.

Shortcode example

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

Shortcode attributes

  • instance (required)
    Domain name of the instance without https:// (e.g. example.org)

  • account (required)
    The account ID (a long number – see FAQ on how to get it)

  • tag
    Use tag instead of account if you want to embed a tag feed instead of a personal feed

  • cache
    If wordpress should cache Mastodon server API calls (Default: false)
    Note: automatically enabled for feeds where auth is used

  • auth
    Auth key that should be used if Mastodon server API needs authentication

  • limit
    Maximum number of statuses (Default: 20)

  • excludeReplies
    Exclude replies to other accounts (Default: false)

  • excludeConversationStarters
    Exclude statuses that start with a user mention (Default: false)

  • excludeBoosts
    Exclude boosted statuses (Default: false)

  • onlyPinned
    Show only pinned statuses (Default: false)

  • onlyMedia
    Show only statuses containing media (Default: false)

  • preserveImageAspectRatio
    Preserve image aspect ratio (Default: false)

  • imageSize
    Load small sized preview images or full size high quality images (Default: preview, full)

  • imageLink
    Link image to status or image (Default: status, image)

  • tagged
    Show only statuses that are tagged with given tag name (Default: false)
    No leading #, case insensitive, e.g.: tagged=”tagname”

  • excludeTags
    Exclude statuses that are tagged with any of the given tag names (Default: false)
    Comma separated list of tags, no leading #, case insensitive, e.g.: excludeTags=”tag1,tag2″

  • linkTarget
    Target for all links e.g. new tab would be “_blank” (Default: _self)

  • showPreviewCards
    Show preview cards (Default: true)

  • hideStatusMeta
    Hide status meta information, automatically also hides date and time (Default: false)

  • hideDateTime
    Hide date and time from status meta information (Default: false)

  • darkmode
    Enable dark mode (Default: false)

  • text-loading
    Loading text (Default: Loading Mastodon feed…)

  • text-noStatuses
    Text if no statuses are available (Default: No statuses available)

  • text-boosted
    Text indicating boosted statuses (Default: boosted 🚀)

  • text-viewOnInstance
    View status on instance link text (Default: view on instance)

  • text-showContent
    Text for content warning buttons (Default: Show content)

  • text-permalinkPre
    Text before post permalink (date & time) (Default: on)

  • text-permalinkPost
    Text after post permalink (date & time) (Default: )

  • text-edited
    Text indicating edited posts (Default: (edited))

  • date-locale
    Locale for date string, used in toLocaleString() (Default: en-US)

Additional customizations

You can define several plugin constants to set custom default options that will be applied site-wide (e.g. date options can only be set as php constant to mitigate an XSS vulnerability).

  1. Open your wp-config.php file
  2. Search for the line /* Add any custom values between this line and the "stop editing" line. */
  3. Define the options you want to override between the line from step #2 and /* That's all, stop editing! Happy publishing. */

See the included config-example.php file for a full list of supported settings.

سوالات متداول

How do I find my account ID?

Please feel free to use this handy lookup tool

To look your ID up manually there are several ways.

As an instance admin you can easily read your user ID in the admin backend.

As regular user you can try an API v2 search to find your ID.

API v2 notes:
* Change example.org to your instance
* Replace username with your handle.

Use the following URL to get your ID:

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

How does caching work?

Server-side caching is disabled by default. When disabled every page load will trigger a new API request to your Mastodon instance for every single feed. This is how the public feeds API is intended and usually not a problem.

If you have a high-traffic site and want to help out your Mastodon instance you can enable caching globally or per shortcode. When enabled the plugin will cache the feed for 5 minutes as a default.

The plugin automatically uses any enabled cache plugin or the WordPress internal transient cache (= WordPress database). Only the statuses JSON response is cached – any media is still served from the Mastodon instance directly.

Note: If you Mastodon instance needs API authentication server-side caching is automatically enabled for all feeds that use authentication. That way your auth token is not exposed to your website visitors.

API authentication

If your Mastodon server needs API authentication you can use the auth parameter.

NOTE
Do NOT add your API auth token directly to the plugin short code

To avoid exposing the auth token to website visitors you have to take extra steps to
set up authentication support

See the very end of config-example.php for an in-depth configuration example

Steps to set up API authentication:

  1. Log into your Mastodon instance and go to Settings > Development (https://yourinstance.example.org/settings/applications)
  2. Create a new Application (any name, only check one single scope read:statuses)
  3. Add the auth mapping configuration to your wp-config.php (See very bottom of the included config-example.php)
  4. Add your custom auth reference to your shortcode
Known Issues / Todo
  • extend Gutenberg block capabilities (support more settings, enable backend preview)
  • integrate i18n into translate.wordpress.org instead of text constants
تصویری برای این آیتم موجود نیست.
نظری برای این آیتم موجود نیست.
0 0 رای ها
امتیازدهی
اشتراک در
اطلاع از
0 نظرات
قدیمی‌ترین
تازه‌ترین بیشترین رأی
نسخه حجم فایل SHA256 تغییرات دانلود
2.1.0 22 کیلوبایت -
دانلود
×
★★★★★
★★★★★
5.0 /5 (16 نظر)

قیمت:

رایگان

نگارش

2.1.0

آخرین انتشار

15 اردیبهشت 1405

آخرین بروزرسانی

3 ماه پیش

نصب های فعال

800+

نگارش وردپرس

وردپرس 6.0+

تست شده از نسخه

وردپرس 7.0

نگارش PHP

PHP 8.2+

تگ ها

نسخه ها

1 نسخه