wordpress钩子和钩子函数

ccc,看了很多博客,无法理解,还是自己来写吧。

wordpress

在wordpress中有很多钩子,还有很多钩子函数,在什么地方用什么钩子,用什么钩子函数,

需要明白两个问题:

1:什么是钩子,钩子都有哪些类型,有多少钩子,每一个钩子的命名、作用都是什么

2: 什么是钩子函数,有哪些类型的,有多少,每一个钩子函数如何使用、如何传参...

一:wp中的所有钩子:

https://codex.wordpress.org/Plugin_API/Action_Reference

https://codex.wordpress.org/Plugin_API/Filter_Reference

二:wp钩子函数:

https://codex.wordpress.org/Plugin_API/

钩子分类:

钩子分为两种,一种叫做动作(action),还有一种叫做过滤器(filter)。这两种钩子实现原理基本一样,

使用上的区别在于过滤器有返回值,而动作没有。


Filter钩子函数:

has_filter()
add_filter()
apply_filters()
apply_filters_ref_array()
current_filter()
remove_filter()
remove_all_filters()
doing_filter()

Actions钩子函数

has_action()
add_action()
do_action()
do_action_ref_array()
did_action()
remove_action()
remove_all_actions()
doing_action()


Activation/Deactivation/Uninstall钩子函数

register_activation_hook()
register_uninstall_hook()

不清楚钩子是依据什么来分类的,有空再了解吧。

http://wangbaiyuan.cn/wordpress-function-hook-hook-book-2.html

原文地址:https://www.cnblogs.com/spacepirate/p/6223965.html