Brandon Hubbard Engineering / wp-gemini-cleaner
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
GitHub ↗
Unicode Sanitization U+200B..U+200F / BOM
Gutenberg Valid 100% Block Grammar
Smart Typography Curly Quotes & Dashes
Hook Overhead < 0.4 ms / Post
Interactive AI Draft Invisible Unicode & Gutenberg Block Sanitizer
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)