Ticket #14280: 14280.diff
File 14280.diff, 10.5 KB (added by , 15 years ago) |
---|
-
wp-includes/default-filters.php
13 13 */ 14 14 15 15 // Strip, trim, kses, special chars for string saves 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 ); 20 } 16 $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' ); 17 add_filter( $filters, 'sanitize_text_field' ); 18 add_filter( $filters, 'wp_filter_kses' ); 19 add_filter( $filters, '_wp_specialchars', 30 ); 21 20 22 21 // Strip, kses, special chars for string display 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_kses_data' ); 26 add_filter( $filter, '_wp_specialchars', 30 ); 27 } 22 $filters = array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname' ); 23 add_filter( $filters, 'sanitize_text_field' ); 24 add_filter( $filters, 'wp_kses_data' ); 25 add_filter( $filters, '_wp_specialchars', 30 ); 28 26 29 27 // Kses only for textarea saves 30 foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) { 31 add_filter( $filter, 'wp_filter_kses' ); 32 } 28 $filters = array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ); 29 add_filter( $filters, 'wp_filter_kses' ); 33 30 34 31 // Kses only for textarea saves displays 35 foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) { 36 add_filter( $filter, 'wp_kses_data' ); 37 } 32 $filters = array( 'term_description', 'link_description', 'link_notes', 'user_description' ); 33 add_filter( $filters, 'wp_kses_data' ); 38 34 39 35 // Email saves 40 foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) { 41 add_filter( $filter, 'trim' ); 42 add_filter( $filter, 'sanitize_email' ); 43 add_filter( $filter, 'wp_filter_kses' ); 44 } 36 $filters = array( 'pre_comment_author_email', 'pre_user_email' ); 37 add_filter( $filters, 'trim' ); 38 add_filter( $filters, 'sanitize_email' ); 39 add_filter( $filters, 'wp_filter_kses' ); 45 40 46 41 // Email display 47 foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) { 48 add_filter( $filter, 'sanitize_email' ); 49 add_filter( $filter, 'wp_kses_data' ); 50 } 42 $filters = array( 'comment_author_email', 'user_email' ); 43 add_filter( $filters, 'sanitize_email' ); 44 add_filter( $filters, 'wp_kses_data' ); 51 45 52 46 // Save URL 53 foreach ( array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image', 54 'pre_link_rss' ) as $filter ) { 55 add_filter( $filter, 'wp_strip_all_tags' ); 56 add_filter( $filter, 'esc_url_raw' ); 57 add_filter( $filter, 'wp_filter_kses' ); 58 } 47 $filters = array( 'pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image', 'pre_link_rss' ); 48 add_filter( $filters, 'wp_strip_all_tags' ); 49 add_filter( $filters, 'esc_url_raw' ); 50 add_filter( $filters, 'wp_filter_kses' ); 59 51 60 52 // Display URL 61 foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url' ) as $filter ) { 62 add_filter( $filter, 'wp_strip_all_tags' ); 63 add_filter( $filter, 'esc_url' ); 64 add_filter( $filter, 'wp_kses_data' ); 65 } 53 $filters = array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url' ); 54 add_filter( $filters, 'wp_strip_all_tags' ); 55 add_filter( $filters, 'esc_url' ); 56 add_filter( $filters, 'wp_kses_data' ); 66 57 67 58 // Slugs 68 foreach ( array( 'pre_term_slug' ) as $filter ) { 69 add_filter( $filter, 'sanitize_title' ); 70 } 59 $filters = array( 'pre_term_slug' ); 60 add_filter( $filters, 'sanitize_title' ); 71 61 72 62 // Keys 73 foreach ( array( 'pre_post_type' ) as $filter ) { 74 add_filter( $filter, 'sanitize_user' ); 75 } 63 $filters = array( 'pre_post_type' ); 64 add_filter( $filters, 'sanitize_user' ); 76 65 77 66 // Places to balance tags on input 78 foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) { 79 add_filter( $filter, 'balanceTags', 50 ); 80 } 67 $filters = array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ); 68 add_filter( $filters, 'balanceTags', 50 ); 81 69 82 70 // Format strings for display. 83 foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title' ) as $filter ) { 84 add_filter( $filter, 'wptexturize' ); 85 add_filter( $filter, 'convert_chars' ); 86 add_filter( $filter, 'esc_html' ); 87 } 71 $filters = array( 'comment_author', 'term_name', 'link_name', 'link_description', 'link_notes', 'bloginfo', 'wp_title', 'widget_title' ); 72 add_filter( $filters, 'wptexturize' ); 73 add_filter( $filters, 'convert_chars' ); 74 add_filter( $filters, 'esc_html' ); 88 75 89 76 // Format WordPress 90 foreach ( array( 'the_content', 'the_title', 'comment_text' ) as $filter ) 91 add_filter( $filter, 'capital_P_dangit', 11 );77 $filters = array( 'the_content', 'the_title', 'comment_text' ); 78 add_filter( $filters, 'capital_P_dangit', 11 ); 92 79 93 80 // Format titles 94 foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) { 95 add_filter( $filter, 'wptexturize' ); 96 add_filter( $filter, 'strip_tags' ); 97 } 81 $filters = array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ); 82 add_filter( $filters, 'wptexturize' ); 83 add_filter( $filters, 'strip_tags' ); 98 84 99 85 // Format text area for display. 100 foreach ( array( 'term_description' ) as $filter ) { 101 add_filter( $filter, 'wptexturize' ); 102 add_filter( $filter, 'convert_chars' ); 103 add_filter( $filter, 'wpautop' ); 104 add_filter( $filter, 'shortcode_unautop'); 105 } 86 $filters = array( 'term_description' ); 87 add_filter( $filters, 'wptexturize' ); 88 add_filter( $filters, 'convert_chars' ); 89 add_filter( $filters, 'wpautop' ); 90 add_filter( $filters, 'shortcode_unautop'); 106 91 107 92 // Format for RSS 108 foreach ( array( 'term_name_rss' ) as $filter ) { 109 add_filter( $filter, 'convert_chars' ); 110 } 93 $filters = array( 'term_name_rss' ); 94 add_filter( $filters, 'convert_chars' ); 111 95 112 96 // Display filters 113 97 add_filter( 'the_title', 'wptexturize' ); … … 200 184 add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 ); 201 185 202 186 // Feed Generator Tags 203 foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) { 204 add_action( $action, 'the_generator' ); 205 } 187 $actions = array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ); 188 add_action( $actions, 'the_generator' ); 206 189 207 190 // WP Cron 208 191 if ( !defined( 'DOING_CRON' ) ) … … 253 236 add_action( 'admin_init', 'register_admin_color_schemes', 1); 254 237 add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); 255 238 239 unset( $filters, $actions ); 256 240 ?> -
wp-includes/plugin.php
56 56 * wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)']'] 57 57 * @global array $merged_filters Tracks the tags that need to be merged for later. If the hook is added, it doesn't need to run through that process. 58 58 * 59 * @param string $tag The name of the filter to hook the $function_to_add to.59 * @param mixed $tags The name of the filter(s) to hook the $function_to_add to, can either be a string or array of strings. 60 60 * @param callback $function_to_add The name of the function to be called when the filter is applied. 61 61 * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. 62 62 * @param int $accepted_args optional. The number of arguments the function accept (default 1). 63 63 * @return boolean true 64 64 */ 65 function add_filter($tag , $function_to_add, $priority = 10, $accepted_args = 1) {65 function add_filter($tags, $function_to_add, $priority = 10, $accepted_args = 1) { 66 66 global $wp_filter, $merged_filters; 67 68 $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); 69 $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); 70 unset( $merged_filters[ $tag ] ); 67 foreach ( (array) $tags as $tag ) { 68 $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); 69 $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); 70 unset( $merged_filters[ $tag ] ); 71 } 71 72 return true; 72 73 } 73 74 … … 316 317 * @subpackage Plugin 317 318 * @since 1.2 318 319 * 319 * @param string $tag The name of the action to which the $function_to_add is hooked.320 * @param mixed $tags The name of the action(s) to which the $function_to_add is hooked, can either be a string or array of strings. 320 321 * @param callback $function_to_add The name of the function you wish to be called. 321 322 * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action. 322 323 * @param int $accepted_args optional. The number of arguments the function accept (default 1). 323 324 */ 324 function add_action($tag , $function_to_add, $priority = 10, $accepted_args = 1) {325 return add_filter($tag , $function_to_add, $priority, $accepted_args);325 function add_action($tags, $function_to_add, $priority = 10, $accepted_args = 1) { 326 return add_filter($tags, $function_to_add, $priority, $accepted_args); 326 327 } 327 328 328 329