Indigenous

I have been briefly testing Indigenous by Eddie Hinkle, a native micropub client for iOS, so you may have seen a couple of rogue 'likes' appear in the RSS feed recently.

While I currently use Workflow to post likes and replies from my phone there is a distinct possibility that Apple will eventually remove it from the App Store should they add some form of automation to future versions of iOS.

I, therefore, wanted to explore alternatives and this meant installing Ryan Barrett’s plugin to provide a micropub endpoint thus allowing the app to post to the blog.

It's early days but Eddie has got a lot planned and the app - which works by way of a share extension, already seems pretty robust with the functionality it's got.

I don't use the indieweb Post Kinds plugin for WordPress as it's never played nicely with my theme so I do things manually with my own plugin.

Consequently, I don't have post types such as like, reply, bookmark and RSVP - such interactions are published as status posts on the blog and include the relevant microformats2 markup.

This difference lead to the rogue likes mentioned above; they were published as standard posts so didn’t display as they normally would.

I needed to find a way for the two to work together so made a few changes.

The micropub plugin adds a hook after_micropub so I used this to change the post format of the latest post to ‘status’:

function micropub_format($post){
  $args = array(
    'numberposts' => '1',
  );
  $recent_posts = wp_get_recent_posts( $args );
  foreach( $recent_posts as $recent );
    $post_id = $recent['ID'];
    set_post_format( $post_id, 'status');
  endforeach;
}

add_action('after_micropub','micropub_format',1,2);

Next, to better match my own implementation, I have edited the plugin to display the page title in the post rather than the link (this uses the same method as my plugin) and alter the styling.

I currently have all posts submitted via the micropub endpoint published as drafts, so you likely won’t see any posted this way for now, but it’s fun to explore this as an alternative.

I look forward to watching Eddie’s progress.

Indigenous

Learning from the pastComments

There was a quick conversation on micro.blog about RSS triggered by a post from Jason Dettbarn which, in turn, was in response to David Sparks' "The case for RSS."

The upshot was that Google Reader was both the standard bearer and pall bearer for RSS at the same time.

James mentioned the ability of large companies to usurp tech like Google did with RSS and asked could it happen again with the #indieweb?

As I’ve written before, webmentions are the glue that binds the indieweb together, connecting sites from across the web by way of comments, likes, replies etc. They are detailed in a W3C recommendation well on its way to becoming a full, recognised standard - but then so was RSS.

Google cornered the RSS market and Reader became synonymous with RSS; everyone designed their feeds to best fit it, just as everyone tweaks their SEO to please Google search largely ignoring other search engines.

But Google Reader demanded certain things. Every post needed a title, for example, and the rest of the RSS ecosystem followed. It became the de facto standard for RSS, effectively pushing everyone else out.

The rise in popularity of social media as a news source meant many were already declaring that RSS was done but Reader's closure sounded the death knell and left a massive vacuum when Google decided to concentrate on Google Plus.

That synonymity between service and standard meant the closure of one symbolised the demise of the other but standards only "die" when they are superseded by something else, something better. While using social streams as news delivery mechanisms certainly became de rigueur, and the real time nature of Twitter is admittedly unsurpassed, this cannot be seen as sufficiently better to kill off a standard.

So, what of the indieweb and webmentions?

I previously argued that wider indieweb adoption would probably happen by stealth rather than being actively sought out by average users.

"What if, for example, Automattic (the company behind WordPress) suddenly decided that all standard WordPress.com themes were going to include microformats2 markup and support webmentions? You've instantly got millions of people with an indieweb presence who haven't got a clue what it is or how it works, just that things are a little different."

The WordPress community currently seems reluctant to entertain the idea of indieweb integration but what would happen if such a major player did enter the arena and started to impose its own requirements just as Google did with RSS?

The sudden injection of millions of indieweb properties would likely cause a further rush of adoption as others seek to implement a technology which they feel would generate exposure and engagement.

Such adoption, however, would not be against the recognised standard but in line with the custom requirements imposed above to (selfishly) ensure maximum compatibility rather than compliance.

