-
-// Some default filters
-add_filter('bloginfo','wp_specialchars');
-add_filter('category_description', 'wptexturize');
-add_filter('list_cats', 'wptexturize');
-add_filter('comment_author', 'wptexturize');
-add_filter('comment_text', 'wptexturize');
-add_filter('single_post_title', 'wptexturize');
-add_filter('the_title', 'wptexturize');
-add_filter('the_content', 'wptexturize');
-add_filter('the_excerpt', 'wptexturize');
-add_filter('bloginfo', 'wptexturize');
-
-// Comments, trackbacks, pingbacks
-add_filter('pre_comment_author_name', 'strip_tags');
-add_filter('pre_comment_author_name', 'trim');
-add_filter('pre_comment_author_name', 'wp_specialchars', 30);
-
-add_filter('pre_comment_author_email', 'trim');
-add_filter('pre_comment_author_email', 'sanitize_email');
-
-add_filter('pre_comment_author_url', 'strip_tags');
-add_filter('pre_comment_author_url', 'trim');
-add_filter('pre_comment_author_url', 'clean_url');
-
-add_filter('pre_comment_content', 'stripslashes', 1);
-add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
-add_filter('pre_comment_content', 'balanceTags', 30);
-add_filter('pre_comment_content', 'addslashes', 50);
-
-add_filter('pre_comment_author_name', 'wp_filter_kses');
-add_filter('pre_comment_author_email', 'wp_filter_kses');
-add_filter('pre_comment_author_url', 'wp_filter_kses');
-
-// Default filters for these functions
-add_filter('comment_author', 'wptexturize');
-add_filter('comment_author', 'convert_chars');
-add_filter('comment_author', 'wp_specialchars');
-
-add_filter('comment_email', 'antispambot');
-
-add_filter('comment_url', 'clean_url');
-
-add_filter('comment_text', 'convert_chars');
-add_filter('comment_text', 'make_clickable');
-add_filter('comment_text', 'force_balance_tags', 25);
-add_filter('comment_text', 'wpautop', 30);
-add_filter('comment_text', 'convert_smilies', 20);
-
-add_filter('comment_excerpt', 'convert_chars');
-
-// Categories
-add_filter('pre_category_name', 'strip_tags');
-add_filter('pre_category_name', 'trim');
-add_filter('pre_category_name', 'wp_filter_kses');
-add_filter('pre_category_name', 'wp_specialchars', 30);
-add_filter('pre_category_description', 'wp_filter_kses');
-
-// Users
-add_filter('pre_user_display_name', 'strip_tags');
-add_filter('pre_user_display_name', 'trim');
-add_filter('pre_user_display_name', 'wp_filter_kses');
-add_filter('pre_user_display_name', 'wp_specialchars', 30);
-add_filter('pre_user_first_name', 'strip_tags');
-add_filter('pre_user_first_name', 'trim');
-add_filter('pre_user_first_name', 'wp_filter_kses');
-add_filter('pre_user_first_name', 'wp_specialchars', 30);
-add_filter('pre_user_last_name', 'strip_tags');
-add_filter('pre_user_last_name', 'trim');
-add_filter('pre_user_last_name', 'wp_filter_kses');
-add_filter('pre_user_last_name', 'wp_specialchars', 30);
-add_filter('pre_user_nickname', 'strip_tags');
-add_filter('pre_user_nickname', 'trim');
-add_filter('pre_user_nickname', 'wp_filter_kses');
-add_filter('pre_user_nickname', 'wp_specialchars', 30);
-add_filter('pre_user_description', 'trim');
-add_filter('pre_user_description', 'wp_filter_kses');
-add_filter('pre_user_url', 'strip_tags');
-add_filter('pre_user_url', 'trim');
-add_filter('pre_user_url', 'clean_url');
-add_filter('pre_user_email', 'trim');
-add_filter('pre_user_email', 'sanitize_email');
+/**
+ * Sets up the default filters and actions for most
+ * of the WordPress hooks.
+ *
+ * If you need to remove a default hook, this file will
+ * give you the priority for which to use to remove the
+ * hook.
+ *
+ * Not all of the default hooks are found in default-filters.php
+ *
+ * @package WordPress
+ */
+
+// Strip, trim, kses, special chars for string saves
+foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname' ) as $filter ) {
+ add_filter( $filter, 'sanitize_text_field' );
+ add_filter( $filter, 'wp_filter_kses' );
+ add_filter( $filter, '_wp_specialchars', 30 );
+}
+
+// Strip, kses, special chars for string display
+foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname' ) as $filter ) {
+ add_filter( $filter, 'sanitize_text_field' );
+ add_filter( $filter, 'wp_kses_data' );
+ add_filter( $filter, '_wp_specialchars', 30 );
+}
+
+// Kses only for textarea saves
+foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
+ add_filter( $filter, 'wp_filter_kses' );
+}
+
+// Kses only for textarea saves displays
+foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) {
+ add_filter( $filter, 'wp_kses_data' );
+}
+
+// Email saves
+foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) {
+ add_filter( $filter, 'trim' );
+ add_filter( $filter, 'sanitize_email' );
+ add_filter( $filter, 'wp_filter_kses' );
+}
+
+// Email display
+foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) {
+ add_filter( $filter, 'sanitize_email' );
+ add_filter( $filter, 'wp_kses_data' );
+}
+
+// Save URL
+foreach ( array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
+ 'pre_link_rss' ) as $filter ) {
+ add_filter( $filter, 'wp_strip_all_tags' );
+ add_filter( $filter, 'esc_url_raw' );
+ add_filter( $filter, 'wp_filter_kses' );
+}
+
+// Display URL
+foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url' ) as $filter ) {
+ add_filter( $filter, 'wp_strip_all_tags' );
+ add_filter( $filter, 'esc_url' );
+ add_filter( $filter, 'wp_kses_data' );
+}
+
+// Slugs
+foreach ( array( 'pre_term_slug' ) as $filter ) {
+ add_filter( $filter, 'sanitize_title' );
+}
+
+// Keys
+foreach ( array( 'pre_post_type' ) as $filter ) {
+ add_filter( $filter, 'sanitize_user' );
+}