Maybe... (i'm writing this code fast, maybe have syntax errors):
<?php namespace AntoineFr\BBCode\FA\Listeners;
use Flarum\Event\ConfigureFormatter;
use Illuminate\Contracts\Events\Dispatcher;
class AddBBCode
{
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigureFormatter::class, [$this, 'addBBCode']);
}
public function addBBCode(ConfigureFormatter $event)
{
$event->configurator->BBCodes->addCustom(
'[ADS]{ADSLOT}[/ADS]',
'<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="blablablabla"
data-ad-slot="' . {ADSLOT} . '"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>'
);
}
}
Not sure if this will work... check by yourself...
You should add into posts the BBCODE like... [ADS]1232234223[/ADS]
assuming that 1232234223 is the ad slot you want to use.
In this way the code will be refreshed when a discussion have lots of replies, because is how flarum works.