A lightweight, developer-focused profanity filter for Craft CMS. Detect and mask inappropriate content in your frontend templates using advanced pattern matching.
- Twig Filters -
maskProfanityandhasProfanityfor template use - Advanced Pattern Matching - Detects variations including substitutions, obscured text, and repeated letters
- Config-Based - Customize the word list via a simple config file
- Craft CMS
4.0.0or later - PHP
8.0.2or later
composer require simplygoodwork/cursesThen install the plugin from the Control Panel or run:
php craft plugin/install cursesMasks profanity in text using the configured mask character (default *):
{{ entry.body|maskProfanity }}
{# Output: "This is some **** text" #}
{# Override mask character for this call #}
{{ entry.body|maskProfanity('#') }}
{# Output: "This is some #### text" #}Check if text contains profanity:
{% if entry.body|hasProfanity %}
<p class="warning">This content may contain inappropriate language.</p>
{% endif %}
{# As a function #}
{% if hasProfanity(entry.body) %}
{# ... #}
{% endif %}The plugin comes with a blank list of words. To customize:
- Copy
vendor/simplygoodwork/curses/src/config.phptoconfig/curses.php - Modify the settings as needed
// config/curses.php
return [
// Character used to mask profanity (default: '*')
// Set to an empty string '' to remove profanity entirely instead of masking
'maskCharacter' => '*',
// Your word list
'profanities' => [
'word1',
'word2',
// ...
],
];The config file is multi-environment aware, so you can have different settings per environment.
The plugin detects various obfuscation techniques:
- Straight Match:
profanity - Substitution:
pr0f@n1ty(common letter replacements like a→@, e→3, i→1) - Obscured:
p-r-o-f-a-n-i-t-y(with separators like -, _, .) - Doubled:
pprrooffaanniittyy(repeated letters) - Combined:
p-r0f@n|tty(mix of techniques)
- Request-level caching - Patterns are compiled once per request
- Efficient regex - Single-pass matching for all word variations
- No database queries - Words loaded from config file
See CHANGELOG.md
Submit an issue on GitHub.
Brought to you by Good Work