XF 1.5 Prevent parsing of URL inside custom BBCode (PHP)

ungovernable

Active member
I made a custom BBCode that takes an URL, verify the link, do some stuff, and display the URL with custom formatting

Something like that:
Code:
class myaddon_bbcode_downloadLink
{
    public static function whatever(array $tag, array $rendererStates, XenForo_BbCode_Formatter_Base $formatter)
    {

        $content = $tag['children'];

           // do some stuff

        return $content;
    }
}

When I post an URL with my custom BBcode, it looks fine at first:
1587545842448.webp

But after posting, the URL is parsed into an embedded link with the page title
1587546207069.webp

How can I prevent parsing url and stripping all bbcode inside my function? I want to keep the raw url as string

Thanks
 
Enable Disable auto-linking in the Advanced options of your custom BB Code.
Thank you! Not sure how I missed this option, but it did the job!

However, it didn't fix the issue with posts already published with the BBCode and containing embedded links inside the BBCode

Is there a "strip bbcode" function to remove BBCode with PHP, while keeping the content between the brackets? Or should I write my own function?
 
Is there a "strip bbcode" function to remove BBCode with PHP, while keeping the content between the brackets? Or should I write my own function?
Depending on how much existing content is affected, if it is feasible, it may be a better move to just manually correct the issue. Otherwise you could probably run a one time script to solve it for you. I definitely wouldn't recommend "fixing" it in the bb code, as that would need to do it every time the content is rendered.
 
I managed to remove the BBCode using this:
Code:
 preg_replace('#\[[^\]]+\]#', '', $str);

Now I'm trying to figure out how I can access the thread_id in my function
$this->get('thread_id') returns an error
 
Top Bottom