From 5383af84832fa27c187941a63803fea8bdb553ca Mon Sep 17 00:00:00 2001 From: johnbillion Date: Sat, 3 Jul 2021 21:41:02 +0000 Subject: [PATCH] Docs: Add and correct examples of common names for various dynamic hooks. See #53581 git-svn-id: https://develop.svn.wordpress.org/trunk@51327 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/admin.php | 10 ++++++++++ src/wp-admin/includes/media.php | 4 +--- src/wp-admin/includes/meta-boxes.php | 6 ++++++ src/wp-includes/category-template.php | 6 ++++++ src/wp-includes/class-wp-rewrite.php | 9 +++++++-- src/wp-includes/comment-template.php | 10 +++++++++- src/wp-includes/post.php | 10 ++++++++++ .../endpoints/class-wp-rest-posts-controller.php | 12 ++++++++++++ src/wp-includes/revision.php | 5 +++++ src/wp-includes/taxonomy.php | 5 +++++ 10 files changed, 71 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/admin.php b/src/wp-admin/admin.php index 4ead0d51d2..45849d6a17 100644 --- a/src/wp-admin/admin.php +++ b/src/wp-admin/admin.php @@ -320,6 +320,16 @@ if ( isset( $plugin_page ) ) { * * The dynamic portion of the hook name, `$importer`, refers to the importer slug. * + * Possible hook names include: + * + * - `load-importer-blogger` + * - `load-importer-wpcat2tag` + * - `load-importer-livejournal` + * - `load-importer-mt` + * - `load-importer-rss` + * - `load-importer-tumblr` + * - `load-importer-wordpress` + * * @since 3.5.0 */ do_action( "load-importer-{$importer}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 269a9ba333..132a968d79 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -578,9 +578,7 @@ function wp_iframe( $content_func, ...$args ) { * (pre-3.5.0) media upload popup. * * The dynamic portion of the hook, `$content_func`, refers to the form - * callback for the media upload type. Possible values include - * 'media_upload_type_form', 'media_upload_type_url_form', and - * 'media_upload_library_form'. + * callback for the media upload type. * * @since 2.5.0 */ diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 61afe0f8e1..517a81d049 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -1582,6 +1582,12 @@ function register_and_do_post_meta_boxes( $post ) { * * The dynamic portion of the hook, `$post_type`, refers to the post type of the post. * + * Possible hook names include: + * + * - `add_meta_boxes_post` + * - `add_meta_boxes_page` + * - `add_meta_boxes_attachment` + * * @since 3.0.0 * * @param WP_Post $post Post object. diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php index 5af7173a9d..a10f9533c3 100644 --- a/src/wp-includes/category-template.php +++ b/src/wp-includes/category-template.php @@ -1346,6 +1346,12 @@ function get_the_term_list( $post_id, $taxonomy, $before = '', $sep = '', $after * The dynamic portion of the filter name, `$taxonomy`, refers * to the taxonomy slug. * + * Possible hook names include: + * + * - `term_links-category` + * - `term_links-post_tag` + * - `term_links-post_format` + * * @since 2.5.0 * * @param string[] $links An array of term links. diff --git a/src/wp-includes/class-wp-rewrite.php b/src/wp-includes/class-wp-rewrite.php index e357593969..fbd9a93157 100644 --- a/src/wp-includes/class-wp-rewrite.php +++ b/src/wp-includes/class-wp-rewrite.php @@ -1411,8 +1411,13 @@ class WP_Rewrite { * Filters rewrite rules used for individual permastructs. * * The dynamic portion of the hook name, `$permastructname`, refers - * to the name of the registered permastruct, e.g. 'post_tag' (tags), - * 'category' (categories), etc. + * to the name of the registered permastruct. + * + * Possible hook names include: + * + * - `category_rewrite_rules` + * - `post_format_rewrite_rules` + * - `post_tag_rewrite_rules` * * @since 3.1.0 * diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 5a0072ff6c..a40a98d170 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -2647,7 +2647,15 @@ function comment_form( $args = array(), $post_id = null ) { * Filters a comment form field for display. * * The dynamic portion of the filter hook, `$name`, refers to the name - * of the comment form field. Such as 'author', 'email', or 'url'. + * of the comment form field. + * + * Possible hook names include: + * + * - `comment_form_field_comment` + * - `comment_form_field_author` + * - `comment_form_field_email` + * - `comment_form_field_url` + * - `comment_form_field_cookies` * * @since 3.0.0 * diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 20072bdcdb..47b86ff855 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -4411,6 +4411,11 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) * The dynamic portion of the hook name, `$post->post_type`, refers to * the post type slug. * + * Possible hook names include: + * + * - `edit_post_post` + * - `edit_post_page` + * * @since 5.1.0 * * @param int $post_ID Post ID. @@ -4448,6 +4453,11 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) * The dynamic portion of the hook name, `$post->post_type`, refers to * the post type slug. * + * Possible hook names include: + * + * - `save_post_post` + * - `save_post_page` + * * @since 3.7.0 * * @param int $post_ID Post ID. diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 5f414fd8bd..b534cec5fb 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -1024,6 +1024,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { * * They dynamic portion of the hook name, `$this->post_type`, refers to the post type slug. * + * Possible hook names include: + * + * - `rest_delete_post` + * - `rest_delete_page` + * - `rest_delete_attachment` + * * @since 4.7.0 * * @param WP_Post $post The deleted or trashed post. @@ -2534,6 +2540,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { * The dynamic portion of the filter, `$this->post_type`, refers to the * post type slug for the controller. * + * Possible hook names include: + * + * - `rest_post_item_schema` + * - `rest_page_item_schema` + * - `rest_attachment_item_schema` + * * @since 5.4.0 * * @param array $schema Item schema data. diff --git a/src/wp-includes/revision.php b/src/wp-includes/revision.php index 630a06d23a..70051a07da 100644 --- a/src/wp-includes/revision.php +++ b/src/wp-includes/revision.php @@ -574,6 +574,11 @@ function wp_revisions_to_keep( $post ) { * The dynamic portion of the hook name, `$post->post_type`, refers to * the post type slug. * + * Possible hook names include: + * + * - `wp_post_revisions_to_keep` + * - `wp_page_revisions_to_keep` + * * @since 5.8.0 * * @param int $num Number of revisions to store. diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 0e7f1312dd..5d9cf1ad2c 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -948,6 +948,11 @@ function get_term( $term, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) { * The dynamic portion of the filter name, `$taxonomy`, refers * to the slug of the term's taxonomy. * + * Possible hook names include: + * + * - `get_category` + * - `get_post_tag` + * * @since 2.3.0 * @since 4.4.0 `$_term` is now a `WP_Term` object. *