This conditional could be made shorter:
```$replacement_append = $token_type === 'LOCAL_URL' ? generate_board_url() . '/' : '';
$replacement = $replacement_append . '${' . ($n + 1) . '}';
$sp_replace = str_replace($token, $replacement, $sp_replace);```