Select one or more tags, then press “Search Plugins”

Find Plugin with any / all of the selected criteria
Search Plugin

Mtwdev Custom HTML Attributes For Blocks Wordpress Plugin - Rating, Reviews, Demo & Download

Mtwdev Custom HTML Attributes For Blocks Preview Wordpress Plugin - Rating, Reviews, Demo & Download
No ratings yet
Free
Follow for free plugins, new theme releases and theme news

Plugin Description

Custom HTML Attributes for Blocks is a lightweight extension for the WordPress Block Editor (Gutenberg) that allows site editors and developers to inject standard and custom HTML attributes into any supported block.

Whether you need to add custom attributes for analytics tracking (data-track-event="click"), improve accessibility (aria-label, aria-describedby, role), or use modern HTML5 boolean attributes (download, inert), this plugin provides an intuitive, high-performance interface directly within the native Gutenberg Advanced panel.

Key Features

  • Native Block Inspector Integration: Seamlessly placed in the block settings sidebar (Advanced panel) without intrusive floating buttons or separate inspectors.
  • Quick Presets Bar: One-click shortcuts for commonly used attributes (data-*, aria-label, title, download, role, tabindex, inert).
  • Clean Boolean Attribute Support: True HTML5 boolean attributes rendered cleanly without empty quotes or values (download, inert).
  • Allow-List Validation: Only data-*, aria-*, and a documented set of standard attributes (role, title, tabindex, lang, dir, inert, hidden, download, rel, target, name, for, autocomplete, xml:lang) are injected. URL-bearing and namespace attributes (href, src, xmlns:*, xlink:*) are always refused.
  • Multi-Layer Security Hardening:
    • Automatic blocking of inline JavaScript event handlers (any name starting with on, see the FAQ).
    • Deep validation against dangerous pseudo-protocols (javascript:, vbscript:, data:text/html).
    • Blocked modification of reserved layout and style attributes (class, id, style).
    • Capability check (unfiltered_html, fully customizable via filter) enforced on save for every post type and editor through parse_blocks()/serialize_blocks().
  • Zero Frontend Bloat: Enqueues zero extra CSS or JS files on the frontend. Attribute injection is handled dynamically at render time via WordPress core’s native WP_HTML_Tag_Processor.
  • Zero Block Invalidation: Attributes are stored safely in block metadata. Disabling the plugin will never break or invalidate your blocks.
  • Translatable: Every string uses the plugin text domain and is ready for the community translations published as language packs on translate.wordpress.org. A .pot template ships in languages/.
  • Fully Extensible: Customizable via PHP filters for developers and agencies.

Source Code

The plugin ships with its compiled assets (build/). The human-readable source of every compiled file is available in the public repository: https://github.com/mtwdeveloper/mtwdev-custom-attributes. It is also included in the distributed ZIP (src/), together with the build configuration (package.json).

Developer Extensibility & Hooks

  • mtwdev_custom_attributes_capability: Customize the required user capability (default: unfiltered_html).
  • mtwdev_custom_attributes_allowed: Extend the allowed attribute names and prefixes.
  • mtwdev_custom_attributes_unsupported_blocks: Add or remove block slugs that should not allow custom attributes.
  • mtwdev_custom_attributes_disallowed: Extend the additional disallowed HTML attribute blacklist.

Screenshots

  1. The Custom HTML Attributes control inside the native Advanced panel of the block settings sidebar.

    The Custom HTML Attributes control inside the native Advanced panel of the block settings sidebar.

  2. A block with key-value attributes (data-track, aria-label) and boolean attributes (download) configured.

    A block with key-value attributes (data-track, aria-label) and boolean attributes (download) configured.

  3. The rendered front-end markup with the attributes injected into the block's opening tag.

    The rendered front-end markup with the attributes injected into the block’s opening tag.


Reviews & Comments