[WORDPRESS series] Common actions of plugin API

Reference source:
http://www.wordpress.la/codex-%E6%8F%92%E4%BB%B6API%E4%B9%8B%E5%B8%B8%E7%94%A8%E5%8A% A8%E4%BD%9C%28action%29.htmlThis

article lists the action hooks available for plugin development in WordPress 2.1 and above.

Want to understand the definition and role of filter hooks and action hooks? See Plugin API.
Want to understand the basic process of writing plugins? See Plugin Development.
Want to see a list of filter hook functions? See Common Filters in the Plugin API.
Looking for filter hooks and action hooks for WordPress versions prior to 2.1? See Plugin API/Hooks 2.0.x.
Note: When adding entries or making other changes to this article, please refer to the current format. When adding, please specify the applicable data type of the filter function, and if the filter function accepts multiple parameters, please specify in the parameter list.

Action Hooks Running on a Typical Request

In WordPress 2.7, when a logged-in user opens the site's home page in the default theme, WordPress runs the following action hook functions:

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
Log, page, attachment and category-related action hook functions

add_attachment The

add_attachment function is executed when the attachment file is added to the database for the first time. Parameters received by the function: the attachment ID.

add_category

is the same as create_category.

This action function is executed when clean_post_cache

clears the log cache. Parameters received by the function: log ID. See clean_post_cache().

This action function is executed when create_category

generates a new category. Parameters received by the function: Category ID.

delete_attachment

This action function is executed after a category has been deleted from the database and corresponding links/logs. Parameters received by the function: Category ID.

delete_post

This action function is executed when a log or page is about to be deleted. Parameters received by the function: log ID or page ID.

After deleted_post

deletes a log or page, this action function is executed. Parameters received by the function: log ID or page ID. This action function is executed when the attachment file in the

edit_attachment database is updated.

Parameters received by the function: the attachment ID.

edit_category

This action function is executed when a category is updated/edited (including adding/removing post or blog backlinks, or updating the category of post/blog backlinks). Parameters received by the function: Category ID.

edit_post

This action function is executed when a post or page is updated/edited (including adding/updating comments, which will result in an update of the total number of post comments). Parameters received by the function: log ID or page ID.

This action function is executed before pre_post_update

update log or page. Parameters received by the function: log ID.

private_to_publish

This action function is executed when the log state changes from private to published. Parameters received by the function: the log object. (Action functions to translate post status are currently available; see wp_transition_post_status()).

publish_page

This action function is executed when a page is published or a page whose status is "published" is edited. Parameters received by the function: page ID. (Warning: This action function does not work in WordPress 2.3 and later; however, the action function 'transition_post_status' does. UPDATE: The publish_page action function works in WordPress 2.6 and later.)

publish_phone

Executes the action function after adding a new log via email. Parameters received by the function: log ID.

This action function is executed when publish_post

publishes a log or edits a log whose status is "published". Parameters received by the function: log ID.

This action function is executed when save_post

creates or updates a post/page. Updates can come from import, log/page edit box, xmlrpc or mail log. Parameters received by the function: log ID.

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

Note: The log ID may refer to the modified version of the log instead of the latest release. wp_is_post_revision can get the ID of the latest version of the post.

wp_insert_post

is the same as save_post. The action function is executed after the update information is stored in the database.

This action function is executed when xmlrpc_public_post

requests to publish logs through XMLRPC, or edits a log whose status is "published" through XMLRPC. Parameters received by the function: log ID.

This action function is executed when the comment, ping, and trackback related action hook function

comment_closed

tries to display the comment input box but the log is set to disallow comments. Parameters received by the function: log ID.

comment_id_not_found

This action function is executed when an attempt is made to display a comment or comment input box but the log ID is not found. Parameters received by the function: log ID.

comment_flood_trigger

This action function is executed if an abnormal increase in the number of comments is detected before wp_die is called to prevent receiving comments. Parameters received by the function: the last comment posting time, the current comment posting time.

This action function is executed when the comment_on_draft

log is in the draft state and attempts to display a comment or comment input box. Parameters received by the function: 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 moderation status ("spam", 0 (indicates not moderation), 1 (indicates moderation)).

