The Special SiteSplat Membership has launched! Check our In Da Club Plan 👌
  • Censored words and BBCode
  • General Questions and chit chat NOT related to support. Please Use the "Buyers" section for any support related needs.
General Questions and chit chat NOT related to support. Please Use the "Buyers" section for any support related needs.
Forum rules: ONLY CHIT CHAT :-) Specific theme, MODs/Extensions support only in the "Buyers section". Thank-you!
 #35845  by pawlshepherd
 December 3rd, 2021, 11:35 pm
Asking here before I try the absolute landfill that the phpBB community forums seem to be 😅

Does anybody know if it's possible to get the censored words list to parse BBCode?

I'm trying to implement a way to post custom icons in line with text. So far there is about 170 svg icons, which I intended to convert into two font files using free svg > font services. Each of those fonts would get a custom code tag, [twsfont1] and [twsfont2], which would be replaced by an HTML span.
The censored words list would then change something like what the user types, following this chain:
[aquila] -> [twsfont2]G[/twsfont2] -> <span style="font-family:twsfont2;">G</span>
This would then result in the 'aquila' icon being added to the text. This is the current list of icons, but there will likely be more added in the future.

As it stands the censored words don't parse BBCode, so the result is that something like [twsfont2]G[/twsfont2] gets posted instead.

There's probably an easier way of doing this (definitely easier than messing around with two font files! 😩) but it was the only way I could think of making it work.
 #35846  by Dion
 December 4th, 2021, 5:13 pm
The short answer is no, there is no simple way to do what you want.

The long answer is that I think it's possible to write an extension that disables the s9e textformatter's word censor and replaces it with the original phpBB word censor. It's also possible to write an extension that replaces the ACP word censor module with one that allows HTML in the word replacements. If the two were combined, it would be possible for you to create HTML-based word replacements.

I have long considered it a flaw in phpBB to not allow HTML-based replacements in the word censor. (And also for rank titles.)
 #35848  by pawlshepherd
 December 4th, 2021, 6:31 pm
Of course there isn't. Why would there be? 😂

Would it be easier for me to simply pay the (actually not outrageous) charges for something like Icomoon and just do it properly? I'm getting the feeling it would be!
 #35849  by Dion
 December 4th, 2021, 7:27 pm
It would be much easier to hack phpBB to allow HTML in word censor replacement text in posts. In the vendor/s9e/text-formatter/src/Plugins/Censor/Helper.php file, find the following line:
Code: Select all
				return \htmlspecialchars($this->getReplacement(\html_entity_decode($m[0], \ENT_QUOTES, 'UTF-8')), \ENT_QUOTES);

Change it to this:
Code: Select all
				return \html_entity_decode($this->getReplacement(\html_entity_decode($m[0], \ENT_QUOTES, 'UTF-8')), \ENT_QUOTES);

Save the file. Next, in the includes/functions_content.php file, find the following line:
Code: Select all
		return preg_replace($censors['match'], $censors['replace'], $text);

Change it to this:
Code: Select all
		$replace = array_map(function($v) {return html_entity_decode($v, ENT_QUOTES, 'UTF-8');}, $censors['replace']);
		return preg_replace($censors['match'], $replace, $text);

Save the file and purge the cache. phpBB will now allow HTML replacement text for censored words.Note that you'll need to repeat this hack every time phpBB is updated.


Recent Topics

For those of us still on 3.2 is it advisable to us[…] »MORE«

I'll have play when I get my laptop out later - ch[…] »MORE«

still terrible delay. The package is done. Now its[…] »MORE«

It might quite nooby question but after registrati[…] »MORE«


About us

BBOOTS™ Is The First And Only Fully Responsive PhpBB® Unofficial HTML5/CSS3 Theme. It’s Clean And Crisp Design Looks AWESOME Across All Browsers And Devices.

It Utilizes A Bootstrap Based Layout Which Has Been Long Waited For And That Is Sure To AMAZE The phpBB Fan Club.

BBOOTSThe Unofficial Responsive Theme