Knowledge Base

How to change word censor behaviour to work with Code Tags
Article ID: 855
Written By: 4Teach
Written On: Sun Nov 28, 2010 11:08 am
Description: This article describes how to change word censor behavior to work with BBCode [code] tags.
link to this article on phpbb.com: Select All
[kb=how-to-change-word-censor-behaviour-to-work-with-code-tags]How to change word censor behaviour to work with Code Tags[/kb]
link to this article on your own board: Select All
[url=http://www.phpbb.com/kb/article/how-to-change-word-censor-behaviour-to-work-with-code-tags/]Knowledge Base - How to change word censor behaviour to work with Code Tags[/url]

Hi,
There are many topics on why the word censor does not work with code tags. This article will cover how to do it.

Tools needed:
FTP Client (like FileZilla), Text editor (like Notepad++)

Procedure:
First of all, you need to download the following file:
root/includes/bbcode.php
Before you begin editing it, you must make a backup of the file.

Open the file "bbcode.php" in a text editor.

Find: (Tip: Press F3 to start searching part of code which you are looking for.)
Code: Select all
         // Remove the uid from tags that have not been transformed into HTML
         if ($this->bbcode_uid)
         {
            $message = str_replace(':' . $this->bbcode_uid, '', $message);

After, add:
Code: Select all
            $message = censor_text($message);

After editing, that part of code should look like the following.

Code: Select all
         // Remove the uid from tags that have not been transformed into HTML
         if ($this->bbcode_uid)
         {
            $message = str_replace(':' . $this->bbcode_uid, '', $message);
            $message = censor_text($message);


Tested on phpBB v3.0.7-PL1
Thanks!