Ticket #8640: 8640.2.diff
File 8640.2.diff, 10.6 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 }25 19 20 add_filters($filter, 'strip_tags'); 21 add_filters($filter, 'trim'); 22 add_filters($filter, 'wp_filter_kses'); 23 add_filters($filter, 'wp_specialchars', 30); 24 26 25 // Kses only for textarea saves 27 26 $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 } 27 add_filters($filter, 'wp_filter_kses'); 31 28 32 29 // Email 33 30 $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 } 31 add_filters($filter, 'trim'); 32 add_filters($filter, 'sanitize_email'); 33 add_filters($filter, 'wp_filter_kses'); 39 34 35 40 36 // Save URL 41 37 $filters = array('pre_comment_author_url', 'pre_user_url', 'pre_link_url', 'pre_link_image', 42 38 '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 } 39 add_filters($filter, 'strip_tags'); 40 add_filters($filter, 'trim'); 41 add_filters($filter, 'sanitize_url'); 42 add_filters($filter, 'wp_filter_kses'); 49 43 50 44 // Display URL 51 45 $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 } 46 add_filters($filter, 'strip_tags'); 47 add_filters($filter, 'trim'); 48 add_filters($filter, 'clean_url'); 49 add_filters($filter, 'wp_filter_kses'); 58 50 59 51 // Slugs 60 52 $filters = array('pre_term_slug'); 61 foreach ( $filters as $filter ) { 62 add_filter($filter, 'sanitize_title'); 63 } 53 add_filters($filter, 'sanitize_title'); 64 54 65 55 // Keys 66 56 $filters = array('pre_post_type'); 67 foreach ( $filters as $filter ) { 68 add_filter($filter, 'sanitize_user'); 69 } 57 add_filters($filter, 'sanitize_user'); 70 58 71 59 // Places to balance tags on input 72 60 $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 } 61 add_filters( $filter, 'balanceTags', 50); 76 62 77 63 // Format strings for display. 78 64 $filters = array('comment_author', 'term_name', 'link_name', 'link_description', 79 65 'link_notes', 'bloginfo', 'wp_title'); 80 foreach ( $filters as $filter ) { 81 add_filter($filter, 'wptexturize'); 82 add_filter($filter, 'convert_chars'); 83 add_filter($filter, 'wp_specialchars'); 84 } 66 add_filters($filter, 'wptexturize'); 67 add_filters($filter, 'convert_chars'); 68 add_filters($filter, 'wp_specialchars'); 85 69 86 70 // Format text area for display. 87 71 $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 } 72 add_filters($filter, 'wptexturize'); 73 add_filters($filter, 'convert_chars'); 74 add_filters($filter, 'wpautop'); 93 75 94 76 // Format for RSS 95 77 $filters = array('term_name_rss'); 96 foreach ( $filters as $filter ) { 97 add_filter($filter, 'convert_chars'); 98 } 78 add_filters($filter, 'convert_chars'); 99 79 100 80 // Display filters 101 add_filter('the_title', 'wptexturize'); 102 add_filter('the_title', 'convert_chars'); 103 add_filter('the_title', 'trim'); 81 $funcitons = array('wptexturize', 'convert_chars', 'trim'); 82 add_filters_func('the_title', $funcitons); 104 83 105 add_filter('the_content', 'wptexturize'); 106 add_filter('the_content', 'convert_smilies'); 107 add_filter('the_content', 'convert_chars'); 108 add_filter('the_content', 'wpautop'); 109 add_filter('the_content', 'prepend_attachment'); 84 $functions = array('wptexturize', 'convert_smilies', 'convert_chars', 'wpautop', 'prepend_attachment'); 85 add_filters_func('the_content', $functions); 110 86 111 add_filter('the_excerpt', 'wptexturize'); 112 add_filter('the_excerpt', 'convert_smilies'); 113 add_filter('the_excerpt', 'convert_chars'); 114 add_filter('the_excerpt', 'wpautop'); 87 $functions = array('wptexturize', 'convert_smilies', 'convert_chars', 'wpautop'); 88 add_filters_func('the_excerpt', $functions); 115 89 add_filter('get_the_excerpt', 'wp_trim_excerpt'); 116 90 117 add_filter('comment_text', 'wptexturize');118 add_filter ('comment_text', 'convert_chars');91 $functions = array('wptexturize', 'convert_chars'); 92 add_filters_func('comment_text', $functions); 119 93 add_filter('comment_text', 'make_clickable', 9); 120 94 add_filter('comment_text', 'force_balance_tags', 25); 121 95 add_filter('comment_text', 'convert_smilies', 20); … … 123 97 124 98 add_filter('comment_excerpt', 'convert_chars'); 125 99 126 add_filter('list_cats', 'wptexturize');127 add_filter ('single_post_title', 'wptexturize');100 $filters = array('list_cats', 'single_post_title'); 101 add_filters($filters, 'wptexturize'); 128 102 129 103 add_filter('wp_sprintf', 'wp_sprintf_l', 10, 2); 130 104 -
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_filters(array('example_filter1', 'example_filter2'), 'example_hook'); 80 * </code> 81 * 82 * @package WordPress 83 * @subpackage Plugin 84 * @since 2.8.0 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 $tags 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 * Hooks multiple filters to a single function. 105 * 106 * <code> 107 * function example_hook1($example) { echo $example; } 108 * function example_hook2($example) { echo $example; } 109 * add_filters_func('example_filter', array('example_hook1', 'example_hook2')); 110 * </code> 111 * 112 * @package WordPress 113 * @subpackage Plugin 114 * @since 2.8.0 115 * @global array $wp_filter Stores all of the filters added in the form of 116 * wp_filter['tag']['array of priorities']['array of functions serialized']['array of ['array (functions, accepted_args)]'] 117 * @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. 118 * 119 * @param string $tag The names of the filters to hook the $functions to. 120 * @param array of functions $functions The name of the functions to be called when the filter is applied. 121 * @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. 122 * @param int $accepted_args optional. The number of arguments the function accept (default 1). 123 * @return boolean true 124 */ 125 126 function add_filters_func($tag, $functions, $priority = 10, $accepted_args = 1) { 127 foreach ( (array) $functions as $function ) { 128 add_filter($tag, $function, $priority, $accepted_args); 129 } 130 return true; 131 } 132 133 134 /** 75 135 * Check if any filter has been registered for a hook. 76 136 * 77 137 * @package WordPress … … 273 333 } 274 334 275 335 336 276 337 /** 338 * Hooks a function on to multiple actions. 339 * 340 * @uses add_filters() Adds an action. Parameter list and functionality are the same. 341 * 342 * @package WordPress 343 * @subpackage Plugin 344 * @since 1.8 345 * 346 * @param array of string $tag The names of the actions to which the $function_to_add is hooked. 347 * @param callback $function_to_add The name of the function you wish to be called. 348 * @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. 349 * @param int $accepted_args optional. The number of arguments the function accept (default 1). 350 */ 351 function add_actions($tags, $function_to_add, $priority = 10, $accepted_args = 1) { 352 return add_filters($tags, $function_to_add, $priority, $accepted_args); 353 } 354 355 /** 356 * Hooks a function on to multiple actions. 357 * 358 * @uses add_filters_func() Adds an action. Parameter list and functionality are the same. 359 * 360 * @package WordPress 361 * @subpackage Plugin 362 * @since 2.8.0 363 * 364 * @param string $tag The names of the actions to which the $functions is hooked. 365 * @param array of $functions The name of the functions you wish to be called. 366 * @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. 367 * @param int $accepted_args optional. The number of arguments the function accept (default 1). 368 */ 369 function add_actions_func($tag, $functions, $priority = 10, $accepted_args = 1) { 370 return add_filters_func($tag, $functions, $priority, $accepted_args); 371 } 372 373 374 /** 277 375 * Execute functions hooked on a specific action hook. 278 376 * 279 377 * This function invokes all functions attached to action hook $tag. It is