web/wp-includes/plugin.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    78  * @subpackage Plugin
    78  * @subpackage Plugin
    79  * @since 2.5
    79  * @since 2.5
    80  * @global array $wp_filter Stores all of the filters
    80  * @global array $wp_filter Stores all of the filters
    81  *
    81  *
    82  * @param string $tag The name of the filter hook.
    82  * @param string $tag The name of the filter hook.
    83  * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached.
    83  * @param callback $function_to_check optional.
    84  * @return int|boolean Optionally returns the priority on that hook for the specified function.
    84  * @return mixed If $function_to_check is omitted, returns boolean for whether the hook has anything registered.
       
    85  * 	When checking a specific function, the priority of that hook is returned, or false if the function is not attached.
       
    86  * 	When using the $function_to_check argument, this function may return a non-boolean value that evaluates to false
       
    87  * 	(e.g.) 0, so use the === operator for testing the return value.
    85  */
    88  */
    86 function has_filter($tag, $function_to_check = false) {
    89 function has_filter($tag, $function_to_check = false) {
    87 	global $wp_filter;
    90 	global $wp_filter;
    88 
    91 
    89 	$has = !empty($wp_filter[$tag]);
    92 	$has = !empty($wp_filter[$tag]);
   252  * @param callback $function_to_remove The name of the function which should be removed.
   255  * @param callback $function_to_remove The name of the function which should be removed.
   253  * @param int $priority optional. The priority of the function (default: 10).
   256  * @param int $priority optional. The priority of the function (default: 10).
   254  * @param int $accepted_args optional. The number of arguments the function accepts (default: 1).
   257  * @param int $accepted_args optional. The number of arguments the function accepts (default: 1).
   255  * @return boolean Whether the function existed before it was removed.
   258  * @return boolean Whether the function existed before it was removed.
   256  */
   259  */
   257 function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
   260 function remove_filter( $tag, $function_to_remove, $priority = 10 ) {
   258 	$function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority);
   261 	$function_to_remove = _wp_filter_build_unique_id($tag, $function_to_remove, $priority);
   259 
   262 
   260 	$r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
   263 	$r = isset($GLOBALS['wp_filter'][$tag][$priority][$function_to_remove]);
   261 
   264 
   262 	if ( true === $r) {
   265 	if ( true === $r) {
   495  * @subpackage Plugin
   498  * @subpackage Plugin
   496  * @since 2.5
   499  * @since 2.5
   497  * @see has_filter() has_action() is an alias of has_filter().
   500  * @see has_filter() has_action() is an alias of has_filter().
   498  *
   501  *
   499  * @param string $tag The name of the action hook.
   502  * @param string $tag The name of the action hook.
   500  * @param callback $function_to_check optional. If specified, return the priority of that function on this hook or false if not attached.
   503  * @param callback $function_to_check optional.
   501  * @return int|boolean Optionally returns the priority on that hook for the specified function.
   504  * @return mixed If $function_to_check is omitted, returns boolean for whether the hook has anything registered.
       
   505  * 	When checking a specific function, the priority of that hook is returned, or false if the function is not attached.
       
   506  * 	When using the $function_to_check argument, this function may return a non-boolean value that evaluates to false
       
   507  * 	(e.g.) 0, so use the === operator for testing the return value.
   502  */
   508  */
   503 function has_action($tag, $function_to_check = false) {
   509 function has_action($tag, $function_to_check = false) {
   504 	return has_filter($tag, $function_to_check);
   510 	return has_filter($tag, $function_to_check);
   505 }
   511 }
   506 
   512 
   516  * @since 1.2
   522  * @since 1.2
   517  *
   523  *
   518  * @param string $tag The action hook to which the function to be removed is hooked.
   524  * @param string $tag The action hook to which the function to be removed is hooked.
   519  * @param callback $function_to_remove The name of the function which should be removed.
   525  * @param callback $function_to_remove The name of the function which should be removed.
   520  * @param int $priority optional The priority of the function (default: 10).
   526  * @param int $priority optional The priority of the function (default: 10).
   521  * @param int $accepted_args optional. The number of arguments the function accepts (default: 1).
       
   522  * @return boolean Whether the function is removed.
   527  * @return boolean Whether the function is removed.
   523  */
   528  */
   524 function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
   529 function remove_action( $tag, $function_to_remove, $priority = 10 ) {
   525 	return remove_filter($tag, $function_to_remove, $priority, $accepted_args);
   530 	return remove_filter( $tag, $function_to_remove, $priority );
   526 }
   531 }
   527 
   532 
   528 /**
   533 /**
   529  * Remove all of the hooks from an action.
   534  * Remove all of the hooks from an action.
   530  *
   535  *