Changeset 12041
- Timestamp:
- 10/15/2009 05:27:45 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/default-filters.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/default-filters.php
r12039 r12041 14 14 15 15 // Strip, trim, kses, special chars for string saves 16 $filters = array('pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 17 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 18 'pre_user_nickname'); 19 foreach ( $filters as $filter ) { 20 add_filter($filter, 'sanitize_text_field'); 21 add_filter($filter, 'wp_filter_kses'); 22 add_filter($filter, '_wp_specialchars', 30); 16 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 ) { 17 add_filter( $filter, 'sanitize_text_field' ); 18 add_filter( $filter, 'wp_filter_kses' ); 19 add_filter( $filter, '_wp_specialchars', 30 ); 23 20 } 24 21 25 22 // Strip, kses, special chars for string display 26 $filters = array('term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname'); 27 foreach ( $filters as $filter ) { 28 add_filter($filter, 'sanitize_text_field'); 29 add_filter($filter, 'wp_filter_kses'); 30 add_filter($filter, '_wp_specialchars', 30); 23 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 ) { 24 add_filter( $filter, 'sanitize_text_field' ); 25 add_filter( $filter, 'wp_filter_kses' ); 26 add_filter( $filter, '_wp_specialchars', 30 ); 31 27 } 32 28 33 29 // Kses only for textarea saves and displays 34 $filters = array('pre_term_description', 'term_description', 'pre_link_description', 'link_description', 'pre_link_notes', 'link_notes', 'pre_user_description', 'user_description'); 35 foreach ( $filters as $filter ) { 36 add_filter($filter, 'wp_filter_kses'); 30 foreach ( array( 'pre_term_description', 'term_description', 'pre_link_description', 'link_description', 'pre_link_notes', 'link_notes', 'pre_user_description', 'user_description' ) as $filter ) { 31 add_filter( $filter, 'wp_filter_kses' ); 37 32 } 38 33 39 34 // Email saves 40 $filters = array('pre_comment_author_email', 'pre_user_email'); 41 foreach ( $filters as $filter ) { 42 add_filter($filter, 'trim'); 43 add_filter($filter, 'sanitize_email'); 44 add_filter($filter, 'wp_filter_kses'); 35 foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) { 36 add_filter( $filter, 'trim' ); 37 add_filter( $filter, 'sanitize_email' ); 38 add_filter( $filter, 'wp_filter_kses' ); 45 39 } 46 40 47 41 // Email display 48 $filters = array('comment_author_email', 'user_email'); 49 foreach ( $filters as $filter ) { 50 add_filter($filter, 'sanitize_email'); 51 add_filter($filter, 'wp_filter_kses'); 42 foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) { 43 add_filter( $filter, 'sanitize_email' ); 44 add_filter( $filter, 'wp_filter_kses' ); 52 45 } 53 46 54 47 // Save URL 55 $filters = array('pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image', 56 'pre_link_rss'); 57 foreach ( $filters as $filter ) { 58 add_filter($filter, 'wp_strip_all_tags'); 59 add_filter($filter, 'esc_url_raw'); 60 add_filter($filter, 'wp_filter_kses'); 48 foreach ( array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image', 49 'pre_link_rss' ) as $filter ) { 50 add_filter( $filter, 'wp_strip_all_tags' ); 51 add_filter( $filter, 'esc_url_raw' ); 52 add_filter( $filter, 'wp_filter_kses' ); 61 53 } 62 54 63 55 // Display URL 64 $filters = array('user_url', 'link_url', 'link_image', 'link_rss', 'comment_url'); 65 foreach ( $filters as $filter ) { 66 add_filter($filter, 'wp_strip_all_tags'); 67 add_filter($filter, 'esc_url'); 68 add_filter($filter, 'wp_filter_kses'); 56 foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url' ) as $filter ) { 57 add_filter( $filter, 'wp_strip_all_tags' ); 58 add_filter( $filter, 'esc_url' ); 59 add_filter( $filter, 'wp_filter_kses' ); 69 60 } 70 61 71 62 // Slugs 72 $filters = array('pre_term_slug'); 73 foreach ( $filters as $filter ) { 74 add_filter($filter, 'sanitize_title'); 63 foreach ( array( 'pre_term_slug' ) as $filter ) { 64 add_filter( $filter, 'sanitize_title' ); 75 65 } 76 66 77 67 // Keys 78 $filters = array('pre_post_type'); 79 foreach ( $filters as $filter ) { 80 add_filter($filter, 'sanitize_user'); 68 foreach ( array( 'pre_post_type' ) as $filter ) { 69 add_filter( $filter, 'sanitize_user' ); 81 70 } 82 71 83 72 // Places to balance tags on input 84 $filters = array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content'); 85 foreach ( $filters as $filter ) { 86 add_filter( $filter, 'balanceTags', 50); 73 foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) { 74 add_filter( $filter, 'balanceTags', 50 ); 87 75 } 88 76 89 77 // Format strings for display. 90 $filters = array('comment_author', 'term_name', 'link_name', 'link_description', 91 'link_notes', 'bloginfo', 'wp_title', 'widget_title'); 92 foreach ( $filters as $filter ) { 93 add_filter($filter, 'wptexturize'); 94 add_filter($filter, 'convert_chars'); 95 add_filter($filter, 'esc_html'); 78 foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title' ) as $filter ) { 79 add_filter( $filter, 'wptexturize' ); 80 add_filter( $filter, 'convert_chars' ); 81 add_filter( $filter, 'esc_html' ); 96 82 } 97 83 98 84 // Format text area for display. 99 $filters = array('term_description'); 100 foreach ( $filters as $filter ) { 101 add_filter($filter, 'wptexturize'); 102 add_filter($filter, 'convert_chars'); 103 add_filter($filter, 'wpautop'); 85 foreach ( array( 'term_description' ) as $filter ) { 86 add_filter( $filter, 'wptexturize' ); 87 add_filter( $filter, 'convert_chars' ); 88 add_filter( $filter, 'wpautop' ); 104 89 } 105 90 106 91 // Format for RSS 107 $filters = array('term_name_rss'); 108 foreach ( $filters as $filter ) { 109 add_filter($filter, 'convert_chars'); 92 foreach ( array( 'term_name_rss' ) as $filter ) { 93 add_filter( $filter, 'convert_chars' ); 110 94 } 111 95 112 96 // Display filters 113 add_filter( 'the_title', 'wptexturize');114 add_filter( 'the_title', 'convert_chars');115 add_filter( 'the_title', 'trim');116 117 add_filter( 'the_content', 'wptexturize');118 add_filter( 'the_content', 'convert_smilies');119 add_filter( 'the_content', 'convert_chars');120 add_filter( 'the_content', 'wpautop');121 add_filter( 'the_content', 'prepend_attachment');122 123 add_filter( 'the_excerpt', 'wptexturize');124 add_filter( 'the_excerpt', 'convert_smilies');125 add_filter( 'the_excerpt', 'convert_chars');126 add_filter( 'the_excerpt', 'wpautop');127 add_filter( 'get_the_excerpt', 'wp_trim_excerpt');128 129 add_filter( 'comment_text', 'wptexturize');130 add_filter( 'comment_text', 'convert_chars');131 add_filter( 'comment_text', 'make_clickable', 9);132 add_filter( 'comment_text', 'force_balance_tags', 25);133 add_filter( 'comment_text', 'convert_smilies', 20);134 add_filter( 'comment_text', 'wpautop', 30);135 136 add_filter( 'comment_excerpt', 'convert_chars');137 138 add_filter( 'list_cats', 'wptexturize');139 add_filter( 'single_post_title', 'wptexturize');140 141 add_filter( 'wp_sprintf', 'wp_sprintf_l', 10, 2);97 add_filter( 'the_title', 'wptexturize' ); 98 add_filter( 'the_title', 'convert_chars' ); 99 add_filter( 'the_title', 'trim' ); 100 101 add_filter( 'the_content', 'wptexturize' ); 102 add_filter( 'the_content', 'convert_smilies' ); 103 add_filter( 'the_content', 'convert_chars' ); 104 add_filter( 'the_content', 'wpautop' ); 105 add_filter( 'the_content', 'prepend_attachment' ); 106 107 add_filter( 'the_excerpt', 'wptexturize' ); 108 add_filter( 'the_excerpt', 'convert_smilies' ); 109 add_filter( 'the_excerpt', 'convert_chars' ); 110 add_filter( 'the_excerpt', 'wpautop' ); 111 add_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); 112 113 add_filter( 'comment_text', 'wptexturize' ); 114 add_filter( 'comment_text', 'convert_chars' ); 115 add_filter( 'comment_text', 'make_clickable', 9 ); 116 add_filter( 'comment_text', 'force_balance_tags', 25 ); 117 add_filter( 'comment_text', 'convert_smilies', 20 ); 118 add_filter( 'comment_text', 'wpautop', 30 ); 119 120 add_filter( 'comment_excerpt', 'convert_chars' ); 121 122 add_filter( 'list_cats', 'wptexturize' ); 123 add_filter( 'single_post_title', 'wptexturize' ); 124 125 add_filter( 'wp_sprintf', 'wp_sprintf_l', 10, 2 ); 142 126 143 127 // RSS filters 144 add_filter( 'the_title_rss', 'strip_tags');145 add_filter( 'the_title_rss', 'ent2ncr', 8);146 add_filter( 'the_title_rss', 'esc_html');147 add_filter( 'the_content_rss', 'ent2ncr', 8);148 add_filter( 'the_excerpt_rss', 'convert_chars');149 add_filter( 'the_excerpt_rss', 'ent2ncr', 8);150 add_filter( 'comment_author_rss', 'ent2ncr', 8);151 add_filter( 'comment_text_rss', 'ent2ncr', 8);152 add_filter( 'comment_text_rss', 'esc_html');153 add_filter( 'bloginfo_rss', 'ent2ncr', 8);154 add_filter( 'the_author', 'ent2ncr', 8);128 add_filter( 'the_title_rss', 'strip_tags' ); 129 add_filter( 'the_title_rss', 'ent2ncr', 8 ); 130 add_filter( 'the_title_rss', 'esc_html' ); 131 add_filter( 'the_content_rss', 'ent2ncr', 8 ); 132 add_filter( 'the_excerpt_rss', 'convert_chars' ); 133 add_filter( 'the_excerpt_rss', 'ent2ncr', 8 ); 134 add_filter( 'comment_author_rss', 'ent2ncr', 8 ); 135 add_filter( 'comment_text_rss', 'ent2ncr', 8 ); 136 add_filter( 'comment_text_rss', 'esc_html' ); 137 add_filter( 'bloginfo_rss', 'ent2ncr', 8 ); 138 add_filter( 'the_author', 'ent2ncr', 8 ); 155 139 156 140 // Misc filters 157 add_filter( 'option_ping_sites', 'privacy_ping_filter');158 add_filter( 'option_blog_charset', '_wp_specialchars'); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop159 add_filter( 'option_home', '_config_wp_home');160 add_filter( 'option_siteurl', '_config_wp_siteurl');161 add_filter( 'tiny_mce_before_init', '_mce_set_direction');162 add_filter( 'pre_kses', 'wp_pre_kses_less_than');163 add_filter( 'sanitize_title', 'sanitize_title_with_dashes');164 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3);165 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);166 add_filter( 'pre_comment_content', 'wp_rel_nofollow', 15);167 add_filter( 'comment_email', 'antispambot');168 add_filter( 'option_tag_base', '_wp_filter_taxonomy_base');169 add_filter( 'option_category_base', '_wp_filter_taxonomy_base');170 add_filter( 'the_posts', '_close_comments_for_old_posts');171 add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 );172 add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 );173 add_filter( 'editable_slug', 'urldecode');141 add_filter( 'option_ping_sites', 'privacy_ping_filter' ); 142 add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop 143 add_filter( 'option_home', '_config_wp_home' ); 144 add_filter( 'option_siteurl', '_config_wp_siteurl' ); 145 add_filter( 'tiny_mce_before_init', '_mce_set_direction' ); 146 add_filter( 'pre_kses', 'wp_pre_kses_less_than' ); 147 add_filter( 'sanitize_title', 'sanitize_title_with_dashes' ); 148 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 ); 149 add_filter( 'comment_flood_filter', 'wp_throttle_comment_flood', 10, 3 ); 150 add_filter( 'pre_comment_content', 'wp_rel_nofollow', 15 ); 151 add_filter( 'comment_email', 'antispambot' ); 152 add_filter( 'option_tag_base', '_wp_filter_taxonomy_base' ); 153 add_filter( 'option_category_base', '_wp_filter_taxonomy_base' ); 154 add_filter( 'the_posts', '_close_comments_for_old_posts' ); 155 add_filter( 'comments_open', '_close_comments_for_old_post', 10, 2 ); 156 add_filter( 'pings_open', '_close_comments_for_old_post', 10, 2 ); 157 add_filter( 'editable_slug', 'urldecode' ); 174 158 175 159 // Atom SSL support 176 add_filter( 'atom_service_url','atom_service_url_filter');160 add_filter( 'atom_service_url','atom_service_url_filter' ); 177 161 178 162 // Actions 179 add_action('wp_head', 'wp_enqueue_scripts', 1); 180 add_action('wp_head', 'feed_links_extra', 3); 181 add_action('wp_head', 'rsd_link'); 182 add_action('wp_head', 'wlwmanifest_link'); 183 add_action('wp_head', 'index_rel_link'); 184 add_action('wp_head', 'parent_post_rel_link', 10, 0); 185 add_action('wp_head', 'start_post_rel_link', 10, 0); 186 add_action('wp_head', 'adjacent_posts_rel_link', 10, 0); 187 add_action('wp_head', 'locale_stylesheet'); 188 add_action('publish_future_post', 'check_and_publish_future_post', 10, 1); 189 add_action('wp_head', 'noindex', 1); 190 add_action('wp_head', 'wp_print_styles', 8); 191 add_action('wp_head', 'wp_print_head_scripts', 9); 192 add_action('wp_head', 'wp_generator'); 193 add_action('wp_head', 'rel_canonical'); 194 add_action('wp_footer', 'wp_print_footer_scripts'); 195 if(!defined('DOING_CRON')) 196 add_action('sanitize_comment_cookies', 'wp_cron'); 197 add_action('do_feed_rdf', 'do_feed_rdf', 10, 1); 198 add_action('do_feed_rss', 'do_feed_rss', 10, 1); 199 add_action('do_feed_rss2', 'do_feed_rss2', 10, 1); 200 add_action('do_feed_atom', 'do_feed_atom', 10, 1); 201 add_action('do_pings', 'do_all_pings', 10, 1); 202 add_action('do_robots', 'do_robots'); 203 add_action('sanitize_comment_cookies', 'sanitize_comment_cookies'); 204 add_action('admin_print_scripts', 'print_head_scripts', 20); 205 add_action('admin_print_footer_scripts', 'print_footer_scripts', 20); 206 add_action('admin_print_styles', 'print_admin_styles', 20); 207 add_action('init', 'smilies_init', 5); 208 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); 209 add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 ); 210 add_action( 'shutdown', 'wp_ob_end_flush_all', 1); 211 add_action( 'pre_post_update', 'wp_save_post_revision' ); 212 add_action('publish_post', '_publish_post_hook', 5, 1); 213 add_action('future_post', '_future_post_hook', 5, 2); 214 add_action('future_page', '_future_post_hook', 5, 2); 215 add_action('save_post', '_save_post_hook', 5, 2); 216 add_action('transition_post_status', '_transition_post_status', 5, 3); 217 add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce'); 163 add_action( 'wp_head', 'wp_enqueue_scripts', 1 ); 164 add_action( 'wp_head', 'feed_links_extra', 3 ); 165 add_action( 'wp_head', 'rsd_link' ); 166 add_action( 'wp_head', 'wlwmanifest_link' ); 167 add_action( 'wp_head', 'index_rel_link' ); 168 add_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); 169 add_action( 'wp_head', 'start_post_rel_link', 10, 0 ); 170 add_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); 171 add_action( 'wp_head', 'locale_stylesheet' ); 172 add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 ); 173 add_action( 'wp_head', 'noindex', 1 ); 174 add_action( 'wp_head', 'wp_print_styles', 8 ); 175 add_action( 'wp_head', 'wp_print_head_scripts', 9 ); 176 add_action( 'wp_head', 'wp_generator' ); 177 add_action( 'wp_head', 'rel_canonical' ); 178 add_action( 'wp_footer', 'wp_print_footer_scripts' ); 179 180 // WP Cron 181 if ( !defined( 'DOING_CRON' ) ) 182 add_action( 'sanitize_comment_cookies', 'wp_cron' ); 183 184 // 2 Actions 2 Furious 185 add_action( 'do_feed_rdf', 'do_feed_rdf', 10, 1 ); 186 add_action( 'do_feed_rss', 'do_feed_rss', 10, 1 ); 187 add_action( 'do_feed_rss2', 'do_feed_rss2', 10, 1 ); 188 add_action( 'do_feed_atom', 'do_feed_atom', 10, 1 ); 189 add_action( 'do_pings', 'do_all_pings', 10, 1 ); 190 add_action( 'do_robots', 'do_robots' ); 191 add_action( 'sanitize_comment_cookies', 'sanitize_comment_cookies' ); 192 add_action( 'admin_print_scripts', 'print_head_scripts', 20 ); 193 add_action( 'admin_print_footer_scripts', 'print_footer_scripts', 20 ); 194 add_action( 'admin_print_styles', 'print_admin_styles', 20 ); 195 add_action( 'init', 'smilies_init', 5 ); 196 add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 ); 197 add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 ); 198 add_action( 'shutdown', 'wp_ob_end_flush_all', 1 ); 199 add_action( 'pre_post_update', 'wp_save_post_revision' ); 200 add_action( 'publish_post', '_publish_post_hook', 5, 1 ); 201 add_action( 'future_post', '_future_post_hook', 5, 2 ); 202 add_action( 'future_page', '_future_post_hook', 5, 2 ); 203 add_action( 'save_post', '_save_post_hook', 5, 2 ); 204 add_action( 'transition_post_status', '_transition_post_status', 5, 3 ); 205 add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); 206 218 207 // Post Image CSS class filtering 219 add_action( 'begin_fetch_post_image_html', '_wp_post_image_class_filter_add' ); 220 add_action( 'end_fetch_post_image_html', '_wp_post_image_class_filter_remove' ); 208 add_action( 'begin_fetch_post_image_html', '_wp_post_image_class_filter_add' ); 209 add_action( 'end_fetch_post_image_html', '_wp_post_image_class_filter_remove' ); 210 221 211 // Redirect Old Slugs 222 add_action('template_redirect', 'wp_old_slug_redirect'); 223 add_action('edit_post', 'wp_check_for_changed_slugs'); 224 add_action('edit_form_advanced', 'wp_remember_old_slug'); 225 add_action('init', '_show_post_preview'); 226 227 add_filter('pre_option_gmt_offset','wp_timezone_override_offset'); 228 229 ?> 212 add_action( 'template_redirect', 'wp_old_slug_redirect' ); 213 add_action( 'edit_post', 'wp_check_for_changed_slugs' ); 214 add_action( 'edit_form_advanced', 'wp_remember_old_slug' ); 215 add_action( 'init', '_show_post_preview' ); 216 217 // Timezone 218 add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' );
Note: See TracChangeset
for help on using the changeset viewer.