=== MarkuClean - AI Markup Cleaner === Contributors: ivijanstefan, creativform Tags: chatgpt, content cleaner, blockeditor, ai, html Requires at least: 5.8 Tested up to: 6.9 Requires PHP: 7.4 Stable tag: 1.0.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Clean and sanitize AI-generated HTML content without breaking WordPress, Gutenberg or Elementor. == Description == MarkuClean Markup Cleaner is a lightweight and safe WordPress plugin designed to clean unwanted HTML artifacts generated by AI tools such as ChatGPT. Modern AI tools often inject technical markup into copied content, including attributes like: - data-start="123" - data-end="456" - <hr data-start="..." data-end="..." /> - UI markers from AI interfaces These attributes are not part of WordPress logic and can pollute your HTML, create spacing issues, or introduce unnecessary clutter into your content. This plugin removes only those AI-specific artifacts while preserving: - Gutenberg block structure - WordPress block comments (``) - Elementor data attributes - Other builder-related data-* attributes - Core WordPress formatting It is designed to be safe, minimal and non-destructive. == Features == - Removes data-start and data-end attributes (numeric only) - Removes entire `
Text...
Text...
` == Performance == The plugin uses targeted regex and minimal processing. It does not load unnecessary libraries. It does not run heavy DOM rewrites unless required. Impact on performance is negligible. == Security == The plugin: - Does not store external data - Does not send data outside WordPress - Does not modify user roles or permissions - Only filters content during save == Installation == 1. Upload the plugin folder to `/wp-content/plugins/` 2. Activate through the WordPress admin panel 3. Done. == Frequently Asked Questions == = Will this break Gutenberg? = No. The plugin does not touch block comments or block JSON attributes. = Will this break Elementor? = No. Elementor data attributes remain untouched. Only AI-specific numeric data-start and data-end attributes are removed. = Does it remove all data-* attributes? = No. Only data-start and data-end when numeric. = Can I disable save cleanup? = Yes, if the plugin version includes the advanced option in settings. = Does this plugin provide developer hooks and filters? = Yes. The plugin provides several WordPress filters that allow developers to change default behavior, extend cleanup rules, and control where cleanup is applied. Below is a list of available filters and practical usage examples. = How do I change the default enabled post types? = Use the `aicc_default_enabled_post_types` filter. By default, the plugin enables cleanup for `post`. You can change that default list like this: `aicc_default_enabled_post_types` Example: `` Use this when you want the plugin to automatically start with more post types enabled on first save or fresh installation. = How do I change which post types are available in plugin settings? = Use the `aicc_available_post_types` filter. This filter lets you modify the list of post types shown in the admin settings screen. `aicc_available_post_types` Example: `` Use this when you want to re-include post types hidden by default, such as `attachment`, or remove custom post types from the UI. = How do I force display cleanup on all WordPress queries, not just the main query? = Use the `aicc_display_apply_to_all_queries` filter. By default, front-end display cleanup is limited to the main query. This filter allows cleanup for secondary queries too. `aicc_display_apply_to_all_queries` Example: `` Use this if your theme or page builder renders content through custom `WP_Query` loops and you want the cleanup to apply there too. = How can I modify the final sanitized output? = Use the `aicc_sanitized_output` filter. This filter runs on the final cleaned string and allows last-step adjustments based on context. `aicc_sanitized_output` Example: `` Possible contexts include values such as `title`, `content`, and `excerpt`. Use this when you want to apply final project-specific formatting after the plugin finishes cleanup. = How do I customize character replacements? = Use the `aicc_character_replacements` filter. The plugin contains a default replacement map for problematic characters and formatting artifacts. You can extend or change that map. `aicc_character_replacements` Example: `` Use this when you want stricter typography normalization or custom replacements for your editorial workflow. = How do I add or remove regex cleanup rules? = Use the `aicc_regex_rules` filter. The plugin includes default regex-based cleanup rules and also merges rules saved in plugin settings. This filter lets you modify that final rule list. `aicc_regex_rules` Example: `` Each pattern must be a valid PCRE regular expression with delimiters. Use this when you want to remove repeated disclaimers, labels, or project-specific AI paste artifacts. = How do I remove additional unwanted DOM elements during cleanup? = Use the `aicc_remove_elements_xpath` filter. The plugin removes several UI-only elements from pasted AI markup using XPath expressions. You can extend that list. `aicc_remove_elements_xpath` Example: `` Use this when pasted content contains extra wrappers, buttons, toolbars, or other non-content HTML elements. = How do I remove additional HTML attributes during DOM cleanup? = Use the `aicc_remove_attributes` filter. The plugin removes a predefined list of noisy attributes such as `data-*`, `style`, and editor-specific attributes. You can extend or reduce that list. `aicc_remove_attributes` Example: `` Use this when your pasted markup contains additional attributes you do not want to keep in saved content. = Where should I add these code snippets? = Add them to one of the following places: 1. Your theme's `functions.php` 2. A custom site plugin 3. A mu-plugin 4. Your own extension plugin For production use, a custom plugin or mu-plugin is recommended instead of editing the active theme. = Do I need to return the same data type in each filter? = Yes. Always return the expected type: - `aicc_default_enabled_post_types` -> array - `aicc_available_post_types` -> array of `WP_Post_Type` objects indexed by slug - `aicc_display_apply_to_all_queries` -> bool - `aicc_sanitized_output` -> string - `aicc_character_replacements` -> array - `aicc_regex_rules` -> array - `aicc_remove_elements_xpath` -> array - `aicc_remove_attributes` -> array Returning the wrong type may cause cleanup issues or unexpected behavior. = Can I use multiple filters together? = Yes. These filters are designed to be combined. For example, you can: - enable more post types by default - add your own regex cleanup rules - remove extra DOM elements - normalize custom characters - force display cleanup on secondary loops This makes the plugin flexible for different editorial workflows and content pipelines. == Changelog == = 1.0.0 = - Initial release - Removes AI-specific data-start and data-end attributes - Removes AI-generated