PHP · WORDPRESS EDITORIAL UTILITY
wp-gemini-cleaner — WordPress Editorial Sanitizer for AI-Generated Content
wp-gemini-cleaner is a WordPress content filter plugin that automatically strips zero-width Unicode watermarks, invisible directional characters, and smart-quote artifacts when pasting text from LLMs. It runs on wp_insert_post_data and inside the Gutenberg editor to keep database markup clean.
$ wp plugin activate wp-gemini-cleaner
Copy
GitHub ↗
Unicode Sanitization
U+200B..U+200F / BOM
Gutenberg Valid
100% Block Grammar
Smart Typography
Curly Quotes & Dashes
Hook Overhead
< 0.4 ms / Post
01. Interactive Workbench
02. Reference Implementation
03. Architecture & Specs
Interactive AI Draft Invisible Unicode & Gutenberg Block Sanitizer
Raw LLM / Gemini Paste Buffer
Sanitization & Normalization Ruleset
Full Editorial Clean (Strip Zero-Width Unicode + Unwrap Codefences + Convert Residual Markdown)
Unicode Hygiene Only (Purge U+200B, U+FEFF, U+00A0, U+202F)
Gutenberg Block Converter (Wrap clean paragraphs in `<!-- wp:paragraph -->`)
Audit Mode — Highlight Hidden AI Watermark Characters
Execute Pipeline ▶
Reset
Deterministic Execution Output & Telemetry
STATUS: READY // 0 ERRORS
PHP (WordPress `wp_insert_post_data` Filter)
function wp_gemini_cleaner_sanitize_content( string $content ): string {
// 1. Strip zero-width spaces, joiners, and byte-order marks
$content = preg_replace( '/[\x{200B}-\x{200D}\x{FEFF}\x{2060}]/u', '', $content );
// 2. Unwrap accidental outer ```html ... ``` fences
$content = preg_replace( '/^\s*```(?:html)?\s*(.*?)\s*```\s*$/is', '$1', $content );
return trim( $content );
}
add_filter( 'content_save_pre', 'wp_gemini_cleaner_sanitize_content', 10, 1 );
Production Engineering Specifications
Repository: https://github.com/bhubbard/wp-gemini-cleaner
Live Studio: https://code.brandonhubbard.com/wp-gemini-cleaner/
Portal: https://code.brandonhubbard.com/
Install: wp plugin activate wp-gemini-cleaner
Design System: Brandon Hubbard Swiss Modernist (#0A0A0C / 1px Exposed Structural Grid)