[ 'href', 'target', 'rel', 'download', 'hreflang', 'type', 'name' ], 'img' => [ 'src', 'alt', 'width', 'height', 'loading', 'decoding', 'srcset', 'sizes' ], 'form' => [ 'action', 'method', 'enctype', 'name', 'target', 'novalidate', 'autocomplete', 'accept-charset' ], 'input' => [ 'type', 'name', 'value', 'checked', 'disabled', 'readonly', 'required', 'placeholder', 'min', 'max', 'step', 'minlength', 'maxlength', 'size', 'pattern', 'autocomplete', 'inputmode', 'form', 'list', 'multiple', 'accept', 'alt', 'src', 'spellcheck', ], 'select' => [ 'name', 'multiple', 'size', 'disabled', 'required', 'form', 'autocomplete' ], 'option' => [ 'value', 'selected', 'disabled', 'label' ], 'optgroup' => [ 'label', 'disabled' ], 'textarea' => [ 'name', 'rows', 'cols', 'placeholder', 'minlength', 'maxlength', 'disabled', 'readonly', 'required', 'form', 'autocomplete', 'wrap', 'spellcheck' ], 'button' => [ 'type', 'name', 'value', 'disabled', 'form', 'formaction', 'formmethod', 'formnovalidate', 'formtarget' ], 'label' => [ 'for', 'form' ], 'fieldset' => [ 'disabled', 'form', 'name' ], 'legend' => [], 'output' => [ 'for', 'form', 'name' ], 'details' => [ 'open' ], 'summary' => [], 'time' => [ 'datetime' ], 'noscript' => [], 'td' => [ 'colspan', 'rowspan', 'headers' ], 'th' => [ 'colspan', 'rowspan', 'headers', 'scope', 'abbr' ], 'svg' => self::SVG_ATTRIBUTES, 'g' => self::SVG_ATTRIBUTES, 'path' => self::SVG_ATTRIBUTES, 'circle' => self::SVG_ATTRIBUTES, 'rect' => self::SVG_ATTRIBUTES, 'line' => self::SVG_ATTRIBUTES, 'polyline' => self::SVG_ATTRIBUTES, 'polygon' => self::SVG_ATTRIBUTES, 'ellipse' => self::SVG_ATTRIBUTES, 'use' => self::SVG_ATTRIBUTES, 'title' => [], ]; /** * @return array> */ public static function allowed_html(): array { $allowed = wp_kses_allowed_html( 'post' ); foreach ( self::ELEMENTS as $tag => $attributes ) { $current = isset( $allowed[ $tag ] ) && is_array( $allowed[ $tag ] ) ? $allowed[ $tag ] : []; $allowed[ $tag ] = array_merge( $current, array_fill_keys( $attributes, true ) ); } // An element without an attributes array would lose data-* and aria-* (wp_kses() needs the array). $global = array_fill_keys( self::GLOBAL_ATTRIBUTES, true ); foreach ( $allowed as $tag => $attributes ) { $allowed[ $tag ] = array_merge( is_array( $attributes ) ? $attributes : [], $global ); } return $allowed; } }