Created
February 23, 2022 09:29
-
-
Save webtoffee-git/86c49caaf3cbe8179aab57fab6a03e7a to your computer and use it in GitHub Desktop.
Allow custom attributes to html elements - CookieYes | GDPR Cookie Consent (https://wordpress.org/plugins/cookie-law-info/)
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 //do not copy this line | |
add_filter( 'wp_kses_allowed_html', 'wt_cli_allow_custom_attributes', 20, 2); | |
function wt_cli_allow_custom_attributes($tags, $context) { | |
$cli_allowed = array( | |
'data-*' => true, | |
); | |
if( isset($tags['a']) && is_array($tags['a']) ) { | |
$tags['a'] = array_merge($tags['a'], $cli_allowed); | |
} | |
return $tags; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment