钩子是代码间交互或修改的机制,允许插件、主题与编辑器交互,并广泛应用于 WordPress 核心。WordPress 支持 PHP 和 JavaScript 两种钩子类型。
Hooks are a way for one piece of code to interact/modify another piece of code. They provide one way for plugins and themes to interact with the editor, but they’re also used extensively by WordPress Core itself.
There are two types of hooks: Actions and Filters. In addition to PHP actions and filters, WordPress also provides a mechanism for registering and executing hooks in JavaScript. This functionality is also available on npm as the @wordpress/hooks package, for general purpose use.
You can also learn more about both APIs: PHP and JavaScript.