Another way might be to installl this mod:
https://vborg.vbsupport.ru/showthread.php?t=264896 (a very cool mod which I'm surprised has gotten more attention), then just use the bbcode manager to create a new bbcode, and put the php in the html replacement box, like:
PHP Code:
<?php
$p = str_replace(array(' ', '"', "'"), array('_', '', ''), $param);
return '<a href="http://alg.garron.us/?alg='.$p.'">'.$param.'</a>';
and just to be clear, you then don't need to create any plugins or change anything else.
BTW, I haven't test this, so if you decide to try this way and it doesn't work, let us know.