wp-html-api

Inspect and mutate HTML in WordPress plugins using WP_HTML_Tag_Processor and WP_HTML_Processor.

21|1|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill wp-html-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wp-html-api
Source: https://github.com/Lonsdale201/wp-agent-skills/tree/main/wordpress/wp-html-api
Command: npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill wp-html-api

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

WordPress plugins and themes rely on HTML parsing and manipulation. Using regex, DOMDocument, or ad-hoc escaping can lead to broken markup and security risks. This skill provides safe server-side HTML inspection and mutation using WordPress' HTML API, guiding you to use WP_HTML_Tag_Processor and WP_HTML_Processor to modify HTML reliably and safely.

Core Features & Use Cases

  • Safe attribute and class mutations via WP_HTML_Tag_Processor
  • Structural HTML handling and token serialization with WP_HTML_Processor
  • Correct data-* attribute handling and awareness of WP 6.9 escaping behavior
  • Suitable for plugin code that reads or modifies rendered HTML, shortcodes, content filters, widget markup, or emails

Quick Start

Process a snippet of HTML with WP_HTML_Tag_Processor to add a class to all links.

Frequently Asked Questions about wp-html-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely modify HTML attributes in WordPress plugins without using regex?

To safely modify HTML attributes in WordPress plugins, use the WP_HTML_Tag_Processor from the HTML API. It performs safe attribute and class mutations on rendered content, avoiding the broken markup and security risks associated with regex.

What is the best way to mutate shortcode HTML output in WordPress?

The best way to mutate shortcode HTML output in WordPress is using the HTML API. Apply WP_HTML_Tag_Processor to inspect and modify rendered shortcode markup safely, then call get_updated_html() to retrieve the final modified content.

Does the WordPress HTML API handle data attributes and escaping correctly?

Yes, the WordPress HTML API handles data attributes and respects the WP 6.9 escaping behavior. Using WP_HTML_Tag_Processor ensures correct data-* attribute manipulation and safe escaping when mutating plugin HTML content.

How do I get the modified HTML after using WP_HTML_Tag_Processor?

To get the modified HTML after using WP_HTML_Tag_Processor, you must explicitly call the get_updated_html() method. This function returns the final HTML string reflecting all attribute, class, or text mutations applied during processing.

Can I use WP_HTML_Processor for structural HTML changes in widget markup?

Yes, you can use WP_HTML_Processor for structural HTML handling and token serialization in widget markup. It works alongside WP_HTML_Tag_Processor to inspect and mutate rendered HTML content safely within WordPress plugins.

Why should I use the WordPress HTML API instead of DOMDocument for content filters?

You should use the WordPress HTML API instead of DOMDocument for content filters to avoid security risks and broken markup. The HTML API provides native, safe server-side HTML inspection and mutation specifically designed for the WordPress environment.