, and , with ARIA, data-* and form attributes. * * @return array */ public static function allowed() { if ( null !== self::$allowed ) { return self::$allowed; } $common = array( 'class' => true, 'id' => true, 'style' => true, 'title' => true, 'role' => true, 'tabindex' => true, 'hidden' => true, 'lang' => true, 'dir' => true, 'aria-label' => true, 'aria-labelledby' => true, 'aria-describedby' => true, 'aria-hidden' => true, 'aria-live' => true, 'aria-atomic' => true, 'aria-busy' => true, 'aria-current' => true, 'aria-expanded' => true, 'aria-controls' => true, 'aria-haspopup' => true, 'aria-modal' => true, 'aria-pressed' => true, 'aria-selected' => true, 'aria-disabled' => true, 'aria-required' => true, 'aria-invalid' => true, 'aria-valuemin' => true, 'aria-valuemax' => true, 'aria-valuenow' => true, 'aria-valuetext' => true, 'data-*' => true, ); $field = array( 'name' => true, 'value' => true, 'type' => true, 'disabled' => true, 'readonly' => true, 'required' => true, 'placeholder' => true, 'autocomplete' => true, 'form' => true, 'size' => true, ); $extra = array( 'form' => array( 'action' => true, 'method' => true, 'enctype' => true, 'target' => true, 'novalidate' => true, ), 'input' => $field + array( 'checked' => true, 'min' => true, 'max' => true, 'step' => true, 'maxlength' => true, 'minlength' => true, 'pattern' => true, 'accept' => true, 'multiple' => true, 'list' => true, 'inputmode' => true, ), 'select' => $field + array( 'multiple' => true ), 'option' => array( 'value' => true, 'selected' => true, 'disabled' => true, 'label' => true, ), 'optgroup' => array( 'label' => true, 'disabled' => true, ), 'textarea' => $field + array( 'rows' => true, 'cols' => true, 'maxlength' => true, ), 'button' => $field, 'label' => array( 'for' => true ), 'fieldset' => array( 'disabled' => true ), 'legend' => array(), 'output' => array( 'for' => true ), 'progress' => array( 'value' => true, 'max' => true, ), 'meter' => array( 'value' => true, 'min' => true, 'max' => true, ), 'template' => array(), 'dialog' => array( 'open' => true ), 'canvas' => array( 'width' => true, 'height' => true, ), 'time' => array( 'datetime' => true ), 'img' => array( 'src' => true, 'srcset' => true, 'sizes' => true, 'alt' => true, 'width' => true, 'height' => true, 'loading' => true, 'decoding' => true, ), 'a' => array( 'href' => true, 'target' => true, 'rel' => true, 'download' => true, ), ); $tags = wp_kses_allowed_html( 'post' ); foreach ( $extra as $tag => $attrs ) { $tags[ $tag ] = array_merge( isset( $tags[ $tag ] ) ? $tags[ $tag ] : array(), $attrs ); } foreach ( $tags as $tag => $attrs ) { $tags[ $tag ] = array_merge( is_array( $attrs ) ? $attrs : array(), $common ); } self::$allowed = $tags; return $tags; } /** * Escape plugin-built markup. * * @param string $html Markup. * @return string */ public static function kses( $html ) { return wp_kses( (string) $html, self::allowed() ); } /** * Echo plugin-built markup, escaped. * * @param string $html Markup. */ public static function out( $html ) { echo wp_kses( (string) $html, self::allowed() ); } }