Instantly share code, notes, and snippets.
Last active
June 17, 2021 22:13
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save DaveyJake/f6977e35a03d260d5a7805ad11e58a8f to your computer and use it in GitHub Desktop.
[WP] KSES Allowed Post Tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Found at {@link https://wp-mix.com/allowed-html-tags-wp_kses}. | |
| * | |
| * Note that these HTML tags and attributes go beyond those provided | |
| * by wp_kses_post(). So if you’re looking to allow only the same tags | |
| * that are allowed in WP Posts, just use that instead of the custom array. | |
| * | |
| * @author Jeff Staff | |
| * @link https://perishablepress.com | |
| * | |
| * @since 1.0.0 Initial commit. | |
| * @since 1.0.1 SVG tags and attributes support added. | |
| */ | |
| global $allowedposttags; | |
| /** | |
| * Standard HTML tags and attributes. | |
| * | |
| * @since 1.0.0 | |
| */ | |
| $allowed_atts = array( | |
| 'align' => array(), | |
| 'class' => array(), | |
| 'type' => array(), | |
| 'id' => array(), | |
| 'dir' => array(), | |
| 'lang' => array(), | |
| 'style' => array(), | |
| 'xml:lang' => array(), | |
| 'src' => array(), | |
| 'alt' => array(), | |
| 'href' => array(), | |
| 'rel' => array(), | |
| 'rev' => array(), | |
| 'target' => array(), | |
| 'novalidate' => array(), | |
| 'type' => array(), | |
| 'value' => array(), | |
| 'name' => array(), | |
| 'tabindex' => array(), | |
| 'action' => array(), | |
| 'method' => array(), | |
| 'for' => array(), | |
| 'width' => array(), | |
| 'height' => array(), | |
| 'data' => array(), | |
| 'title' => array(), | |
| ); | |
| // Allow HTML tags to have the above attributes. | |
| $allowedposttags['form'] = $allowed_atts; | |
| $allowedposttags['label'] = $allowed_atts; | |
| $allowedposttags['input'] = $allowed_atts; | |
| $allowedposttags['textarea'] = $allowed_atts; | |
| $allowedposttags['iframe'] = $allowed_atts; | |
| $allowedposttags['script'] = $allowed_atts; | |
| $allowedposttags['style'] = $allowed_atts; | |
| $allowedposttags['strong'] = $allowed_atts; | |
| $allowedposttags['small'] = $allowed_atts; | |
| $allowedposttags['table'] = $allowed_atts; | |
| $allowedposttags['span'] = $allowed_atts; | |
| $allowedposttags['abbr'] = $allowed_atts; | |
| $allowedposttags['code'] = $allowed_atts; | |
| $allowedposttags['pre'] = $allowed_atts; | |
| $allowedposttags['div'] = $allowed_atts; | |
| $allowedposttags['img'] = $allowed_atts; | |
| $allowedposttags['h1'] = $allowed_atts; | |
| $allowedposttags['h2'] = $allowed_atts; | |
| $allowedposttags['h3'] = $allowed_atts; | |
| $allowedposttags['h4'] = $allowed_atts; | |
| $allowedposttags['h5'] = $allowed_atts; | |
| $allowedposttags['h6'] = $allowed_atts; | |
| $allowedposttags['ol'] = $allowed_atts; | |
| $allowedposttags['ul'] = $allowed_atts; | |
| $allowedposttags['li'] = $allowed_atts; | |
| $allowedposttags['em'] = $allowed_atts; | |
| $allowedposttags['hr'] = $allowed_atts; | |
| $allowedposttags['br'] = $allowed_atts; | |
| $allowedposttags['tr'] = $allowed_atts; | |
| $allowedposttags['td'] = $allowed_atts; | |
| $allowedposttags['p'] = $allowed_atts; | |
| $allowedposttags['a'] = $allowed_atts; | |
| $allowedposttags['b'] = $allowed_atts; | |
| $allowedposttags['i'] = $allowed_atts; | |
| /** | |
| * SVG tags and attributes. | |
| * | |
| * @since 1.0.1 | |
| */ | |
| $svg_atts = array( | |
| 'alignment-baseline' => array(), | |
| 'aria-hidden' => array(), | |
| 'baseline-shift' => array(), | |
| 'clip' => array(), | |
| 'clip-path' => array(), | |
| 'clip-rule' => array(), | |
| 'color' => array(), | |
| 'color-interpolation' => array(), | |
| 'color-interpolation-filters' => array(), | |
| 'color-profile' => array(), | |
| 'color-rendering' => array(), | |
| 'cursor' => array(), | |
| 'd' => array(), | |
| 'direction' => array(), | |
| 'display' => array(), | |
| 'dominant-baseline' => array(), | |
| 'enable-background' => array(), | |
| 'focusable' => array(), | |
| 'fill' => array(), | |
| 'fill-opacity' => array(), | |
| 'fill-rule' => array(), | |
| 'filter' => array(), | |
| 'flood-color' => array(), | |
| 'flood-opacity' => array(), | |
| 'font-family' => array(), | |
| 'font-size' => array(), | |
| 'font-size-adjust' => array(), | |
| 'font-stretch' => array(), | |
| 'font-style' => array(), | |
| 'font-variant' => array(), | |
| 'font-weight' => array(), | |
| 'glyph-orientation-horizontal' => array(), | |
| 'glyph-orientation-vertical' => array(), | |
| 'image-rendering' => array(), | |
| 'kerning' => array(), | |
| 'letter-spacing' => array(), | |
| 'lighting-color' => array(), | |
| 'marker-end' => array(), | |
| 'marker-mid' => array(), | |
| 'marker-start' => array(), | |
| 'mask' => array(), | |
| 'opacity' => array(), | |
| 'overflow' => array(), | |
| 'pointer-events' => array(), | |
| 'role' => array(), | |
| 'shape-rendering' => array(), | |
| 'solid-color' => array(), | |
| 'solid-opacity' => array(), | |
| 'stop-color' => array(), | |
| 'stop-opacity' => array(), | |
| 'stroke' => array(), | |
| 'stroke-dasharray' => array(), | |
| 'stroke-dashoffset' => array(), | |
| 'stroke-linecap' => array(), | |
| 'stroke-linejoin' => array(), | |
| 'stroke-miterlimit' => array(), | |
| 'stroke-opacity' => array(), | |
| 'stroke-width' => array(), | |
| 'text-anchor' => array(), | |
| 'text-decoration' => array(), | |
| 'text-rendering' => array(), | |
| 'transform' => array(), | |
| 'unicode-bidi' => array(), | |
| 'vector-effect' => array(), | |
| 'viewbox' => array(), | |
| 'visibility' => array(), | |
| 'word-spacing' => array(), | |
| 'writing-mode' => array(), | |
| 'xmlns' => array(), | |
| ); | |
| // Allow SVG tag to have the above attributes. | |
| $allowedposttags['svg'] = $svg_attrs; | |
| $allowedposttags['symbol'] = $svg_attrs; | |
| $allowedposttags['g'] = $svg_attrs; | |
| $allowedposttags['path'] = $svg_attrs; | |
| $allowedposttags['use'] = array( | |
| 'href' => true, | |
| 'xlink:href' => true, | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment