# As mentioned yesterday I was looking to get "nomentions" working without having to edit the webmention plugin itself.
David pointed out that the plugin sets up a filter which enables you to process the target URLs before mentions are sent so I needed to hook into this:
$targets = apply_filters( 'webmention_links', $links, $post_id );
By default nothing happens with this line as no filters are defined leaving you free to add whatever you need. So I moved my code from the webmention plugin to a callback function in a new plugin which hooks in using add_filter()
and checks each link in the post for the nomention
class, excluding any it finds.
The code is as follows:
function nomention_links( $links, $post_id ) {
$post = get_post( $post_id );
preg_match_all('/]+>/i',$post->post_content, $results);
$mentions = '';
foreach ($results[0] as $link) {
if (!strpos($link, 'class="nomention')) {
$mentions .= $link;
}
}
$links = wp_extract_urls($mentions);
return $links;
}
add_filter( 'webmention_links', 'nomention_links', 10, 2 );
As my posts are written in Markdown (and WordPress uses MultiMarkdown thanks to JetPack) I can easily add the nomention class to any link like this:
[link text here](http://thisisthe.link) {.nomention}
My original use case was to be able to link to a conversation on micro.blog without the post automatically being treated as a reply but there could be other occasions when you don't want to send a mention for whatever reason.
As always, the plugin is listed on GitHub should you have a need and want to try it.
Note: the plugin only handles a
tags, if you wanted to extend this to other types of link such as img
tags please see the note in the readme.
Comments
# I recently noticed that since the change to British Summer Time (BST) the auto-added post titles were an hour out:

I don't know why I hadn't picked up on this before. ¯\_(ツ)_/¯
I've added date_default_timezone_set( "Europe/London" );
to the function which adds the title when none exists (status posts) and things are back to being as they should.
The plugin has also been updated on GitHub.
Comments
# Liked: Doc Searls Weblog · GDPR will pop the adtech bubble...
"Adtech has caused the largest boycott in human history. By more than a year ago, 1.7+ billion human beings were already blocking ads online."
This piece by Doc Searls on adtech and the GDPR is certainly an eye opener, and there's a lot to unpack, but that one quote really got me.
@colinwalker I implemented this on my WordPress website this morning. Thank you!
@khurt Cool. It's probably not something many will find a use for but good to have it there.