Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent webmentions sending for specified links #166

Open
colin-walker opened this Issue Apr 6, 2018 · 14 comments

Comments

Projects
None yet
3 participants
@colin-walker
Copy link

colin-walker commented Apr 6, 2018

The webmention plugin sends mention for all links in a post but there may be times when you don’t want a webmention sent, especially when dealing with social properties like micro.blog or Mastodon where a mention may create duplication if your post is going to be POSSE’d over.

How about a mechanism to specify on a link that you don’t want it to trigger a mention?

A site blacklist is too extreme as this precludes ever sending to that domain so here’s a suggestion:

We could add class=“nomention” to the link then check for this in the plugin using the following:

Replace $links = wp_extract_urls( $post->post_content ); within public static function send_webmentions with

preg_match_all('/<a[^>]+>/i',$post->post_content, $results); 

$mentions = '';
foreach ($results[0] as $link) {
  if (!strpos($link, 'nomention')) {
    $mentions .= $link;
  }
}

$links = wp_extract_urls($mentions);

to cycle through the tags in the post, add those without the nomention class to a new string and extract the URLs from that strong instead.

@dshanske

This comment has been minimized.

Copy link
Contributor

dshanske commented Apr 6, 2018

Isn't this basically rel=nofollow ?

@pfefferle

This comment has been minimized.

Copy link
Owner

pfefferle commented Apr 6, 2018

This limits the parser to links and ignores images, videos, ... It is also not very user friendly, because nearly noone knows about microformats and only a small crowd really writes plain HTML. Besides that, I do not think this is really an issue that needs to be solved on the WordPress side, only if micro.blog does not handle the Webmentions well.

@colin-walker

This comment has been minimized.

Copy link
Author

colin-walker commented Apr 6, 2018

Yes, I was thinking about it like nofollow but that doesn’t impact webmentions does it?

Good point, about images & videos - that could be extended.

It was just a quick thought about generating a mechanism to do it.

@pfefferle

This comment has been minimized.

Copy link
Owner

pfefferle commented Apr 6, 2018

For my better understanding, is this really an issue or is it only because of the handling of micro.blog?

@colin-walker

This comment has been minimized.

Copy link
Author

colin-walker commented Apr 6, 2018

The micro.blog incident was what triggered the thinking but surely they may be other times when you don’t necessarily want/need a mention generated. Just thinking out loud.

@pfefferle

This comment has been minimized.

Copy link
Owner

pfefferle commented Apr 6, 2018

I would prefer a more gen 2 - 4 friendly solution, if this is really a problem that needs to be solved.

@pfefferle

This comment has been minimized.

Copy link
Owner

pfefferle commented Apr 6, 2018

@colin-walker but is this really link specific, or is a handling on blog level also a solution?

@colin-walker

This comment has been minimized.

Copy link
Author

colin-walker commented Apr 6, 2018

As I say, it was just an initial idea based on the plugin itself. If there was a wider need then, yes, there would no doubt be a better way of implementing it at the spec level.

@pfefferle

This comment has been minimized.

Copy link
Owner

pfefferle commented Apr 6, 2018

sorry, I meant "post-level" instead of "blog-level"...

Perhaps we can add a "flag" to the editor, to disable "send pings" for specific posts.

@colin-walker

This comment has been minimized.

Copy link
Author

colin-walker commented Apr 6, 2018

Possibly, but I was thinking more at the individual link level as there may be multiple links in a post.

@dshanske

This comment has been minimized.

Copy link
Contributor

dshanske commented May 11, 2018

@dshanske

This comment has been minimized.

Copy link
Contributor

dshanske commented May 11, 2018

But you can always add something to the box that sends pings and trackbacks on a post a blacklist hooked into this filter

@colin-walker

This comment has been minimized.

Copy link
Author

colin-walker commented May 11, 2018

Thanks David. I think I've got it using the filter hook.

https://github.com/colin-walker/nomention

I know this is an edge case but it was something I wanted for my own workflow and the filter lets me do it without having to edit the plugin. Appreciate the pointer.

@dshanske

This comment has been minimized.

Copy link
Contributor

dshanske commented May 11, 2018

Any time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.