Ticket #8640: 8640.3.diff
File 8640.3.diff, 6.8 KB (added by , 16 years ago) |
---|
-
wp-includes/default-filters.php
16 16 $filters = array('pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 17 17 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 18 18 'pre_user_nickname'); 19 foreach ( $filters as $filter ) { 20 add_filter($filter, 'strip_tags'); 21 add_filter($filter, 'trim'); 22 add_filter($filter, 'wp_filter_kses'); 23 add_filter($filter, 'wp_specialchars', 30); 24 } 19 add_filters($filters, 'strip_tags'); 20 add_filters($filters, 'trim'); 21 add_filters($filters, 'wp_filter_kses'); 22 add_filters($filters, 'wp_specialchars', 30); 25 23 26 24 // Kses only for textarea saves 27 25 $filters = array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description'); 28 foreach ( $filters as $filter ) { 29 add_filter($filter, 'wp_filter_kses'); 30 } 26 add_filters($filters, 'wp_filter_kses'); 31 27 32 28 // Email 33 29 $filters = array('pre_comment_author_email', 'pre_user_email'); 34 foreach ( $filters as $filter ) { 35 add_filter($filter, 'trim'); 36 add_filter($filter, 'sanitize_email'); 37 add_filter($filter, 'wp_filter_kses'); 38 } 30 add_filters($filters, 'trim'); 31 add_filters($filters, 'sanitize_email'); 32 add_filters($filters, 'wp_filter_kses'); 39 33 40 34 // Save URL 41 35 $filters = array('pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image', 42 36 'pre_link_rss'); 43 foreach ( $filters as $filter ) { 44 add_filter($filter, 'strip_tags'); 45 add_filter($filter, 'trim'); 46 add_filter($filter, 'sanitize_url'); 47 add_filter($filter, 'wp_filter_kses'); 48 } 37 add_filters($filters, 'strip_tags'); 38 add_filters($filters, 'trim'); 39 add_filters($filters, 'sanitize_url'); 40 add_filters($filters, 'wp_filter_kses'); 49 41 50 42 // Display URL 51 43 $filters = array('user_url', 'link_url', 'link_image', 'link_rss', 'comment_url'); 52 foreach ( $filters as $filter ) { 53 add_filter($filter, 'strip_tags'); 54 add_filter($filter, 'trim'); 55 add_filter($filter, 'clean_url'); 56 add_filter($filter, 'wp_filter_kses'); 57 } 44 add_filters($filters, 'strip_tags'); 45 add_filters($filters, 'trim'); 46 add_filters($filters, 'clean_url'); 47 add_filters($filters, 'wp_filter_kses'); 58 48 59 49 // Slugs 60 50 $filters = array('pre_term_slug'); 61 foreach ( $filters as $filter ) { 62 add_filter($filter, 'sanitize_title'); 63 } 51 add_filters($filters, 'sanitize_title'); 64 52 65 53 // Keys 66 54 $filters = array('pre_post_type'); 67 foreach ( $filters as $filter ) { 68 add_filter($filter, 'sanitize_user'); 69 } 55 add_filters($filters, 'sanitize_user'); 70 56 71 57 // Places to balance tags on input 72 58 $filters = array('content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content'); 73 foreach ( $filters as $filter ) { 74 add_filter( $filter, 'balanceTags', 50); 75 } 59 add_filters($filters, 'balanceTags', 50); 76 60 77 61 // Format strings for display. 78 62 $filters = array('comment_author', 'term_name', 'link_name', 'link_description', 79 63 'link_notes', 'bloginfo', 'wp_title', 'widget_title'); 80 foreach ( $filters as $filter ) { 81 add_filter($filter, 'wptexturize'); 82 add_filter($filter, 'convert_chars'); 83 add_filter($filter, 'wp_specialchars'); 84 } 64 add_filters($filters, 'wptexturize'); 65 add_filters($filters, 'convert_chars'); 66 add_filters($filters, 'wp_specialchars'); 85 67 86 68 // Format text area for display. 87 69 $filters = array('term_description'); 88 foreach ( $filters as $filter ) { 89 add_filter($filter, 'wptexturize'); 90 add_filter($filter, 'convert_chars'); 91 add_filter($filter, 'wpautop'); 92 } 70 add_filters($filters, 'wptexturize'); 71 add_filters($filters, 'convert_chars'); 72 add_filters($filters, 'wpautop'); 93 73 94 74 // Format for RSS 95 75 $filters = array('term_name_rss'); 96 foreach ( $filters as $filter ) { 97 add_filter($filter, 'convert_chars'); 98 } 76 add_filters($filters, 'convert_chars'); 99 77 100 78 // Display filters 101 79 add_filter('the_title', 'wptexturize'); … … 209 187 210 188 add_filter('pre_option_gmt_offset','wp_timezone_override_offset'); 211 189 212 ?> 190 ?> 191 No newline at end of file -
wp-includes/plugin.php
72 72 } 73 73 74 74 /** 75 * Hooks multiple functions to a specific filter action. 76 * 77 * <code> 78 * function example_hook($example) { echo $example; } 79 * add_filter(array('example_filter1', 'example_filter2'), 'example_hook'); 80 * </code> 81 * 82 * @package WordPress 83 * @subpackage Plugin 84 * @since 2.8 85 * @global array $wp_filter Stores all of the filters added in the form of 86 * wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] 87 * @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. 88 * 89 * @param array of string $tag The names of the filters to hook the $function_to_add to. 90 * @param callback $function_to_add The name of the function to be called when the filter is applied. 91 * @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. 92 * @param int $accepted_args optional. The number of arguments the function accept (default 1). 93 * @return boolean true 94 */ 95 96 function add_filters($tags, $function_to_add, $priority = 10, $accepted_args = 1) { 97 foreach ( (array) $tags as $tag ) { 98 add_filter($tag, $function_to_add, $priority, $accepted_args); 99 } 100 return true; 101 } 102 103 104 /** 75 105 * Check if any filter has been registered for a hook. 76 106 * 77 107 * @package WordPress … … 273 303 } 274 304 275 305 306 276 307 /** 308 * Hooks a function on to multiple actions. 309 * 310 * @uses add_filters() Adds an action. Parameter list and functionality are the same. 311 * 312 * @package WordPress 313 * @subpackage Plugin 314 * @since 1.8 315 * 316 * @param array of string $tag The names of the actions to which the $function_to_add is hooked. 317 * @param callback $function_to_add The name of the function you wish to be called. 318 * @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. 319 * @param int $accepted_args optional. The number of arguments the function accept (default 1). 320 */ 321 function add_actions($tags, $function_to_add, $priority = 10, $accepted_args = 1) { 322 return add_filters($tags, $function_to_add, $priority, $accepted_args); 323 } 324 325 326 /** 277 327 * Execute functions hooked on a specific action hook. 278 328 * 279 329 * This function invokes all functions attached to action hook $tag. It is