Narwhal is a free WordPress plugin I maintain which adds a minimal front end new post box. You may configure it within WordPress' Writing settings. I use t...
Tag: WordPress plugins
Added by PressForward
Automating syndication of reply contexts in Twitter Cards using OGP metacrap and plugins in WordPress
A Metacrap Problem
It’s metacrap–I know, I know–but I’ve been thinking about easy ways to use Open Graph Protocol meta data to add contextual Twitter cards to some of my content when syndicating posts to Twitter. My goal is to leverage the speed and ease-of-use of Micropub clients while doing as little as possible manually, but achieving as much parity between posts on multiple sites.
I’m particularly keen to do this to syndicate/share more of the articles I read and post about on my site without adding additional manual work on my own part.
Outline of Some Resources
The Post Kinds plugin for WordPress parses URLs for me and pulls in data to create reply contexts for a variety of posts like bookmarks, reads, watches, listens, etc. Since Post Kinds doesn’t display featured images (yet), I’ve also been using the External Featured Image plugin to display the featured images from the original to add to the reply context of my posts as well.
In addition to all these I’ve been using the All in One SEO plugin to easily add an SEO layer to posts without having to do much thinking about it. AIOSEO recently upgraded their UI and features in the last year, and yesterday I upgraded to the newest v4.0+. One of the new features it’s got is the ability to add default fields or pull in pre-existing custom fields to output OGP meta data.
Start of a Solution
So I got the idea that since Post Kinds and External Featured Image plugins are pulling in and displaying the sort of data I’d like to show in Twitter cards, I figured why not use them? While metacrap is a DRY violation, the fact that it’s automated for me and is based on data I’m actually showing visually on my website makes it feel much less dirty. It also has the benefit that it helps make some of my syndicated content look and feel on Twitter, more like it does on my website. This is also a problem since Twitter hampers how much data I can syndicate in a single post.
I’ve still got some issues about how to deal with the Post Kinds data, but after a bit of digging around, I discovered the image URL for External Featured Image plugin is hiding in the _dcms_eufi_img
field. So I can make the default Twitter settings in AIOSEO pull the external image by setting Default Post Image Source
to Image from Custom Field
and set the Post Custom Field Name
to _dcms_eufi_img
.
Since a lot of my posts are reads, bookmarks, etc., this works well, but I can easily override the settings for articles or other custom posts which I make less frequently.
Hopefully I can figure out the settings for Post Kinds to get the rest of the default fields to map across. I’m happy to hear ideas on what field names I’d need to use to get the Post Kinds Name
and Summary/Quote
fields to map over for the og:title
and og:description
respectively. Ideally I can manage to get it done without needing to get a subscription to the pro version of AIOSEO which also has support for custom taxonomies which is how Post Kinds works.
Since my theme has relatively solid microformats support, and I have plugin infrastructure to allow easy syndication from my website to Twitter through micropub clients, this last bit for creating Twitter reply contexts helps close some of the loop for me in my syndication workflow while keeping as much context across platforms.
Example
Here’s a visual example of a native post on my site and the corresponding syndicated copy on Twitter. There are some differences, mostly because I don’t have as much control of the appearance on Twitter as I do on my own site, but they’re about as close as I can get them with minimal work.
Hooray for one less plugin in the stack!
Crediting your own website when syndicating to Mastodon with WordPress plugins
I was trying to syndicate from my website so that the post on Mastodon would credit my website for the post and link back to my homepage as the application that made the post. You’ll notice at the bottom of the post there’s the post date and a globe icon, which indicates the post is public, followed by my website name ‘BoffoSocko.com’ and details about replies, reposts, and favorites.
I assuredly won’t release a public plugin for WordPress that does this. But since some have asked how I did it, I thought I’d share some of the internals of a few WordPress plugins that one can quickly modify to achieve the same thing.
That I can currently see, there are three plugins in the repository that will allow one to syndicate content to a variety of Mastodon instances. They are Mastodon Autopost, Mastodon Auto Share, and Share on Mastodon. The first two are closely related and essentially replicate the same codebase.
Similar to using Twitter’s API to crosspost, Mastodon is looking for two bits of information when an application is registered: a client name and a website URL.
Mastodon Autopost and Mastodon Auto Share, both have a file called client.php
which define these two variables.
public function register_app($redirect_uri) { $response = $this->_post('/api/v1/apps', array( 'client_name' => 'Mastodon Share for WordPress', 'redirect_uris' => $redirect_uri, 'scopes' => 'write:statuses write:media read:accounts', 'website' => $this->instance_url ));
You can edit this file with a text editor to change the 'client_name'
from 'Mastodon Share for WordPress'
to 'Anything You Want'
. If you’re in a joking mood, maybe change it to 'Twitter'
?
To change the URL so that the link on the client_name
directs to your website, you’ll want to change the line 'website' => $this->instance_url
.
In particular change $this->instance_url
to 'https://example.com'
where example.com would be your website. I’ll note that $this->instance_url
on this line in the original plugin is a bug. If left alone, it points the URL to your home Mastodon instance instead of to the more logical https://wordpress.org/plugins/autopost-to-mastodon/
where the plugin lives.
If you prefer using Jan Boddez‘ excellent plugin, you’ll want to do something similar, except in that case you’ll want to change a file named class-options-handler.php
in the includes
folder.
Here you’ll want something like:
'client_name' => __( 'Example.com' ),
But note that Boddez doesn’t have a similar bug, so the website line
'website' => home_url(),
is already correctly defined so that your website will automatically be linked without any changes to it.
If you’re already using one of these plugins and manually modify them, note that you’ll probably need to re-authorize the plugin so that the changes propagate.

Some modification ideas to the Curator’s Code Plugin
It looks like it used to be in the repository, but perhaps with the rise of Gutenberg, they opted not to maintain it?
I follow most of the code there, but I’m thinking too much of the actual output is done via JS with tinyMCE, so maybe I’m missing some of the finer portions. It also needs some tweaks to redirect to maybe the Internet Archive since curatorscode.org no longer exists.
I’m thinking an output closer to the following for each type might still be simple, but provide some additional context, (presuming my microformats aren’t too horrific/mis-nested):
<p><small><cite class="h-cite via"><abbr title="via">ᔥ</abbr> <span class="p-author h-card">AuthorTK</span> <a class="u-url p-name" href="https://example.com/TK" target="_blank" rel="noopener noreferrer">TitleTK</a> (<time class="dt-published">2020-TK-TK</time>)</cite></small></p>
<p><small><cite class="h-cite ht"><abbr title="hat tip">↬</abbr> <span class="p-author h-card">AuthorTK</span> <a class="u-url p-name" href="https://example.com/TK" target="_blank" rel="noopener noreferrer">TitleTK</a> (<time class="dt-published">2020-01-29</time>)</cite></small></p>
Hopefully the via and ht classes also give people enough to latch onto for doing some custom styling of the output if necessary.
With more prevalence of crediting like this, I also wonder how parsers might better display received webmentions for these types of notifications beyond the basic “Sue mentioned this”. Maybe a facepile of avatars under the heading “Inspired by this post”? Though the way “via” is used in practice, it might also fit under the category of a repost?
Keep your WordPress blogroll in sync with your feed reader.
A new version of Simple Location is out. Version 4.1.12 has many under the hood tweaks/fixes, and only one major user facing feature, a redo of the caching system. The caching system is used by the weather system to avoid poling for the weather on every refresh. There is now a setting in each widget...
Micropub 2.2.3 for WordPress has been released. It fixes a variety of warning notices. Published, updated, name, and summary properties are no longer stored in post meta. When queried, they will be pulled from the equivalent WordPress properties. Content should be as well, however as content in th...
Theme components are bite sized code snippets that can be reused across multiple themes, but are either too small or don’t make sense to be released as a plugin. Stop cluttering up your functions.php file and start using theme components! Who are theme components for? Th...
A new feature that will allow automatic updating of plugins and themes will be available in WordPress version 5.5, which is scheduled to be released on August 11, 2020. In this core release of the world’s most popular content management system, site owners will have the option to turn auto-updates on for individual plugins and ...Read More
Earlier in the week, I noted the release of IndieAuth 3.5.0, but I didn’t explain the major under the hood changes that occurred here in a post, which I need to do as at least one person is experiencing issues(probably necessitating a 3.5.1 as soon as I figure out why.) I also noted I forgot to de...
Micropub 2.2.0 has one major change in it. IndieAuth client code was removed. This code now lives in the IndieAuth plugin. This means that Micropub does not check for scopes. It uses the built-in WordPress capability system to determine if an action should be performed. The IndieAuth plugin limits c...
Compare all WordPress plugins side by side and get us and get detailed plugin insights that actually makes sense including memory usage, PageSpeed impact, compatibility metrics & more