This action function is executed after a comment in the edit_comment

database has been updated or edited. Parameters received by the function: Comment ID.

delete_comment

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

This action function is executed after a new pingback is added to the pingback_post

log. Parameters received by the function: Comment ID.

This action function is executed before pre_ping

executes pingback. Parameters received by the function: an array of log links that will be processed, and the "pung" setting for the log. This action function is executed after a new trackback is added to the

trackback_post log.

Parameters received by the function: Comment ID.

wp_blacklist_check

executes the action function to determine whether comments should be banned. Parameters received by the function: commenter's name, email, URL, comment content, IP address, user agent (browser). This function can execute wp_die to reject comments, or modify a parameter to allow comments to contain blacklist keywords set by the user in the WordPress options.

wp_set_comment_status

This action function is executed when the comment status changes. Parameters received by the function: comment ID, a status string indicating the new status ("delete", "approve", "spam", "hold").

Backlink action hook function

add_link

This action function is executed when a new backlink is added to the database for the first time. Parameters received by the function: link ID.

delete_link

This action function is executed when the backlink is deleted. Parameters received by the function: link ID.

edit_link When

editing a backlink, this action function is executed. Parameters received by the function: link ID.

Feed action hook function

atom_entry

executes this action function after displaying a certain blog log information in atom subscription (but before closing the log tag).

atom_head

executes this action function in atom subscription, after displaying the information of a subscribed blog, but before the first log of the blog is displayed.

atom_ns

executes this action function (to add namespaces) for the root XML element that atom subscribes to.

commentrss2_item

