There are e.g. the following dynamic sanitize_term_fields()
filters:
edit_term_{$field}
filter for the edit context
pre_term_{$field}
filter for the the db context
term_{$field}_rss
filter for the the rss context
term_{$field}
filter (default)
and also the taxonomy-specific ones:
edit_{$taxonomy}_{$field}
filter for the edit context
pre_{$taxonomy}_{$field}
filter for the the db context
{$taxonomy}_{$field}_rss
filter for the the rss context
{$taxonomy}_{$field}
filter (default)
If the context is raw then none of the above filters are applied.
The db context is used within the wp_insert_term()
and wp_update_term()
:
$args = sanitize_term($args, $taxonomy, 'db');
There's also the pre_insert_term
filter wihtin wp_insert_term()
.
/**
* Filters a term before it is sanitized and inserted into the database.
*
* @since 3.0.0
*
* @param string $term The term to add or update.
* @param string $taxonomy Taxonomy slug.
*/
$term = apply_filters( 'pre_insert_term', $term, $taxonomy );
Here are simple demo examples for the term description in the case of the post tags taxonomy:
edit context:
add_filter( 'edit_post_tag_description', 'wp_strip_all_tags' );
db context:
add_filter( 'pre_post_tag_description', 'wp_strip_all_tags' );
You might want to test and restrict this further to your needs.
Note: It might be better to just strip it where you output the term description on the front-end, so you don't mess with the user input in the backend?