0
Add a shared helper so shortcodes validate attributes against the block's own attribute schema
Source: impress-org/givewp#8372 · opened by @WayneRocha
Context Shortcodes that render block templates through ShortcodeRenderController parse their own attributes separately from the blocks they mirror. In CampaignGridShortcode::parseAttributes(), the allowed values and defaults for layout, sort_by and order_by currently live as inline arrays, while the mirrored block's block.json already defines the same enums and defaults as its own attribute schema. ShortcodeRenderController exists so shortcodes can reuse block functionality and keep rendering in sync — attribute parsing should work the same way. Proposal Add a helper (on or alongside ShortcodeRenderController) that loads a block's attribute schema (block.json) and applies it to shortcode attributes, so shortcode and block controls share one source: • Allowed values come from each attribute's enum; invalid values fall back to the attribute's default. • String-valued attributes are sanitized (sanitize_text_field) before use. • Read the block me…
No pledges yet. Be the first to back this.
No comments yet.