| 开发者 | motylanogha |
|---|---|
| 更新时间 | 2026年10月2日 19:41 |
| PHP版本: | 8.1 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
<select> dropdowns with visual, accessible swatches on single product pages. Choose a swatch type per attribute (colour dots or button/label pills) and assign a colour or label per term.
The swatches drive WooCommerce's own variations form, so price, stock and the add-to-cart button update exactly as they do with the stock dropdowns. Selected and out-of-combination states are reflected automatically.
The full source lives on GitHub at github.com/wppoland/plogins-swatch if you want to read the code or report a problem.
Features
sanitize_hex_color) and custom label, stored as term meta.plogins-swatch folder to /wp-content/plugins/.Yes. Swatch extends WooCommerce's variable products and does nothing without it.
They get the plugin's default swatch type (button swatches out of the box), the same as any attribute you have not given its own type. Only a colour attribute with no colours configured falls back to the dropdown automatically.
Yes. The front-end is vanilla JavaScript that hooks WooCommerce's own variation events.
Yes. Swatches use radiogroup semantics, arrow-key navigation and visible focus rings.
Yes. Swatches stay in the native variations form with touch-friendly targets; no separate mobile app or script framework is required.
Yes. This plugin is compatible with WordPress Multisite. Network activate it or activate it on individual sites; each site keeps its own settings and data.
wp_kses() with an explicit allowlist at the point it is printed. Every renderer escapes the values it writes, but each one ends in a filter, so what actually reached the page was whatever the last callback returned. An add-on, or anything else hooking those filters, could put unescaped markup on a storefront page. The allowlist covers the elements and attributes the swatches use, including img for the paid edition's image swatches and data-* for the values the script reads.rgb(...) loses that colour. Colours saved on an attribute term are unaffected: they go through sanitize_hex_color() on the way in and on the way out.swatch folder. The package has unpacked to plogins-swatch since the build started taking the folder name from the text domain, so following the readme put the plugin somewhere WordPress would not find it.aria-describedby, so a screen reader reads the explanation with the control.swatch/swatch_group_vars and swatch/swatch_group_classes for PRO sizing and shapes.swatch/product_swatch_html, swatch/archive_swatch_html) and swatch/swatch_items for PRO tooltips and add-ons.swatch/archive_enabled and swatch/archive_html filters for add-ons.swatch/variation_gallery filter and expose swatch_variation_gallery on variation JSON for add-ons.