Ticket #14671: 14671.002.diff
File 14671.002.diff, 4.5 KB (added by , 15 years ago) |
---|
-
wp-includes/plugin.php
59 59 * @param string $tag The name of the filter to hook the $function_to_add to. 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 * @param int $accepted_args optional. The number of arguments the function accept (default 1).62 * @param int $accepted_args optional. The number of arguments the function accept (default: 1 for internal php functions, 100 for user function). 63 63 * @return boolean true 64 64 */ 65 function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {65 function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = NULL) { 66 66 global $wp_filter, $merged_filters; 67 67 68 68 $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); 69 if ( NULL === $accepted_args && is_string( $function_to_add ) && is_internal_php_function( $function_to_add ) ) 70 $accepted_args = 1; 71 elseif ( NULL === $accepted_args ) 72 $accepted_args = 100; 69 73 $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); 70 74 unset( $merged_filters[ $tag ] ); 71 75 return true; … … 173 177 return $value; 174 178 } 175 179 180 function is_internal_php_function( $function_name ) { 181 global $php_internal_functions; 182 if ( !isset( $php_internal_functions ) ) { 183 $functions = get_defined_functions(); 184 $php_internal_functions = array_flip( $functions['internal'] ); 185 } 186 return isset( $php_internal_functions[$function_name] ); 187 } 188 176 189 /** 177 190 * Execute functions hooked on a specific filter hook, specifying arguments in an array. 178 191 * … … 244 257 * @param string $tag The filter hook to which the function to be removed is hooked. 245 258 * @param callback $function_to_remove The name of the function which should be removed. 246 259 * @param int $priority optional. The priority of the function (default: 10). 247 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).248 260 * @return boolean Whether the function existed before it was removed. 249 261 */ 250 function remove_filter( $tag, $function_to_remove, $priority = 10, $accepted_args = 1) {262 function remove_filter( $tag, $function_to_remove, $priority = 10 ) { 251 263 $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority); 252 264 253 265 $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); … … 319 331 * @param string $tag The name of the action to which the $function_to_add is hooked. 320 332 * @param callback $function_to_add The name of the function you wish to be called. 321 333 * @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 * @param int $accepted_args optional. The number of arguments the function accept (default 1).334 * @param int $accepted_args optional. The number of arguments the function accept (default: 1 for internal php functions, 100 for user functions). 323 335 */ 324 function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {336 function add_action($tag, $function_to_add, $priority = 10, $accepted_args = NULL) { 325 337 return add_filter($tag, $function_to_add, $priority, $accepted_args); 326 338 } 327 339 … … 507 519 * @param string $tag The action hook to which the function to be removed is hooked. 508 520 * @param callback $function_to_remove The name of the function which should be removed. 509 521 * @param int $priority optional The priority of the function (default: 10). 510 * @param int $accepted_args optional. The number of arguments the function accpets (default: 1).511 522 * @return boolean Whether the function is removed. 512 523 */ 513 function remove_action( $tag, $function_to_remove, $priority = 10, $accepted_args = 1) {514 return remove_filter( $tag, $function_to_remove, $priority, $accepted_args);524 function remove_action( $tag, $function_to_remove, $priority = 10 ) { 525 return remove_filter( $tag, $function_to_remove, $priority ); 515 526 } 516 527 517 528 /**