wordpress中的动作钩子和过滤器钩子有什么区别? [英] what is difference between action hook and filter hook in wordpress?

查看:29
本文介绍了wordpress中的动作钩子和过滤器钩子有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到动作钩子用于调用函数,过滤器钩子用于在保存或显示在网站上之前过滤内容.你能告诉我我们使用 action 和 filter hook 的项目示例的一些工作阶段吗?所以了解更多会更好.

I read the action hook is use for call the functions and filter hook is use for filtering the content before save or display on website. Can you tell me the some working phases of project example where we use action and filter hook. So it will better to understand more.

推荐答案

行动:做新的事情.前任.添加 CSS 和 JS.

Action: Doing new things. Ex. adding CSS and JS.

过滤器:做一些已经在 WordPress 中的事情.添加或删除一些东西.假设在发布内容后添加一些文本.这意味着用 WordPress 做点什么.

Filter: Doing something which is already in WordPress. Adding or removing some things. Assume adding some text after post content. It means doing something with WordPress.

add_action('admin_menu','my_func',8,2);
function my_func($one, $two){
    //Something here …
}

这篇关于wordpress中的动作钩子和过滤器钩子有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