Created
September 12, 2022 05:21
-
-
Save dlxsnippets/a45b74953c34cd24eeda12606027c3da to your computer and use it in GitHub Desktop.
Get KSES Allowed HTML with SVGs
This file contains 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 | |
/** | |
* Returns appropriate html for KSES. | |
* | |
* @param bool $svg Whether to add SVG data to KSES. | |
*/ | |
public static function get_kses_allowed_html( $svg = true ) { | |
$allowed_tags = wp_kses_allowed_html(); | |
$allowed_tags['nav'] = array( | |
'class' => array(), | |
); | |
$allowed_tags['a']['class'] = array(); | |
if ( ! $svg ) { | |
return $allowed_tags; | |
} | |
$allowed_tags['svg'] = array( | |
'xmlns' => array(), | |
'fill' => array(), | |
'viewbox' => array(), | |
'role' => array(), | |
'aria-hidden' => array(), | |
'focusable' => array(), | |
'class' => array(), | |
); | |
$allowed_tags['path'] = array( | |
'd' => array(), | |
'fill' => array(), | |
'opacity' => array(), | |
); | |
$allowed_tags['g'] = array(); | |
$allowed_tags['use'] = array( | |
'xlink:href' => array(), | |
); | |
$allowed_tags['symbol'] = array( | |
'aria-hidden' => array(), | |
'viewBox' => array(), | |
'id' => array(), | |
'xmls' => array(), | |
); | |
return $allowed_tags; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment