WordPress:Plugin API/Action Reference
This article is a (hopefully complete) list of the action hooks available for use in plugin development in Version 2.1 and above of WordPress. For more information:
这篇文章是WordPress2.1以及更高版本中的插件发展中可以使用的action hooks的列表(希望全面)。更多的信息:
- To learn more about what filter and action hooks are, see WordPress:Plugin API.
- 学习更多关于filter和action hooks是什么的内容,请看看插件API。
- To learn about writing plugins in general, see WordPress:Writing a Plugin.
- 学习更多编写插件的内容,请看看编写插件。
- For a reference list of filter hooks, see WordPress:Plugin API/Filter Reference.
- 关于filter hooks的reference列表,请看看插件API/Filter Reference。
- For information about filter and action hooks in previous versions of WordPress, see WordPress:Plugin API/Hooks 2.0.x.
- 关于WordPress早期版本的filter 和 action hooks的信息,请看看插件API/Hooks 2.0.x
Note: If you want to add to or clarify this documentation, please follow the style of the existing entries. Describe when the action runs, and if the action function takes arguments, describe the arguments.
注:如果你想要添加或者阐明这个文件,请采用当前的文章格式。描述action运行的时间,如action function带有参数,请描述这个参数。
Post, Page, Attachment, and Category Actions
文章,网页,配属,和类别Actions
- add_attachment
- Runs when an attached file is first added to the database. Action function arguments: attachment ID.
- add_attachment
- 当附属文件首次添加到数据库的时候,请运行这个。Action function 参数:attachment ID。
- add_category
- Same as create_category.
- add_category
- 与create_category相同。
- create_category
- Runs when a new category is created. Action function arguments: category ID.
- create_category
- 创建新的类别的时候,运行。Aciton function arguments: 类别 ID。
- delete_attachment
- Runs just after an attached file is deleted from the database. Action function arguments: attachment ID.
- delete_attachment
- 数据库中删除附加文件后,运行。Action function arguments: attachment ID。
- delete_category
- Runs just after a category is deleted from the database and its corresponding links/posts are updated to remove the category. Action function arguments: category ID.
- delete_category
- 类别从数据库中删除而且类别相关的链接/文章得到更新,移除类别的时候,运行。Action function arguments: 类别 ID。
- delete_post
- Runs when a post or page is about to be deleted. Action function arguments: post or page ID.
- delete_post
- 文章或者网页将要删除的时候,运行。Action function arguments:文章或者网页ID。
- edit_attachment
- Runs when an attached file is edited/updated to the database. Action function arguments: attachment ID.
- edit_attachment
- 附加文件编辑/更新到数据库中的时候,运行。Action function arguments: attachment ID。
- edit_category
- Runs when a category is updated/edited, including when a post or blogroll link is added/deleted or its categories are updated (which causes the count for the category to update). Action function arguments: category ID.
- edit_category
- 类别升级/编辑的时候,包括文章或者友情链接添加/删除的时间或者类别更新的时间(致使类别数目更新),运行edit_category。Action function arguments: 类别 ID。
- edit_post
- Runs when a post or page is updated/edited, including when a comment is added or updated (which causes the comment count for the post to update). Action function arguments: post or page ID.
- edit_post
- 文章或者网页更新/编辑的时候,包括添加或者更新评论的时候(致使文章的评论数目更新),运行edit_post。Action function arguments: 文章或者网页 ID。
- private_to_published
- Runs when a post is changed from private to published status. Action function arguments: post ID.
- private_to_published
- 文章从保密更改为发表状态的时候,运行private_to_published。Action function arguments: 文章 ID。
- publish_page
- Runs when a page is published, or if it is edited and its status is "published". Action function arguments: page ID. (WARNING: this hook seems to never fire on v2.3 and higher. The 'transition_post_status' hook does work though; UPDATE: publish_page hook appears to be working as of 2.6)
- publish_page
- 发表网页的时候,或者编辑网页,或者网页状态为"已发表"的时候,运行publish_page。Action function arguments:网页ID。(注:这个hook似乎在2.3版本以及更高的版本中已经不能够运行了。'transition_post_status'能够运行;更新:publish_page hook似乎从2.6版本开始,即可运行)
- publish_phone
- Runs just after a post is added via email. Action function argument: post ID.
- publish_phone
- 在文章通过电子邮件添加后,运行publish_phone。Action function argument: 文章 ID。
- publish_post
- Runs when a post is published, or if it is edited and its status is "published". Action function arguments: post ID.
- publish_post
- 文章发表,或者文章正在编辑并且状态是"已发表"时,运行publish_post。Action function arguments:文章ID。
- save_post
- Runs whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. Action function arguments: post ID.
- save_post
- 创建或者更新文章或者网页的时候,可以是导入的文章/网页编辑形式,xmlrpc,或者通过电子邮件发送的文章,运行save_post。Action function arguments:文章ID。
- wp_insert_post
- Same as save_post, runs just afterwards.
- wp_insert_post
- 与save_post相同,在稍后运行。
- xmlrpc_publish_post
- Runs when a post is published via XMLRPC request, or if it is edited via XMLRPC and its status is "published". Action function arguments: post ID.
- xmlrpc_publish_post
- 文章通过XMLRPC发表,或者文章通过XMLRPC编辑,并且文章的状态是"已发表"时,运行xmlrpc_publish_post。Action function arguments:文章ID。
Comment, Ping, and Trackback Actions
评论, Ping,和 Trackback Actions
- comment_closed
- Runs when the post is marked as not allowing comments while trying to display comment entry form. Action function argument: post ID.
- comment_closed
- 尝试显示评论内容形式的时候,文章标记为不允许评论,运行。Action function argument: 文章 ID。
- comment_id_not_found
- Runs when the post ID is not found while trying to display comments or comment entry form. Action function argument: post ID.
- comment_id_not_found
- 试着显示评论或者评论内容形式的时候,没有找到文章ID时,运行。Action function argument: 文章 ID。
- comment_flood_trigger
- Runs when a comment flood is detected, just before wp_die is called to stop the comment from being accepted. Action function arguments: time of previous comment, time of current comment.
- comment_flood_trigger
- 发现垃圾评论,在调用wp_die阻止接受评论之前,运行。Action function arguments:先前评论时间,当前评论时间。
- comment_on_draft
- Runs when the post is a draft while trying to display a comment entry form or comments. Action function argument: post ID.
- comment_on_draft
- 当文章是草稿,试着显示评论内容形式或者评论的时候,运行。Action function argument: 文章ID。
- comment_post
- Runs just after a comment is saved in the database. Action function arguments: comment ID, approval status ("spam", or 0/1 for disapproved/approved).
- comment_post
- 评论保存到数据库时,运行。Action function arguments: 评论 ID, 批准状态 ("垃圾广告", 或者 0/1 表示不批准/批准)。
- edit_comment
- Runs after a comment is updated/edited in the database. Action function arguments: comment ID.
- edit_comment
- 评论在数据库中更新/编辑时候,运行。Action function arguments: 评论 ID。
- delete_comment
- Runs just before a comment is deleted. Action function arguments: comment ID.
- delete_comment
- 评论删除之前,运行。Action function arguments: 评论 ID。
- pingback_post
- Runs when a ping is added to a post. Action function argument: comment ID.
- pingback_post
- 当ping添加到文章时候,运行。Action function argument: 评论 ID。Action function argument: comment ID.
- pre_ping
- Runs before a ping is fully processed. Action function arguments: array of the post links to be processed, and the "pung" setting for the post.
- pre_ping
- ping完全地运行之前,运行。Action function arguments:运行一组文章链接,以及文章的"pung"设置。
- trackback_post
- Runs when a trackback is added to a post. Action function argument: comment ID.
- trackback_post
- 当trackback添加到文章的时候,运行。Action function argument:评论ID。
- wp_blacklist_check
- Runs to check whether a comment should be blacklisted. Action function arguments: author name, author email, author URL, comment text, author IP address, author's user agent (browser). Your function can execute a wp_die to reject the comment, or perhaps modify one of the input arguments so that it will contain one of the blacklist keywords set in the WordPress options.
- wp_blacklist_check
- 运行,查看评论是否应该放到黑名单。Action function arguments:作者名,作者电子邮件,作者URL,评论文本,作者IP地址,作者的用户代理(浏览器)。你的函数能够执行wp_die拒绝评论,或者更改其中输入的一个函数,这样WordPress选项中会包含其中的一个黑名单关键词。
- wp_set_comment_status
- Runs when the status of a comment changes. Action function arguments: comment ID, status string indicating the new status ("delete", "approve", "spam", "hold").
- wp_set_comment_status
- 评论状态更改的时候,运行。Action function arguments:评论ID,状态字符串只是新的状态("删除", "准许", "垃圾广告", "hold")。
Blogroll Actions
友情链接 Actions
- add_link
- Runs when a new blogroll link is first added to the database. Action function arguments: link ID.
- add_link
- 当一个新的友情链接首次添加到数据库的时候,运行。Action function arguments:链接ID。
- delete_link
- Runs when a blogroll link is deleted. Action function arguments: link ID.
- delete_link
- 删除友情链接的时候,运行。Action function arguments:链接ID。
- edit_link
- Runs when a blogroll link is edited. Action function arguments: link ID.
- edit_link
- 编辑友情链接的时候,运行。Action function arguments:链接ID。
Feed Actions
Feed Actions
- atom_entry
- Runs just after the entry information has been printed (but before closing the entry tag) for each blog entry in an atom feed.
- atom_entry
- atom feed中的每个博客entry信息发表后(但是entry标签关闭之前),运行。
- atom_head
- Runs just after the blog information has been printed in an atom feed, just before the first entry.
- atom_head
- 博客信息在atom feed,第一个entry之前,发表后,运行。
- atom_ns
- Runs inside the root XML element for an atom feed (to add namespaces).
- atom_ns
- 为atom feed,在根XML元素内部运行(要添加名字空间)。
- commentrss2_item
- Runs just after a single comment's information has been printed in a comment feed (but before closing the item tag). Action function arguments: comment ID, post ID.
- commentrss2_item
- 评论feed中发表了单个评论的信息后(但是在关闭item标签之前),运行。Action function arguments:评论ID,文章ID。
- commentrss2_item
- commentrss2_item
- do_feed_feed
- Runs when a feed is generated, where feed is the type of feed (rss2, atom, rdf, etc.). Use priority less than 10 to run before printing the feed. Action function argument: true (the feed is for comments) or false (it is for posts).
- do_feed_feed
- 产生feed时,运行,feed是feed的类型(rss2, atom, rdf, 等等)。
- rdf_header
- Runs just after the blog information has been printed in an RDF feed, just before the first entry.
- rdf_header
- 博客信息在RDF feed中发表后,在第一个entry之前,运行。
- rdf_item
- Runs just after the entry information has been printed (but before closing the item tag) for each blog entry in an RDF feed.
- rdf_item
- RDF feed中的每篇博客文章信息都发表后(但是在关闭文章标签之前),运行。
- rdf_ns
- Runs inside the root XML element in an RDF feed (to add namespaces).
- rdf_ns
- 在RDF feed中的根XML元素内运行(添加名字空间)。
- rss_head
- Runs just after the blog information has been printed in an RSS feed, just before the first entry.
- rss_head
- 博客信息在RSS feed中发表后,在第一篇文章之前,运行。
- rss_item
- Runs just after the entry information has been printed (but before closing the item tag) for each blog entry in an RSS feed.
- rss_item
- RSS feed中的每篇博客文章信息发表后(但是在文章标签关闭之前),运行。
- rss2_head
- Runs just after the blog information has been printed in an RSS 2 feed, just before the first entry.
- rss2_head
- 博客信息在RSS 2 feed中发表后,在第一篇文章之前,运行。
- rss2_item
- Runs just after the entry information has been printed (but before closing the item tag) for each blog entry in an RSS 2 feed.
- rss2_item
- 在RSS 2 feed中发表了每篇博客文章信息后(但是在文章标签关闭之前),运行。
- rss2_ns
- Runs inside the root XML element in an RSS 2 feed (to add namespaces).
- rss2_ns
- 在RSS 2 feed内的根XML元素中运行(添加名字空间)。
Template Actions
模板 Actions
- comment_form
- Runs in standard themes to insert the comment form. Action function argument: post ID.
- comment_form
- 在标准主题中运行,插入评论形式。Action function argument:文章ID。
- do_robots
- Runs when the template file chooser determines that it is a robots.txt request.
- do_robots
- 选择模板文件的人,确认模板文件是robots.txt请求的时候,运行。
- do_robotstxt
- Runs in the do_robots function before it prints out the Disallow lists for the robots.txt file.
- do_robotstxt
- 在do_robots函数中运行,然后输出robots.txt文件不接受的列表。
- get_footer
- Runs when the template calls the get_footer function, just before the footer.php template file is loaded.
- get_footer
- 模板调用get_footer函数的时候,运行,在载入footer.php模板文件之前。
- get_header
- Runs when the template calls the get_header function, just before the header.php template file is loaded.
- get_header
- 模板调用get_header函数时候,运行,在载入header.php模板文件之前。
- switch_theme
- Runs when the blog's theme is changed. Action function argument: name of the new theme.
- switch_theme
- 博客的主题更改的时候,运行。Action function argument:新的主题的名称。
- template_redirect
- Runs before the determination of the template file to be used to display the requested page, so that a plugin can override the template file choice. Example (pedagogical, not useful): Redirect all requests to the all.php template file in the current themes' directory.
- template_redirect
- 在决定使用模板文件,显示请求的网页之前,运行,这样插件可以废除模板文件选项。例子(教育学的, 没用):将所有请求重新导向当前主题目录的all.php模板文件。
function all_on_one () { include(TEMPLATEPATH . '/all.php'); exit; } add_action('template_redirect', 'all_on_one');
function all_on_one () { include(TEMPLATEPATH . '/all.php'); exit; } add_action('template_redirect', 'all_on_one');
- wp_footer
- Runs when the template calls the wp_footer function, generally near the bottom of the blog page.
- wp_footer
- 模板调用wp_footer函数的时候,运行,一般在博客页面的底部。
- wp_head
- Runs when the template calls the wp_head function. This hook is generally placed near the top of a page template between <head> and </head>. This hook does not take any parameters.
- wp_head
- 当模板调用wp_head函数的时候,运行。这个hook一般放在网页模板的顶上方,在<head>和 </head>之间。这个hook没有任何参数。
- wp_meta
- Runs when the sidebar.php template file calls the wp_meta function, to allow the plugin to insert content into the sidebar.
- wp_meta
- sidebar.php模板文件调用wp_meta函数的时候,运行,使得插件将内容插入到边栏中。
- wp_print_scripts
- Runs just before WordPress prints registered JavaScript scripts into the page header.
- wp_print_scripts
- WordPress将注册的JavaScript脚本发表到网页标头之前,运行。
Administrative Actions
Administrative Actions
- activate_(plugin file name)
- Runs when the plugin is first activated. See example in WordPress:Creating Tables with Plugins.
- activate_(plugin file name)
- 插件首次激活的时候,运行。请看看使用插件创建表格中的例子。
- activity_box_end
- Runs at the end of the activity box on the admin Dashboard screen.
- activity_box_end
- 在管理Dashboard界面上,activity box的结尾部分,运行。
- add_category_form_pre
- Runs before the add category form is put on the screen in the admin menus.
- add_category_form_pre
- 在添加类别形式放到管理菜单的界面之前,运行。
- admin_head
- Runs in the HTML <head> section of the admin panel.
- admin_head
- 在管理面板的HTML <head>部分,运行。
- admin_head-(page_hook) or admin_head-(plugin_page)
- Runs in the HTML <head> section of the admin panel of a plugin-generated page.
- admin_head-(page_hook)或者admin_head-(plugin_page)
- 在插件产生的网页的管理面板的HTML <head>部分运行。
- admin_footer
- Runs at the end of the admin panel inside the body tag.
- admin_footer
- 在标签内,管理面板的结尾,运行。
- admin_print_scripts
- Runs in the HTML header so a plugin can add JavaScript scripts to all admin pages.
- admin_print_scripts
- 在HTML标头中运行,这样插件可以将JavaScript脚本添加到所有的管理页面。
- admin_print_scripts-(page_hook) or admin_print_scripts-(plugin_page)
- Runs to print JavaScript scripts in the HTML head section of a specific plugin-generated admin page. The (page_hook) is returned when using any of the functions that add plugin menu items to the admin menu: add_management_page(), add_options_page(), etc. Example:
- admin_print_scripts-(page_hook) 或者admin_print_scripts-(plugin_page)
- 运行,将JavaScript脚本放到插件产生的管理页面的HTML标头部分。使用任何将插件菜单内容添加到管理菜单的函数时,返回(page_hook):add_management_page(), add_options_page(),等等。例如:
function myplugin_menu() { if ( function_exists('add_management_page') ) { $page = add_management_page( 'myplugin', 'myplugin', 9, __FILE__, 'myplugin_admin_page' ); add_action( "admin_print_scripts-$page", 'myplugin_admin_head' ); } }
function myplugin_menu() {
if ( function_exists('add_management_page') ) { $page = add_management_page( 'myplugin', 'myplugin', 9, __FILE__, 'myplugin_admin_page' ); add_action( "admin_print_scripts-$page", 'myplugin_admin_head' ); } }
- check_passwords
- Runs to validate the double-entry of password when creating a new user. Action function arguments: array of login name, first password, second password.
- check_passwords
- 运行,在创建新的用户的时候,两次输入密码确认。Action function arguments:登录名,第一个密码,第二个密码。
- dbx_page_advanced
- Runs at the bottom of the "advanced" section on the page editing screen in the admin menus.
- dbx_page_advanced
- 在管理菜单,网页编辑界面的"高级"部分的底部,运行。
- dbx_page_sidebar
- Runs at the bottom of the sidebar on the page editing screen in the admin menus.
- dbx_page_sidebar
- 在管理菜单,网页编辑界面的边栏的底部,运行。
- dbx_post_advanced
- Runs at the bottom of the "advanced" section on the post editing screen in the admin menus.
- dbx_post_advanced
- 在管理菜单,网页编辑界面的"高级"部分的底部运行。
- dbx_post_sidebar
- Runs at the bottom of the sidebar on the post editing screen in the admin menus.
- dbx_post_sidebar
- 在管理菜单,文本编辑界面的边栏的底部,运行。
- deactivate_(plugin file name)
- Runs when a plugin is deactivated.
- deactivate_(插件文件名)
- 插件不运行的状态,运行。
- delete_user
- Runs when a user is deleted. Action function arguments: user ID.
- delete_user
- 删除用户的时候,运行。Action function arguments: 用户 ID。
- edit_category_form
- Runs after the add/edit category form is put on the screen (but before the end of the HTML form tag).
- edit_category_form
- 在添加/编辑类别形式放到界面之后(但是在HTML形式标签结束之前)运行。
- edit_category_form_pre
- Runs before the edit category form is put on the screen in the admin menus.
- edit_category_form_pre
- 在编辑类别形式放入管理菜单中的界面之前,运行。
- edit_form_advanced
- Runs just before the "advanced" section of the post editing form in the admin menus.
- edit_form_advanced
- 在管理菜单中的文本编辑形式的"高级"部分之前,运行。
- edit_page_form
- Runs just before the "advanced" section of the page editing form in the admin menus.
- edit_page_form
- 在管理菜单中的文本编辑形式的"高级"部分之前,运行。
- edit_user_profile
- Runs near the end of the user profile editing screen in the admin menus.
- edit_user_profile
- 在管理菜单中的用户基本资料编辑界面的结尾部分运行。
- load-(page)
- Runs when an administration menu page is loaded. This action is not usually added directly -- see WordPress:Adding Administration Menus for more details of how to add admin menus. If you do want to use it directly, the return value from add_options_page and similar functions gives you the (page) part of the action name.
- load-(page)
- 载入菜单页面的时候,运行。这个部分并不是直接添加的—关于怎样添加管理菜单的更多详细信息,请看看添加管理菜单。如果你不想直接使用,add_options_page的返回值和相似的函数,会给你action 名称的(page)部分。
- login_form
- Runs just before the end of the login form.
- login_form
- 在登录形式之前,运行。
- login_head
- Runs just before the end of the HTML head section of the login page.
- login_head
- 在登录页面的HTML标头部分的结束之前,运行。
- lost_password
- Runs before the "retrieve your password by email" form is printed on the login screen.
- lost_password
- 在"通过电子邮件得到你的密码"形式,发表在管理界面之前,运行。
- lostpassword_form
- Runs at the end of the form used to retrieve a user's password by email, to allow a plugin to supply extra fields.
- lostpassword_form
- 在使用形式,通过电子邮件获得用户密码,结束之后,运行,使用插件支持额外的栏。
- lostpassword_post
- runs when the user has requested an email message to retrieve their password, to allow a plugin to modify the PHP $_POST variable before processing.
- lostpassword_post
- 当用户需要电子邮件信息,获取密码的时候,运行,运行前,运行插件更改PHP $_POST变数。
- manage_link_custom_column
- Runs when there is an unknown column name for the blogroll managing admin screen. Action function arguments: column name, link ID. See also filter manage_link_columns in the WordPress:Plugin API/Filter Reference, which adds custom columns.
- manage_link_custom_column
- 当友情链接管理界面有个不知名的栏的时候,运行。Action function arguments:栏名,链接ID。也看看WordPress:Plugin API/Filter Reference中的filter manage_link_columns,添加自定义栏。
- manage_posts_custom_column
- Runs when there is an unknown column name for the managing posts admin screen. Action function arguments: column name, post ID. See also filter manage_posts_columns in the WordPress:Plugin API/Filter Reference, which adds custom columns. (see Scompt's tutorial for examples and use.)
- manage_posts_custom_column
- 管理文章管理界面有未知的栏名称的时候,运行。Action function arguments:栏名,文章ID。也看看WordPress:Plugin API/Filter Reference中的filter manage_posts_columns,添加了自定义栏。(关于例子和使用,请看看Scompt的指南。)
- manage_pages_custom_column
- Runs when there is an unknown column name for the managing pages admin screen. Action function arguments: column name, page ID. See also filter manage_pages_columns in the WordPress:Plugin API/Filter Reference, which adds custom columns.
- manage_pages_custom_column
- 管理网页管理界面有未知的栏名称的时候,运行。Action function arguments:栏名,网页ID。也看看 Plugin API/Filter Reference中的filter manage_pages_columns,添加了自定义栏。
- password_reset
- Runs before the user's password is reset to a random new password.
- password_reset
- 用户密码重新设置为随意的新密码之前,运行。
- personal_options_update
- Runs when a user updates personal options from the admin screen.
- personal_options_update
- 用户从管理界面更新个人选项的时候,运行。
- plugins_loaded
- Runs after all plugins have been loaded.
- plugins_loaded
- 载入所有插件的时候,运行。
- profile_personal_options
- Runs at the end of the Personal Options section of the user profile editing screen.
- profile_personal_options
- 在用户基本资料编辑界面的个人选项部分的结尾部分,运行。
- profile_update
- Runs when a user's profile is updated. Action function argument: user ID.
- profile_update
- 更新用户基本资料的时候,运行。Action function argument: 用户 ID。
- register_form
- Runs just before the end of the new user registration form.
- register_form
- 新的用户注册形式结束之前,运行。
- register_post
- Runs before a new user registration request is processed.
- register_post
- 处理新的用户注册请求之前,运行。
- restrict_manage_posts
- Runs before the list of posts to edit is put on the screen in the admin menus.
- restrict_manage_posts
- 文章放到管理菜单界面中编辑之前,运行。
- retrieve_password
- Runs when a user's password is retrieved, to send them a reminder email. Action function argument: login name.
- retrieve_password
- 返回用户密码时,运行,向用户发送电子邮件提醒。Action function argument:注册名。
- set_current_user
- Runs after the user has been changed by the default wp_set_current_user function. Note that wp_set_current_user is also a "pluggable" function, meaning that plugins can override it; see WordPress:Plugin API).
- set_current_user
- 用户被默认的wp_set_current_user函数更改后,运行。注意wp_set_current_user也是个"pluggable"函数,意思是插件可以取代这个函数。请看看插件API。)
- show_user_profile
- Runs near the end of the user profile editing screen.
- show_user_profile
- 在用户基本资料编辑界面的结束部分附近,运行。
- simple_edit_form
- Runs at the end of the "simple" post editing form in the admin menus (by default the simple form is used only for bookmarklets -- it doesn't have the "advanced" sections).
- simple_edit_form
- 在管理菜单的"简单"文章编辑形式的结尾,运行(默认情况下,只有bookmarklets使用简单形式—没有"高级"部分)。
- update_option_(option_name)
- Runs after a WordPress option has been update by the update_option function. Action function arguments: old option value, new option value. You must add an action for the specific options that you want to respond to, such as update_option_foo to respond when option "foo" has been updated.
- update_option_(option_name)
- WordPress选项已经由update_option函数更新后,运行。Action function arguments:旧选项参数值,新的选项参数值。你必须为你想要回应的选项添加一个action,例如更新了选项"foo"时,回应update_option_foo。
- upload_files_(tab)
- Runs to print a screen on the upload files admin screen; "tab" is the name of the custom action tab. Define custom tabs using the wp_upload_tabs filter (see WordPress:Plugin API/Filter Reference).
- upload_files_(tab)
- 运行,在管理界面上传文件上产生界面;"tab"是自定义action 标签的名称。使用wp_upload_tabs filter定义自定义的标签(请看看 Plugin API/Filter Reference)。
- user_register
- Runs when a user's profile is first created. Action function argument: user ID.
- user_register
- 首次创建用户基本资料的时候,运行。Action function argument: 用户 ID。
- wp_ajax_(action)
- Runs to do an unknown type of AJAX action in the administrative menus.
- wp_ajax_(action)
- 运行,在管理菜单中操作未知类型的AJAX。
- wp_authenticate
- Runs to authenticate a user when they log in. Action function arguments: array with user name and password.
- wp_authenticate
- 用于用户登录时,确认用户。Action function arguments:用户名和密码数组。
- wp_login
- Runs when a user logs in.
- wp_login
- 用户登录时,运行。
- wp_logout
- Runs when a user logs out.
- wp_logout
- 用户退出时,运行。
Advanced Actions
Advanced Actions
This section contains actions related to the queries WordPress uses to figure out what posts to display, the WordPress loop, activating plugins, and other fundamental-level WordPress code.
这个部分包含了与WordPress使用的查询相关的actions,取人要显示什么文章,WordPress Loop,激活插件,以及其它基本的WordPress代码。
- admin_menu
- Runs after the basic admin panel menu structure is in place.
- admin_menu
- 基本的管理面板菜单结构到位后,运行。
- admin_notices
- Runs after the admin menu is printed to the screen.
- admin_notices
- 管理菜单出现在界面上后,运行。
- blog_privacy_selector
- Runs after the default blog privacy options are printed on the screen.
- blog_privacy_selector
- 默认博客保密选项出现在界面上后,运行。
- check_admin_referer
- Runs in the default check_admin_referrer function after the nonce has been checked for security purposes, to allow a plugin to force WordPress to die for extra security reasons. Note that check_admin_referrer is also a "pluggable" function, meaning that plugins can override it; see WordPress:Plugin API).
- check_admin_referer
- nonce经过了安全检查后,在默认check_admin_referrer函数中,运行,允许插件迫使WordPress因为额外的安全考虑,而停止运行。注意check_admin_referrer也是"pluggable"函数,指的是插件可以代替这个函数;请看看插件API)。
- check_ajax_referer
- Runs in the default check_ajax_referer function (which is called when an AJAX request goes to the wp-admin/admin-ajax.php script) after the user's login and password have been successfully validated from cookies, to allow a plugin to force WordPress to die for extra security reasons. Note that check_ajax_referer is also a "pluggable" function, meaning that plugins can override it; see WordPress:Plugin API).
- check_ajax_referer
- 在默认check_ajax_referer函数中运行(当AJAX请求进入了wp-admin/admin-ajax.php脚本,这个函数得到调用),cookies成功地确认了用户登录和密码后,允许插件迫使WordPress停止运行,以增加安全性。注check_ajax_referer也是个"pluggable"函数,意思是插件可以代替这个函数;请看看插件API)。
- generate_rewrite_rules
- Runs after the rewrite rules are generated. Action function arguments: the WP_Rewrite class variables as a list. Note that it is easier to use the rewrite_rules_array filter instead of this action, to modify the rewrite rules.
- generate_rewrite_rules
- 产生rewrite 规则之后,运行。Action function arguments: WP_Rewrite class variables作为列表。注意,使用rewrite_rules_array比使用这个action,更易于更改rewrite 规则。
- init
- Runs after WordPress has finished loading but before any headers are sent. Useful for intercepting $_GET or $_POST triggers.
- init
- WordPress结束了载入,但是在发送任何标头之前,运行。有利于截取$_GET or $_POST triggers。
- loop_end
- Runs after the last post of the WordPress loop is processed.
- loop_end
- 运行WordPress loop最后一篇文章的时候,运行。
- loop_start
- Runs before the first post of the WordPress loop is processed.
- loop_start
- 运行WordPress loop中第一篇文章之前,运行。
- parse_query
- Runs at the end of query parsing. Action function arguments: contents of the $wp_query object as a list.
- parse_query
- 在查询解析结束后,运行。Action function arguments: $wp_query object的内容作为列表。
- parse_request
- Runs after the query request is parsed inside the main WordPress function wp. Action function argument: an array with a reference to the global $wp object.
- parse_request
- 查询请求在主要的WordPress函数 wp中解析后,运行。Action function argument: an array with a reference to the global $wp object.
- pre_get_posts
- Runs before the query in the get_posts function. Action function argument: contents of the $wp_query object, as a list.
- pre_get_posts
- 在get_posts函数查询之前,运行。Action function argument: $wp_query object的内容,作为列表。
- sanitize_comment_cookies
- Runs after cookies have been read from the HTTP request.
- sanitize_comment_cookies
- cookies已经从HTTP请求中读出之后,运行。
- send_headers
- Runs after the basic HTTP headers are sent inside the main WordPress function wp. Action function argument: an array with a reference to the global $wp object.
- send_headers
- 基本的HTTP标头发送到主要的WordPress函数wp内部后,运行。Action function argument: an array with a reference to the global $wp object.
- shutdown
- Runs when the page output is complete.
- shutdown
- 输出网页后,运行。
- wp
- Executes after the query has been parsed and post(s) loaded, but before any template execution, inside the main WordPress function wp. Useful if you need to have access to post data but can't use templates for output. Action function argument: an array with a reference to the global $wp object.
- wp
- 查询已经解析并且文章载入后,运行,但是在运行模板之前,在主要的WordPress函数wp中。如果你需要使用文章数据,但是不能使用模板输出数据,这个有用。Action function argument: an array with a reference to the global $wp object.
Further Reading
深入阅读
- WordPress:Writing a Plugin - description of how to write a plugin
- WordPress:Plugin API - article on how to use filters and actions
- WordPress:Plugin API/Filter Reference - reference list for filter hooks
- WordPress:Plugin Resources - comprehensive list of plugin-related resources
- Skippy's list of actions and filters
- WordPress Hooks, a work in progress directory of all of WordPress’ hooks.
- WordPress Hooks Database, a database of all WordPress' hooks, showing which version they come from, and linking to the source code spots that use them
- Angsuman's list, a comprehensive listing of WordPress action hooks with documentation and source code location information. It contains all documented and undocumented action hooks in WordPress 2.0.
- 编写插件 – 描述怎样编写插件
- 插件API – 关于怎样使用filters和actions的文章
- Plugin API/Filter Reference - reference list for filter hooks
- 插件资源 – 插件相关资源的完整列表
- Skippy's list of actions and filters
- WordPress Hooks, a work in progress directory of all of WordPress’ hooks.
- WordPress Hooks 数据库, a database of all WordPress的所有的hooks的数据库,显示这些hooks是源自那个版本,并且链接到使用这些hooks的源代码。
- Angsuman's list, a comprehensive listing of WordPress action hooks 的完整列表,带有文件和源代码位置信息。包含了WordPress2.0中所有备有文件证明的和没有备有文件正面的action hooks。