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:
parent
95a814ffe6
commit
83c2393f43
|
@ -13,99 +13,83 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Strip, trim, kses, special chars for string saves
|
// Strip, trim, kses, special chars for string saves
|
||||||
$filters = array('pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target',
|
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 ) {
|
||||||
'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name',
|
|
||||||
'pre_user_nickname');
|
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'sanitize_text_field' );
|
add_filter( $filter, 'sanitize_text_field' );
|
||||||
add_filter( $filter, 'wp_filter_kses' );
|
add_filter( $filter, 'wp_filter_kses' );
|
||||||
add_filter( $filter, '_wp_specialchars', 30 );
|
add_filter( $filter, '_wp_specialchars', 30 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip, kses, special chars for string display
|
// 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 ( 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 ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'sanitize_text_field' );
|
add_filter( $filter, 'sanitize_text_field' );
|
||||||
add_filter( $filter, 'wp_filter_kses' );
|
add_filter( $filter, 'wp_filter_kses' );
|
||||||
add_filter( $filter, '_wp_specialchars', 30 );
|
add_filter( $filter, '_wp_specialchars', 30 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kses only for textarea saves and displays
|
// 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 ( array( 'pre_term_description', 'term_description', 'pre_link_description', 'link_description', 'pre_link_notes', 'link_notes', 'pre_user_description', 'user_description' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'wp_filter_kses' );
|
add_filter( $filter, 'wp_filter_kses' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Email saves
|
// Email saves
|
||||||
$filters = array('pre_comment_author_email', 'pre_user_email');
|
foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'trim' );
|
add_filter( $filter, 'trim' );
|
||||||
add_filter( $filter, 'sanitize_email' );
|
add_filter( $filter, 'sanitize_email' );
|
||||||
add_filter( $filter, 'wp_filter_kses' );
|
add_filter( $filter, 'wp_filter_kses' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Email display
|
// Email display
|
||||||
$filters = array('comment_author_email', 'user_email');
|
foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'sanitize_email' );
|
add_filter( $filter, 'sanitize_email' );
|
||||||
add_filter( $filter, 'wp_filter_kses' );
|
add_filter( $filter, 'wp_filter_kses' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save URL
|
// Save URL
|
||||||
$filters = array('pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
|
foreach ( array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image',
|
||||||
'pre_link_rss');
|
'pre_link_rss' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'wp_strip_all_tags' );
|
add_filter( $filter, 'wp_strip_all_tags' );
|
||||||
add_filter( $filter, 'esc_url_raw' );
|
add_filter( $filter, 'esc_url_raw' );
|
||||||
add_filter( $filter, 'wp_filter_kses' );
|
add_filter( $filter, 'wp_filter_kses' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display URL
|
// Display URL
|
||||||
$filters = array('user_url', 'link_url', 'link_image', 'link_rss', 'comment_url');
|
foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'wp_strip_all_tags' );
|
add_filter( $filter, 'wp_strip_all_tags' );
|
||||||
add_filter( $filter, 'esc_url' );
|
add_filter( $filter, 'esc_url' );
|
||||||
add_filter( $filter, 'wp_filter_kses' );
|
add_filter( $filter, 'wp_filter_kses' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slugs
|
// Slugs
|
||||||
$filters = array('pre_term_slug');
|
foreach ( array( 'pre_term_slug' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'sanitize_title' );
|
add_filter( $filter, 'sanitize_title' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keys
|
// Keys
|
||||||
$filters = array('pre_post_type');
|
foreach ( array( 'pre_post_type' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'sanitize_user' );
|
add_filter( $filter, 'sanitize_user' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Places to balance tags on input
|
// Places to balance tags on input
|
||||||
$filters = array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content');
|
foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'balanceTags', 50 );
|
add_filter( $filter, 'balanceTags', 50 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format strings for display.
|
// Format strings for display.
|
||||||
$filters = array('comment_author', 'term_name', 'link_name', 'link_description',
|
foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title' ) as $filter ) {
|
||||||
'link_notes', 'bloginfo', 'wp_title', 'widget_title');
|
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'wptexturize' );
|
add_filter( $filter, 'wptexturize' );
|
||||||
add_filter( $filter, 'convert_chars' );
|
add_filter( $filter, 'convert_chars' );
|
||||||
add_filter( $filter, 'esc_html' );
|
add_filter( $filter, 'esc_html' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format text area for display.
|
// Format text area for display.
|
||||||
$filters = array('term_description');
|
foreach ( array( 'term_description' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'wptexturize' );
|
add_filter( $filter, 'wptexturize' );
|
||||||
add_filter( $filter, 'convert_chars' );
|
add_filter( $filter, 'convert_chars' );
|
||||||
add_filter( $filter, 'wpautop' );
|
add_filter( $filter, 'wpautop' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format for RSS
|
// Format for RSS
|
||||||
$filters = array('term_name_rss');
|
foreach ( array( 'term_name_rss' ) as $filter ) {
|
||||||
foreach ( $filters as $filter ) {
|
|
||||||
add_filter( $filter, 'convert_chars' );
|
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', 'wp_generator' );
|
||||||
add_action( 'wp_head', 'rel_canonical' );
|
add_action( 'wp_head', 'rel_canonical' );
|
||||||
add_action( 'wp_footer', 'wp_print_footer_scripts' );
|
add_action( 'wp_footer', 'wp_print_footer_scripts' );
|
||||||
|
|
||||||
|
// WP Cron
|
||||||
if ( !defined( 'DOING_CRON' ) )
|
if ( !defined( 'DOING_CRON' ) )
|
||||||
add_action( 'sanitize_comment_cookies', 'wp_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_rdf', 'do_feed_rdf', 10, 1 );
|
||||||
add_action( 'do_feed_rss', 'do_feed_rss', 10, 1 );
|
add_action( 'do_feed_rss', 'do_feed_rss', 10, 1 );
|
||||||
add_action( 'do_feed_rss2', 'do_feed_rss2', 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( 'save_post', '_save_post_hook', 5, 2 );
|
||||||
add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
|
add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
|
||||||
add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' );
|
add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' );
|
||||||
|
|
||||||
// Post Image CSS class filtering
|
// Post Image CSS class filtering
|
||||||
add_action( 'begin_fetch_post_image_html', '_wp_post_image_class_filter_add' );
|
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' );
|
add_action( 'end_fetch_post_image_html', '_wp_post_image_class_filter_remove' );
|
||||||
|
|
||||||
// Redirect Old Slugs
|
// Redirect Old Slugs
|
||||||
add_action( 'template_redirect', 'wp_old_slug_redirect' );
|
add_action( 'template_redirect', 'wp_old_slug_redirect' );
|
||||||
add_action( 'edit_post', 'wp_check_for_changed_slugs' );
|
add_action( 'edit_post', 'wp_check_for_changed_slugs' );
|
||||||
add_action( 'edit_form_advanced', 'wp_remember_old_slug' );
|
add_action( 'edit_form_advanced', 'wp_remember_old_slug' );
|
||||||
add_action( 'init', '_show_post_preview' );
|
add_action( 'init', '_show_post_preview' );
|
||||||
|
|
||||||
|
// Timezone
|
||||||
add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' );
|
add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' );
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in New Issue