Skip to content

pgedeon/wordpress-ai-sanitizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unicode Invisible Character Cleaner

A WordPress plugin that sanitizes all saved and rendered post content, titles, and excerpts using the same normalization/removal rules as the provided "Unicode Invisible Character Cleaner" HTML tool.

What it does

  • Normalizes CRLF and CR line endings to LF, converts Unicode line/paragraph separators to newlines.
  • Converts tabs to four spaces and collapses a wide range of Unicode space-likes (NBSP, typographic spaces, fillers, zero-width space, etc.) to a regular space.
  • Converts smart quotes and ellipses to ASCII equivalents.
  • Converts invisible mathematical operators to visible characters and replaces the object replacement character with [OBJECT].
  • Removes bidi/formatting characters, variation selectors, soft hyphens, and other invisible control characters.
  • Optionally collapses repeated spaces per line and trims edges (matching the optional toggles in the HTML tool).

Usage

  1. Drop this plugin into your WordPress installation (wp-content/plugins/wordpress-ai-sanitizer).
  2. Activate Unicode Invisible Character Cleaner in the WordPress admin.
  3. All saved content (title, excerpt, and body) is cleaned before storage, and rendered content is also cleaned to cover legacy data.

Configuration

Enable the optional toggles via a filter:

add_filter('wpais_cleaner_options', function ($options) {
    $options['collapse_spaces'] = true; // Collapse multiple spaces per line (newlines preserved)
    $options['trim_edges'] = true;      // Trim leading/trailing whitespace
    return $options;
});

Direct use in code

You can also clean any string manually:

use WordPressAISanitizer\Unicode_Cleaner;

$cleaned = Unicode_Cleaner::clean($text);

Buy me a coffee

https://www.paypal.com/donate/?business=petermgedeon%40gmail.com

About

Removes special characters generated by ai

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages