Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Created February 23, 2022 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webtoffee-git/86c49caaf3cbe8179aab57fab6a03e7a to your computer and use it in GitHub Desktop.
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/)
<?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