James' fear of a big tech company usurping an open platform could be realised and this custom implementation may become synonymous with the technology itself.

To take this to its logical conclusion, what would happen if after a few years the major player suddenly decided to ditch indieweb technologies in favour of the next big thing?

Where would that leave everyone?

Those who relied directly on the platform dropping support would obviously be affected until an alternative became available. In the case of something like WordPress this would obviously be via plugins.

But, the advantage this has over the RSS issue, even with a major player dropping support, is the very nature of the indieweb itself.

When Google Reader closed people had to actively seek an alternative in order to continue consuming their RSS feeds. This pushed many towards simply using their social streams - they couldn’t be bothered to find an equivalent service and re-add all their feeds.

No such need would exist with something like webmentions. People may not be able to immediately interact with as many properties but things wouldn’t stop working for those not hosted on the major player’s platform.

Sites interact directly with each other without the need for any central agency. If everyone had decided to adopt a custom implementation it would still work between all those sites that used it.

The very fact the technology would have been deployed across many different platforms means it couldn’t contain any showstopping proprietary requirements even if it did not adhere strictly to the original standard.

The overall impact would be significantly reduced.

Learning from the past

Doing things properly

While quickly discussing an issue (where native comments from others were posted as from me on micro.blog) Aaron Parecki pointed out on the #indieweb slack that the microformats markup was incomplete in that the comments were missing h-cards.

The h-card gives machine readable information about the author of an on page element so it was wondered if this was the cause of the issue.

Manton has confirmed it's not but that doesn't mean I shouldn't fix things.

So, hopefully, I’ve made some changes to the theme that resolve this and correctly identify the author (name and URL) for each comment, although I did have to force every comment to have the class h-as-reply to ensure child comments (replies to replies) are distinguished from their parents.

To ensure correct parsing I also had to add a filter to the comment_text() function so that the comment body was marked up with the e-content class:
 

function add_class_comment_text($content) 
    return "<div class='e-content'>" . $content . "</div>";
}
add_filter('commenttext', 'add_class_comment_text');
Doing things properly

More on comments, platforms and the indiewebComments

Colin Devroe wrote a thorough and thought-provoking response to my most recent musings on replies and comments. I would urge you to check it out.

He makes some very interesting and compelling points while outlining his particular answer to the question about comments.

One such point is that he doesn't like micro.blog becoming a comment platform that every reply has to be sent or received via, otherwise it's akin to a silo and you might as well just use Twitter.

It's an interesting angle.

I've likened it to a comment platform myself but one that's not like a social silo but a feed reader with an inbuilt two-way communication system.

If all you could do was list and reply to posts from blogs hosted with the service then it would, indeed, be considered a silo. Being able to add any RSS or JSON feed to your account, however, opens it up but Colin's objection is still well articulated and I can certainly see his point.

Forcing people to interact via only one avenue is bad for conversation and bad for the web.

I'm personally guilty of limiting my reader's options (although I am reconsidering this) but, if you are using micro.blog as a comment platform it means that your site accepts webmentions which can obviously originate from anywhere able to send them.

It's a shame this isn't more widespread.

But what really got me thinking was Colin's observation:

"I do have a M.b account but I’m beginning to wonder if I need one as I have my own fully functional weblog."

That's both perfect and prophetic.

Ideally, this is the open web's goal: for people not to need something like micro.blog; for connective technologies to be sufficiently simple and widespread that ideas can be posted and conversations had between any site regardless of platform or hosting.

I think something like micro.blog is a stepping stone, a proof of concept, if you will. Because the web is so dominated by platforms and silos we need it (or, rather, a familiar platform-style service) to serve as an effective illustration of how blogs in different locations can be truly connected and interact directly with each other via #indieweb style technologies.

Whether that is the way it will ultimately pan out remains to be seen but, as things stand, it is an elegant solution as long as you're willing to work within its limits.

It's not ideal but, if it gets people interested in blogging again and plants the seeds of a more connected open web, I'm all for it.

More on comments, platforms and the indieweb

When writing about ownership I explored the difference between comments and replies and that part of it was context.

I started thinking about that again but in a wider sense.

I've never really liked that Medium turned all replies into full posts so that they showed as standalone items in your feed.

It didn't matter if it was an essay length response or just a quick one-liner; they all became "posts" in their own right.

Wrong!

But, thinking about it, this is what's mirrored, and encouraged, by the #indieweb where a reply is designed to be written on your own site and replicated as a comment on the original via a webmention. Regardless of length.

I can't complain about one but countenance the other.

"There are different types of reply and they should be treated accordingly."

There has to be a line, a point where a comment is just that and not a reply. It's a question of semantics but not everyone's answer to "what is a comment and where does it belong?" will be the same.

Status

More on the progression of the indieweb

From John Johnston:

Perhaps shorter how-tos that don’t link off too much might and have a smaller scope might help generation 2 & 3? I am not the best person to judge this.

Some friction comes with the power. Especially if you have already got a blog, workflows etc going. I’ve found quite a few assumptions I had were slightly wrong.

And...

as I click Publish, will this end up as a comment on Chris’s post? How will it look on twitter, on micro.blog, I can’t say I am wholly confident that I know!

Then from Eli Mellen:

I wonder if the generations are still applicable and/or useful? Generation 2 is so broadly defined it is difficult to say what "they" need, because as a group of users they're not very clearly articulated.

And from a second post:

I think better on boarding materials and user-friendlier documentation would go a LOOOOONG way. BUT, before one can create such documents there needs to be a relatively stable way of joining the indieweb.

The theme of simplicity and reliability is a recurring one.

Eli does go on to say "Between wordpress and micro.blog I think that is starting to emerge" but this is currently an edge case; we need the support of a major player.

I still think getting indieweb support baked into WordPress core would be one of the quickest routes to adoption.

More on the progression of the indieweb

The beauty of micro.blogComments

In the latest episode of the Core Int podcast Manton re-emphasised that micro.blog is a blogging platform rather than a social network.

It's flexibility, however, means it can be different things to different people.

For me, rather than being a blogging platform, it has become an extension of my blog almost like a comment engine. The webmention support means that the conversations around my posts get fed straight back.

Because I don't take advantage of micro.blog's hosting it is definitely more a social environment for me and, because of this, I see how it starts to achieve one of Manton's goals: to act as a layer tying the blogosphere together.

If we go back to Tantek's reasoning for why social networks took over (a combined reading and posting interface) we also see the true depths of the service.

It looks like a basic Twitter-style network but that is only scratching the surface; its simplicity belies its power.

At its core is a feed reader presenting posts in the usual reverse chronological order but, although it feels like you are following users on a social network you are actually subscribing to their blogs - and not just microblogs depending on what feeds they include.

The social element allows us to reply to posts in situ but these aren't simply replies, they are also comments which, as mentioned above, can automatically co-exist on externally hosted blogs.

And then you can use exactly the same interface to post to your own blog, be it natively hosted by micro.blog (a massive part of the offering) or external, or any other tool that supports the APIs used.

While a degree of web plumbing can be used to back feed posts from social networks to our own sites, micro.blog does all this natively - and that is the beauty of it.

There is a lot going on behind the deceptively simple façade.

The beauty of micro.blog

Explaining the test

Reworking the blog for the #indieweb meant adding microformats2 classes to specific template areas in order to correctly identify the required content.

Nowhere is this felt more keenly than in the social element that ties much of the indieweb together: webmentions.

To be correctly interpreted a webmention needs a number of attributes:

  • target URL: the location it is referencing,
  • source URL: where it is coming from,
  • the type of webmention: like, reply, RSVP, etc.
  • the author: who is sending it, and
  • the content: what the webmention is saying

Ive covered various parts of this before so won't retread that ground but I noticed one thing I had wrong: the content.

By wrong I mean that it included extra information that didn't need to be part of the webmention. The post meta.

WordPress, or more specifically the theme used, structures posts in certain ways so that it repeatedly, reliably includes the same information when running through the post loop.

Essentially my posts were formatted as article > entry > entry content & post meta. As well as inserting a h-card for author, I had marked up entry as h-entry and the entry content as e-content but then realised that the post meta was held within the entry content div.

