5 years ago (2015-05-27)  Hundred Encyclopedias |   First to comment  12 
post score 0 times, average 0.0

An action hook that runs in a typical request

When a logged-in user opens the site home page in the default theme, WordPress runs the following action hook function:

  • Plugins_loaded
  • Sanitize_comment_cookies
  • Setup_theme
  • Auth_cookie_malformed
  • Auth_cookie_valid
  • Set_current_user
  • Init
  • Widgets_init
  • Parse_request
  • Send_headers
  • Pre_get_posts
  • Posts_selection
  • Wp
  • Template_redirect
  • Get_header
  • Wp_head
  • Wp_print_styles
  • Wp_print_scripts
  • Loop_start
  • Loop_end
  • Get_sidebar
  • Wp_meta
  • Get_footer
  • Wp_footer

Second, log, page, attachment and category-related action hook function

Add_attachment

When the attachment file first joins the database, the add_attachment function is executed.Function received parameters: Attachment ID.

Add_category

Same as create_category.

Clean_post_cache

When clearing the log cache, execute this action function.Function received parameters: log ID.See clean_post_cache().

Create_category

When a new category is generated, this action function is executed.Function received parameters: Category ID.

Delete_attachment

After removing a category from the database and the corresponding link/log, execute the action function.Function received parameters: Category ID.

Delete_post

This action function is executed when a log or page is to be deleted.Function received parameters: log ID or page ID.

Deleted_post

After deleting a log or page, execute the action function.Function received parameters: log ID or page ID.

Edit_attachment

This action function is executed when the attachment file in the database is updated.Function received parameters: Attachment ID.

Edit_category

When you update/edit a category (including adding/removing logs or blog backlinks, or updating log/blog backlink categories), execute the action function.Function received parameters: Category ID.

Edit_post

When updating/editing a certain log or page (including adding/updating comments, this will result in updating the total number of log comments), execute this action function.Function received parameters: log ID or page ID.

Pre_post_update

Perform this action function before updating the log or page.Function received parameters: log ID.

Private_to_publish

This action function is executed when the log status is changed from private to published.The parameters received by the function: Log object.(An action function to translate the log state is currently available; see wp_transition_post_status()).

Publish_page

This action function is executed when the page is published or when a page with a status of "published" is edited.Function received parameters: page ID.(Warning: The action function cannot be run in WordPress 2.3 and higher; however, the action function 'transition_post_status' can run.Update: The publish_page action function can be run in WordPress 2.6 and later.)

Publish_phone

After adding a new log via email, execute the action function.Function received parameters: log ID.

Publish_post

This action function is executed when posting a log or editing a log with a status of "published".Function received parameters: log ID.

Save_post

When you create or update a log/page, execute the action function.Updates can come from import, log/page edit boxes, xmlrpc, or mail logs.Function received parameters: log ID.

The action information is executed after the update information is stored in the database.

Note: The log ID may refer to a modified version of the log rather than the latest release.Wp_is_post_revision gets the latest version of the log ID.

Wp_insert_post

Same as save_post, execute the action function after the update information is stored in the database.

Xmlrpc_public_post

This action function is executed when the log is requested by XMLRPC, or when a log with a status of "published" is edited by XMLRPC.Function received parameters: log ID.

Third, comments, pings, and quotations related to the action hook function

Comment_closed

When you try to display the comment input box and the log is set to not allow comments, execute the action function.Function received parameters: log ID.

Comment_id_not_found

This action function is executed when trying to display a comment or comment input box without finding the log ID.Function received parameters: log ID.

Comment_flood_trigger

Before calling wp_die to prevent receiving comments, if the number of detected comments is abnormally increased, the action function is executed.The parameters received by the function: the time when the last comment was posted and the time when the current comment was posted.

Comment_on_draft

This action function is executed when the log is in draft status but attempts to display a comment or comment input box.Function received parameters: log ID.

Comment_post

This action function is executed when the comment has just been stored in the database.Parameters received by the function: Comment ID, comment review status ("spam", 0 (indicating no approval), 1 (indicated audited)).

Edit_comment

After the comments in the database are updated or edited, this action function is executed.Function received parameters: Comment ID.

Delete_comment

This action function is executed before the comment is about to be deleted.Function received parameters: Comment ID.

Pingback_post

After adding new pingback to the log, execute this action function.Function received parameters: Comment ID.

Pre_ping

Execute this action function before executing pingback.Parameters received by the function: The array of log links to be processed, and the "pung" setting of the log.

Trackback_post

After adding new trackback to the log, execute this action function.Function received parameters: Comment ID.

Wp_blacklist_check

This action function is executed to determine if the comment should be banned.The parameters received by the function: the name of the reviewer, email, URL, comment content, IP address, user agent (browser).This function can execute wp_die to reject the comment. It can also modify a parameter so that the comment can include the blacklist keyword set by the user in the WordPress option.

Wp_set_comment_status

When the comment status changes, this action function is executed.The parameters received by the function: the comment ID, the status string indicating the new state ("delete", "approve", "spam", "hold").

 

This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/wordpress-function-hook-hook-book-1-2.html

Post comment

Style

No Comment

登录

Forget password?

您也可以使用第三方帐号快捷登录

切换登录

注册

TW