>|null */ private static $allowed = null; /** * Tags and attributes the admin screens print, for wp_kses(). * * @return array> */ public static function allowed(): array { if ( null !== self::$allowed ) { return self::$allowed; } $global = array_fill_keys( array( 'class', 'id', 'style', 'title', 'role', 'tabindex', 'hidden', 'inert', 'lang', 'dir', 'data-*', 'aria-current', 'aria-describedby', 'aria-expanded', 'aria-haspopup', 'aria-hidden', 'aria-label', 'aria-labelledby', 'aria-pressed', 'aria-live', 'aria-controls', 'aria-modal', 'aria-selected', 'aria-valuemin', 'aria-valuemax', 'aria-valuenow', ), true ); $extra = array( 'a' => array( 'href', 'target', 'rel', 'download' ), 'button' => array( 'type', 'name', 'value', 'disabled', 'form' ), 'form' => array( 'method', 'action', 'target', 'enctype', 'name', 'novalidate' ), 'input' => array( 'type', 'name', 'value', 'checked', 'disabled', 'readonly', 'required', 'placeholder', 'min', 'max', 'step', 'maxlength', 'minlength', 'autocomplete', 'spellcheck', 'size', 'form', 'pattern', 'multiple', 'accept' ), 'textarea' => array( 'name', 'rows', 'cols', 'placeholder', 'readonly', 'disabled', 'required', 'maxlength', 'minlength', 'spellcheck', 'autocomplete' ), 'select' => array( 'name', 'disabled', 'required', 'multiple', 'autocomplete' ), 'option' => array( 'value', 'selected', 'disabled', 'label' ), 'optgroup' => array( 'label', 'disabled' ), 'label' => array( 'for' ), 'fieldset' => array( 'disabled', 'name' ), 'legend' => array(), 'details' => array( 'open', 'name' ), 'summary' => array(), 'dialog' => array( 'open' ), 'img' => array( 'src', 'alt', 'width', 'height', 'loading', 'decoding' ), 'time' => array( 'datetime' ), 'table' => array(), 'thead' => array(), 'tbody' => array(), 'tr' => array(), 'th' => array( 'scope', 'colspan', 'rowspan' ), 'td' => array( 'colspan', 'rowspan' ), 'svg' => array( 'xmlns', 'viewbox', 'width', 'height', 'fill', 'stroke', 'stroke-width', 'focusable' ), 'g' => array( 'fill', 'stroke', 'transform' ), 'path' => array( 'd', 'fill', 'stroke', 'stroke-width', 'stroke-linecap', 'stroke-linejoin', 'fill-rule', 'clip-rule', 'transform' ), 'rect' => array( 'x', 'y', 'width', 'height', 'rx', 'ry', 'fill', 'stroke', 'stroke-width', 'transform' ), 'circle' => array( 'cx', 'cy', 'r', 'fill', 'stroke', 'stroke-width' ), 'defs' => array(), 'lineargradient' => array( 'id', 'x1', 'x2', 'y1', 'y2', 'gradientunits' ), 'stop' => array( 'offset', 'stop-color', 'stop-opacity' ), 'ol' => array( 'start', 'reversed' ), 'ul' => array(), 'li' => array( 'value' ), 'dl' => array(), 'dt' => array(), 'dd' => array(), ); foreach ( array( 'div', 'span', 'p', 'strong', 'b', 'em', 'i', 'small', 'code', 'pre', 'br', 'hr', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'section', 'aside', 'header', 'footer', 'main', 'nav', 'kbd', 'mark', 'sup', 'sub', 'abbr' ) as $tag ) { $extra[ $tag ] = isset( $extra[ $tag ] ) ? $extra[ $tag ] : array(); } $allowed = array(); foreach ( $extra as $tag => $attrs ) { $allowed[ $tag ] = array_merge( $global, array_fill_keys( $attrs, true ) ); } /** * Filters the HTML allowed on HandyMCP admin screens. * * @param array> $allowed Tags and attributes. */ self::$allowed = (array) apply_filters( 'handymcp_admin_allowed_html', $allowed ); return self::$allowed; } /** * Escape admin markup for output. * * @param string $html Markup. */ public static function kses( string $html ): string { return wp_kses( $html, self::allowed() ); } }