This meant the permalink code was included in the content sent to the target URL and not always getting display correctly.

Moving the post meta outside of the entry content solved the problem but meant I had to rework the CSS to keep it all looking like it should.

Explaining the test

Well, yesterday's post caused a bit of discussion (and, frankly, that was always the intention) but it was largely denied that there was any kind of existential crisis within the indieweb community.

I may have used the term for a bit of dramatic effect but I believe the point still stands.

I'm not alone.

The main argument against my point seemed to be that the different generations of indieweb users are well understood and documented.

The page states the division into generations allows advocates to "build tools for and create language to encourage growth" but this is a primary issue: the current tools are not simple enough and the language used is definitely confusing to most non-developers.

We may be seeing moves into Generation 2 with bloggers adding indieweb functionality to their sites but I would argue, due to the amount of manual intervention required to achieve a satisfactory result, they are still borderline Generation 1.

There is talk about trying to get certain indieweb technologies into WordPress core or the Jetpack plugin and this would be fantastic; it would be the start of "adoption by stealth" that I wrote about before.

Were this to happen we could effectively be skipping Generation 2 and going straight to Generation 3: those with personal domains managed by third parties, e.g. wordpress.com.

But, as I also wrote, were this to happen it would probably not be couched in indieweb terms and the responsibility for creating the language to encourage growth would be passed on.

Status

The confusion about the indiewebComments

Alex Kearney wrote about her first two years of indieweb. It makes for a very interesting read.

One thing that really came through was the confusion people feel when looking to "join the #indieweb" - it illustrates a common misconception that sites have to implement every bit of technology going.

Dave Winer said in a blog post that the indieweb community "chose such an inclusive name, but have an exclusive approach" giving RSS as an example, arguing that this established web technology has been ignored.

He obviously has a vested interest because RSS is his baby; I also thought some of his initial comments about JSON Feed were particularly harsh.

Such a comment understandably hasn't gone down too well in some quarters and there is a sense of defensiveness. But there is also a move for the community to look at itself, especially the wiki, in order to identify why these confusions and misconceptions arise.

When new technology is introduced it threatens the status quo whether it intends to or not.

Incumbents can reject 'new' because the status quo is how they've always done things and see no reason to change.

Conversely, the inventors of 'new' will have done so because the status quo doesn't meet their needs or they feel there is a better way.

It's a tricky situation but doesn't need to be either/or.

It's not all about the tech

At its core the indieweb has a set of principles such as owning your data, building tools for yourself and dogfooding them on your own site. The principles even state that user experience design is more important than protocols.

I wrote recently that the indieweb:

"promotes and relies on the open web but recognises that the closed web exists, plays a large part of people’s lives, and tries to integrate with it"

So much of what is discussed and developed as part of the movement relates not to the replacement of social networks and data silos but the integration with them whilst retaining ownership.

That doesn't sound very exclusive to me.

The problem, however, goes back to the perception that the indieweb is effectively insular because of the knowledge required to implement all the various technical elements. Plugins can only take you so far.

The community wrestles with the self-realised existential crisis that it is, currently, a developer community not a user community.

What to implement?

Look back at the principles above.

Okay, they talk about building tools but put the emphasis on the experience before protocols.

For me the indieweb is an idea, a way of doing things rather than the specific technology used to achieve it.

When examining how to establish the number of indieweb properties that existed it was suggested you could:

"consider a page part of the IndieWeb if it has a microformats2 class or advertizes a webmention or micropub endpoint."

This is looking at it from a technical perspective - an obvious indication that the page or site has implemented some form of identifiable indieweb technology. Not all are required, just one.

Yet there is still a problem, and that is the apparent insistence on the implementation of specific technologies as implied by the guides and documentation.

So much for design over protocols.

It is entirely possible for a site to be considered part of the indieweb and conform to its principles without any of these elements being present.

Stepping back

Just as the likes of Winer can seem too close to an established technology so proponents of a new way can be too focused.

Perhaps this is because many of the indieweb developers have been involved for a number of years and, psychologically, moved beyond the initial stages. They can see the destination and are driving full speed to get there.