In the comment subscription, after displaying a comment (but before closing the comment's tag), this action function is executed. Parameters received by the function: comment ID, log ID.

do_feed_(feed)

This action function is executed when the subscription information is generated, where the subscription refers to the subscription type (rss2, atom, rdf, etc.). The priority used to display subscription information should be lower than 10. Parameters received by the function: true (comment subscription), or false (log subscription).

rdf_header

executes this action function in rdf subscription, after displaying the subscribed blog information, but before the first log of the blog is displayed.

rdf_item

executes this action function after displaying a certain blog log information (but before closing the log tag) in the RDF subscription.

rdf_ns

executes this action function (to add a namespace) for the root XML element of an RDF subscription.

rss_head

executes this action function in RSS subscription, after displaying the subscribed blog information, but before displaying the first log of the blog.

rss_item

executes this action function after displaying a blog log information (but before closing the log tag) in RSS feeds.

rss2_head

executes this action function in RSS2 subscription, after displaying the subscribed blog information, but before displaying the first log of the blog.

rss2_item

In RSS2 subscription, after displaying a blog log information (but before closing the log tag), this action function is executed.

rss2_ns

executes this action function (to add a namespace) for the root XML element of an RSS2 subscription.

The template related action hook function

comment_form

executes this action function in standard WordPress themes to insert a comment form. Parameters received by the function: log ID.

do_robots

This action function is executed when the template file selector thinks this is a request from robots.txt.

do_rebotstxt

executes this action function before the do_robots function displays a "Disallow" link for the robots.txt file.

Before get_footer

loads the footer.php template file, this action function is executed when the template calls the get_footer function.

Before get_header

loads the header.php template file, this action function is executed when the template calls the get_header function.

switch_theme

This action function is executed when the blog theme is changed. Parameters received by the function: the name of the new topic.

template_redirect

decides to execute this action function before the template file used to display the requested page, so that the plugin can override the template file selection. Example (for reference only, no practical use): redirect all requests to the all.php template file in the current theme directory.

function all_on_one () {
include(TEMPLATEPATH . '/all.php');
exit;
}

add_action('template_redirect', 'all_on_one');
The wp_footer

template executes the action function when the wp_footer function is called near the bottom of the blog page.

wp_head

The action function wp_head is executed when the template calls the wp_head function. wp_head is usually placed between <head> and </head> at the top of the page template. The action function takes no arguments.

The wp_meta

template file sidebar.php calls the wp_meta function to allow plugins to execute this action function when adding content to the sidebar.

wp_print_scripts

WordPress executes this action function before entering the recorded JavaScript script into the header section of the page. The action hook function activate_(plugin file name)

related to the management interface executes this action function when a plugin is activated for the first time. See common function - register_activation_hook. activity_box_end executes the action function at the end of the activity box on the dashboard interface. add_category_form_pre This action function is executed when the text box of the added category has not been displayed on the interface of the management menu. admin_head executes this action function in the HTML section <head> of the dashboard. admin_head-(page_hook) or admin_head-(plguin_page) executes this action function in the HTML section <head> of the dashboard of the page generated by the plugin. admin_init executes this action function before loading the management interface. See wp-admin/admin.php, wp-admin/admin-post.php, and wp-admin/admin-ajax.php.

























admin_footer

executes the action function at the end of the dashboard in the main tab.

admin_print_scripts

executes this action function in the header section of the HTML to make the plugin add JavaScript scripts to all admin screens.

admin_print_styles

executes this action function in the header section of the HTML to make the plugin add CSS or style sheets to all admin interfaces.

admin_print_scripts-(page_hook) or admin_print_scripts-(plugin_page)

executes this action function to enter JavaScript scripts into the HTML header section of a plugin-generated admin page. Returns (page_hook) when adding plugin menu options to the management menu using functions such as add_management_page(), add_options_page(). Example:

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

When creating a new user account, execute this action function to verify that the passwords entered twice are the same. Parameters received by the function: an array of login names, the password entered for the first time, and the password entered for the second time.

dbx_page_advanced

executes this action function at the bottom of the "advanced" section on the page editing interface of the management menu.

dbx_page_sidebar

executes this action function at the bottom of the page editing interface toolbar of the management menu.

dbx_post_advanced

executes this action function at the bottom of the "advanced" section on the log editing interface of the management menu.

dbx_post_siderbar

executes this action function at the bottom of the toolbar of the log editing interface of the management menu. WordPress 2.5 or later executes the add_meta_box() function.

deactivate_(plugin filename)

This action function is executed when the plugin is disabled. This action function is executed when

delete_user deletes a user.

Parameters received by the function: User ID.

edit_category_form After

adding/editing the category table is displayed on the interface (before the end of the HTML table tag), execute this action function.

edit_category_form_pre

This action function is executed before the edit category table is displayed in the management menu interface.

edit_tag_form After

adding/editing the tag table is displayed on the interface (before the HTML table tag ends), execute this action function.

edit_tag_form_pre

This action function is executed before the edit label table is displayed in the management menu interface.

edit_form_advanced

executes this action function before the "advanced" section of the log edit box in the admin menu.

edit_page_form

executes this action function before the "advanced" section of the page edit box in the admin menu.

edit_user_profile

executes this action function in the last section of the user profile in the admin menu.



load_(page)

This action function is executed when the management menu page is loaded. This action function cannot be added directly - for the process of adding a management menu, see Customizing the Plug-in Management Menu. If you want to add the function directly, the value returned by add_options_page and similar functions can give the action function name.

login_form

executes this action function before the end of the login box.

login_head

executes this action function before the end of the HTML header part of the login interface.

lost_password

executes this action function before "Password Retrieved by Email" is displayed on the login screen.

lostpassward_form

executes this action function at the end of the form to retrieve the password via email, enabling the plugin to provide more fields.

This action function is executed when the lostpassward_post

user requests to retrieve the password via email, enabling the plugin to modify the PHP $_POST variable before retrieving the password.

manage_link_custom_column

This action function is executed when an unknown column name appears in the backlink management interface. Parameters received by the function: column name, link ID. See the filter function manage_links_columns in Plugin API/Common Filter Functions, which can add custom columns.

This action function is executed when an unknown column name appears in the manage_posts_custom_column

log management interface. Parameters received by the function: column name, log ID. See the filter function manage_posts_columns in Plugin API/Common Filter Functions, which can add custom columns. (See Scompt's tutorial for specific usage and examples).

This action function is executed when an unknown column name appears in the manage_pages_custom_column

page management interface. Parameters received by the function: column name, page ID. See the filter function manage_pages_columns in Plugin API/Common Filter Functions, which can add custom columns.

password_reset

This action function is executed before the user changes the old password to the new password.

personal_options_update

This action function is executed when the user updates settings in the dashboard.

plugins_loaded

This action function is executed after all plugins are loaded.

profile_personal_options

executes this action function at the end of the "About yourself" section of the user profile editor iemian.

This action function is executed when profile_update

updates the user profile. Function combined with search parameters: user ID.

register_form

This action function is executed before the end of the new user registry.

register_post

executes this action function before processing a new user registration request.

restrict_manage_posts

Execute this action function before the list of logs to be edited is displayed in the management menu interface.

retrieve_password

This action function is executed when the user's password is retrieved to send a password reminder email. Parameters received by the function: login name.

set_current_user

default function wp_set_current_user After changing the user, execute this action function. Note: wp_set_current_user is a "plug-in" function, i.e. plugins can override this function; see plugin API.

show_user_profile

executes this action function at the end of the user profile editing interface.

simple_edit_form

executes this action function at the end of the "simple" log edit box in the dashboard (by default, the simple edit box is only used for the bookmark tool - no "advanced" options).

update_option_(option_name)

The update_option function executes the action function after updating the WordPress options. Parameters received by the function: the original option value, the new option value. Users need to add an action function for the option they want to update, for example, when updating "foo", use the function update_option_foo to echo.

upload_files_(tab)

Execute the action function to display a page on the upload file management interface; "tab" is the name of the custom action function table. Custom tables can be defined with the filter function wp_upload_tabs (see Plugin API/Common Filter Functions). This action function is executed when

user_register first creates a user profile.

Parameters received by the function: User ID.

wp_ajax_(action)

executes this action function in the admin menu to run an unknown type of AJAX.

wp_authenticate When a

user logs in, execute this action function to authenticate the user. Parameters received by the function: an array of usernames and passwords. This action function is executed when the

wp_login user logs in. This action function is executed when the wp_logout user logs out. Advanced Action Functions This section covers all action functions related to WordPress queries (determining which post to display), the WordPress main loop, activating plugins, and the WordPress base code. After the menu structure in the admin_menu control panel is displayed correctly, execute this action function. admin_notices This action function is executed when the admin menu is displayed on the page. blog_privacy_selector This action function is executed when the blog default privacy options are displayed on the page. check_admin_referer

























The system executes the check_admin_referer action hook in the default function check_admin_referrer after checking the random number for security reasons, so that the plugin forces WordPress to stop running for security reasons. Note: check_admin_referrer is also a "plug-in" function, i.e. plugins can override this function; see plugin API.

After the check_ajax_referer

system successfully authenticates the user's login name and password from cookies, it executes this action function in the default function check_ajax_referer (this is the function called when an AJAX request enters the wp-admin/admin-ajax.php script) to make the plugin Ability to force WordPress to stop for security reasons. Note: The check_ajax_referer function is also a "plug-in" function, meaning that plugins can override this function; see Plugin API.

generate_rewrite_rules

This action function is executed after the rewrite rules are generated. Parameters received by the function: list of WP_Rewrite class variables. Note: When modifying rewrite rules, it is more convenient to use the rewrite_rules_array filter function than the action function.

init

This action function is executed when WordPress is loaded but the header information has not been sent. Function for parsing $_GET or $_POST triggers.

loop_end

This action function is executed after the last log of the WordPress main loop is executed.

This action function is executed before loop_start

executes the first log of the WordPress main loop.

parse_query

This action function is executed at the end of query parsing in the main query or any instance of WP_Query such as query_posts, get_posts or get_children. Parameters received by the function: $wp_query object content list.

parse_request

executes the action function after parsing the query request in the main WordPress function wp. Parameters received by the function: an array of references to the global variable $wp object.

pre_get_posts

executes this action function before the get_posts function starts manipulating the query. Parameters received by the function: the content list of the $wp_query object.

sanitize_comment_cookies

HTTP request reads cookies and executes this action function.

send_headers

executes this action function after sending the basic HTTP headers in the WordPress main function wp. Parameters received by the function: an array of references to the global variable $wp object. This action function is executed after the content of the

shutdown page is output. wp parses the query in the WordPress main function wp, after the page is loaded, and before executing the template, this action function is executed. Parameters received by the function: an array of references to the global variable $wp object.





Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327017926&siteId=291194637