站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Function Reference/add action
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
Fludlen
(
讨论
|
贡献
)
2008年7月21日 (一) 15:32的版本
(
差异
)
←上一版本
|
最后版本
(
差异
) |
下一版本→
(
差异
)
跳转至:
导航
、
搜索
警告:您正在编辑的是本页面的旧版本。
如果您发布该更改,该版本后的所有更改都会丢失。
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
== Description == == 描述== Hooks a function on to a specific [[WordPress:Plugin_API#Actions|action]]. See [[WordPress:Plugin_API#Current_Hooks_For_actions|Plugin API]] for a list of hooks for action. Hooks函数到一个特别的[[WordPress:Plugin_API#Actions|action]]。请看看[[WordPress:Plugin_API#Current_Hooks_For_actions|Plugin API|插件API]]关于hooks for action的列表。 == Usage == == 用法 == %%% <?php add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1); ?> %%% %%% <?php add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1); ?> %%% == Examples == == 例子 == To email some friends whenever an entry is posted on your blog: 给一些朋友发送电子邮件,询问你的博客上是否已经发表了一篇文章。 <pre> function email_friends($post_ID) { $friends = 'bob@example.org, susie@example.org'; mail($friends, "sally's blog updated" , 'I just put something on my blog: http://blog.example.com'); return $post_ID; } add_action('publish_post', 'email_friends'); </pre> <pre> function email_friends($post_ID) { $friends = 'bob@example.org, susie@example.org'; mail($friends, "sally's blog updated" , 'I just put something on my blog: http://blog.example.com'); return $post_ID; } add_action('publish_post', 'email_friends'); </pre> == Parameters == == 参数 == ; <tt>$tag</tt> : (''string'') The name of the action you wish to hook onto. ; <tt>$tag</tt> : (''string'')你想要hook onto的action的名称。 ; <tt>$function_to_add</tt> : (''callback'') The name of the function you wish to be called. Note: any of the syntaxes explained in [http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback the PHP documentation for the 'callback' type] are valid. ; <tt>$function_to_add</tt> : (''callback'')你希望调用的函数的名称。注:[http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback the PHP documentation for the 'callback' type]中解释的任何语法都是有效的。 ; <tt>$priority</tt> : How important your function is. Alter this to make your function be called before or after other functions. The default is 10, so (for example) setting it to 5 would make it run earlier and setting it to 12 would make it run later. ; <tt>$priority</tt> :你的函数有多么重要。更改这个重要性,使得你的函数在其它函数之前或者之后得到调用。默认值是10,因此(例如)将这个值设置为5,会使得函数更早运行,如果设置为12,会使得函数迟一点运行。 ; <tt>$accepted_args</tt> : How many arguments your function takes. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. For example, the action <tt>comment_id_not_found</tt> will pass any functions that hook onto it the ID of the requested comment. ; <tt>$accepted_args</tt> :你的函数拥有多少个参数。在WordPress1.5.1+,hooked 函数可以获得,matching do_action() 或者apply_filters() call运行时,设置的额外参数。例如,action <tt>comment_id_not_found</tt>会传递任何hook onto it需要的评论ID的函数。
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)