Changeset 6320 for trunk/wp-includes/plugin.php
- Timestamp:
- 11/07/2007 04:30:11 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/plugin.php
r6319 r6320 80 80 81 81 /** 82 * Check if any filter has been registered for a hook. Optionally returns the priority on that hook for the specified function. 83 * @package WordPress 84 * @subpackage Plugin 85 * @since 2.4 86 * @global array $wp_filter Stores all of the filters 87 * 88 * @param string $tag The name of the filter hook. 89 * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached. 90 * @return int|boolean 91 */ 92 function has_filter($tag, $function_to_check = false) { 93 global $wp_filter; 94 95 $has = !empty($wp_filter[$tag]); 96 if ( false === $function_to_check || false == $has ) 97 return $has; 98 99 if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false, 'filter') ) 100 return false; 101 102 foreach ( array_keys($wp_filter[$tag]) as $priority ) { 103 if ( isset($wp_filter[$tag][$priority][$idx]) ) 104 return $priority; 105 } 106 107 return false; 108 } 109 110 /** 82 111 * Call the functions added to a filter hook. 83 112 * … … 181 210 if ( true === $r) { 182 211 unset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]); 212 if ( empty($GLOBALS['wp_filter'][$tag][$priority]) ) 213 unset($GLOBALS['wp_filter'][$tag][$priority]); 183 214 unset($GLOBALS['merged_filters'][$tag]); 184 215 } … … 326 357 * the functions hooked to <tt>$tag</tt> are supplied using an array. 327 358 * 328 * @uses merge_filters()329 *330 359 * @package WordPress 331 360 * @subpackage Plugin … … 378 407 379 408 /** 409 * Check if any action has been registered for a hook. Optionally returns the priority on that hook for the specified function. 410 * @package WordPress 411 * @subpackage Plugin 412 * @since 2.4 413 * @global array $wp_action Stores all of the actions 414 * 415 * @param string $tag The name of the action hook. 416 * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached. 417 * @return int|boolean 418 */ 419 function has_action($tag, $function_to_check = false) { 420 global $wp_action; 421 422 $has = !empty($wp_action[$tag]); 423 if ( false === $function_to_check || false == $has ) 424 return $has; 425 426 if ( !$idx = _wp_filter_build_unique_id($tag, $function_to_check, false, 'action') ) 427 return false; 428 429 foreach ( array_keys($wp_action[$tag]) as $priority ) { 430 if ( isset($wp_action[$tag][$priority][$idx]) ) 431 return $priority; 432 } 433 434 return false; 435 } 436 437 /** 380 438 * Removes a function from a specified action hook. 381 439 * … … 383 441 * method can be used to remove default functions attached to a specific filter 384 442 * hook and possibly replace them with a substitute. 385 *386 * @uses remove_filter() Uses remove_filter to remove actions added.387 443 * 388 444 * @package WordPress … … 403 459 if ( true === $r) { 404 460 unset($GLOBALS['wp_action'][$tag][$priority][$function_to_remove]); 461 if ( empty($GLOBALS['wp_action'][$tag][$priority]) ) 462 unset($GLOBALS['wp_action'][$tag][$priority]); 405 463 unset($GLOBALS['merged_actions'][$tag]); 406 464 } … … 514 572 * @param string $tag Used in counting how many hooks were applied 515 573 * @param string|array $function Used for creating unique id 516 * @param int $priority Used in counting how many hooks were applied574 * @param int|bool $priority Used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise. 517 575 * @param string $type filter or action 518 576 * @return string Unique ID for usage as array key … … 529 587 $obj_idx = get_class($function[0]).$function[1]; 530 588 if ( !isset($function[0]->wp_filter_id) ) { 589 if ( false === $priority ) 590 return false; 531 591 if ( 'filter' == $type ) 532 592 $count = count((array)$wp_filter[$tag][$priority]);
Note: See TracChangeset
for help on using the changeset viewer.