Director of Whitespace rules default-filters.php with an iron fist

git-svn-id: http://svn.automattic.com/wordpress/trunk@12041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2009-10-15 17:27:45 +00:00
parent 95a814ffe6
commit 83c2393f43
1 changed files with 147 additions and 158 deletions

View File

@ -13,99 +13,83 @@
*/
// Strip, trim, kses, special chars for string saves
$filters = 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');
foreach ( $filters as $filter ) {
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
$filters = array('term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname');
foreach ( $filters as $filter ) {
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_filter_kses' );
add_filter( $filter, '_wp_specialchars', 30 );
}
// Kses only for textarea saves and displays
$filters = array('pre_term_description', 'term_description', 'pre_link_description', 'link_description', 'pre_link_notes', 'link_notes', 'pre_user_description', 'user_description');
foreach ( $filters as $filter ) {
foreach ( array( 'pre_term_description', 'term_description', 'pre_link_description', 'link_description', 'pre_link_notes', 'link_notes', 'pre_user_description', 'user_description' ) as $filter ) {
add_filter( $filter, 'wp_filter_kses' );
}
// Email saves
$filters = array('pre_comment_author_email', 'pre_user_email');
foreach ( $filters as $filter ) {
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
$filters = array('comment_author_email', 'user_email');
foreach ( $filters as $filter ) {
foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) {
add_filter( $filter, 'sanitize_email' );
add_filter( $filter, 'wp_filter_kses' );
}
// Save URL
$filters = array('pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
'pre_link_rss');
foreach ( $filters as $filter ) {
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
$filters = array('user_url', 'link_url', 'link_image', 'link_rss', 'comment_url');
foreach ( $filters as $filter ) {
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_filter_kses' );
}
// Slugs
$filters = array('pre_term_slug');
foreach ( $filters as $filter ) {
foreach ( array( 'pre_term_slug' ) as $filter ) {
add_filter( $filter, 'sanitize_title' );
}
// Keys
$filters = array('pre_post_type');
foreach ( $filters as $filter ) {
foreach ( array( 'pre_post_type' ) as $filter ) {
add_filter( $filter, 'sanitize_user' );
}
// Places to balance tags on input
$filters = array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content');
foreach ( $filters as $filter ) {
foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) {
add_filter( $filter, 'balanceTags', 50 );
}
// Format strings for display.
$filters = array('comment_author', 'term_name', 'link_name', 'link_description',
'link_notes', 'bloginfo', 'wp_title', 'widget_title');
foreach ( $filters as $filter ) {
foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title' ) as $filter ) {
add_filter( $filter, 'wptexturize' );
add_filter( $filter, 'convert_chars' );
add_filter( $filter, 'esc_html' );
}
// Format text area for display.
$filters = array('term_description');
foreach ( $filters as $filter ) {
foreach ( array( 'term_description' ) as $filter ) {
add_filter( $filter, 'wptexturize' );
add_filter( $filter, 'convert_chars' );
add_filter( $filter, 'wpautop' );
}
// Format for RSS
$filters = array('term_name_rss');
foreach ( $filters as $filter ) {
foreach ( array( 'term_name_rss' ) as $filter ) {
add_filter( $filter, 'convert_chars' );
}
@ -192,8 +176,12 @@ add_action('wp_head', 'wp_print_head_scripts', 9);
add_action( 'wp_head', 'wp_generator' );
add_action( 'wp_head', 'rel_canonical' );
add_action( 'wp_footer', 'wp_print_footer_scripts' );
// WP Cron
if ( !defined( 'DOING_CRON' ) )
add_action( 'sanitize_comment_cookies', 'wp_cron' );
// 2 Actions 2 Furious
add_action( 'do_feed_rdf', 'do_feed_rdf', 10, 1 );
add_action( 'do_feed_rss', 'do_feed_rss', 10, 1 );
add_action( 'do_feed_rss2', 'do_feed_rss2', 10, 1 );
@ -215,15 +203,16 @@ add_action('future_page', '_future_post_hook', 5, 2);
add_action( 'save_post', '_save_post_hook', 5, 2 );
add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' );
// Post Image CSS class filtering
add_action( 'begin_fetch_post_image_html', '_wp_post_image_class_filter_add' );
add_action( 'end_fetch_post_image_html', '_wp_post_image_class_filter_remove' );
// Redirect Old Slugs
add_action( 'template_redirect', 'wp_old_slug_redirect' );
add_action( 'edit_post', 'wp_check_for_changed_slugs' );
add_action( 'edit_form_advanced', 'wp_remember_old_slug' );
add_action( 'init', '_show_post_preview' );
// Timezone
add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' );
?>