I found a really big mistake in my opinion in your plugin.
As i see it is not working properly, beacsue it add to canonical not the main URL of discussion, but it add too all links like ?near=2 near=10
THat means for one same thread can be indexed many different copies, main url plus all ?near=##
As we know CANONICAL should be only one and relative the main thread, with "near" potetially google could index for the same thread as many compies as are the replies.
THis should be fixed, or we risk to incurr in the issue of duplicated contents with risk to be penalized.