wordpress-webmention icon indicating copy to clipboard operation
wordpress-webmention copied to clipboard

Implement Custom Comment Walker

Open dshanske opened this issue 6 years ago • 12 comments

Semantic Linkbacks has a custom comment walker that changes comment displays to support extra parameters.

I want to move this into webmentions and reimplement it. But, as noted in a request in that plugin, it needs to easily allow theme customization of displays.

It needs to have a few parameters. This is based on a theme calling wp_list_comments

  1. Since this is a Walker, if there is a callback, that would have to take precedence.

  2. The Walker should call a handler that uses individual template files in the plugin that can be overidden by placing a file in the theme.

  3. There should be accounting for two different presentations, triggered by the short_ping setting. Short ping would be the short presentation.

dshanske avatar Sep 20 '19 17:09 dshanske

Do we really need a comment walker? In semantic linkbacks it is, as far as I understood it, only because we have not really implemented emoji support to the parser.

pfefferle avatar Sep 20 '19 19:09 pfefferle

Well, the walker would handle webmention display... initially just text, but ultimately the Facepile and other options.

dshanske avatar Sep 20 '19 19:09 dshanske

Currently it works without... any advantage over the current version?

pfefferle avatar Sep 20 '19 19:09 pfefferle

I am trying to figure out how to move Semantic Linkbacks pieces over without disruption.

dshanske avatar Sep 20 '19 19:09 dshanske

So, this piece does exist in that plugin

dshanske avatar Sep 20 '19 19:09 dshanske

We have multiple requests related to presentation that this would cover... different presentation types

dshanske avatar Sep 20 '19 19:09 dshanske

But the comment walker does not handle the custom comment-types... it only handles the emojis and this was a hack, that is why I am challenging the need of the walker...

pfefferle avatar Sep 20 '19 19:09 pfefferle

The comment walker handled the replies. It displayed them marked up with mf2. You disabled that on your theme, I believe

dshanske avatar Sep 20 '19 20:09 dshanske

Looking at how WordPress handles this. Assuming themes use wp_list_comments...the function offers the option to call an alternate walker or a custom callback function.

But the custom callback function is passed to the comment walker. So, if we use the 'wp_list_comments_args' filter to pass a custom comment walker, that comment walker would decide whether to load the custom callback function.

So, the proposed logic would be as follows.

  • Filter loads walker at a low priority, so anything higher would override, which gives other plugins freedom to do what they want.
  • Add a filter that would allow different callbacks to be loaded based on comment type.
  • There are two options for handling the type 'comment'. One is only getting involved if it is protocol=webmention to present additional info if it is a webmention reply. Second is to take over all comments in order to add microformats 2 markup, but have it look almost exactly like the existing one.
  • If a custom callback is requested in the wp_list_comment arguments, that would override this handling.

@pfefferle Thoughts?

dshanske avatar Mar 22 '22 00:03 dshanske

I think it is a good plan to start but I would skip the comment template overwriting in the first release and fokus on grouping of the comment types. I would also add an option to disable the whole comment-display section, to be able to implement "native" support in themes.

pfefferle avatar Mar 22 '22 12:03 pfefferle

I'm thinking about this... https://core.trac.wordpress.org/ticket/31282

dshanske avatar Mar 26 '22 20:03 dshanske

I added in this https://core.trac.wordpress.org/ticket/55470 to Core, which I thought might help, based on my solution.

dshanske avatar Mar 27 '22 17:03 dshanske