Perhaps the principles become obscured by the need to get the tools ready for the next generation but they haven't even begun the journey so see completely different scenery.

In the drive to create systems that are simple enough for anyone to use (and we are nowhere near that stage) the how has become more important than the why.

Fortunately, the community already acknowledges the need to step back and view things from a user's perspective rather than that of a developer.

The confusion about the indieweb

I currently have webmentions enabled for posts from my own site; it serves as a means to highlight relevant posts or, maybe, parts of a thread.

But it almost feels like I'm flying in the face of convention and that most wouldn't do this.

Maybe I'll filter them into their own "relevant posts" section to differentiate them from external mentions.

But, as Tantek Çelik suggested on the Indieweb Slack, they could possibly be used as much more than just relevant posts.

This, however, leads me on to other ideas. A link from one post to another just shows as "mentioned this post" in the list of comments which isn't that illustrative. I could post it as a reply (using my custom fields solution) but what if I wanted the reply link within the body rather than at the start of the post?

Markdown let's you include inline HTML so you could add the u-in-reply-to class to the link but switching to HTML when writing in markdown always feels awkward.

What if Markdown was extended to allow for microformats attributes to be added links?

Instead of just

[link_text_here](url_here "Title")

We could have

[link_text_here](url_here "Title" c:'class_names, comma_separated' r:'rel_type' )

A quick search reveals Markdown supersets like Maruku and Kramdown but these would require a different toolset.

Status

To syndicate or noComments

Realising that I had not cross-posted a few of my recent items to Medium got me thinking.

After mentioning that I was not reading much there either I find it curious that there should be such a change in my online behaviour in so short a space of time.

This wasn't a deliberate act, I forgot to change the options on the Medium plugin for these posts, but I still don't feel compelled to go back and do it.

Although POSSEing your content to other places isn't a requirement for having an #Indieweb property they generally go hand in hand.

Most people will still engage on the same services they have been using, or reply to other people's posts, but just make sure that they are putting the original items on their own site.

It can, therefore, be surprising when someone says they won't be syndicating their posts.

Returning to the subject of display and distribution, however, not syndicating your content - or, at least, not syndicating all of it - makes a good degree of sense.

If distribution or syndication doesn't work then don't do it, simple. Keep things where they are, where they look how they should, within the context in which they were created.

Some content types work well when distributed so, if it's not a chore to do it, why not? Use these as the bait to the blogging hook.

Hand in hand with data ownership we should be leading by example to encourage more direct site visits rather than viewing via a third party service.

To syndicate or no

Valuing the right things

Chris Aldridge queried my current approach in making the blog an #Indieweb property but telling people to reply on Medium - it's anathema to the ethos of ownership.

My response was that the blog is in transition, moving from one phase to another.

And I think a lot of the confusion is down to value: what is the value associated with what we do on the web? It's not always obvious, not the same for everyone, and not even the same for the same person at different times.

Stats and reach vs ownership and control.

When I first started blogging properly in 2003 I had total control, total ownership, and a static IP address from my ISP meant it was easy to self host at home.

I had the blog on SharePoint running on a server sat in my dining room. All my email was handled by my own Exchange Server - again at home - the MX records pointing to my static IP.

Although I had total and full control I didn't really value it; I was doing it because it was the geeky thing to do. I valued the nerd-factor.

I learnt quite a lot though.

When SharePoint was no longer a viable blogging platform (was it really ever?) I moved to WordPress. My wife had been trying to get me to switch for a while but I had been so invested in my own setup and mistook the value in what I had done technically for what mattered.

At that point the value was actually in having a modern, purpose built blogging platform.

Blogging was (and largely still is) a numbers game and a few lucky people became six figure bloggers - they were there at the beginning and seized an opportunity to turn it into a meta business - making money blogging about making money from blogging.

Then the rise of social meant that numbers were more important than ever. Reach, influence, followers, all these things were purely about increasing the what and bypassing the why.

We got sucked in.

