Make WordPress Core

Opened 10 months ago

Last modified 2 months ago

#50734 new enhancement

Document common values for hook names that contain dynamic portions

Reported by: johnbillion Owned by:
Milestone: 5.8 Priority: normal
Severity: normal Version:
Component: Plugins Keywords: 2nd-opinion
Focuses: docs Cc:


The names of many hooks in WordPress core contain a dynamic portion, for example manage_{$post->post_type}_posts_custom_column.

This can make it is difficult for developers to find the documentation relating to such a hook. For example, searching the Developer Resources site for `manage_page_posts_custom_column` returns no results despite it being a valid hook name. I've seen this happen in practice when working with both new and seasoned developers.

A few hooks include documentation which lists possible values, which allows them to appear in search results on the dev site. For example searching for `load-post-new.php` correctly shows the documentation for the load-{$pagenow} hook.

We should formalise this sort of documentation of potential values for dynamic hook names in order to make it easier for developers to find documentation. This won't be exhaustive of course, but it can cover common values.

There was some discussion on #37748 about doing this, but it didn't go anywhere.

Ideally these potential hook names would be list in a dedicated tag (eg. @hook) so that developer tools that work with the docs can understand them.

 * @hook manage_page_posts_custom_column
 * @hook manage_post_posts_custom_column
 * @hook manage_attachment_posts_custom_column
do_action( "manage_{$post->post_type}_posts_custom_column" );


Change History (3)

This ticket was mentioned in Slack in #docs by johnbillion. View the logs.

9 months ago

#2 @johnbillion
2 months ago

In 50505:

Docs: Add examples of possible names for various hooks whose name contains a dynamic portion.

This provides greater discoverability of such hooks in search results on the Code Reference site as well as increased clarity when reading the source.

See #50734, #52628

#3 @SergeyBiryukov
2 months ago

  • Milestone changed from Awaiting Review to 5.8
Note: See TracTickets for help on using tickets.