Ticket #14671: 14671.3.diff
File 14671.3.diff, 4.6 KB (added by , 15 years ago) |
---|
-
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). 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 69 72 $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); 70 73 unset( $merged_filters[ $tag ] ); 71 74 return true; … … 174 177 } 175 178 176 179 /** 180 * Whether function name is internal to PHP. 181 * 182 * @package WordPress 183 * @since 3.1 184 * 185 * @global array $php_internal_functions 186 * @param string $function_name 187 * @return bool 188 */ 189 function is_internal_php_function( $function_name ) { 190 global $php_internal_functions; 191 if ( !isset( $php_internal_functions ) ) { 192 $functions = get_defined_functions(); 193 $php_internal_functions = array_flip( $functions['internal'] ); 194 } 195 return isset( $php_internal_functions[$function_name] ); 196 } 197 198 /** 177 199 * Execute functions hooked on a specific filter hook, specifying arguments in an array. 178 200 * 179 201 * @see apply_filters() This function is identical, but the arguments passed to the … … 244 266 * @param string $tag The filter hook to which the function to be removed is hooked. 245 267 * @param callback $function_to_remove The name of the function which should be removed. 246 268 * @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 269 * @return boolean Whether the function existed before it was removed. 249 270 */ 250 function remove_filter( $tag, $function_to_remove, $priority = 10, $accepted_args = 1) {271 function remove_filter( $tag, $function_to_remove, $priority = 10 ) { 251 272 $function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority); 252 273 253 274 $r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); … … 319 340 * @param string $tag The name of the action to which the $function_to_add is hooked. 320 341 * @param callback $function_to_add The name of the function you wish to be called. 321 342 * @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).343 * @param int $accepted_args Optional. The number of arguments the function accept (default: 1 for internal php functions). 323 344 */ 324 function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {345 function add_action($tag, $function_to_add, $priority = 10, $accepted_args = null) { 325 346 return add_filter($tag, $function_to_add, $priority, $accepted_args); 326 347 } 327 348 … … 507 528 * @param string $tag The action hook to which the function to be removed is hooked. 508 529 * @param callback $function_to_remove The name of the function which should be removed. 509 530 * @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 531 * @return boolean Whether the function is removed. 512 532 */ 513 function remove_action( $tag, $function_to_remove, $priority = 10, $accepted_args = 1) {514 return remove_filter( $tag, $function_to_remove, $priority, $accepted_args);533 function remove_action( $tag, $function_to_remove, $priority = 10 ) { 534 return remove_filter( $tag, $function_to_remove, $priority ); 515 535 } 516 536 517 537 /**