When social really started catching on around 2008 I became involved in a lot of very interesting conversations and my "online stock" was reasonably high in certain circles. But everything I wrote about and stood for was predicated on promoting the mainstream adoption of social.

Guess what? Social got adopted, and how! I became lost and didn't know where to take what I was doing.

People drifted away, moved on to the next thing, while the conversation moved from blogs to social networks.

Rather than realise the value of what I had I lamented what I had lost so the drive behind what I was doing changed. I placed more value on the audience than control, first with Google Plus and then (to a lesser degree) with Medium.

That's not to say there isn't value in those places but the relative value is so individual that we can't discount things completely.

In an attempt to recreate the audience I got away from what made blogging special and I'm not too proud to admit it. This realisation was key to understanding what I should be appreciating.

It's taken me a while to get here but I'm glad I've arrived.

Valuing the right things

Indieweb adoption – how does a new way spread?Comments

A conversation cropped up in the #indieweb slack about how wide its adoption currently was. It surprised me to learn that there were, at most, around 10,000 sites that could currently be described as indieweb properties.

While Micro.blog supports indieweb technologies (so will technically boost those numbers as it grows) it was wondered if its members were "all 'actively' seeking out an indieweb presence" and whether this actually mattered.

Does having it but not understanding make a difference?

Of course not.

Everyone uses the web and email without having a clue about how they work, about the protocols behind them or the RFCs these protocols originated in.

People don't need to know and the indieweb will be no different.

An understanding is currently required solely because it's the only way to get it set up: implementing it yourself, either completely manually or in conjunction with a selection of plugins.

Stealth

When I wrote about mainstream social media adoption back in 2008 I said it would happen by stealth. People weren't actively seeking a social presence, they didn't wake up one day and suddenly think "I'm going to join a social network!"

They fell in to social, they just wanted to talk to their friends and family.

Widespread indieweb adoption will be the same, it will happen by stealth because someone with a bit of clout decides to implement it.

What if, for example, Automattic (the company behind WordPress) suddenly decided that all standard WordPress.com themes were going to include microformats2 markup and support webmentions? You've instantly got millions of people with an indieweb presence who haven't got a clue what it is or how it works, just that things are a little different.

Attempts at getting microformats2 markup into the WordPress core, however, have so far proved unfruitful.

Trigger

Ideas spread slowly, organically, word of mouth and person to person, until a tipping point is reached.

Even though something may be ratified as a W3C standard it doesn't mean everyone is going to start using it.

Maybe there needs to a trigger, a light bulb moment, a catalyst that galvanises the decision. What if something like Micro.blog takes off and starts getting a lot of attention.

What would it take?

If such a moment did occur any widespread adoption certainly wouldn't be couched in indieweb terms; there would be new terminology. Perhaps it would just be described as a new way to present your information to make it easier to identify, respond to, and to interact with other sites.

After all, if the indieweb becomes mainstream it's no longer indie.

Indieweb adoption – how does a new way spread?

Sending likes and replies using custom fieldsComments

Historically, we would visit someone else's site to leave a comment or click a like button. Sometimes these interactions would be held within their own site's data but, frequently, they would be stored remotely - think Facebook Likes or Disqus comments.

In keeping with owning your content, part of the #indieweb ethos is to perform these actions on your own site but pass them back so they show in both locations. The original, however, is held by yourself.

The Post Kinds plugin for WordPress is designed to add support for "responding to and interacting with other sites" by implementing "kinds of posts" - specific post types with a particular purpose. So I thought I'd give it a try.

The plugin didn't work in the way I'd imagined, however, and caused issues with my theme due to the way it maps its own post types to those already in WordPress.

While new templates can be designed for how it integrates, all I really wanted it for was likes and replies so the effort required to get everything back as if should be seemed a bit counter-productive.

Back to the drawing board.

A different way

Once webmentions are enabled the actual markup required to turn a link to another page into a like or reply is actually pretty simple - specific classes are added to identify their purpose:

  • Reply = class="u-in-reply-to"
  • Like = class="u-like-of"

This would be easy enough to add to the post HTML but, as I avoid the WordPress back end as much as possible, I wanted an easier way.

What if I could automatically add this without a plugin?

