Skip to content

Instantly share code, notes, and snippets.

@andcam
Created June 21, 2021 13:12
Show Gist options
  • Save andcam/05829e404f47319dc7c1dd51d903e53a to your computer and use it in GitHub Desktop.
Save andcam/05829e404f47319dc7c1dd51d903e53a to your computer and use it in GitHub Desktop.
Wordpress: Allow HTML in term descriptions (disable KSES filter)
/*
* Allow HTML in term descriptions.
* https://developer.wordpress.org/reference/functions/wp_filter_kses/
*
*/
function ljxdm_disable_kses_on_terms() {
if ( current_user_can( 'unfiltered_html' ) ) {
foreach ( array( 'pre_term_description' ) as $filter ) {
remove_filter( $filter, 'wp_filter_kses' );
}
}
foreach ( array( 'term_description' ) as $filter ) {
remove_filter( $filter, 'wp_kses_data' );
}
}
add_action( 'init', 'ljxdm_disable_kses_on_terms' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment