Include Mastodon Feed

Description

Plugin that provides an [include-mastodon-feed] shortcode to easily integrate mastodon feeds into wordpress pages.

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

Installation

  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 shortcode into any page.

Shortcode example

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

Shortcode attributes

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

  • instance (required)
    Domain name of the instance (e.g. example.org)

  • limit
    Maximum number of statuses (Default: 20)

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

  • excludeBoosts
    Exclude boosted statuses (Default: false)

  • onlyPinned
    Show only pinned statuses (Default: false)

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

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

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

  • darkmode
    Enable dark mode (Default: false)

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

  • 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)

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

  • date-options
    Format options directly fed into toLocaleString() (Default: {})

Additional customizations

You can define several plugin constants to set custom default options that will be applied site-wide.

  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.

FAQ

How do I find my account ID?

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:
* You might have to be logged in to get any results
* 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=true&limit=5

Known Issues / Todo

  • improve support for video and audio media attachment types

Reviews

January 6, 2023 1 reply
Please resist the temptation to add stuff - except it would be nice to have both pinned and latest posts 😉 Thanks for freely contributing this plugin.
December 20, 2022 1 reply
Works well but needs a little bit of configurationI wish there was a way to resize the avatar display which is too large at present
December 13, 2022
Been looking for something just like this for weeks. Easy to set up and does exactly what I need. Extremely configurable. I had a small issue with the feed being stuck on a "Loading Mastodon feed..." message. Contacted the creator and got an instant fix; in the short code use your instance url without https or trailing slash. Superb work and service.
December 8, 2022
I love it. Does exactly what I was hoping for. I ended up making the following custom css changes to get it to look the way I wanted: // THESE ARE FOR MASTODON WIDGET div.card a div.meta div.description { display: none; } a .meta .description { display: none; } div.account:has(> span.booster) { display: none; padding: 0; } .include-mastodon-feed .status { background: #f5f5f5; margin: 5px 0 10px 0; padding: 15px 15px 0 15px; //border-bottom: 1px solid #E4E4E4; border: 1px solid #E4E4E4; } .include-mastodon-feed .contentWrapper.boosted { padding: 0; background: #f5f5f5; } .include-mastodon-feed .account { padding: 0 0 11px 0; font-size: 11px; font-style: italic; font-family: Verdana, Arial, Helvetica, Sans Serif; color: #808080; } .include-mastodon-feed .boosted .account a:nth-child(2), .include-mastodon-feed .contentWarning a { border: none; padding: 0; background: none; color: #A25A1B; text-decoration: none; } .include-mastodon-feed .boosted .account > a:first-child, .include-mastodon-feed .contentWarning a, .include-mastodon-feed .boosted .account a:nth-child(2), .include-mastodon-feed .contentWarning a { border: none; padding: 0; background: none; color: #A25A1B; text-decoration: none; } .include-mastodon-feed .boosted .account > a:first-child:hover, .include-mastodon-feed .contentWarning a:hover, .include-mastodon-feed .boosted .account a:nth-child(2):hover, .include-mastodon-feed .contentWarning a:hover { color: #F90; border: none; padding: 0; background: none; text-decoration: underline; } (Please forgive the css. I just hacked this together. I don't really understand what I'm doing, ha ha.)
Read all 5 reviews

Contributors & Developers

“Include Mastodon Feed” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

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