The kses_init_filters() WordPress PHP function adds all KSES input form content filters.
Usage
kses_init_filters();
Parameters
- None
More information
See WordPress Developer Resources: kses_init_filters()
Examples
Enable KSES filters
Enable the KSES filters for input form content in your WordPress theme or plugin:
add_action('init', 'kses_init_filters');
Remove KSES filters
To remove the KSES filters from input form content in your WordPress theme or plugin:
remove_filter('pre_comment_content', 'wp_filter_kses'); remove_filter('title_save_pre', 'wp_filter_kses'); remove_filter('content_save_pre', 'wp_filter_post_kses'); remove_filter('excerpt_save_pre', 'wp_filter_post_kses'); remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
Check if KSES filters are enabled
To check if KSES filters are enabled for a specific hook:
if (has_filter('pre_comment_content', 'wp_filter_kses')) { echo 'KSES filters are enabled for pre_comment_content.'; } else { echo 'KSES filters are not enabled for pre_comment_content.'; }
Enable KSES filters for custom fields
To enable KSES filters for custom fields, add a filter for the sanitize_meta
hook:
add_filter('sanitize_meta', 'wp_filter_kses', 10, 4);
Enable KSES filters for a custom hook
To enable KSES filters for your custom hook:
add_filter('your_custom_hook', 'wp_filter_kses');
Replace your_custom_hook
with the name of your custom hook.