As I post from my phone I starting thinking how I could pass a URL to WordPress along with the post; I was instantly reminded of the trick I used to tell it about the path to microcast episodes:

Custom fields.

A like is usually a short post so perfect for Drafts and Workflow - custom fields can be populated directly from the 'Post to WordPress' action.

Replies are more likely to be longer posts but Ulysses doesn't, natively, allow for the same behaviour. I would just have to add the custom field after posting as a draft.

Now that the link data could be included with the post how could it be added with the relevant markup to trigger webmentions?

Functions

I had already used code in functions.php to alter posts (the creation of hashtag links, for example) but this was purely a run-time change altering how the content was displayed, not stored:

add_filter( 'the_content', 'linked_hashtags' );

To trigger webmentions the links need to be included in the actual body of the post so modifying the_content wouldn't work. Luckily, WordPress includes a way to do this in content_save_pre which lets you modify a post's content before being saved to the database.

In order to build the webmention links I needed to get the page title as well as the link. The function file_get_contents() reads the contents of a file (in this case a web page) into a string and I used an example found on the web to extract the page title from that:

$str = file_get_contents($replyurl);
$str = trim(preg_replace('/\s+/', ' ', $str));
preg_match("/\<title\>(.*)\<\/title\>/i",$str,$replytitle);

Putting it together

With all the pieces in place, all that remained was to put everything together running a function to build the links when saving the post:

add_filter( 'content_save_pre', 'mentiontypes' );

Pulling the URL from the custom field is done using get_post_meta() specifying the post ID and field name. The required string is built and added to the front of the post content before being returned back to the post as the new body.

Because content_save_pre runs whenever a post is saved editing would cause the link to be re-added on each occasion. To prevent this I opted to delete the custom field using delete_post_meta() after the link is first inserted to avoid duplication.

The full code is included below. Let me know if you can think of any improvements.

Update: Jeremy Cherfas pointed out that some consider file_get_contents() to be insecure so advised using wp_remote_get() instead. The code below has been updated to reflect this change.

function mentiontypes ( $content ) {

  $id = get_the_ID();
  $types = array ( 'Reply', 'Liked' );

  foreach ( $types as $type) {
    $mentionurl = (get_post_meta($id, $type, true));

    if ( $mentionurl !="" ) {
      $url = wp_remote_get($mentionurl);
      $str = wp_remote_retrieve_body($url);
      $str = trim(preg_replace('/\s+/', ' ', $str));
      preg_match("/\<title\>(.*)\<\/title\>/i",$str,$mentontitle);

      if ( $type == 'Reply' ) {
        $mentionstr = '<p><em>In reply to: <a class="u-in-reply-to" href="' . $mentionurl . '">' . $mentiontitle[1] . '</a>...</em></p>';
      } else {
        $mentionstr = '<p><em>Liked: <a class="u-like-of" href="' . $mentionurl . '">' . $mentiontitle[1] . '</a>...</em></p>';
      }

      $content = $mentionstr . $content;
      delete_post_meta( $id, $type, $mentionurl );
    }
  }

  return $content;  
}

add_filter( 'content_save_pre', 'mentiontypes' );
Sending likes and replies using custom fields

In transition

In reply to: Perhaps I'm not quite reading your meaning properly, but I'm curious about the portion about your having turned off comments. I also notice your link

When I rebooted the blog last year I aspired to the goals of the indieweb but wasn't yet familiar with the #indieweb movement. I knew I wanted ownership of what I was doing but hadn't filled in the fine details.

Consequently, the site is in transition as I adopt different ideas and find how I've previously done things may have to change accordingly.

But, not all parts of the indieweb are for everyone and no one should feel they need to implement everything.

The core principles are enough.

My initial desire was to take full control of what I was doing, that's what was important to (and for) me and that's why I didn't mind outsourcing replies to Medium.

While opening things up to webmentions on all posts (not just the microblog) I still don't want the aggravation of handling local comments so that won't happen.

Those that want to can own their replies, for everyone else Medium is still a service that I support, especially in light of the decision to scrap advertising for membership.

In transition