功能:
remove_action函数用来从一个动作上删除一个函数,当指定的动作被调用的时候,这个函数就不再执行了。
用法:
参数:
$tag
(字符串)(必须)挂载函数的动作名称。
默认值:None
$function_to_remove
(回调函数)(必须)卸载的函数,直接填写字符串形式的函数名即可
默认值:None
$priority
(整数)(可选)动作执行的优先级,数值越小越先被执行。
默认值:10
返回值:
(布尔)始终返回 True.
所在位置:
remove_action()函数包含在wp-includes/plugin.php中.
源码:
/**
* Removes a function from a specified action hook.
*
* This function removes a function attached to a specified action hook. This
* method can be used to remove default functions attached to a specific filter
* hook and possibly replace them with a substitute.
*
* @since 1.2.0
*
* @param string $tag The action hook to which the function to be removed is hooked.
* @param callback $function_to_remove The name of the function which should be removed.
* @param int $priority Optional. The priority of the function. Default 10.
* @return boolean Whether the function is removed.
*/
function remove_action( $tag, $function_to_remove, $priority = 10 ) {
return remove_filter( $tag, $function_to_remove, $priority );
}
示例:
remove_action( 'wp_head', feed_links’, 2 );
相关函数:
do_action()
add_action()
remove_filter()
感觉本站内容不错,读后有收获?小额赞助
还可以分享文章给好友: